change 3 vuotta sitten
vanhempi
commit
693c870ba8

+ 75 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/exam/ExamApplyController.java

@@ -0,0 +1,75 @@
+package com.zhongzheng.controller.exam;
+
+import com.zhongzheng.common.annotation.Log;
+import com.zhongzheng.common.core.controller.BaseController;
+import com.zhongzheng.common.core.domain.AjaxResult;
+import com.zhongzheng.common.core.page.TableDataInfo;
+import com.zhongzheng.common.enums.BusinessType;
+import com.zhongzheng.modules.exam.bo.*;
+import com.zhongzheng.modules.exam.service.IExamApplyGoodsService;
+import com.zhongzheng.modules.exam.service.IExamApplyService;
+import com.zhongzheng.modules.exam.service.IExamApplySiteService;
+import com.zhongzheng.modules.exam.vo.ExamApplySiteVo;
+import com.zhongzheng.modules.exam.vo.ExamApplyVo;
+import com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo;
+import com.zhongzheng.modules.exam.vo.ExamUserApplyVo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 考试安排Controller
+ * 
+ * @author ruoyi
+ * @date 2021-12-07
+ */
+@Api(value = "考试预约", tags = {"考试预约"})
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
+@RestController
+@RequestMapping("/apply")
+public class ExamApplyController extends BaseController {
+
+    private final IExamApplyService iExamApplyService;
+
+    private final IExamApplySiteService iExamApplySiteService;
+
+    private final IExamApplyGoodsService iExamApplyGoodsService;
+
+    /**
+     * 获取考试安排详细信息
+     */
+    @ApiOperation("点击预约报考按钮")
+    @GetMapping("/subscribe")
+    public AjaxResult<ExamUserApplyVo> subscribe(ExamApplyQueryBo bo) {
+        ExamUserApplyVo examUserApplyVo = iExamApplyService.subscribe(bo);
+        return AjaxResult.success(examUserApplyVo);
+    }
+
+    /**
+     * 获取考试安排详细信息
+     */
+    @ApiOperation("预约报考下一步按钮 1 进入有前陪有考试地点得预约考试  2进入无前陪有考试地点预约考试 3无考试次数购买商品")
+    @GetMapping("/subscribeNext")
+    public AjaxResult<Long> subscribeNext(ExamApplyQueryBo bo) {
+        Long count = iExamApplyService.subscribeNext(bo);
+        return AjaxResult.success(count);
+    }
+
+
+    /**
+     * 获取考试安排详细信息
+     */
+/*    @ApiOperation("预约报考下一步按钮 1 进入有前陪有考试地点得预约考试  2进入无前陪有考试地点预约考试 3无考试次数购买商品")
+    @GetMapping("/subscribeNext")
+    public AjaxResult<Long> subscribeNext(ExamApplyQueryBo bo) {
+        Long count = iExamApplyService.subscribeNext(bo);
+        return AjaxResult.success(count);
+    }*/
+
+
+}

+ 13 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/bo/ExamApplyQueryBo.java

