haogh 7 mesi fa
parent
commit
880ee33602

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

@@ -1189,17 +1189,28 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
     @Transactional
     @Override
     public boolean saveOrUpdateStudentApply(StudentApplyEntity studentApply) {
-        // 缓存中查看考生是否已经预约
+        // 缓存中考生是否已经预约
         ApplyRecordCacheBean studentApplyRecord = cacheService.getStudentApplyRecord(studentApply.getStudentId(), studentApply.getExamSiteId(),
                 studentApply.getTimePeriodId());
-        // 考生未预约
+        //数据库中考生是否已经预约
+        StudentApplyEntity existStudentApply = findStudentApply(studentApply);
+
+        // 缓存中考生未预约
         if (studentApplyRecord == null) {
-            baseMapper.insert(studentApply);
+            // 数据库中不存在
+            if (existStudentApply == null) {
+                baseMapper.insert(studentApply);
+            } else if (existStudentApply.getCancel()) { //数据库中存在,但已取消
+                existStudentApply.setCancel(Boolean.FALSE);
+                baseMapper.updateById(existStudentApply);
+            } else { // 数据库中已存在预约信息
+                return false;
+            }
             return true;
         }
+
         // 考生先预约,然后做了取消操作
         if (studentApplyRecord.getCancel()) {
-            StudentApplyEntity existStudentApply = findStudentApply(studentApply);
             if (existStudentApply != null) {
                 existStudentApply.setCancel(Boolean.FALSE);
                 baseMapper.updateById(existStudentApply);