|
@@ -38,6 +38,7 @@ import com.zhongzheng.modules.distribution.service.IDistributionActivityService;
|
|
|
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.bo.QuestionOpenImportBo;
|
|
|
import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.domain.GoodsFreeBank;
|
|
|
import com.zhongzheng.modules.goods.domain.GoodsQuestionRel;
|
|
@@ -46,6 +47,7 @@ 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.goods.vo.QuestionOpenImportVo;
|
|
|
import com.zhongzheng.modules.grade.bo.ClassGradeListBo;
|
|
|
import com.zhongzheng.modules.grade.bo.ClassGradeQueryBo;
|
|
|
import com.zhongzheng.modules.grade.bo.ClassGradeSortBo;
|
|
@@ -2230,6 +2232,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
|
|
|
//检查是否购买过商品
|
|
|
public boolean checkBuyGoods(Long goodsId, Long userId, Integer goodsType) {
|
|
|
+ if (goodsType == 9){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
String businessName = iGoodsService.getGoodsBusinessName(goodsId);
|
|
|
if (businessName.contains("继续教育") && businessName.contains("施工现场专业人员")){
|
|
|
return true;
|
|
@@ -2653,6 +2658,160 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public QuestionOpenImportVo questionGoodsOpenImport(List<QuestionOpenImportBo> importBoList,Long loginId,String loginName) {
|
|
|
+ QuestionOpenImportVo importVo = new QuestionOpenImportVo();
|
|
|
+ List<Long> userIds = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ List<String> errorMsgList = new ArrayList<>();
|
|
|
+ for (QuestionOpenImportBo bo : importBoList) {
|
|
|
+ String error = "";
|
|
|
+ User user = iUserService.getOne(new LambdaQueryWrapper<User>()
|
|
|
+ .eq(User::getIdCard, EncryptHandler.encrypt(bo.getIdCard())));
|
|
|
+ if (ObjectUtils.isNull(user)){
|
|
|
+ error = String.format("【%s】学员信息查询不到,请检查身份证号码",bo.getUserName());
|
|
|
+ errorMsgList.add(error);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<UserSubscribe> subscribeList = iUserSubscribeService.list(new LambdaQueryWrapper<UserSubscribe>()
|
|
|
+ .eq(UserSubscribe::getUserId, user.getUserId())
|
|
|
+ .eq(UserSubscribe::getSubscribeStatus, 1)
|
|
|
+ .eq(UserSubscribe::getExamStatus, 0));
|
|
|
+ if (CollectionUtils.isEmpty(subscribeList)){
|
|
|
+ error = String.format("【%s】学员没有预约考试,请检查",bo.getUserName());
|
|
|
+ errorMsgList.add(error);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<Goods> goodsList = iGoodsService.listByIds(subscribeList.stream().map(UserSubscribe::getGoodsId).collect(Collectors.toList()));
|
|
|
+ List<Major> majorList = iMajorService.listByIds(goodsList.stream().filter(x -> ObjectUtils.isNotNull(x.getMajorId())).map(Goods::getMajorId).collect(Collectors.toList()));
|
|
|
+ if (CollectionUtils.isEmpty(majorList)){
|
|
|
+ error = String.format("【%s】学员没有预约当前专业课的考试,请检查",bo.getUserName());
|
|
|
+ errorMsgList.add(error);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (majorList.stream().noneMatch(x -> x.getCategoryName().equals(bo.getApplyMajor()))){
|
|
|
+ error = String.format("【%s】学员没有预约当前专业课的考试,请检查",bo.getUserName());
|
|
|
+ errorMsgList.add(error);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ QuestionMerchant merchant = iQuestionMerchantService.getOne(new LambdaQueryWrapper<QuestionMerchant>()
|
|
|
+ .eq(QuestionMerchant::getMerchantName, bo.getMerchant())
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNull(merchant)){
|
|
|
+ error = String.format("【%s】学员开通题库商家不存在,请检查商家名称",bo.getUserName());
|
|
|
+ errorMsgList.add(error);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //学员是否已开通题库
|
|
|
+ UserSubscribe userSubscribe = subscribeList.stream().filter(item -> {
|
|
|
+ Goods goods = iGoodsService.getById(item.getGoodsId());
|
|
|
+ if (ObjectUtils.isNull(goods.getMajorId())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ Major major = iMajorService.getById(goods.getMajorId());
|
|
|
+ return major.getCategoryName().equals(bo.getApplyMajor());
|
|
|
+ }).findFirst().orElse(null);
|
|
|
+ if (ObjectUtils.isNull(userSubscribe)){
|
|
|
+ error = String.format("【%s】学员预约考试信息异常,请联系管理员",bo.getUserName());
|
|
|
+ errorMsgList.add(error);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ int count = iGoodsQuestionRelService.count(new LambdaQueryWrapper<GoodsQuestionRel>()
|
|
|
+ .eq(GoodsQuestionRel::getOrderGoodsId, userSubscribe.getOrderGoodsId())
|
|
|
+ .gt(GoodsQuestionRel::getQuestionDoNum, 0)
|
|
|
+ .eq(GoodsQuestionRel::getStatus, 1));
|
|
|
+ if (count > 0){
|
|
|
+ error = String.format("【%s】学员已开通该题库,请勿重复开通!",bo.getUserName());
|
|
|
+ errorMsgList.add(error);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //题库开通
|
|
|
+ questionOpen(user,merchant,userSubscribe,loginId,loginName);
|
|
|
+
|
|
|
+ //是否发送短信
|
|
|
+ if (ObjectUtils.isNotNull(bo.getSendStatus()) && bo.getSendStatus().equals("是")){
|
|
|
+ userIds.add(user.getUserId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ importVo.setErrorMsgList(errorMsgList);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ //短信发送
|
|
|
+ return importVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void questionOpen(User user, QuestionMerchant merchant,UserSubscribe userSubscribe,Long loginId,String loginName) {
|
|
|
+ //商家商品
|
|
|
+ Goods merGoods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>()
|
|
|
+ .eq(Goods::getQuestionMerchantId, merchant.getMerchantId())
|
|
|
+ .eq(Goods::getStatus, 1)
|
|
|
+ .last("limit 1"));
|
|
|
+
|
|
|
+ Order order = new Order();
|
|
|
+ //生成订单号
|
|
|
+ String out_trade_no = DateUtils.getDateOrderSn();
|
|
|
+ order.setOrderSn(out_trade_no);
|
|
|
+ order.setUserId(user.getUserId());
|
|
|
+ order.setOrderPrice(merGoods.getStandPrice());
|
|
|
+ order.setOrderStatus(1);
|
|
|
+ order.setCreateTime(DateUtils.getNowTime());
|
|
|
+ order.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ order.setPayTime(DateUtils.getNowTime());
|
|
|
+ order.setPayType(8);
|
|
|
+ order.setFinishTime(DateUtils.getNowTime());
|
|
|
+ order.setOrderType(4);
|
|
|
+ order.setPayPrice(merGoods.getStandPrice());
|
|
|
+ order.setOrderFrom(9);
|
|
|
+ order.setCreateUsername(loginName);
|
|
|
+ order.setStatus(1);
|
|
|
+ order.setCreateSysUserId(loginId);
|
|
|
+ order.setOrderBase(1);
|
|
|
+ order.setPayStatus(2);
|
|
|
+ order.setCheckStatus(1);
|
|
|
+ order.setOrderRefundStatus(1);
|
|
|
+ order.setInvoiceStatus(0);
|
|
|
+ order.setFinishStatus(1);
|
|
|
+ order.setAccomplishTime(DateUtils.getNowTime());
|
|
|
+ order.setOperationType(1);
|
|
|
+ save(order);
|
|
|
+ //订单商品
|
|
|
+ OrderGoods add = new OrderGoods();
|
|
|
+ add.setOrderSn(out_trade_no);
|
|
|
+ add.setGoodsId(merGoods.getGoodsId());
|
|
|
+ add.setGoodsYear(merGoods.getYear().toString());
|
|
|
+ add.setGoodsRealPrice(merGoods.getStandPrice());
|
|
|
+ add.setGoodsPrice(merGoods.getStandPrice());
|
|
|
+ add.setCreateTime(DateUtils.getNowTime());
|
|
|
+ add.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ add.setStatus(1);
|
|
|
+ add.setGoodsReceived(order.getOrderPrice());
|
|
|
+ add.setRefundStatus(0);
|
|
|
+ add.setPayStatus(3);
|
|
|
+ //考试日期
|
|
|
+ Long examTime = userSubscribe.getApplySiteExamTime();
|
|
|
+ //前推8天
|
|
|
+ Long dayBefore = DateUtils.getDayBefore(examTime, 8);
|
|
|
+ add.setServiceStartTime(dayBefore);
|
|
|
+ add.setServiceEndTime(examTime);
|
|
|
+ iOrderGoodsService.save(add);
|
|
|
+
|
|
|
+ //题库关联
|
|
|
+ GoodsQuestionRel rel = new GoodsQuestionRel();
|
|
|
+ rel.setOrderGoodsId(userSubscribe.getOrderGoodsId());
|
|
|
+ rel.setQsOrderGoodsId(add.getOrderGoodsId());
|
|
|
+ rel.setQuestionGoodsId(merGoods.getGoodsId());
|
|
|
+ rel.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ rel.setCreateTime(DateUtils.getNowTime());
|
|
|
+ rel.setStatus(1);
|
|
|
+ rel.setQuestionDoNum(merchant.getDoNum());
|
|
|
+ iGoodsQuestionRelService.save(rel);
|
|
|
+ }
|
|
|
+
|
|
|
private String createGradeCode(Long goodsId, CourseBusinessVo business) {
|
|
|
|
|
|
Goods goods = iGoodsService.getById(goodsId);
|