@@ -50,7 +50,7 @@ public class ExamApplyQueryBo extends BaseEntity {
 	@ApiModelProperty("考试简介")
 	private String applyIntroduce;
 	/** 1非补考学员 2补考学员 3都有 */
-	@ApiModelProperty("1非补考学员 2补考学员 3都有")
+	@ApiModelProperty("1非补考学员 2补考学员")
 	private Integer applyStatus;
 	/** 开始日期 */
 	@ApiModelProperty("开始日期")
@@ -81,4 +81,16 @@ public class ExamApplyQueryBo extends BaseEntity {
 	/** 项目ID */
 	@ApiModelProperty("项目ID")
 	private Long projectId;
+
+	/** 用户ID */
+	@ApiModelProperty("用户ID")
+	private Long userId;
+
+	/** 商品Id */
+	@ApiModelProperty("商品Id")
+	private Long goodsId;
+
+	/** 班级ID */
+	@ApiModelProperty("班级ID")
+	private Long gradeId;
 }

+ 15 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/mapper/ExamApplyMapper.java

@@ -4,10 +4,7 @@ import com.zhongzheng.modules.exam.bo.ExamApplyQueryBo;
 import com.zhongzheng.modules.exam.bo.ExamNumberGoodsQueryBo;
 import com.zhongzheng.modules.exam.domain.ExamApply;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.zhongzheng.modules.exam.vo.ExamApplySiteTimeVo;
-import com.zhongzheng.modules.exam.vo.ExamApplySiteVo;
-import com.zhongzheng.modules.exam.vo.ExamApplyVo;
-import com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo;
+import com.zhongzheng.modules.exam.vo.*;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -35,4 +32,18 @@ public interface ExamApplyMapper extends BaseMapper<ExamApply> {
     List<ExamApplyVo> queryExam(ExamApplyQueryBo bo);
 
     List<Long> countGoodsHold(Long applyId);
+
+    Integer countGradePeriod(ExamApplyQueryBo bo);
+
+    Integer countSubscribe(ExamApplyQueryBo bo);
+
+    Integer countHaveSubscribe(ExamApplyQueryBo bo);
+
+    ExamUserApplyVo selectExamUserApplyVo(ExamApplyQueryBo bo);
+
+    Integer countHaveSubscribeNext(ExamApplyQueryBo bo);
+
+    Integer residueSubscribeNext(ExamApplyQueryBo bo);
+
+    Integer beforeSubscribeNext(ExamApplyQueryBo bo);
 }

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

@@ -24,4 +24,6 @@ public interface ExamBeforeMapper extends BaseMapper<ExamBefore> {
     ExamBeforeVo selectByBefore(Long beforeId);
 
     List<ExamBeforeVo> queryBefore(ExamBeforeQueryBo bo);
+
+    Integer countBeforeGoods(Long beforeId);
 }

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

@@ -9,6 +9,7 @@ import com.zhongzheng.modules.exam.bo.ExamApplyAddBo;
 import com.zhongzheng.modules.exam.bo.ExamApplyEditBo;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo;
+import com.zhongzheng.modules.exam.vo.ExamUserApplyVo;
 
 import java.util.Collection;
 import java.util.List;
@@ -58,4 +59,8 @@ public interface IExamApplyService extends IService<ExamApply> {
 	List<ExamApplySiteVo> getSiteInfo(ExamApplyQueryBo bo);
 
 	ExamApplyVo getGoodsInfo(ExamApplyQueryBo bo);
+
+	ExamUserApplyVo subscribe(ExamApplyQueryBo bo);
+
+    Long subscribeNext(ExamApplyQueryBo bo);
 }

+ 40 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/impl/ExamApplyServiceImpl.java

@@ -6,9 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.modules.exam.bo.ExamNumberGoodsQueryBo;
-import com.zhongzheng.modules.exam.vo.ExamApplySiteTimeVo;
-import com.zhongzheng.modules.exam.vo.ExamApplySiteVo;
-import com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo;
+import com.zhongzheng.modules.exam.vo.*;
 import io.swagger.annotations.ApiModelProperty;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -20,7 +18,6 @@ import com.zhongzheng.modules.exam.bo.ExamApplyQueryBo;
 import com.zhongzheng.modules.exam.bo.ExamApplyEditBo;
 import com.zhongzheng.modules.exam.domain.ExamApply;
 import com.zhongzheng.modules.exam.mapper.ExamApplyMapper;
-import com.zhongzheng.modules.exam.vo.ExamApplyVo;
 import com.zhongzheng.modules.exam.service.IExamApplyService;
 
 import java.util.Collection;
@@ -171,4 +168,43 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
         examApplyVo.setGoodsId(array);
         return examApplyVo;
     }
+
+    @Override
+    public ExamUserApplyVo subscribe(ExamApplyQueryBo bo) {
+        Integer countGradePeriod = baseMapper.countGradePeriod(bo);
+        if (countGradePeriod < 1){
+            throw new IllegalArgumentException("学时审核未通过,不可以报名参加考试");
+        }
+        Integer countSubscribe = baseMapper.countSubscribe(bo);
+        if (countSubscribe > 1){
+            throw new IllegalArgumentException("考试已通过,不需要重考");
+        }
+        Integer countHaveSubscribe = baseMapper.countHaveSubscribe(bo);
+        if (countSubscribe > 1){
+            throw new IllegalArgumentException("您所报考的专业,已经预约成功,您可在“我的-我的考试预约”中查询详情");
+        }
+        ExamUserApplyVo examUserApplyVo = baseMapper.selectExamUserApplyVo(bo);
+        if (examUserApplyVo == null){
+            throw new IllegalArgumentException("商品无考试计划,无需预约考试");
+        }
+        return examUserApplyVo;
+    }
+
+    @Override
+    public Long subscribeNext(ExamApplyQueryBo bo) {
+        Integer countHaveSubscribeNext = baseMapper.countHaveSubscribeNext(bo);
+        if (bo.getApplyStatus() == 1 && countHaveSubscribeNext > 0){
+            throw new IllegalArgumentException("系统检索到您不符合【非补考学员】的报名条件,请重新选择!");
+        }
+        //查询剩余考试次数
+        Integer residueSubscribeNext = baseMapper.residueSubscribeNext(bo);
+        if (residueSubscribeNext < 1){
+            return 3L;
+        }
+        Integer beforeSubscribeNext = baseMapper.beforeSubscribeNext(bo);
+        if (beforeSubscribeNext > 0){
+            return 1L;
+        }
+        return 2L;
+    }
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/impl/ExamBeforeGoodsServiceImpl.java

