yangdamao hace 2 años
padre
commit
7cac2cd5f2

+ 16 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/order/OrderController.java

@@ -10,6 +10,8 @@ import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.SecurityUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.framework.web.service.TokenService;
+import com.zhongzheng.modules.goods.bo.QuestionOpenImportBo;
+import com.zhongzheng.modules.goods.vo.QuestionOpenImportVo;
 import com.zhongzheng.modules.grade.vo.ClassPeriodStudentExportAllVo;
 import com.zhongzheng.modules.order.bo.*;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
@@ -18,6 +20,7 @@ import com.zhongzheng.modules.order.vo.OrderGoodsVo;
 import com.zhongzheng.modules.order.vo.OrderListVo;
 import com.zhongzheng.modules.order.vo.OrderVo;
 import com.zhongzheng.modules.user.bo.UserSubscribeExportBo;
+import com.zhongzheng.modules.user.vo.UserSubscribeImport;
 import lombok.RequiredArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -37,6 +40,7 @@ import com.zhongzheng.common.utils.poi.ExcelUtil;
 import com.zhongzheng.common.core.page.TableDataInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * 订单Controller
@@ -182,5 +186,17 @@ public class OrderController extends BaseController {
         return toAjax(iOrderService.questionGoodsOpen(bo) ? 1 : 0);
     }
 
+    /**
+     * 七大员题库商品导入开通
+     */
+    @ApiOperation("七大员题库商品导入开通")
+    @PostMapping("/question/open/import")
+    public AjaxResult<QuestionOpenImportVo> questionGoodsOpenImport(MultipartFile file)throws Exception {
+        ExcelUtil<QuestionOpenImportBo> util = new ExcelUtil<>(QuestionOpenImportBo.class);
+        List<QuestionOpenImportBo> importBoList = util.importExcel(file.getInputStream());
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        return AjaxResult.success(iOrderService.questionGoodsOpenImport(importBoList,loginUser.getUser().getUserId(),SecurityUtils.getUsername()));
+    }
+
 
 }

+ 33 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/QuestionOpenImportBo.java

@@ -0,0 +1,33 @@
+package com.zhongzheng.modules.goods.bo;
+
+import com.zhongzheng.common.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author yangdamao
+ * @date 2023年09月07日 18:01
+ */
+@Data
+public class QuestionOpenImportBo implements Serializable {
+
+    @Excel(name = "*姓名")
+    private String userName;
+
+    @Excel(name = "*身份证号" )
+    private String idCard;
+
+    @Excel(name = "*报考专业")
+    private String applyMajor;
+
+    @Excel(name = "是否已开通")
+    private String openStatus;
+
+    @Excel(name = "是否发送短信")
+    private String sendStatus;
+
+    @Excel(name = "*题库商家")
+    private String merchant;
+
+}

+ 16 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/vo/QuestionOpenImportVo.java

@@ -0,0 +1,16 @@
+package com.zhongzheng.modules.goods.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author yangdamao
+ * @date 2023年09月07日 17:53
+ */
+@Data
+public class QuestionOpenImportVo implements Serializable {
+
+    private List<String> errorMsgList;
+}

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/IOrderService.java

@@ -2,6 +2,8 @@ package com.zhongzheng.modules.order.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
+import com.zhongzheng.modules.goods.bo.QuestionOpenImportBo;
+import com.zhongzheng.modules.goods.vo.QuestionOpenImportVo;
 import com.zhongzheng.modules.order.bo.*;
 import com.zhongzheng.modules.order.domain.Order;
 import com.zhongzheng.modules.order.vo.OrderGoodsVo;
@@ -116,4 +118,7 @@ public interface IOrderService extends IService<Order> {
 	boolean questionGoodsOpen(questionOpenBo bo);
 
     Boolean studyCheck(Long orderGoodsId, Long userId);
+
+	QuestionOpenImportVo questionGoodsOpenImport(List<QuestionOpenImportBo> importBoList,Long userId,String userName);
+
 }

+ 159 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderServiceImpl.java

@@ -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);

+ 1 - 1
zhongzheng-system/src/main/resources/mapper/modules/exam/ExamApplyMapper.xml

@@ -622,7 +622,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             us.seat_number AS seatNum,
             u.realname AS userName,
             u.id_card AS idCard,
-            u.avatar
+            CONCAT("https://file.xyyxt.net/",u.avatar) AS imageUrl
         FROM
             user_subscribe us
                 LEFT JOIN `user` u ON us.user_id = u.user_id