|
@@ -146,29 +146,26 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
throw new StatusException(msg);
|
|
throw new StatusException(msg);
|
|
}
|
|
}
|
|
|
|
|
|
- // 当前预约时段剩余可约数量
|
|
|
|
- int availableCount = applyTaskCacheService.getApplyAvailableCount(examSiteId, timePeriodId);
|
|
|
|
- if (availableCount < 1) {
|
|
|
|
|
|
+ // 某考点某时段的“剩余可约数量” 累减1(抢占1个数量)
|
|
|
|
+ boolean takeSuccess = applyTaskCacheService.decreaseApplyAvailableCount(examSiteId, timePeriodId);
|
|
|
|
+ if (!takeSuccess) {
|
|
log.warn("预约失败,当前预约时段已约满!examSiteId:{} timePeriodId:{}", examSiteId, timePeriodId);
|
|
log.warn("预约失败,当前预约时段已约满!examSiteId:{} timePeriodId:{}", examSiteId, timePeriodId);
|
|
throw new StatusException("当前预约时段已约满");
|
|
throw new StatusException("当前预约时段已约满");
|
|
}
|
|
}
|
|
|
|
|
|
- // 某考点某时段的“已预约数量” 累加1(优先执行抢占1个数量)
|
|
|
|
- applyTaskCacheService.increaseApplyFinishCount(examSiteId, timePeriodId);
|
|
|
|
-
|
|
|
|
try {
|
|
try {
|
|
// StudentApplyEntity existApply = applyTaskCacheService.getStudentApplyRecordFormDB(student.getId(), examSiteId, timePeriodId);
|
|
// StudentApplyEntity existApply = applyTaskCacheService.getStudentApplyRecordFormDB(student.getId(), examSiteId, timePeriodId);
|
|
ApplyRecordCacheBean existApply = applyTaskCacheService.getStudentApplyRecord(student.getId(), examSiteId, timePeriodId);
|
|
ApplyRecordCacheBean existApply = applyTaskCacheService.getStudentApplyRecord(student.getId(), examSiteId, timePeriodId);
|
|
if (existApply != null) {
|
|
if (existApply != null) {
|
|
if (!existApply.getCancel()) {
|
|
if (!existApply.getCancel()) {
|
|
- // 某考点某时段的“已预约数量” 累减1(释放1个被占数量)
|
|
|
|
- applyTaskCacheService.decreaseApplyFinishCount(examSiteId, timePeriodId);
|
|
|
|
|
|
+ // 已存在预约记录,则归还1个刚才被占数量
|
|
|
|
+ applyTaskCacheService.increaseApplyAvailableCount(examSiteId, timePeriodId);
|
|
|
|
|
|
log.warn("当前时段已预约,请勿重复预约!examSiteId:{} timePeriodId:{}", examSiteId, timePeriodId);
|
|
log.warn("当前时段已预约,请勿重复预约!examSiteId:{} timePeriodId:{}", examSiteId, timePeriodId);
|
|
throw new StatusException("当前时段已预约,请勿重复预约");
|
|
throw new StatusException("当前时段已预约,请勿重复预约");
|
|
}
|
|
}
|
|
|
|
|
|
- // 存在“已取消”预约记录,则恢复预约
|
|
|
|
|
|
+ // 存在历史“已取消”的预约记录,则恢复预约
|
|
existApply.setCancel(false);
|
|
existApply.setCancel(false);
|
|
existApply.setOperateId(student.getId());
|
|
existApply.setOperateId(student.getId());
|
|
existApply.setOperateTime(System.currentTimeMillis());
|
|
existApply.setOperateTime(System.currentTimeMillis());
|
|
@@ -201,8 +198,8 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
throw e;
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
|
|
- // 异常时,释放1个被占数量
|
|
|
|
- applyTaskCacheService.decreaseApplyFinishCount(examSiteId, timePeriodId);
|
|
|
|
|
|
+ // 其它异常时,归还1个被占数量
|
|
|
|
+ applyTaskCacheService.increaseApplyAvailableCount(examSiteId, timePeriodId);
|
|
log.error("预约异常!examSiteId:{} timePeriodId:{} err:{}", examSiteId, timePeriodId, e.getMessage());
|
|
log.error("预约异常!examSiteId:{} timePeriodId:{} err:{}", examSiteId, timePeriodId, e.getMessage());
|
|
throw new StatusException("预约失败,请稍后再试!", e);
|
|
throw new StatusException("预约失败,请稍后再试!", e);
|
|
}
|
|
}
|
|
@@ -292,8 +289,8 @@ public class ExamReserveServiceImpl implements ExamReserveService {
|
|
|
|
|
|
// this.updateStudentApplyForCancel(existApply.getId(), true, student.getId());
|
|
// this.updateStudentApplyForCancel(existApply.getId(), true, student.getId());
|
|
|
|
|
|
- // 某考点某时段的“已预约数量” 累减1
|
|
|
|
- applyTaskCacheService.decreaseApplyFinishCount(examSiteId, timePeriodId);
|
|
|
|
|
|
+ // 某考点某时段的“剩余可约数量” 累加1(归还1个被占数量)
|
|
|
|
+ applyTaskCacheService.increaseApplyAvailableCount(examSiteId, timePeriodId);
|
|
log.warn("取消预约成功!studentId:{} examSiteId:{} timePeriodId:{}", student.getId(), examSiteId, timePeriodId);
|
|
log.warn("取消预约成功!studentId:{} examSiteId:{} timePeriodId:{}", student.getId(), examSiteId, timePeriodId);
|
|
} finally {
|
|
} finally {
|
|
try {
|
|
try {
|