|
@@ -5,19 +5,26 @@ import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
+import com.zhongzheng.modules.bank.service.IQuestionOtherService;
|
|
|
import com.zhongzheng.modules.course.domain.CourseTopic;
|
|
|
+import com.zhongzheng.modules.course.domain.Major;
|
|
|
+import com.zhongzheng.modules.course.service.IMajorService;
|
|
|
import com.zhongzheng.modules.goods.bo.GoodsQuestionRelExamAddBo;
|
|
|
import com.zhongzheng.modules.goods.bo.GoodsQuestionRelExamEditBo;
|
|
|
import com.zhongzheng.modules.goods.bo.GoodsQuestionRelExamQueryBo;
|
|
|
+import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.domain.GoodsQuestionRel;
|
|
|
import com.zhongzheng.modules.goods.domain.GoodsQuestionRelExam;
|
|
|
import com.zhongzheng.modules.goods.mapper.GoodsQuestionRelExamMapper;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsCourseService;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsQuestionRelExamService;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsQuestionRelService;
|
|
|
+import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsQuestionRelExamVo;
|
|
|
import com.zhongzheng.modules.order.domain.OrderGoods;
|
|
|
import com.zhongzheng.modules.order.service.IOrderGoodsService;
|
|
|
+import com.zhongzheng.modules.user.domain.UserSubscribe;
|
|
|
+import com.zhongzheng.modules.user.service.IUserSubscribeService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -46,6 +53,18 @@ public class GoodsQuestionRelExamServiceImpl extends ServiceImpl<GoodsQuestionRe
|
|
|
@Autowired
|
|
|
private IOrderGoodsService iOrderGoodsService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IGoodsService iGoodsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IMajorService iMajorService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IQuestionOtherService iQuestionOtherService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserSubscribeService iUserSubscribeService;
|
|
|
+
|
|
|
@Override
|
|
|
public GoodsQuestionRelExamVo queryById(Long id){
|
|
|
GoodsQuestionRelExam db = this.baseMapper.selectById(id);
|
|
@@ -108,21 +127,42 @@ public class GoodsQuestionRelExamServiceImpl extends ServiceImpl<GoodsQuestionRe
|
|
|
validEntityBeforeSave(add);
|
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
|
- add.setExpTime(DateUtils.getNowTime()+7*24*3600);
|
|
|
+
|
|
|
GoodsQuestionRel questionRel = iGoodsQuestionRelService.getOne(new LambdaQueryWrapper<GoodsQuestionRel>()
|
|
|
.eq(GoodsQuestionRel::getId, bo.getRelId()).eq(GoodsQuestionRel::getStatus, 1));
|
|
|
if(Validator.isEmpty(questionRel)){
|
|
|
throw new CustomException("该题库商品无法访问");
|
|
|
}
|
|
|
- OrderGoods orderGoods = iOrderGoodsService.getOne(new LambdaQueryWrapper<OrderGoods>()
|
|
|
+ OrderGoods qsOrderGoods = iOrderGoodsService.getOne(new LambdaQueryWrapper<OrderGoods>()
|
|
|
.eq(OrderGoods::getOrderGoodsId, questionRel.getQsOrderGoodsId()));
|
|
|
- if(Validator.isEmpty(orderGoods)||orderGoods.getServiceEndTime()<DateUtils.getNowTime()||orderGoods.getServiceStartTime()>DateUtils.getNowTime()){
|
|
|
+ if(Validator.isEmpty(qsOrderGoods)||qsOrderGoods.getServiceEndTime()<DateUtils.getNowTime()||qsOrderGoods.getServiceStartTime()>DateUtils.getNowTime()){
|
|
|
throw new CustomException("未在服务期内无法访问");
|
|
|
-
|
|
|
}
|
|
|
if(questionRel.getQuestionDoNum()<1){
|
|
|
throw new CustomException("该题库商品试卷可用次数不足");
|
|
|
}
|
|
|
+ UserSubscribe userSubscribe = iUserSubscribeService.getOne(new LambdaQueryWrapper<UserSubscribe>()
|
|
|
+ .eq(UserSubscribe::getUserId, bo.getUserId()).eq(UserSubscribe::getOrderGoodsId, questionRel.getOrderGoodsId())
|
|
|
+ .eq(UserSubscribe::getExamStatus, 1).orderByDesc(UserSubscribe::getSubscribeId).last("limit 1"));
|
|
|
+ if(Validator.isEmpty(userSubscribe)){
|
|
|
+ throw new CustomException("预约数据不存在");
|
|
|
+ }
|
|
|
+ OrderGoods orderGoods = iOrderGoodsService.getOne(new LambdaQueryWrapper<OrderGoods>()
|
|
|
+ .eq(OrderGoods::getOrderGoodsId, questionRel.getOrderGoodsId()));
|
|
|
+ Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>()
|
|
|
+ .eq(Goods::getGoodsId, orderGoods.getGoodsId()));
|
|
|
+ if(Validator.isEmpty(goods.getMajorId())){
|
|
|
+ throw new CustomException("商品专业不存在");
|
|
|
+ }
|
|
|
+ Major major = iMajorService.getOne(new LambdaQueryWrapper<Major>()
|
|
|
+ .eq(Major::getId, goods.getMajorId()));
|
|
|
+ Long examId = iQuestionOtherService.queryByUserMajor(bo.getUserId(),major.getCategoryName());
|
|
|
+ if(Validator.isEmpty(examId)){
|
|
|
+ throw new CustomException("试卷不存在");
|
|
|
+ }
|
|
|
+ add.setExpTime(qsOrderGoods.getServiceEndTime());
|
|
|
+ add.setExamId(examId);
|
|
|
+ add.setUserSubscribeId(userSubscribe.getSubscribeId());
|
|
|
this.save(add);
|
|
|
return BeanUtil.toBean(add,GoodsQuestionRelExamVo.class);
|
|
|
}
|