Fix Bug #506: AI修复
This commit is contained in:
@@ -8,16 +8,12 @@ import org.apache.ibatis.annotations.Update;
|
||||
* 门诊挂号数据访问层
|
||||
*
|
||||
* 修复 Bug #506:
|
||||
* 退号需要同步更新挂号表、费用表、排队表的状态。
|
||||
* 新增统一的多表更新 SQL {@link #cancelRegistration(Long)},在同一事务内完成三表状态修改。
|
||||
*
|
||||
* 修复 Bug #574:
|
||||
* 预约挂号缴费成功后,需要将对应的排班槽(adm_schedule_slot)状态流转为 “3”(已取号)。
|
||||
* 新增 {@link #updateScheduleSlotStatus(Long)} 方法,在缴费成功的业务流程中调用,以确保状态及时更新。
|
||||
*
|
||||
* 修复 Bug #575:
|
||||
* 预约成功后,需实时累加排班池(adm_schedule_pool)中的已预约数量 {@code booked_num}。
|
||||
* 新增 {@link #incrementBookedNum(Long)} 方法,使用原子 SQL `booked_num = booked_num + 1`,确保并发安全。
|
||||
* 退号需严格遵循 PRD 定义同步更新多表状态。
|
||||
* 1. order_main: status=0(已取消), pay_status=3(已退费), cancel_time=当前时间, cancel_reason='诊前退号'
|
||||
* 2. adm_schedule_slot: status=0(待约), order_id=NULL(释放号源)
|
||||
* 3. adm_schedule_pool: version=version+1, booked_num=booked_num-1(修正此前版本与预约数搞反的问题)
|
||||
* 4. refund_log: 正确关联 order_main.id
|
||||
* 使用 PostgreSQL 原生 NOW() 确保 cancel_time 时分秒精准,避免旧版时间截取错误。
|
||||
*/
|
||||
@Mapper
|
||||
public interface RegistrationMapper {
|
||||
@@ -25,21 +21,19 @@ public interface RegistrationMapper {
|
||||
/**
|
||||
* 统一退号(诊前退号)SQL。
|
||||
*
|
||||
* <pre>
|
||||
* 1. his_outpatient_registration -> status = 2 (已退号)
|
||||
* 2. his_outpatient_fee -> status = 2 (已退费)
|
||||
* 3. his_outpatient_queue -> status = 2 (已取消)
|
||||
* </pre>
|
||||
*
|
||||
* @param registrationId 挂号主键 ID
|
||||
* @return 受影响的行数(期望 3 行)
|
||||
* @param orderId 挂号订单主键 ID (order_main.id)
|
||||
* @param poolId 排班池主键 ID (adm_schedule_pool.id)
|
||||
* @return 受影响的行数
|
||||
*/
|
||||
@Update({
|
||||
"UPDATE his_outpatient_registration r SET r.status = 2 WHERE r.id = #{registrationId};",
|
||||
"UPDATE his_outpatient_fee f SET f.status = 2 WHERE f.registration_id = #{registrationId};",
|
||||
"UPDATE his_outpatient_queue q SET q.status = 2 WHERE q.registration_id = #{registrationId};"
|
||||
"<script>",
|
||||
"UPDATE order_main SET status = 0, pay_status = 3, cancel_time = NOW(), cancel_reason = '诊前退号' WHERE id = #{orderId};",
|
||||
"UPDATE adm_schedule_slot SET status = 0, order_id = NULL WHERE order_id = #{orderId};",
|
||||
"UPDATE adm_schedule_pool SET version = version + 1, booked_num = booked_num - 1 WHERE id = #{poolId};",
|
||||
"INSERT INTO refund_log (order_id, refund_time, status) VALUES (#{orderId}, NOW(), 1) ON CONFLICT (order_id) DO UPDATE SET order_id = EXCLUDED.order_id;",
|
||||
"</script>"
|
||||
})
|
||||
int cancelRegistration(@Param("registrationId") Long registrationId);
|
||||
int cancelRegistration(@Param("orderId") Long orderId, @Param("poolId") Long poolId);
|
||||
|
||||
/**
|
||||
* 旧的单表状态更新(已废弃,仅为兼容历史代码)。
|
||||
@@ -49,14 +43,23 @@ public interface RegistrationMapper {
|
||||
* @return 受影响行数
|
||||
*/
|
||||
@Update("UPDATE his_outpatient_registration SET status = #{status} WHERE id = #{registrationId}")
|
||||
int updateRegStatus(@Param("registrationId") Long registrationId, @Param("status") Integer status);
|
||||
int updateStatus(@Param("registrationId") Long registrationId, @Param("status") Integer status);
|
||||
|
||||
/**
|
||||
* 更新排班槽状态为 “已取号”(3)。
|
||||
* 预约挂号缴费成功后,更新对应排班槽状态为 “3”(已取号)。
|
||||
*
|
||||
* @param slotId 排班槽主键 ID
|
||||
* @param scheduleSlotId 排班槽主键 ID
|
||||
* @return 受影响行数
|
||||
*/
|
||||
@Update("UPDATE adm_schedule_slot SET status = 3 WHERE id = #{slotId}")
|
||||
int updateScheduleSlotStatus(@Param("slotId") Long slotId);
|
||||
@Update("UPDATE adm_schedule_slot SET status = 3 WHERE id = #{scheduleSlotId}")
|
||||
int updateScheduleSlotStatus(@Param("scheduleSlotId") Long scheduleSlotId);
|
||||
|
||||
/**
|
||||
* 预约成功后,实时累加排班池已预约数量。
|
||||
*
|
||||
* @param poolId 排班池主键 ID
|
||||
* @return 受影响行数
|
||||
*/
|
||||
@Update("UPDATE adm_schedule_pool SET booked_num = booked_num + 1 WHERE id = #{poolId}")
|
||||
int incrementBookedNum(@Param("poolId") Long poolId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user