yangdamao 2 жил өмнө
parent
commit
81e5d649f0

+ 41 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderGoodsServiceImpl.java

@@ -39,9 +39,11 @@ import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
 import com.zhongzheng.modules.goods.bo.GoodsSectionListBo;
 import com.zhongzheng.modules.goods.bo.GoodsSectionListBo;
 import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.domain.GoodsQuestionRel;
 import com.zhongzheng.modules.goods.domain.GoodsQuestionRel;
+import com.zhongzheng.modules.goods.domain.QuestionMerchant;
 import com.zhongzheng.modules.goods.service.IGoodsCourseService;
 import com.zhongzheng.modules.goods.service.IGoodsCourseService;
 import com.zhongzheng.modules.goods.service.IGoodsQuestionRelService;
 import com.zhongzheng.modules.goods.service.IGoodsQuestionRelService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
+import com.zhongzheng.modules.goods.service.IQuestionMerchantService;
 import com.zhongzheng.modules.goods.vo.GoodsSectionListVo;
 import com.zhongzheng.modules.goods.vo.GoodsSectionListVo;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import com.zhongzheng.modules.grade.domain.ClassGradeGoods;
 import com.zhongzheng.modules.grade.domain.ClassGradeGoods;
@@ -166,6 +168,8 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
     private IOrderInputService iOrderInputService;
     private IOrderInputService iOrderInputService;
     @Autowired
     @Autowired
     private IUserProfileService iUserProfileService;
     private IUserProfileService iUserProfileService;
+    @Autowired
+    private IQuestionMerchantService iQuestionMerchantService;
 
 
     @Override
     @Override
     public OrderGoodsVo queryById(Long orderGoodsId) {
     public OrderGoodsVo queryById(Long orderGoodsId) {
@@ -675,6 +679,43 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
                     examApplyGoodsVos.addAll(examApplyGoodsVos2);
                     examApplyGoodsVos.addAll(examApplyGoodsVos2);
                     goodsVo.setExamApplyGoodsList(examApplyGoodsVos);
                     goodsVo.setExamApplyGoodsList(examApplyGoodsVos);
                 }
                 }
+
+                //预约考试是否可以购买题库(该商品没有关联题库且预约考试的时间提前8天)
+                UserSubscribe userSubscribeTwo = iUserSubscribeService.getOne(new LambdaQueryWrapper<UserSubscribe>()
+                        .eq(UserSubscribe::getOrderGoodsId,goodsVo.getOrderGoodsId())
+                        .eq(UserSubscribe::getSubscribeStatus,1)
+                        .eq(UserSubscribe::getExamStatus,0)
+                        .last("limit 1"));
+                if (ObjectUtils.isNotNull(userSubscribeTwo)){
+                    Goods goods = iGoodsService.getById(goodsVo.getGoodsId());
+                    if (ObjectUtils.isNull(goods.getQuestionGoodsId())){
+                        //没有关联题库 是否购买过题库
+                        int count = iGoodsQuestionRelService.count(new LambdaQueryWrapper<GoodsQuestionRel>()
+                                .eq(GoodsQuestionRel::getOrderGoodsId, userSubscribeTwo.getOrderGoodsId())
+                                .gt(GoodsQuestionRel::getQuestionDoNum, 0));
+                        if (count <= 0){
+                            //考试时间往前推8天
+                            Long appointTime = DateUtils.getDayBefore(userSubscribeTwo.getApplySiteExamTime(), 8);
+                            if (DateUtils.getNowTime() < appointTime){
+                                goodsVo.setOpenQuestion(1);
+                                //获取默认题库商家商品
+                                QuestionMerchant one = iQuestionMerchantService.getOne(new LambdaQueryWrapper<QuestionMerchant>()
+                                        .eq(QuestionMerchant::getSign, 1)
+                                        .eq(QuestionMerchant::getStatus, 1)
+                                        .last("limit 1"));
+                                if (ObjectUtils.isNotNull(one)){
+                                    Goods goodsOne = iGoodsService.getOne(new LambdaQueryWrapper<Goods>()
+                                            .eq(Goods::getQuestionMerchantId, one.getMerchantId())
+                                            .eq(Goods::getStatus, 1)
+                                            .last("limit 1"));
+                                    if (ObjectUtils.isNotNull(goodsOne)){
+                                        goodsVo.setQuestionGoodsId(goodsOne.getGoodsId());
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
             }
             }
         }
         }
         return list;
         return list;

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/vo/OrderGoodsVo.java

@@ -349,4 +349,10 @@ public class OrderGoodsVo {
 
 
 	@ApiModelProperty("是否可以预约标识:1未参加考试 2已参加考试 3考试成绩未通过")
 	@ApiModelProperty("是否可以预约标识:1未参加考试 2已参加考试 3考试成绩未通过")
 	private Integer subscribeSign;
 	private Integer subscribeSign;
+
+	@ApiModelProperty("学员是否可以购买题库:1是 0否")
+	private Integer openQuestion;
+
+	@ApiModelProperty("关联题库商品ID")
+	private Long questionGoodsId;
 }
 }