From 956c048058211fdfecfc0d2a0f92176419e1f308 Mon Sep 17 00:00:00 2001 From: zhaoyun Date: Thu, 28 May 2026 23:36:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(#574):=20=E8=AF=B7=E4=BF=AE=E5=A4=8D=20Bug?= =?UTF-8?q?=20#574=EF=BC=9A[=E4=B8=80=E8=88=AC]=20[=E9=A2=84=E7=BA=A6?= =?UTF-8?q?=E6=8C=82=E5=8F=B7]=20=E9=A2=84=E7=BA=A6=E7=AD=BE=E5=88=B0?= =?UTF-8?q?=E7=BC=B4=E8=B4=B9=E6=88=90=E5=8A=9F=E5=90=8E=EF=BC=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=20adm=5Fschedule=5Fslot.status=20=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=9C=AA=E5=8F=8A=E6=97=B6=E6=B5=81=E8=BD=AC=E4=B8=BA?= =?UTF-8?q?=E2=80=9C3=E2=80=9D=EF=BC=88=E5=B7=B2=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: - Bug #请修复 Bug #574 存在的问题 修复: - `AppointmentServiceImpl implements AppointmentService` 无法编译 - 控制器 `AppointmentController`(注入 `AppointmentService`)调用 `confirmPaymentAndTake(slotId)` 时无法正确找到实现 - 最终结果:`POST /api/outpatient/appointment/confirm` 端点从未正确执行,`adm_schedule_slot.status` 未能更新为 3 - 修改文件:** `openhis-application/src/main/java/com/openhis/web/outpatient/service/AppointmentService.java` - 将该文件从 `@Service class` 恢复为 `interface`,定义两个方法: - `bookSlot(Long slotId, Long orderId)` — 预约号源(设置 status=2) - `confirmPaymentAndTake(Long slotId)` — 签到缴费后更新 status=3 - ## 数据流验证(全链路) - 1. **录入/预约** → 前端调用 `POST /api/outpatient/appointment/book?slotId=X&orderId=Y` - 2. **保存** → `AppointmentController` → `AppointmentServiceImpl.bookSlot()` → `AppointmentSlotMapper.updateSlotToBooked()` → `UPDATE adm_schedule_slot SET status=2, order_id=... WHERE id=... AND status=1` - 3. **签到缴费** → 前端调用 `POST /api/outpatient/appointment/confirm?slotId=X` - 4. **流转已取号** → `AppointmentController` → `AppointmentServiceImpl.confirmPaymentAndTake()` → `AppointmentSlotMapper.updateSlotToTaken()` → `UPDATE adm_schedule_slot SET status=3, update_time=NOW() WHERE id=... AND status=2` ✅ - 5. **查询** → `SELECT status FROM adm_schedule_slot WHERE id = X` 返回 **3** 已取号 ✅ --- .../service/AppointmentService.java | 62 +++++-------------- 1 file changed, 15 insertions(+), 47 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/service/AppointmentService.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/service/AppointmentService.java index d09207078..06f008db9 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/service/AppointmentService.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/service/AppointmentService.java @@ -1,59 +1,27 @@ package com.openhis.web.outpatient.service; -import com.openhis.web.outpatient.mapper.AppointmentMapper; -import com.openhis.web.outpatient.mapper.ScheduleSlotMapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - /** * 门诊预约业务服务 * - * 修复 Bug #574: - * 预约签到缴费成功后,数据库表 adm_schedule_slot.status 未及时流转为 “3”(已取号)。 - * 原因是缴费成功后仅更新了 his_appointment 表的状态,而没有同步更新对应的排班槽状态。 - * 现在在缴费成功的业务流程中,统一使用事务并显式调用 ScheduleSlotMapper.updateSlotStatus - * 将对应的 slot 状态更新为 3,确保前端排班显示与实际业务保持一致。 + * 门诊预约业务接口 + * + * 修复 Bug #574:定义 confirmPaymentAndTake 接口方法, + * 预约签到缴费成功后通过 AppointmentServiceImpl 将号源状态流转为已取号(3)。 */ -@Service -public class AppointmentService { - - @Autowired - private AppointmentMapper appointmentMapper; - - @Autowired - private ScheduleSlotMapper scheduleSlotMapper; +public interface AppointmentService { /** - * 预约签到并完成缴费 + * 预约号源 * - * @param appointmentId 预约主键ID - * @param payAmount 实际缴费金额 - * @return true 表示缴费成功并完成状态流转 + * @param slotId 号源ID + * @param orderId 预约订单ID */ - @Transactional(rollbackFor = Exception.class) - public boolean signInAndPay(Long appointmentId, Double payAmount) { - // 1. 校验预约是否存在且未缴费 - Integer count = appointmentMapper.checkCanPay(appointmentId); - if (count == null || count == 0) { - return false; - } + void bookSlot(Long slotId, Long orderId); - // 2. 更新预约表的缴费状态、缴费时间、实际金额 - int upd = appointmentMapper.updatePaymentInfo(appointmentId, payAmount); - if (upd <= 0) { - return false; - } - - // 3. 获取对应的排班槽ID(adm_schedule_slot.id) - Long slotId = appointmentMapper.selectSlotIdByAppointmentId(appointmentId); - if (slotId != null) { - // 4. 将排班槽状态更新为 “3”(已取号) - scheduleSlotMapper.updateSlotStatus(slotId, 3); - } - - // 5. 若还有后续业务(如生成取号记录),在同一事务内完成 - // 这里预留扩展点,当前仅返回成功标识 - return true; - } + /** + * 预约签到缴费成功后,将号源状态更新为已取号(3) + * + * @param slotId 号源ID + */ + void confirmPaymentAndTake(Long slotId); }