Explorar el Código

商品学习服务期设置

tanzh hace 3 años
padre
commit
d231873cbe

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/IGoodsService.java

@@ -75,4 +75,6 @@ public interface IGoodsService extends IService<Goods> {
 
 	int queryUpGoods();
 
+	Goods setStudyServiceTime(Goods g);
+
 }

+ 37 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/impl/GoodsServiceImpl.java

@@ -71,6 +71,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     @Autowired
     private IOrderGoodsService iOrderGoodsService;
 
+    @Autowired
+    private IGoodsService iGoodsService;
+
 
     @Override
     public GoodsVo queryById(Long goodsId){
@@ -285,8 +288,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
         if(bo.getGoodsPhotographExamConfig()!=null){
             update.setGoodsPhotoExamConfig(JSON.toJSONString(bo.getGoodsPhotographExamConfig()));
         }
-
-        return this.updateById(update);
+        //学习服务期设置
+        Goods edit= this.setStudyServiceTime(update);
+        return this.updateById(edit);
     }
 
     @Override
@@ -433,4 +437,35 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
     public int queryUpGoods() {
         return baseMapper.queryUpGoods();
     }
+
+    //设置学习服务期
+    @Override
+    public Goods setStudyServiceTime(Goods g){
+        GoodsVo goodsVo = iGoodsService.queryById(g.getGoodsId());
+        //商品设置学习服务有效期
+            if(Validator.isNotEmpty(goodsVo.getServiceTimeType())){
+                if(Validator.isNotEmpty(goodsVo.getServiceTimeNum())){
+                    if(goodsVo.getServiceTimeType()==1){ //年
+                        Calendar cal = new GregorianCalendar();
+                        cal.add(Calendar.YEAR,goodsVo.getServiceTimeNum().intValue());
+                        g.setStudyStartTime(DateUtils.getNowTime());
+                        g.setStudyEndTime(cal.getTimeInMillis()/1000);
+                    }
+                    else if(goodsVo.getServiceTimeType()==2){ //月
+                        Calendar cal = new GregorianCalendar();
+                        cal.add(Calendar.MONTH,goodsVo.getServiceTimeNum().intValue());
+                        g.setStudyStartTime(DateUtils.getNowTime());
+                        g.setStudyEndTime(cal.getTimeInMillis()/1000);
+                    }
+                    else if(goodsVo.getServiceTimeType()==3){ //天
+                        Calendar cal = new GregorianCalendar();
+                        cal.add(Calendar.DATE,goodsVo.getServiceTimeNum().intValue());
+                        g.setStudyStartTime(DateUtils.getNowTime());
+                        g.setStudyEndTime(cal.getTimeInMillis()/1000);
+                    }
+                }
+            }
+
+        return g;
+    }
 }