yangdamao vor 2 Jahren
Ursprung
Commit
247fa73279

+ 15 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/common/CommonController.java

@@ -33,6 +33,7 @@ import com.zhongzheng.modules.distribution.service.IDistributionSellerService;
 import com.zhongzheng.modules.distribution.vo.DistributionSellerVo;
 import com.zhongzheng.modules.exam.bo.ExamApplyDetailBo;
 import com.zhongzheng.modules.exam.bo.ExamApplyResultBo;
+import com.zhongzheng.modules.exam.bo.ExamApplySubscribeBo;
 import com.zhongzheng.modules.exam.service.IExamApplyService;
 import com.zhongzheng.modules.exam.vo.ExamApplyDetailVo;
 import com.zhongzheng.modules.goods.bo.AlikeGoodsBo;
@@ -67,6 +68,7 @@ import com.zhongzheng.modules.system.vo.SysTenantVo;
 import com.zhongzheng.modules.top.user.bo.TopSysTenantRegisterAddBo;
 import com.zhongzheng.modules.top.user.service.ITopSysTenantRegisterService;
 import com.zhongzheng.modules.user.service.IUserService;
+import com.zhongzheng.modules.user.service.IUserSubscribeService;
 import com.zhongzheng.modules.wx.bo.WxShareGoodsBo;
 import com.zhongzheng.modules.wx.service.IWxPayService;
 import io.swagger.annotations.ApiOperation;
@@ -139,6 +141,8 @@ public class CommonController extends BaseController {
     @Autowired
     private IExamApplyService iExamApplyService;
     @Autowired
+    private IUserSubscribeService iUserSubscribeService;
+    @Autowired
     private IClassGradeUserService iClassGradeUserService;
 
     /**
@@ -269,6 +273,17 @@ public class CommonController extends BaseController {
         return AjaxResult.success();
     }
 
+    @ApiOperation("七大员考试预约")
+    @PostMapping("common/apply/subscribe")
+    public AjaxResult examApplySubscribe(@RequestBody ExamApplySubscribeBo bo) {
+        if (!ToolsUtils.checkSignFromOldSys(bo.getStamp().toString(), bo.getSign())) {
+            return AjaxResult.error("签名错误");
+        }
+        ServletUtils.getResponse().setHeader("TenantId",bo.getTenantId().toString());
+        iUserSubscribeService.examApplySubscribe(bo);
+        return AjaxResult.success();
+    }
+
 
     @ApiOperation("获取某场考试信息")
     @PostMapping("common/apply/detail")

+ 3 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseFileServiceImpl.java

@@ -135,7 +135,9 @@ public class CourseFileServiceImpl extends ServiceImpl<CourseFileMapper, CourseF
                 throw new CustomException("已有商品关联此讲义,不能改动!");
             }
         }
-        iCourseHandoutsService.update(new LambdaUpdateWrapper<CourseHandouts>().set(CourseHandouts::getUpdateStatus,0).eq(CourseHandouts::getHandoutsId,bo.getHandoutsId()));
+        iCourseHandoutsService.update(new LambdaUpdateWrapper<CourseHandouts>()
+                .set(CourseHandouts::getUpdateStatus,0)
+                .eq(CourseHandouts::getHandoutsId,bo.getHandoutsId()));
         Long nowTime = DateUtils.getNowTime();
         String sign = ToolsUtils.EncoderByMd5(nowTime.toString() + "pubilc2022");
         bo.setSign(sign);

+ 51 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/bo/ExamApplySubscribeBo.java

@@ -0,0 +1,51 @@
+package com.zhongzheng.modules.exam.bo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import java.io.Serializable;
+
+/**
+ * @author yangdamao
+ * @date 2023年06月20日 11:22
+ */
+@Data
+public class ExamApplySubscribeBo implements Serializable {
+
+    @ApiModelProperty("考生身份证号")
+    private String idCard;
+
+    @ApiModelProperty("联系方式")
+    private String telphone;
+
+    @ApiModelProperty("标识ID")
+    private Integer signId;
+
+    @ApiModelProperty("学员类型:1非补考 2补考")
+    private Integer studentType;
+
+    @ApiModelProperty("专业名称")
+    private String majorName;
+
+    @ApiModelProperty("考试日期")
+    private Long applyTime;
+
+    @ApiModelProperty("考试开始时间段")
+    private String applyStartTime;
+
+    @ApiModelProperty("考试结束时间段")
+    private String applyEndTime;
+
+    @ApiModelProperty("机构ID")
+    private Long tenantId;
+
+    @ApiModelProperty("当前时间戳")
+    @NotBlank(message = "当前时间戳不能为空")
+    private Long stamp;
+
+    @ApiModelProperty("签名")
+    @NotBlank(message = "签名不能为空")
+    private String sign;
+
+}

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/mapper/ExamApplyMapper.java

@@ -87,4 +87,6 @@ public interface ExamApplyMapper extends BaseMapper<ExamApply> {
 
     @InterceptorIgnore(tenantLine = "true")
     List<ExamApplyUserDetailVo> getExamUserInfo(ExamApplyDetailVo bo);
+
+    List<Long> getApplyGoodsId(@Param("applyId") Long applyId,@Param("majorName")  String majorName);
 }

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/IExamApplyService.java

@@ -5,6 +5,7 @@ import com.zhongzheng.modules.exam.bo.*;
 import com.zhongzheng.modules.exam.domain.ExamApply;
 import com.zhongzheng.modules.exam.vo.*;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 
 import java.util.Collection;
@@ -92,4 +93,6 @@ public interface IExamApplyService extends IService<ExamApply> {
 	ExamBeforeKnowVo getBeforeKnow();
 
 	boolean saveOrUpBeforeKnow(ExamBeforeKnowBo bo);
+
+    List<Long> getApplyGoodsId(Long applyId, String majorName);
 }

+ 7 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/impl/ExamApplyServiceImpl.java

@@ -34,6 +34,7 @@ import com.zhongzheng.modules.exam.domain.*;
 import com.zhongzheng.modules.exam.mapper.ExamApplyMapper;
 import com.zhongzheng.modules.exam.service.*;
 import com.zhongzheng.modules.exam.vo.*;
+import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import com.zhongzheng.modules.system.domain.SysConfig;
@@ -977,6 +978,12 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
         return true;
     }
 
