Files
his/com/openhis/web/outpatient/mapper/RegistrationMapper.java
2026-05-27 00:19:39 +08:00

43 lines
1.5 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.openhis.web.outpatient.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
/**
* 门诊挂号业务数据访问层
*
* 新增:
* 1. updateSlotStatusToPaid 预约签到缴费成功后,将对应号源状态更新为 “3”(已取号)。
* 2. incrementBookedNumByOrderId 预约成功后,实时累加 adm_schedule_pool 表中的 booked_num 字段。
*
* 该方法在支付成功后调用,确保号源状态及时流转,修复 Bug #574。
* 新增方法用于修复 Bug #575。
*/
@Mapper
public interface RegistrationMapper {
/**
* 预约签到缴费成功后将号源状态置为已取号status = 3
*
* @param orderId 关联的订单ID
* @return 受影响的行数
*/
@Update("UPDATE adm_schedule_slot " +
"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);
}