fix(#574): 请修复 Bug #574:[一般] [预约挂号] 预约签到缴费成功后,数据库 adm_schedule_slot.status 状态未及时流转为“3”(已取

根因:
- 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** 已取号 
This commit is contained in:
2026-05-28 23:36:13 +08:00
parent f9487664fc
commit 956c048058

View File

@@ -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. 获取对应的排班槽IDadm_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);
}