|
@@ -10,13 +10,25 @@ import com.zhongzheng.common.core.redis.RedisLockEntity;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
|
+import com.zhongzheng.common.utils.ToolsUtils;
|
|
|
import com.zhongzheng.modules.bank.domain.QuestionChapterExam;
|
|
|
import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
|
|
|
import com.zhongzheng.modules.base.service.IProfileTpService;
|
|
|
import com.zhongzheng.modules.base.service.IShoppingCartService;
|
|
|
+import com.zhongzheng.modules.course.bo.CourseMenuQueryBo;
|
|
|
import com.zhongzheng.modules.course.service.ICourseBusinessService;
|
|
|
+import com.zhongzheng.modules.course.service.ICourseMenuService;
|
|
|
import com.zhongzheng.modules.course.vo.CourseBusinessVo;
|
|
|
+import com.zhongzheng.modules.course.vo.CourseMenuVo;
|
|
|
+import com.zhongzheng.modules.course.vo.CourseModuleFreeExamVo;
|
|
|
+import com.zhongzheng.modules.course.vo.CourseVo;
|
|
|
+import com.zhongzheng.modules.goods.bo.GoodsAttachedAddBo;
|
|
|
+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.service.IGoodsCourseService;
|
|
|
+import com.zhongzheng.modules.goods.service.IGoodsFreeBankService;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import com.zhongzheng.modules.grade.bo.ClassGradeQueryBo;
|
|
|
import com.zhongzheng.modules.grade.bo.ClassGradeUserTempQueryBo;
|
|
@@ -81,10 +93,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
private IClassGradeUserService iClassGradeUserService;
|
|
|
@Autowired
|
|
|
private IClassGradeGoodsService iClassGradeGoodsService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private IGoodsCourseService iGoodsCourseService;
|
|
|
@Autowired
|
|
|
private IOrderBillSheetService iOrderBillSheetService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private ICourseMenuService iCourseMenuService;
|
|
|
@Autowired
|
|
|
private IProfileTpService iProfileTpService;
|
|
|
|
|
@@ -112,6 +126,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
@Autowired
|
|
|
private IUserExamGoodsService userExamGoodsService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IGoodsFreeBankService iGoodsFreeBankService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IOrderGoodsFreeService iOrderGoodsFreeService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
|
|
@@ -349,6 +369,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
throw new CustomException("分班错误");
|
|
|
}
|
|
|
iOrderGoodsService.updateById(orderGoods);
|
|
|
+ newFreeBankGoods(goods.getGoodsId(), orderGoods.getOrderGoodsId());
|
|
|
}
|
|
|
|
|
|
if (!canRepeatBuy && goods.getGoodsType() != 3 && goods.getGoodsType() != 4) {
|
|
@@ -481,6 +502,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
throw new CustomException("分班错误",510);
|
|
|
}
|
|
|
iOrderGoodsService.updateById(orderGoods);
|
|
|
+ newFreeBankGoods(goods.getGoodsId(), orderGoods.getOrderGoodsId());
|
|
|
}
|
|
|
|
|
|
if (!canRepeatBuy && goods.getGoodsType() != 3 && goods.getGoodsType() != 4) {
|
|
@@ -653,6 +675,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
redisCache.unlockLua(redisLockEntity);
|
|
|
}
|
|
|
iOrderGoodsService.updateById(orderGoods);
|
|
|
+ newFreeBankGoods(goods.getGoodsId(), orderGoods.getOrderGoodsId());
|
|
|
}
|
|
|
|
|
|
if (!canRepeatBuy && goods.getGoodsType() != 3 && goods.getGoodsType() != 4) {
|
|
@@ -796,6 +819,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
redisCache.unlockLua(redisLockEntity);
|
|
|
}
|
|
|
iOrderGoodsService.updateById(orderGoods);
|
|
|
+ newFreeBankGoods(goods.getGoodsId(), orderGoods.getOrderGoodsId());
|
|
|
}
|
|
|
|
|
|
if (!canRepeatBuy && goods.getGoodsType() != 3 && goods.getGoodsType() != 4) {
|
|
@@ -1053,6 +1077,106 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
return baseMapper.getConsoleRebuyNum(bo);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 课程商品ID产生免费的题库商品
|
|
|
+ * @param goodsId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Long newFreeBankGoods(Long goodsId, Long orderGoodsId) {
|
|
|
+ Long freeBankGoodsId = null;
|
|
|
+ String key = "FREEBANK-" + "-" + goodsId;
|
|
|
+ Long value = redisCache.getCacheObject(key);
|
|
|
+ if (Validator.isNotEmpty(value)) {
|
|
|
+ freeBankGoodsId = value;
|
|
|
+ if(freeBankGoodsId.longValue()<0){
|
|
|
+ freeBankGoodsId = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<CourseModuleFreeExamVo> moduleExamList = new ArrayList<>();
|
|
|
+ if(Validator.isEmpty(freeBankGoodsId)){
|
|
|
+ List<CourseVo> courseVoList = iGoodsCourseService.selectList(goodsId);
|
|
|
+ for(CourseVo vo : courseVoList){
|
|
|
+ CourseMenuQueryBo bo = new CourseMenuQueryBo();
|
|
|
+ bo.setCourseId(vo.getCourseId());
|
|
|
+ bo.setType(1);//过滤模块
|
|
|
+ List<CourseMenuVo> moduleList = iCourseMenuService.selectList(bo);
|
|
|
+ for(CourseMenuVo menuVo : moduleList){
|
|
|
+ if(Validator.isNotEmpty(menuVo.getExamType())&&Validator.isNotEmpty(menuVo.getFreeExamId())){
|
|
|
+ //获取模块绑定的免费卷ID
|
|
|
+ CourseModuleFreeExamVo freeExamVo = BeanUtil.toBean(menuVo, CourseModuleFreeExamVo.class);
|
|
|
+ boolean hasExit = false;
|
|
|
+ for(int i=0;i<moduleExamList.size();i++){
|
|
|
+ if(moduleExamList.get(i).getExamType()==freeExamVo.getExamType()&&moduleExamList.get(i).getFreeExamId().longValue()==freeExamVo.getFreeExamId().longValue()){
|
|
|
+ hasExit = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!hasExit){
|
|
|
+ moduleExamList.add(freeExamVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //课程模块有赠送的试卷
|
|
|
+ if(moduleExamList.size()>0){
|
|
|
+ String jsonList = JSON.toJSONString(moduleExamList);
|
|
|
+ String examListMd5 = ToolsUtils.StringToMd5(jsonList);
|
|
|
+ //判断该课程商品是否已经存在相同结构的赠送卷商品
|
|
|
+ GoodsFreeBank freeBank = iGoodsFreeBankService.getOne(new LambdaQueryWrapper<GoodsFreeBank>().eq(GoodsFreeBank::getFromGoodsId, goodsId)
|
|
|
+ .eq(GoodsFreeBank::getMd5, examListMd5));
|
|
|
+ if(Validator.isNotEmpty(freeBank)){
|
|
|
+ freeBankGoodsId = freeBank.getGoodsId();//赠送的商品ID
|
|
|
+ }else{
|
|
|
+ Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId, goodsId));//获取课程商品
|
|
|
+ String code = ServletUtils.getEncoded("ZS");
|
|
|
+ //创建赠送卷商品
|
|
|
+ GoodsBankAddBo addBo = new GoodsBankAddBo();
|
|
|
+ addBo.setGoodsType(5);
|
|
|
+ String goodsName = goods.getGoodsName()+"-"+code;
|
|
|
+ addBo.setGoodsName(goodsName);
|
|
|
+ addBo.setEducationTypeId(goods.getEducationTypeId());
|
|
|
+ addBo.setProjectId(goods.getProjectId());
|
|
|
+ addBo.setBusinessId(goods.getBusinessId());
|
|
|
+ addBo.setMajorId(goods.getMajorId());
|
|
|
+ addBo.setCoverUrl("oss/images/avatar/20211013/1634097664410_1397766697");
|
|
|
+ List<GoodsAttachedAddBo> bankList = new ArrayList<>();
|
|
|
+ int sort = 1;
|
|
|
+ for(CourseModuleFreeExamVo menuVo :moduleExamList){
|
|
|
+ GoodsAttachedAddBo attachedAddBo = new GoodsAttachedAddBo();
|
|
|
+ attachedAddBo.setType(menuVo.getExamType());
|
|
|
+ attachedAddBo.setMajorId(menuVo.getFreeExamId());
|
|
|
+ attachedAddBo.setSort(sort);
|
|
|
+ sort++;
|
|
|
+ bankList.add(attachedAddBo);
|
|
|
+ }
|
|
|
+ addBo.setBankList(bankList);
|
|
|
+ addBo.setStatus(1);
|
|
|
+ addBo.setGoodsStatus(1);
|
|
|
+ addBo.setStandPrice(new BigDecimal(0));
|
|
|
+ freeBankGoodsId = iGoodsService.insertBankByAddBo(addBo);
|
|
|
+ GoodsFreeBankAddBo bankAddBo = new GoodsFreeBankAddBo();
|
|
|
+ bankAddBo.setGoodsId(freeBankGoodsId);
|
|
|
+ bankAddBo.setFromGoodsId(goodsId);
|
|
|
+ bankAddBo.setExamJson(jsonList);
|
|
|
+ bankAddBo.setMd5(examListMd5);
|
|
|
+ iGoodsFreeBankService.insertByAddBo(bankAddBo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(Validator.isNotEmpty(freeBankGoodsId)){
|
|
|
+ OrderGoodsFreeAddBo goodsFreeAddBo = new OrderGoodsFreeAddBo();
|
|
|
+ goodsFreeAddBo.setFreeGoodsId(freeBankGoodsId);
|
|
|
+ goodsFreeAddBo.setOrderGoodsId(orderGoodsId);
|
|
|
+ iOrderGoodsFreeService.insertByAddBo(goodsFreeAddBo);
|
|
|
+ }else{
|
|
|
+ freeBankGoodsId = -1L; //课程商品不存在免费题库商品
|
|
|
+ }
|
|
|
+ redisCache.setCacheObject(key, freeBankGoodsId, 10, TimeUnit.SECONDS);
|
|
|
+
|
|
|
+ return freeBankGoodsId;
|
|
|
+ }
|
|
|
+
|
|
|
//判断视频商品是否购买过且服务期是否过期
|
|
|
public Long getHaveBuyGoods(Long goodsId, Long userId) {
|
|
|
OrderGoodsQueryBo orderGoodsQueryBo = new OrderGoodsQueryBo();
|