|
@@ -881,6 +881,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
.eq(UserSubscribe::getUserId, one.getUserId())
|
|
|
.eq(UserSubscribe::getOrderGoodsId, orderGoods.getOrderGoodsId())
|
|
|
.eq(UserSubscribe::getSubscribeStatus, 1)
|
|
|
+ .eq(UserSubscribe::getExamStatus,0)
|
|
|
.last("limit 1"));
|
|
|
if (ObjectUtils.isNull(subscribe)){
|
|
|
return add;
|
|
@@ -895,7 +896,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void questionOrderHandle(Long orderGoodsId,Long goodsId,Long qsOrderGoodsId) {
|
|
|
+ private void questionOrderHandle(Long orderGoodsId,Long goodsId,Long qsOrderGoodsId,Long userId) {
|
|
|
//第三方题库商品
|
|
|
Goods questionGoods = iGoodsService.getById(goodsId);
|
|
|
if (ObjectUtils.isNull(questionGoods) || questionGoods.getGoodsType() != 9){
|
|
@@ -917,6 +918,29 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
rel.setCreateTime(DateUtils.getNowTime());
|
|
|
rel.setUpdateTime(DateUtils.getNowTime());
|
|
|
iGoodsQuestionRelService.save(rel);
|
|
|
+ //补充题库商品服务时间
|
|
|
+ setQuestionServiceTime(qsOrderGoodsId,userId);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void setQuestionServiceTime(Long orderGoodsId,Long userId) {
|
|
|
+ UserSubscribe subscribe = iUserSubscribeService.getOne(new LambdaQueryWrapper<UserSubscribe>()
|
|
|
+ .eq(UserSubscribe::getUserId, userId)
|
|
|
+ .eq(UserSubscribe::getOrderGoodsId, orderGoodsId)
|
|
|
+ .eq(UserSubscribe::getSubscribeStatus, 1)
|
|
|
+ .eq(UserSubscribe::getExamStatus,0)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNull(subscribe)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //考试日期
|
|
|
+ Long examTime = subscribe.getApplySiteExamTime();
|
|
|
+ //前推8天
|
|
|
+ Long dayBefore = DateUtils.getDayBefore(examTime, 8);
|
|
|
+ OrderGoods orderGoods = iOrderGoodsService.getById(orderGoodsId);
|
|
|
+ orderGoods.setServiceStartTime(dayBefore);
|
|
|
+ orderGoods.setServiceEndTime(examTime);
|
|
|
+ iOrderGoodsService.updateById(orderGoods);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -1010,7 +1034,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
boolean orderGoodsRs = iOrderGoodsService.save(orderGoods);
|
|
|
if (ObjectUtils.isNotNull(g.getRelevanceId())){
|
|
|
//购买关联题库商品
|
|
|
- questionOrderHandle(g.getRelevanceId(),g.getGoodsId(),orderGoods.getOrderGoodsId());
|
|
|
+ questionOrderHandle(g.getRelevanceId(),g.getGoodsId(),orderGoods.getOrderGoodsId(),bo.getUserId());
|
|
|
}
|
|
|
boolean canRepeatBuy = false;
|
|
|
validUserBeforeBuy(goods, bo.getUserId());
|
|
@@ -1408,7 +1432,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
boolean orderGoodsRs = iOrderGoodsService.save(orderGoods);
|
|
|
if (ObjectUtils.isNotNull(g.getRelevanceId())){
|
|
|
//购买关联题库商品
|
|
|
- questionOrderHandle(g.getRelevanceId(),g.getGoodsId(),orderGoods.getOrderGoodsId());
|
|
|
+ questionOrderHandle(g.getRelevanceId(),g.getGoodsId(),orderGoods.getOrderGoodsId(),bo.getUserId());
|
|
|
}
|
|
|
boolean canRepeatBuy = false;
|
|
|
validUserBeforeBuy(goods, bo.getUserId());
|
|
@@ -1569,7 +1593,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
boolean orderGoodsRs = iOrderGoodsService.save(orderGoods);
|
|
|
if (ObjectUtils.isNotNull(g.getRelevanceId())){
|
|
|
//购买关联题库商品
|
|
|
- questionOrderHandle(g.getRelevanceId(),g.getGoodsId(),orderGoods.getOrderGoodsId());
|
|
|
+ questionOrderHandle(g.getRelevanceId(),g.getGoodsId(),orderGoods.getOrderGoodsId(),bo.getUserId());
|
|
|
}
|
|
|
boolean canRepeatBuy = false;
|
|
|
validUserBeforeBuy(goods, bo.getUserId());
|
|
@@ -2806,13 +2830,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
//校验学员是否已经购买题库
|
|
|
UserSubscribe userSubscribe = iUserSubscribeService.getById(userSubscribeId);
|
|
|
User user = iUserService.getById(userSubscribe.getUserId());
|
|
|
- if (ObjectUtils.isNull(userSubscribe)){
|
|
|
- throw new CustomException(String.format("学员【%s】预约信息有误",user.getRealname()));
|
|
|
+ if (ObjectUtils.isNull(userSubscribe) || userSubscribe.getSubscribeStatus() == 0){
|
|
|
+ throw new CustomException(String.format("学员【%s】没有预约考试,请勿开通题库",user.getRealname()));
|
|
|
}
|
|
|
int count = iGoodsQuestionRelService.count(new LambdaQueryWrapper<GoodsQuestionRel>()
|
|
|
.eq(GoodsQuestionRel::getOrderGoodsId, userSubscribe.getOrderGoodsId())
|
|
|
.eq(GoodsQuestionRel::getQuestionGoodsId, bo.getGoodsId())
|
|
|
- .eq(GoodsQuestionRel::getStatus, 1)
|
|
|
.gt(GoodsQuestionRel::getQuestionDoNum, 0));
|
|
|
if (count > 0) {
|
|
|
throw new CustomException(String.format("学员【%s】已购买当前题库商品,请勿重复开通!",user.getRealname()));
|