+    @Override
+    public List<Long> getApplyGoodsId(Long applyId, String majorName) {
+        return baseMapper.getApplyGoodsId(applyId, majorName);
+    }
+
+
     private void userStudyRecord(String userPath, List<UserSubscribe> list) {
         Map<Long, List<UserSubscribe>> map = list.stream().collect(Collectors.groupingBy(UserSubscribe::getUserId));
         map.forEach((k, v) -> {

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/mapper/OrderGoodsMapper.java

@@ -66,4 +66,6 @@ public interface OrderGoodsMapper extends BaseMapper<OrderGoods> {
     List<TopOldOrderGoodsListVo> listByOrderSn(TopOldOrderGoodsQuery query);
 
     String getBusinessById(@Param("orderGoodsId") Long orderGoodsId);
+
+    List<OrderGoods> getApplyOrderGoods(@Param("goodsIds")List<Long> goodsIds,@Param("userId") Long userId);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/IOrderGoodsService.java

@@ -116,4 +116,6 @@ public interface IOrderGoodsService extends IService<OrderGoods> {
     List<TopOldOrderGoodsListVo> listByOrderSn(TopOldOrderGoodsQuery query);
 
     String getBusinessById(Long orderGoodsId);
+
+    List<OrderGoods> getApplyOrderGoods(List<Long> goodsIds, Long userId);
 }

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

@@ -719,6 +719,11 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
         return baseMapper.getBusinessById(orderGoodsId);
     }
 
+    @Override
+    public List<OrderGoods> getApplyOrderGoods(List<Long> goodsIds, Long userId) {
+        return baseMapper.getApplyOrderGoods(goodsIds,userId);
+    }
+
     private boolean checkUnique(Long GoodsId,Long UserId) {
         ShoppingCart info = iShoppingCartService.getOne(new LambdaQueryWrapper<ShoppingCart>()
                 .eq(ShoppingCart::getUserId,UserId).eq(ShoppingCart::getGoodsId,GoodsId).last("limit 1"));

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserSubscribeService.java

@@ -1,6 +1,7 @@
 package com.zhongzheng.modules.user.service;
 
 import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
+import com.zhongzheng.modules.exam.bo.ExamApplySubscribeBo;
 import com.zhongzheng.modules.exam.vo.ExamSessionVo;
 import com.zhongzheng.modules.user.bo.*;
 import com.zhongzheng.modules.user.domain.UserSubscribe;
@@ -104,4 +105,6 @@ public interface IUserSubscribeService extends IService<UserSubscribe> {
 	Long saveByAddBo(UserSubscribeAddBo bo) throws ParseException;
 
 	List<ExamSessionVo> getExamSession(String applyDate);
+
+    void examApplySubscribe(ExamApplySubscribeBo bo);
 }

+ 137 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserSubscribeServiceImpl.java

@@ -3,6 +3,7 @@ package com.zhongzheng.modules.user.service.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.lang.Validator;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
@@ -33,6 +34,7 @@ import com.zhongzheng.modules.course.service.IMajorService;
 import com.zhongzheng.modules.exam.bo.ExamApplyQueryBo;
 import com.zhongzheng.modules.exam.bo.ExamApplySiteTimeJson;
 import com.zhongzheng.modules.exam.bo.ExamApplySiteTimeTwoAddBo;
+import com.zhongzheng.modules.exam.bo.ExamApplySubscribeBo;
 import com.zhongzheng.modules.exam.domain.ExamApply;
 import com.zhongzheng.modules.exam.domain.ExamApplySite;
 import com.zhongzheng.modules.exam.domain.ExamApplySiteTime;
@@ -49,12 +51,16 @@ import com.zhongzheng.modules.exam.vo.ExamSessionVo;
 import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
+import com.zhongzheng.modules.grade.domain.ClassGradeUser;
+import com.zhongzheng.modules.grade.service.IClassGradeUserService;
 import com.zhongzheng.modules.grade.vo.ClassGradeVo;
 import com.zhongzheng.modules.inform.bo.InformUserAddBo;
 import com.zhongzheng.modules.inform.service.IInformRemindService;
 import com.zhongzheng.modules.inform.service.IInformUserService;
 import com.zhongzheng.modules.inform.vo.InformRemindBusinessVo;
 import com.zhongzheng.modules.inform.vo.InformRemindVo;
+import com.zhongzheng.modules.order.domain.OrderGoods;
+import com.zhongzheng.modules.order.service.IOrderGoodsService;
 import com.zhongzheng.modules.user.bo.*;
 import com.zhongzheng.modules.user.domain.User;
 import com.zhongzheng.modules.user.domain.UserExamGoods;
@@ -141,6 +147,11 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
     @Autowired
     private IMajorService majorService;
 
+    @Autowired
+    private IOrderGoodsService iOrderGoodsService;
+    @Autowired
+    private IClassGradeUserService iClassGradeUserService;
+
     @Value("${aliyun.sms.cancellationReminder}")
     private String cancellationReminder;
 
@@ -2101,6 +2112,16 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
         if (System.currentTimeMillis()/1000 > time){
             throw new CustomException("当前选择的考试时间已过期,请重新预约,选择未过期考试时间");
         }
+
+        //查询是否已预约考试
+        ExamApplyQueryBo queryBo = new ExamApplyQueryBo();
+        queryBo.setUserId(bo.getUserId());
+        queryBo.setGoodsId(bo.getGoodsId());
+        queryBo.setOrderGoodsId(bo.getOrderGoodsId());
+        Integer countHaveSubscribe = examApplyMapper.countHaveSubscribe(queryBo);
+        if (countHaveSubscribe > 0) {
+            throw new CustomException("您所报考的专业,已经预约成功,您可在“我的-我的考试预约”中查询详情");
+        }
         //生成座位号
         ExamApplySite applySite = iExamApplySiteService.getOne(new LambdaQueryWrapper<ExamApplySite>()
                 .eq(ExamApplySite::getApplyId, bo.getApplyId())
@@ -2238,6 +2259,122 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
         }).collect(Collectors.toList());
     }
 
+    @Override
+    public void examApplySubscribe(ExamApplySubscribeBo bo) {
+        //学员校验
+        User user = iUserService.getOne(new LambdaQueryWrapper<User>()
+                .eq(ObjectUtils.isNotNull(bo.getIdCard()), User::getIdCard, EncryptHandler.encrypt(bo.getIdCard()))
+                .eq(ObjectUtil.isNotNull(bo.getTelphone()), User::getTelphone, EncryptHandler.encrypt(bo.getTelphone()))
+                .last("limit 1"));
+        if (ObjectUtil.isNull(user)){
+            throw new CustomException("学员信息查询不到!请检查");
+        }
+
+        //考场信息
+        ExamApply examApply = iExamApplyService.getById(bo.getSignId());
+        if (ObjectUtil.isNull(examApply)){
+            throw new CustomException("考场信息查询不到!请检查");
+        }
+        List<Long> goodsIds = iExamApplyService.getApplyGoodsId(examApply.getApplyId(),bo.getMajorName());
+        if (CollectionUtils.isEmpty(goodsIds)){
+            throw new CustomException("该专业下找不到考试对应的课程!请检查");
+        }
+
+        //是否存在订单
+        List<OrderGoods> orderGoodsList = iOrderGoodsService.getApplyOrderGoods(goodsIds,user.getUserId());
+        if (CollectionUtils.isEmpty(orderGoodsList)){
+            throw new CustomException("当前学员没有购买该专业下的课程!请检查");
+        }
+        OrderGoods applyOrder = null;
+        for (OrderGoods orderGoods : orderGoodsList) {
+            ClassGradeUser gradeUser = iClassGradeUserService
+                    .getOne(new LambdaQueryWrapper<ClassGradeUser>()
+                    .eq(ClassGradeUser::getUserId, user.getUserId())
+                    .eq(ClassGradeUser::getGradeId, orderGoods.getGradeId())
+                    .eq(ClassGradeUser::getOrderGoodsId, orderGoods.getOrderGoodsId())
+                    .last("limit 1"));
+            if (ObjectUtil.isNotNull(gradeUser)){
+                //学时是否通过审核
+                if (ObjectUtils.isNotNull(gradeUser.getPeriodStatus()) && gradeUser.getPeriodStatus() == 1){
+                    applyOrder = orderGoods;
+                }
+            }
+        }
+
+        if(Validator.isEmpty(applyOrder)){
+            throw new CustomException("该学员未学完,不能预约考试!");
+        }
+
+        //查询是否已预约考试
+        ExamApplyQueryBo queryBo = new ExamApplyQueryBo();
+        queryBo.setUserId(user.getUserId());
+        queryBo.setGoodsId(applyOrder.getGoodsId());
+        queryBo.setOrderGoodsId(applyOrder.getOrderGoodsId());
+        Integer countHaveSubscribe = examApplyMapper.countHaveSubscribe(queryBo);
+        if (countHaveSubscribe > 0) {
+            throw new CustomException("您所报考的专业,已经预约成功,您可在“我的-我的考试预约”中查询详情");
+        }
+
+        ExamSite site = iExamSiteService.getOne(new LambdaQueryWrapper<ExamSite>().eq(ExamSite::getSign, 1).eq(ExamSite::getStatus, 1).last("limit 1"));
+
+        //生成座位号
+        ExamApplySite applySite = iExamApplySiteService.getOne(new LambdaQueryWrapper<ExamApplySite>()
+                .eq(ExamApplySite::getApplyId, examApply.getApplyId())
+                .eq(ExamApplySite::getSiteId, site.getSiteId())
+                .last("limit 1"));
+        if (ObjectUtils.isNull(applySite)){
+            throw new CustomException("考试地点查询有误,请检查");
+        }
+        List<ExamApplySiteTime> siteTimeList = iExamApplySiteTimeService.list(new LambdaQueryWrapper<ExamApplySiteTime>()
+                .eq(ExamApplySiteTime::getApplyId, examApply.getApplyId())
+                .eq(ExamApplySiteTime::getApplySiteId, applySite.getId())
+                .eq(ExamApplySiteTime::getExamTime, bo.getApplyTime()));
+        if (CollectionUtils.isEmpty(siteTimeList)){
+            throw new CustomException("考试时间查询有误,请检查");
+        }
+        ExamApplySiteTime examApplySiteTime = siteTimeList.stream().filter(item -> {
+            List<ExamApplySiteTimeTwoAddBo> siteTimeTwoAddBos = JSONArray.parseArray(item.getSiteTime(), ExamApplySiteTimeTwoAddBo.class);
+            ExamApplySiteTimeTwoAddBo twoAddBo = siteTimeTwoAddBos.get(0);
+            return twoAddBo.getStartTime().equals(bo.getApplyStartTime()) && twoAddBo.getEndTime().equals(bo.getApplyEndTime());
+        }).findFirst().orElse(null);
+        if (ObjectUtils.isNull(examApplySiteTime)){
+            throw new CustomException("预约考试时间不存在,请重新选择");
+        }
+        //考场人数
+        List<ExamApplySiteTimeTwoAddBo> siteTimeTwoAddBos = JSONArray.parseArray(examApplySiteTime.getSiteTime(), ExamApplySiteTimeTwoAddBo.class);
+        Long userNum = siteTimeTwoAddBos.get(0).getNum();
+
+        //生成座位号
+        UserSubscribeAddBo userSubscribeAddBo = new UserSubscribeAddBo();
+        userSubscribeAddBo.setApplyId(examApply.getApplyId());
+        userSubscribeAddBo.setApplySiteStartTime(bo.getApplyStartTime());
+        userSubscribeAddBo.setApplySiteEndTime(bo.getApplyEndTime());
+        userSubscribeAddBo.setSiteId(site.getSiteId());
+        Integer tNum = getSeatNumber(userSubscribeAddBo,userNum);
+
+        //考场信息
+        UserSubscribe add = new UserSubscribe();
+        add.setOrderGoodsId(applyOrder.getOrderGoodsId());
+        add.setGoodsId(applyOrder.getGoodsId());
+        add.setUserId(user.getUserId());
+        add.setSeatNumber(tNum.toString());
+        add.setApplyId(examApply.getApplyId());
+        add.setApplySiteStartTime(bo.getApplyStartTime());
+        add.setApplySiteEndTime(bo.getApplyEndTime());
+        add.setApplySiteExamTime(bo.getApplyTime());
+        add.setSiteId(site.getSiteId());
+        add.setExamExpend(1);
+        add.setApplySiteAddress(site.getSiteAddress());
+        add.setSubscribeStatus(1);
+        add.setExamStatus(0);
+        add.setCreateTime(DateUtils.getNowTime());
+        add.setUpdateTime(DateUtils.getNowTime());
+        add.setExamineeCode(ServletUtils.getEncoded("ZZ"+ ToolsUtils.autoGenericCode(String.valueOf(add.getApplyId()),4) +ToolsUtils.autoGenericCode(String.valueOf(add.getUserId()),4)));
+        this.save(add);
+
+        //发送预约考试消息
+//        sendExamSucceed(bo);
+    }
 
 
     private Integer getSeatNumber(UserSubscribeAddBo bo,Long userNum) {

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

@@ -591,4 +591,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
           AND us.apply_site_end_time = #{endTime}
           AND us.tenant_id = 867735392558919680
     </select>
+
+
+    <select id="getApplyGoodsId" parameterType="map" resultType="java.lang.Long">
+        SELECT
+            eag.goods_id
+        FROM
+            exam_apply_goods eag
+                LEFT JOIN goods g ON eag.goods_id = g.goods_id
+                LEFT JOIN major m ON g.major_id = m.id
+        WHERE
+            eag.apply_id = #{applyId}
+          AND g.`status` = 1
+          AND m.`status` = 1
+          AND m.category_name = #{majorName}
+    </select>
 </mapper>

+ 18 - 0
zhongzheng-system/src/main/resources/mapper/modules/order/OrderGoodsMapper.xml

@@ -852,4 +852,22 @@
             og.`status` = 1
           AND og.order_goods_id = #{orderGoodsId}
     </select>
+
+    <select id="getApplyOrderGoods" parameterType="map" resultType="com.zhongzheng.modules.order.domain.OrderGoods">
+        SELECT
+            og.*
+        FROM
+            order_goods og
+                LEFT JOIN `order` o ON og.order_sn = o.order_sn
+        WHERE
+            og.`status` = 1
+            AND og.refund_status != 2
+	        AND og.pay_status IN ( 2, 3, 4 )
+            AND og.goods_id in
+            <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+	        AND o.`status` = 1
+	        AND o.user_id = #{userId}
+    </select>
 </mapper>