he2802 2 роки тому
батько
коміт
3190f30f15

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/domain/Goods.java

@@ -161,4 +161,6 @@ private static final long serialVersionUID=1L;
     private Integer gradeType;
     /** 题库商家ID */
     private Integer questionMerchantId;
+    /** 第三方题库商品ID */
+    private Integer questionGoodsId;
 }

+ 37 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderServiceImpl.java

@@ -44,8 +44,12 @@ import com.zhongzheng.modules.goods.bo.GoodsBankAddBo;
 import com.zhongzheng.modules.goods.bo.GoodsFreeBankAddBo;
 import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.domain.GoodsFreeBank;
+import com.zhongzheng.modules.goods.domain.GoodsQuestionRel;
+import com.zhongzheng.modules.goods.domain.QuestionMerchant;
 import com.zhongzheng.modules.goods.service.IGoodsFreeBankService;
+import com.zhongzheng.modules.goods.service.IGoodsQuestionRelService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
+import com.zhongzheng.modules.goods.service.IQuestionMerchantService;
 import com.zhongzheng.modules.grade.bo.ClassGradeListBo;
 import com.zhongzheng.modules.grade.bo.ClassGradeQueryBo;
 import com.zhongzheng.modules.grade.bo.ClassGradeSortBo;
@@ -198,6 +202,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
     private ITopOldOrderCheckLogService topOldOrderCheckLogService;
     @Autowired
     private ITopInstSettleService topInstSettleService;
+    @Autowired
+    private IGoodsQuestionRelService iGoodsQuestionRelService;
+    @Autowired
+    private IQuestionMerchantService iQuestionMerchantService;
 
 
     @Override
@@ -805,17 +813,45 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         //给用户增加商品考试次数前培次数
         iWxPayService.updateUserExamGoods(orderGoods, order);
         iWxPayService.joinLockGrade(order.getOrderSn(), orderGoods.getGoodsId(), orderGoods.getOrderGoodsId());
+        //商品是否关联第三方题库商品
+        Goods goods = iGoodsService.getById(orderGoods.getGoodsId());
+        if (ObjectUtils.isNotNull(goods.getQuestionGoodsId())){
+            questionGoodsHandle(orderGoods,goods);
+        }
 //        //商品是否有活动模考
 //        iUserMockSubscribeService.addActivityMock(orderGoods.getGoodsId(),order.getUserId());
     }
 
+    private void questionGoodsHandle(OrderGoods orderGoods,Goods goods) {
+        //第三方题库商品
+        Goods questionGoods = iGoodsService.getById(goods.getQuestionGoodsId());
+        if (ObjectUtils.isNull(questionGoods) || questionGoods.getGoodsType() != 9){
+            //商品类型不符合
+            return;
+        }
+        //添加第三方关联记录
+        QuestionMerchant merchant = iQuestionMerchantService.getById(questionGoods.getQuestionMerchantId());
+        if (ObjectUtils.isNull(merchant)){
+            //商家不存在
+            return;
+        }
+        GoodsQuestionRel rel = new GoodsQuestionRel();
+        rel.setOrderGoodsId(orderGoods.getOrderGoodsId());
+        rel.setQuestionGoodsId(questionGoods.getGoodsId());
+        rel.setStatus(1);
+        rel.setQuestionDoNum(merchant.getDoNum());
+        rel.setCreateTime(DateUtils.getNowTime());
+        rel.setUpdateTime(DateUtils.getNowTime());
+        iGoodsQuestionRelService.save(rel);
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Map<String, String> placeSmallOrder(OrderAddBo bo) {
         String key = "ORDER-" + "-" + bo.getUserId();
         Long value = redisCache.getCacheObject(key);
         if (Validator.isNotEmpty(value)) {
-            throw new CustomException("请勿频繁提交订单");
+            throw new CustomException("goods");
         }
         redisCache.setCacheObject(key, 1L, 5, TimeUnit.SECONDS);//5秒
         List<OrderGoodsAddBo> goodsList = bo.getGoodsList();

+ 38 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/wx/service/impl/WxPayServiceImpl.java

@@ -36,7 +36,12 @@ import com.zhongzheng.modules.course.service.ICourseProjectTypeService;
 import com.zhongzheng.modules.course.service.ICourseService;
 import com.zhongzheng.modules.distribution.domain.*;
 import com.zhongzheng.modules.distribution.service.*;
+import com.zhongzheng.modules.goods.domain.Goods;
+import com.zhongzheng.modules.goods.domain.GoodsQuestionRel;
+import com.zhongzheng.modules.goods.domain.QuestionMerchant;
+import com.zhongzheng.modules.goods.service.IGoodsQuestionRelService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
+import com.zhongzheng.modules.goods.service.IQuestionMerchantService;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import com.zhongzheng.modules.grade.domain.ClassGradeUserTemp;
 import com.zhongzheng.modules.grade.domain.StudyCountLog;
@@ -226,6 +231,10 @@ public class WxPayServiceImpl implements IWxPayService {
     private ITopOldOrderCheckLogService topOldOrderCheckLogService;
     @Autowired
     private ITopInstSettleService topInstSettleService;
+    @Autowired
+    private IGoodsQuestionRelService iGoodsQuestionRelService;
+    @Autowired
+    private IQuestionMerchantService iQuestionMerchantService;
 
     private String gzh_tokenUrl = "https://api.weixin.qq.com/cgi-bin/token";
 
@@ -519,6 +528,8 @@ public class WxPayServiceImpl implements IWxPayService {
                         //分销返利
                         distributionRebate(g);
                     }
+                    //第三方题库商品
+                    questionGoodsHandle(g);
                 }
                 shareToOldSys(order,goodsList);
                 instTimeSettleOrder(order,DateUtils.getNowTime());
@@ -535,6 +546,33 @@ public class WxPayServiceImpl implements IWxPayService {
         return true;
     }
 
+    private void questionGoodsHandle(OrderGoods orderGoods) {
+        Goods goods = iGoodsService.getById(orderGoods.getGoodsId());
+        if (ObjectUtils.isNull(goods.getQuestionGoodsId())){
+            return;
+        }
+        //第三方题库商品
+        Goods questionGoods = iGoodsService.getById(goods.getQuestionGoodsId());
+        if (ObjectUtils.isNull(questionGoods) || questionGoods.getGoodsType() != 9){
+            //商品类型不符合
+            return;
+        }
+        //添加第三方关联记录
+        QuestionMerchant merchant = iQuestionMerchantService.getById(questionGoods.getQuestionMerchantId());
+        if (ObjectUtils.isNull(merchant)){
+            //商家不存在
+            return;
+        }
+        GoodsQuestionRel rel = new GoodsQuestionRel();
+        rel.setOrderGoodsId(orderGoods.getOrderGoodsId());
+        rel.setQuestionGoodsId(questionGoods.getGoodsId());
+        rel.setStatus(1);
+        rel.setQuestionDoNum(merchant.getDoNum());
+        rel.setCreateTime(DateUtils.getNowTime());
+        rel.setUpdateTime(DateUtils.getNowTime());
+        iGoodsQuestionRelService.save(rel);
+    }
+
     private void instTimeSettleOrder(Order order, Long checkTime) {
         //业务层次
         List<String> fullName = iOrderService.queryBusinessFullNameBySn(order.getOrderSn());