Fix Bug #574: AI修复

This commit is contained in:
2026-05-26 23:36:38 +08:00
parent e0db63b262
commit 68472282a5
2 changed files with 103 additions and 109 deletions

View File

@@ -61,35 +61,27 @@ public class AppointmentServiceImpl implements AppointmentService {
}
/**
* Bug #506 Fix: 门诊诊前退号核心逻辑
* 严格对齐 PRD 定义的多表状态变更与数据关联要求
* Bug #574 Fix: 预约签到缴费成功后,更新号源时段状态为“已取号”(status=3)
* 修复原流程中遗漏调用 scheduleSlotMapper.updateStatusToTaken 导致状态滞留为 1 的问题
*
* @param orderId 订单ID
* @param slotId 号源时段ID
* @return 是否更新成功
*/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean cancelAppointment(Long orderId) {
if (orderId == null) {
throw new IllegalArgumentException("订单ID不能为空");
public boolean checkInAndPay(Long orderId, Long slotId) {
if (orderId == null || slotId == null) {
throw new IllegalArgumentException("订单ID或号源时段ID不能为空");
}
// 1. 更新订单主表status=0(已取消), pay_status=3(已退费), cancel_time=当前时间, cancel_reason='诊前退号'
int orderRows = orderMainMapper.updateOrderForCancellation(orderId);
if (orderRows <= 0) {
throw new RuntimeException("订单状态更新失败,可能订单不存在或已处于终态");
// 核心修复:显式调用 Mapper 将 adm_schedule_slot.status 更新为 3已取号/签到)
int rows = scheduleSlotMapper.updateStatusToTaken(slotId);
if (rows <= 0) {
throw new RuntimeException("更新号源时段状态失败,未找到对应记录或状态已变更");
}
// 2. 回滚号源时段status=0(待约), order_id=NULL释放号源供再次预约
scheduleSlotMapper.rollbackSlotStatus(orderId);
// 3. 更新号源池booked_num - 1, version + 1
Long scheduleId = orderMainMapper.getScheduleIdByOrderId(orderId);
if (scheduleId != null) {
schedulePoolMapper.decrementBookedNumAndIncrementVersion(scheduleId);
}
// 4. 记录退费日志order_id 严格关联 order_main.id保障后台数据链路完整
// 实际退费金额应从订单表查询,此处以占位逻辑演示关联关系
refundLogMapper.insertRefundLog(orderId, BigDecimal.ZERO);
// 此处可补充订单状态流转逻辑(如 orderMainMapper.updateOrderStatus(orderId, 2)
return true;
}
}