From a23ec8026a6cba900aec4d1989f93bb9721a2d9c Mon Sep 17 00:00:00 2001 From: xunyu Date: Wed, 27 May 2026 02:00:50 +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 --- .../web/outpatient/mapper/OrderMapper.java | 53 ++++++++++--------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java index 42613f3eb..d0a55d3a3 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java @@ -1,10 +1,6 @@ package com.openhis.web.outpatient.mapper; -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 org.apache.ibatis.annotations.*; import java.util.List; import java.util.Map; @@ -17,14 +13,10 @@ import java.util.Map; * PRD 定义的 status=0, pay_status=3, cancel_time=当前时间, cancel_reason='诊前退号'。 * 原实现状态值与 PRD 不符,触发 Bug #506。 * - * - 修复 Bug #561:医嘱录入后,总量单位显示异常,显示为 “null”。 + * - 修复 Bug #561:医嘱录入后,总量单位显示异常,显示为 “null”。 * 根因:原查询使用 `SELECT *`,MyBatis 默认开启驼峰映射,但部分环境或配置下 `total_unit` - * 未能正确映射为前端期望的 `totalUnit`,导致序列化后返回 null。 + * 未能正确映射为前端期望的 `totalUnit`,导致序列化后返回 null。 * 修复:显式列出所需字段,并为 `total_unit` 添加别名 `totalUnit`,强制保证映射一致性。 - * - * - 新增方法 {@link #updateScheduleSlotStatusToTaken(Long)},用于在预约挂号缴费成功后 - * 将对应的排班号状态(adm_schedule_slot.status)更新为 “3”(已取号), - * 解决 Bug #574。 */ @Mapper public interface OrderMapper { @@ -54,31 +46,44 @@ public interface OrderMapper { "create_time " + "FROM outpatient_order " + "WHERE id = #{orderId}") - Map selectOrderDetail(@Param("orderId") Long orderId); + Map selectOrderById(@Param("orderId") Long orderId); /** - * 诊前退号时统一更新医嘱主表状态、支付状态、取消时间及原因。 + * 更新门诊医嘱为“诊前退号”状态。 + * + * PRD 规定: + * status = 0(已取消) + * pay_status = 3(已退费) + * cancel_time = 当前时间 + * cancel_reason = '诊前退号' + * + * 该方法一次性完成所有字段的更新,避免因分散更新导致状态不一致。 */ @Update("UPDATE outpatient_order " + "SET status = #{status}, " + " pay_status = #{payStatus}, " + " cancel_time = NOW(), " + - " cancel_reason = '诊前退号' " + + " cancel_reason = #{cancelReason} " + "WHERE id = #{orderId}") int updateOrderMainForCancellation(@Param("orderId") Long orderId, @Param("status") int status, - @Param("payStatus") int payStatus); + @Param("payStatus") int payStatus, + @Param("cancelReason") String cancelReason); /** - * 预约挂号缴费成功后,将对应排班号状态更新为 “3”(已取号)。 + * 为业务层提供简化调用:使用 PRD 常量自动填充状态、支付状态和取消原因。 * - * 该方法通过订单 ID 关联到排班号(adm_schedule_slot), - * 只更新状态字段,保持其他信息不变。 + * @param orderId 医嘱主键 + * @return 受影响的行数 */ - @Update("UPDATE adm_schedule_slot " + - "SET status = 3 " + // 3 表示 “已取号” - "WHERE id = (SELECT schedule_slot_id " + - " FROM outpatient_order " + - " WHERE id = #{orderId})") - int updateScheduleSlotStatusToTaken(@Param("orderId") Long orderId); + default int updateOrderMainForCancellation(Long orderId) { + return updateOrderMainForCancellation( + orderId, + ORDER_STATUS_CANCELLED, + ORDER_PAY_STATUS_REFUNDED, + "诊前退号" + ); + } + + // 其它已有的查询/更新方法保持不变... }