@@ -90,7 +90,7 @@ public class ExamBeforeGoodsServiceImpl extends ServiceImpl<ExamBeforeGoodsMappe
             add.setUpdateTime(DateUtils.getNowTime());
             add.setGoodsId(goodsId);
             add.setBeforeId(bo.getBeforeId());
-            return this.save(add);
+            this.save(add);
         }
         return true;
     }

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/impl/ExamBeforeServiceImpl.java

@@ -76,6 +76,11 @@ public class ExamBeforeServiceImpl extends ServiceImpl<ExamBeforeMapper, ExamBef
     @Override
     public Boolean updateByEditBo(ExamBeforeEditBo bo) {
         ExamBefore update = BeanUtil.toBean(bo, ExamBefore.class);
+        if (bo.getStatus() == 1) {
+            if (baseMapper.countBeforeGoods(bo.getBeforeId()) < 1) {
+                throw new IllegalArgumentException("请先设置适用商品");
+            }
+        }
         validEntityBeforeSave(update);
         update.setUpdateTime(DateUtils.getNowTime());
         return this.updateById(update);

+ 50 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/vo/ExamUserApplySiteVo.java

@@ -0,0 +1,50 @@
+package com.zhongzheng.modules.exam.vo;
+
+import com.zhongzheng.common.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+
+/**
+ * 考试安排地点视图对象 mall_package
+ *
+ * @author ruoyi
+ * @date 2021-12-07
+ */
+@Data
+@ApiModel("考试安排地点视图对象")
+public class ExamUserApplySiteVo {
+	private static final long serialVersionUID = 1L;
+
+	/** $pkColumn.columnComment */
+	@ApiModelProperty("$pkColumn.columnComment")
+	private Long id;
+
+	/** 考试地点 */
+	@Excel(name = "考试地点")
+	@ApiModelProperty("考试地点")
+	private Long siteId;
+	/** 考试安排ID */
+	@Excel(name = "考试安排ID")
+	@ApiModelProperty("考试安排ID")
+	private Long applyId;
+	/** 1 考试地点 2考培地点 */
+	@Excel(name = "1 考试地点 2考培地点")
+	@ApiModelProperty("1 考试地点 2考培地点")
+	private Integer status;
+	/** 地址 */
+	@Excel(name = "地址")
+	@ApiModelProperty("地址")
+	private String siteAddress;
+
+	/** 人数 */
+	@Excel(name = "人数")
+	@ApiModelProperty("人数")
+	private Long people;
+
+	@ApiModelProperty("考试地点时间")
+	private List<ExamApplySiteTimeVo> examApplySiteTime;
+}

+ 64 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/vo/ExamUserApplyVo.java

@@ -0,0 +1,64 @@
+package com.zhongzheng.modules.exam.vo;
+
+import com.zhongzheng.common.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+
+/**
+ * 考试安排视图对象 mall_package
+ *
+ * @author ruoyi
+ * @date 2021-12-07
+ */
+@Data
+@ApiModel("考试安排视图对象")
+public class ExamUserApplyVo {
+	private static final long serialVersionUID = 1L;
+
+	/** $pkColumn.columnComment */
+	@ApiModelProperty("$pkColumn.columnComment")
+	private Long applyId;
+
+	/** 考试封面 */
+	@Excel(name = "考试封面")
+	@ApiModelProperty("考试封面")
+	private String applyUrl;
+	/** 考试标题 */
+	@Excel(name = "考试标题")
+	@ApiModelProperty("考试标题")
+	private String applyName;
+	/** 考试简介 */
+	@Excel(name = "考试简介")
+	@ApiModelProperty("考试简介")
+	private String applyIntroduce;
+
+	/** 开始日期 */
+	@Excel(name = "开始日期")
+	@ApiModelProperty("开始日期")
+	private Long applyStartTime;
+	/** 结束日期 */
+	@Excel(name = "结束日期")
+	@ApiModelProperty("结束日期")
+	private Long applyEndTime;
+
+	@ApiModelProperty("专业")
+	private String major;
+
+	/** 真实姓名 */
+	@ApiModelProperty("真实姓名")
+	private String realname;
+
+	/** 身份证号 */
+	@ApiModelProperty("身份证号")
+	private String idCard;
+
+	/** 1非补考学员 2补考学员 3都有 */
+	@Excel(name = "1非补考学员 2补考学员 ")
+	@ApiModelProperty("1非补考学员 2补考学员 ")
+	private String applyStatus;
+
+}

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

@@ -33,6 +33,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="people" column="people"/>
     </resultMap>
 
+    <resultMap type="com.zhongzheng.modules.exam.vo.ExamUserApplyVo" id="ExamUserApplyVo">
+        <result property="applyId" column="apply_id"/>
+        <result property="applyUrl" column="apply_url"/>
+        <result property="applyName" column="apply_name"/>
+        <result property="applyIntroduce" column="apply_introduce"/>
+        <result property="applyStartTime" column="apply_start_time"/>
+        <result property="applyEndTime" column="apply_end_time"/>
+        <result property="major" column="major"/>
+        <result property="realname" column="realname"/>
+        <result property="idCard" column="id_card"/>
+    </resultMap>
+
     <resultMap type="com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo" id="ExamNumberGoodsVoResult">
         <result property="id" column="id"/>
         <result property="examNumberId" column="exam_number_id"/>
@@ -181,4 +193,97 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </if>
         order by ea.create_time desc
     </select>
+
+    <select id="countGradePeriod" parameterType="long" resultType="integer">
+        SELECT
+            COUNT(cg.grade_id)
+        FROM
+            class_grade cg
+                LEFT JOIN class_grade_user cgu  ON cg.grade_id = cgu.grade_id
+        WHERE
+            1 = 1
+          AND cgu.user_id = #{userId}
+          and cgu.grade_id = #{gradeId}
+          AND cgu.period_status = 1
+          and unix_timestamp(now()) BETWEEN cg.class_start_time and cg.class_end_time
+          and cg.`status` =1
+          and cgu.`status` =1
+    </select>
+    <select id="countSubscribe" parameterType="long" resultType="integer">
+        SELECT
+            COUNT(1)
+        FROM
+            user_subscribe us
+        WHERE
+            1 =1
+          and us.user_id = #{userId}
+          and us.result = 1
+          and us.goods_id = #{goodsId}
+    </select>
+
+    <select id="countHaveSubscribe" parameterType="long" resultType="integer">
+        SELECT
+            COUNT(1)
+        FROM
+            user_subscribe us
+        WHERE
+            1 =1
+          and us.user_id = #{userId}
+          and us.exam_status = 0
+          and subscribe_status = 1
+          and us.goods_id = #{goodsId}
+    </select>
+    <select id="selectExamUserApplyVo" parameterType="com.zhongzheng.modules.exam.bo.ExamApplyQueryBo" resultMap="ExamUserApplyVo">
+        SELECT
+            ea.apply_id,
+            ea.apply_url,
+            ea.apply_name,
+            ea.apply_introduce,
+            ea.apply_start_time,
+            ea.apply_end_time,
+            ea.apply_status,
+            (SELECT m.category_name FROM major m where m.id = g.major_id) as major,
+            (SELECT u.realname FROM `user` u wher u.user_id = #{user_id}) as realname,
+(SELECT u.id_card FROM `user` u wher u.user_id = #{user_id}) as id_card
+        FROM
+            exam_apply ea
+            LEFT JOIN exam_apply_goods eag ON ea.apply_id = eag.apply_id
+            LEFT JOIN goods g on eag.goods_id=g.goods_id
+        WHERE
+            1 = 1
+          AND eag.goods_id = #{goodsId}
+          AND ea.`status` =1
+    </select>
+
+
+    <select id="countHaveSubscribeNext" parameterType="long" resultType="integer">
+        SELECT
+            COUNT(1)
+        FROM
+            user_subscribe us
+        where 1=1
+          and us.user_id =#{userId}
+          and us.exam_expend = 1
+          and us.goods_id = #{goodsId}
+    </select>
+    <select id="residueSubscribeNext" parameterType="long" resultType="integer">
+        SELECT
+            ueg.exam_number - ueg.expend_number
+        FROM
+            user_exam_goods ueg
+        WHERE
+            ueg.user_id =#{userId}
+          AND ueg.goods_id = #{goodsId}
+    </select>
+
+    <select id="beforeSubscribeNext" parameterType="long" resultType="integer">
+        SELECT
+            COUNT(eb.before_id)
+        FROM
+            exam_before eb
+                LEFT JOIN exam_before_goods ebg on eb.before_id=ebg.before_id
+        WHERE
+            ebg.goods_id =3
+          and eb.`status`=1
+    </select>
 </mapper>

+ 9 - 0
zhongzheng-system/src/main/resources/mapper/modules/exam/ExamBeforeMapper.xml

@@ -101,6 +101,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
           and eb.before_id = #{beforeId}
     </select>
 
+    <select id="countBeforeGoods" parameterType="long" resultType="long">
+        SELECT
+            COUNT( 1 )
+        FROM
+            exam_before_goods ebg
+        WHERE
+            ebg.before_id = #{beforeId}
+    </select>
+
     <select id="queryBefore" parameterType="com.zhongzheng.modules.exam.bo.ExamBeforeQueryBo" resultMap="ExamBeforeVo">
         SELECT
             *,