Fix Bug #575: AI修复

This commit is contained in:
2026-05-27 00:19:39 +08:00
parent 7e6af7b359
commit 93791bdd3e
3 changed files with 33 additions and 11 deletions

View File

@@ -9,8 +9,10 @@ import org.apache.ibatis.annotations.Update;
*
* 新增:
* 1. updateSlotStatusToPaid 预约签到缴费成功后,将对应号源状态更新为 “3”(已取号)。
* 2. incrementBookedNumByOrderId 预约成功后,实时累加 adm_schedule_pool 表中的 booked_num 字段。
*
* 该方法在支付成功后调用,确保号源状态及时流转,修复 Bug #574。
* 新增方法用于修复 Bug #575。
*/
@Mapper
public interface RegistrationMapper {
@@ -25,4 +27,16 @@ public interface RegistrationMapper {
"SET status = 3 " +
"WHERE order_id = #{orderId}")
int updateSlotStatusToPaid(@Param("orderId") Long orderId);
/**
* 预约成功后,将对应排班池的已预约数量 booked_num 实时 +1。
* 通过 order_id 关联 slot 表获取 pool_id 进行原子更新,保证数据一致性。
*
* @param orderId 关联的订单ID
* @return 受影响的行数
*/
@Update("UPDATE adm_schedule_pool " +
"SET booked_num = booked_num + 1 " +
"WHERE id = (SELECT pool_id FROM adm_schedule_slot WHERE order_id = #{orderId})")
int incrementBookedNumByOrderId(@Param("orderId") Long orderId);
}

View File

@@ -12,6 +12,9 @@ import org.springframework.transaction.annotation.Transactional;
* 修复 Bug #574在预约签到缴费成功后调用 {@link RegistrationMapper#updateSlotStatusToPaid}
* 将对应的 adm_schedule_slot.status 状态及时流转为 “3”(已取号)。
*
* 修复 Bug #575在预约成功后调用 {@link RegistrationMapper#incrementBookedNumByOrderId}
* 实时累加 adm_schedule_pool 表中的 booked_num 字段。
*
* 该方法假设在支付成功的业务流程中被调用,确保状态同步。
*/
@Service
@@ -50,5 +53,11 @@ public class RegistrationServiceImpl implements RegistrationService {
// 如果未更新到任何号源,说明数据异常,抛异常回滚事务
throw new RuntimeException("号源状态未更新为已取号orderId=" + orderId);
}
// 3. 实时累加排班池已预约数量 booked_num修复 Bug #575
int poolUpdated = registrationMapper.incrementBookedNumByOrderId(orderId);
if (poolUpdated == 0) {
throw new RuntimeException("排班池 booked_num 累加失败orderId=" + orderId);
}
}
}