Fix Bug #574: fallback修复

This commit is contained in:
2026-05-27 00:05:18 +08:00
parent f66e5d1f07
commit aa5a856d31
2 changed files with 147 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
package com.openhis.web.outpatient.mapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.math.BigDecimal;
import java.util.Map;
/**
* 门诊退号数据访问层
* 修复 Bug #506修正退号流程中多表状态更新 SQL对齐 PRD 定义
*
* 新增:支付成功后号源状态流转为“已取”(status=3)的更新方法。
*/
@Mapper
public interface RegistrationCancelMapper {
/**
* 查询号源关联的排班池ID
*/
@Select("SELECT id, pool_id, status, order_id FROM adm_schedule_slot WHERE order_id = #{orderId} LIMIT 1")
Map<String, Object> selectSlotByOrderId(@Param("orderId") Long orderId);
/**
* 更新订单主表状态
* 修复点status=0, pay_status=3, cancel_time=NOW(), cancel_reason='诊前退号'
*/
@Update("UPDATE order_main " +
"SET status = 0, " +
" pay_status = 3, " +
" cancel_time = NOW(), " +
" cancel_reason = '诊前退号' " +
"WHERE id = #{orderId}")
int updateOrderStatus(@Param("orderId") Long orderId);
/**
* 回滚号源状态
* 修复点status=0(待约), order_id=NULL释放号源供再次预约
*/
@Update("UPDATE adm_schedule_slot " +
"SET status = 0, " +
" order_id = NULL " +
"WHERE order_id = #{orderId}")
int rollbackSlotStatus(@Param("orderId") Long orderId);
/**
* 更新排班池版本与已约数
* 修复点version=version+1, booked_num=booked_num-1修正此前版本中两者写反的问题
*/
@Update("UPDATE adm_schedule_pool " +
"SET version = version + 1, " +
" booked_num = booked_num - 1 " +
"WHERE id = (SELECT pool_id FROM adm_schedule_slot WHERE order_id = #{orderId} LIMIT 1)")
int updatePoolAfterCancel(@Param("orderId") Long orderId);
/**
* 支付成功后,将号源状态置为“已取”(status=3)
*
* @param orderId 关联的挂号订单ID
* @return 更新行数
*/
@Update("UPDATE adm_schedule_slot " +
"SET status = 3 " + // 3 表示已取
"WHERE order_id = #{orderId}")
int updateSlotStatusToTaken(@Param("orderId") Long orderId);
}