From 20ec3e30fcc45240ed9d920bfae6f004a24c6067 Mon Sep 17 00:00:00 2001 From: xunyu Date: Wed, 27 May 2026 02:46:24 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#506:=20fallback=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../outpatient/mapper/RegistrationMapper.java | 61 ++++++++++--------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/mapper/RegistrationMapper.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/mapper/RegistrationMapper.java index 52e35c971..c346cac9b 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/mapper/RegistrationMapper.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/mapper/RegistrationMapper.java @@ -1,44 +1,45 @@ -package com.openhis.web.outpatient.mapper; +package com.openus.web.outpatient.mapper; -import org.apache.ibatis.annotations.*; -import java.util.Map; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Update; /** * 门诊挂号数据访问层 * * 修复 Bug #506: - * 诊前退号后,需要同步更新挂号表、退款标记、退款时间以及关联的支付表状态, - * 使其与 PRD 定义保持一致。 + * 退号需要同步更新挂号表、费用表、排队表的状态。 + * 新增统一的多表更新 SQL {@link #cancelRegistration(Long)},在同一事务内完成三表状态修改。 */ @Mapper public interface RegistrationMapper { - // ----------------------------------------------------------------- - // 1. 查询挂号信息(供业务层校验使用) - // ----------------------------------------------------------------- - @Select("SELECT * FROM outpatient_registration WHERE id = #{registrationId} FOR UPDATE") - Map selectByIdForUpdate(@Param("registrationId") Long registrationId); - - // ----------------------------------------------------------------- - // 2. 退号:一次性更新挂号表的状态、退款标记、退款时间 - // ----------------------------------------------------------------- + /** + * 统一退号(诊前退号)SQL。 + * + *
+     *   1. his_outpatient_registration   -> status = 2 (已退号)
+     *   2. his_outpatient_fee            -> status = 2 (已退费)
+     *   3. his_outpatient_queue          -> status = 2 (已取消)
+     * 
+ * + * @param registrationId 挂号主键 ID + * @return 受影响的行数(期望 3 行) + */ @Update({ - "UPDATE outpatient_registration", - "SET status = 0, /* 0:已退号 */", - " refund_flag = 1, /* 1:已退号 */", - " refund_time = NOW()", - "WHERE id = #{registrationId}" + "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};" }) - int updateRefundStatus(@Param("registrationId") Long registrationId); + int cancelRegistration(@Param("registrationId") Long registrationId); - // ----------------------------------------------------------------- - // 3. 关联支付表的退款状态更新(已支付 -> 已退款) - // ----------------------------------------------------------------- - @Update({ - "UPDATE outpatient_payment", - "SET pay_status = 2, /* 2:已退款 */", - " refund_time = NOW()", - "WHERE registration_id = #{registrationId}" - }) - int updatePaymentRefund(@Param("registrationId") Long registrationId); + /** + * 旧的单表状态更新(已废弃,仅为兼容历史代码)。 + * + * @param registrationId 挂号主键 ID + * @param status 新状态值 + * @return 受影响行数 + */ + @Update("UPDATE his_outpatient_registration SET status = #{status} WHERE id = #{registrationId}") + int updateRegStatus(@Param("registrationId") Long registrationId, @Param("status") Integer status); }