haogh 7 сар өмнө
parent
commit
2f8de20ed4

+ 7 - 0
src/main/java/com/qmth/exam/reserve/bean/stdapply/StudentApplyVO.java

@@ -53,4 +53,11 @@ public class StudentApplyVO implements IModel {
 
     @ApiModelProperty("考生所预约教学点")
     private String applyTeachingName;
+
+    @ApiModelProperty("时段ID")
+    private Long timePeriodId;
+
+    @ApiModelProperty("是否可取消")
+    private Boolean canCancelFlag;
+
 }

+ 13 - 4
src/main/java/com/qmth/exam/reserve/service/impl/StudentApplyServiceImpl.java

@@ -127,10 +127,8 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
 
     @Override
     public PageResult<StudentApplyVO> page(StudentApplyReq req) {
-        if (req.getTaskId() == null) {
-            ApplyTaskEntity task = getApplyTask();
-            req.setTaskId(task.getId());
-        }
+        ApplyTaskEntity task = getApplyTask();
+        req.setTaskId(task.getId());
         if (req.getTeachingId() != null) {
             List<CategoryVO> examSiteList = examSiteService.listExamSite(req.getTeachingId(), Boolean.FALSE);
             if (examSiteList == null || examSiteList.isEmpty()) {
@@ -139,6 +137,7 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
             List<Long> examSiteIds = examSiteList.stream().map(CategoryVO::getId).collect(Collectors.toList());
             req.setExamSiteIds(examSiteIds.isEmpty() ? null : examSiteIds);
         }
+
         IPage<StudentApplyVO> iPage = baseMapper.page(new Page<>(req.getPageNumber(), req.getPageSize()), req);
         List<StudentApplyVO> records = iPage.getRecords();
         for (StudentApplyVO record : records) {
@@ -148,6 +147,16 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
             record.setApplyTeachingName(agentRoom.getApplyTeachingName());
             record.setRoomName(agentRoom.getRoomName());
             record.setUserName(agentRoom.getUserName());
+
+            // 是否可取消
+            TimePeriodEntity timePeriod = timePeriodService.getById(record.getTimePeriodId());
+            Date applyDate = DateUtils.truncate(new Date(timePeriod.getStartTime()), Calendar.DATE);
+            Date canCancelDay = DateUtil.addValues(applyDate, Calendar.DAY_OF_MONTH, -task.getAllowApplyCancelDays());
+            if (new Date().after(canCancelDay)) {
+                record.setCanCancelFlag(Boolean.FALSE);
+            } else {
+                record.setCanCancelFlag(Boolean.TRUE);
+            }
         }
         return PageUtil.of(iPage);
     }

+ 1 - 0
src/main/resources/mapper/StudentApplyMapper.xml

@@ -4,6 +4,7 @@
     <select id="page"  resultType="com.qmth.exam.reserve.bean.stdapply.StudentApplyVO">
         SELECT
         a.id,
+        a.time_period_id timePeriodId,
         s.NAME,
         s.identity_number identityNumber,
         s.student_code studentCode,