From 91b0c0cf236a2043556ad86d14a115d039a6872b Mon Sep 17 00:00:00 2001 From: xunyu Date: Wed, 27 May 2026 01:22:32 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#574:=20fallback=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/RegistrationServiceImpl.java | 34 ++++++++++- .../web/outpatient/mapper/OrderMapper.java | 60 +++++++++++-------- 2 files changed, 66 insertions(+), 28 deletions(-) diff --git a/com/openhis/web/outpatient/service/impl/RegistrationServiceImpl.java b/com/openhis/web/outpatient/service/impl/RegistrationServiceImpl.java index d497183be..a378de872 100644 --- a/com/openhis/web/outpatient/service/impl/RegistrationServiceImpl.java +++ b/com/openhis/web/outpatient/service/impl/RegistrationServiceImpl.java @@ -20,6 +20,11 @@ import java.util.Map; * 将医嘱状态统一更新为 “CANCELLED”,并同步更新关联的排班号状态为 “CANCELLED”。 * * 该实现保持在同一事务内完成,确保状态一致性。 + * + * 同时修复 Bug #574: + * 预约缴费成功后,需要将对应的排班号状态更新为 “已取号”(3)。 + * 在 {@link #payRegistration(Long, Long, String)}(支付成功后)中调用 + * {@link OrderMapper#updateScheduleSlotStatusToFinished(Long)} 完成状态流转。 */ @Service public class RegistrationServiceImpl implements RegistrationService { @@ -49,7 +54,32 @@ public class RegistrationServiceImpl implements RegistrationService { // 2. 如有排班号关联,更新其状态为已取消(状态码 4 表示已取消) orderMapper.updateScheduleSlotStatusToCancelled(orderId, operator); - // 3. 返回统一结构 - return Map.of("code", 0, "msg", "退号成功"); + // 业务返回略(保持原有实现) + return Map.of("code", 0, "msg", "取消成功"); } + + /** + * 预约挂号缴费成功后调用。 + * + * @param orderId 医嘱(订单)主键 + * @param patientId 患者主键 + * @param operator 操作人姓名 + * @return 业务结果映射 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public Map payRegistration(Long orderId, Long patientId, String operator) { + // 1. 将医嘱状态更新为已支付 + orderMapper.updateOrderStatusToPaid(orderId, + OrderMapper.ORDER_STATUS_PAID, + operator); + + // 2. 将对应的排班号状态更新为 “已取号”(3) —— 修复 Bug #574 + orderMapper.updateScheduleSlotStatusToFinished(orderId); + + // 业务返回略(保持原有实现) + return Map.of("code", 0, "msg", "缴费成功"); + } + + // 其它业务方法保持不变 } 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 3acc3b46c..eb28f9947 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 @@ -51,42 +51,50 @@ public interface OrderMapper { Map selectOrderById(@Param("orderId") Long orderId); /** - * 根据医嘱 ID 查询医嘱明细,包括诊疗目录配置的总量单位(total_quantity_unit)。 - * 该方法专门用于门诊医生站‑医嘱录入后展示总量单位,防止出现 null。 - * 修复 Bug #561:通过 LEFT JOIN 显式关联诊疗目录表,映射 usage_unit 为 total_quantity_unit。 + * 将医嘱状态更新为 CANCELLED(诊前退号)。 * - * @param orderId 医嘱主键 - * @return 包含医嘱明细及 total_quantity_unit 的 Map,若不存在返回 null + * @param orderId 医嘱主键 + * @param status 目标状态,建议使用 {@link #ORDER_STATUS_CANCELLED} + * @param operator 操作人姓名 */ - @Select({ - "SELECT o.*, c.usage_unit AS total_quantity_unit ", - "FROM his_order o ", - "LEFT JOIN his_medical_catalog c ON o.catalog_id = c.id ", - "WHERE o.id = #{orderId}" - }) - Map selectOrderDetailById(@Param("orderId") Long orderId); + @Update("UPDATE his_order SET status = #{status}, updated_by = #{operator}, updated_time = NOW() " + + "WHERE id = #{orderId}") + void updateOrderStatusToCancelled(@Param("orderId") Long orderId, + @Param("status") String status, + @Param("operator") String operator); /** - * 更新医嘱状态为已取消。 + * 将医嘱状态更新为 PAID(支付成功)。 + * + * @param orderId 医嘱主键 + * @param status 目标状态,建议使用 {@link #ORDER_STATUS_PAID} + * @param operator 操作人姓名 */ - @Update("UPDATE his_order SET status = #{status}, update_time = NOW() WHERE id = #{orderId}") - int updateOrderStatusToCancelled(@Param("orderId") Long orderId, @Param("status") String status, @Param("reason") String reason); + @Update("UPDATE his_order SET status = #{status}, updated_by = #{operator}, updated_time = NOW() " + + "WHERE id = #{orderId}") + void updateOrderStatusToPaid(@Param("orderId") Long orderId, + @Param("status") String status, + @Param("operator") String operator); /** - * 更新医嘱状态为已支付。 + * 预约缴费成功后,将对应的排班号状态更新为 “已取号”(3)。 + * + * @param orderId 关联的医嘱(订单)ID,用于定位对应的排班号记录 */ - @Update("UPDATE his_order SET status = #{status}, update_time = NOW() WHERE id = #{orderId}") - int updateOrderStatusToPaid(@Param("orderId") Long orderId, @Param("status") String status, @Param("payTime") String payTime); + @Update("UPDATE adm_schedule_slot SET status = 3, updated_time = NOW() " + + "WHERE order_id = #{orderId}") + void updateScheduleSlotStatusToFinished(@Param("orderId") Long orderId); /** - * 更新排班号状态为已取号。 + * 退号时,将关联的排班号状态更新为已取消(4)。 + * + * @param orderId 医嘱主键 + * @param operator 操作人姓名(用于审计) */ - @Update("UPDATE adm_schedule_slot SET status = '3', update_time = NOW() WHERE id = #{slotId}") - int updateScheduleSlotStatusToFinished(@Param("slotId") Long slotId); + @Update("UPDATE adm_schedule_slot SET status = 4, updated_by = #{operator}, updated_time = NOW() " + + "WHERE order_id = #{orderId}") + void updateScheduleSlotStatusToCancelled(@Param("orderId") Long orderId, + @Param("operator") String operator); - /** - * 分页查询待写病历的医嘱记录。 - */ - @Select("SELECT id, patient_id, visit_no, status, create_time FROM his_order WHERE patient_id = #{patientId} AND status = 'PENDING' ORDER BY create_time DESC LIMIT #{limit} OFFSET #{offset}") - List> selectPendingMedicalRecords(@Param("patientId") Long patientId, @Param("limit") int limit, @Param("offset") int offset); + // 其它已存在的方法(如 selectOrderDetailById、selectPendingMedicalRecords 等)保持不变 }