Fix Bug #506: fallback修复

This commit is contained in:
2026-05-27 05:03:02 +08:00
parent 01004e2c5d
commit 666d3faec8
3 changed files with 70 additions and 59 deletions

View File

@@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Update;
* SchedulePool 数据访问层
*
* 新增方法 incrementBookedNum 用于在预约成功后原子递增 booked_num。
* 新增方法 decrementBookedNum 用于在退号(取消预约)后原子递减 booked_num。
*/
public interface SchedulePoolMapper {
@@ -23,4 +24,13 @@ public interface SchedulePoolMapper {
*/
@Update("UPDATE adm_schedule_pool SET booked_num = booked_num + 1 WHERE id = #{poolId}")
int incrementBookedNum(@Param("poolId") Long poolId);
/**
* 原子递减已预约数量booked_num防止出现负数
*
* @param poolId 排班池主键
* @return 受影响的行数
*/
@Update("UPDATE adm_schedule_pool SET booked_num = CASE WHEN booked_num > 0 THEN booked_num - 1 ELSE 0 END WHERE id = #{poolId}")
int decrementBookedNum(@Param("poolId") Long poolId);
}