Fix Bug #506: AI修复

This commit is contained in:
2026-05-26 23:19:10 +08:00
parent ed9b18afa7
commit cd97745b42
2 changed files with 107 additions and 87 deletions

View File

@@ -62,35 +62,20 @@ public class AppointmentServiceImpl implements AppointmentService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean cancelAppointment(Long orderId) {
// 1. 更新 order_main 表状态
// status = 0 (已取消), pay_status = 3 (已退费), cancel_time = 当前精确时间, cancel_reason = '诊前退号'
LocalDateTime cancelTime = LocalDateTime.now();
orderMainMapper.updateCancelStatus(orderId, 0, 3, cancelTime, "诊前退号");
// 2. 回滚 adm_schedule_slot 表状态
// status = 0 (待约), order_id = NULL (释放号源供再次预约)
scheduleSlotMapper.rollbackSlotByOrderId(orderId);
// 1. 更新 order_main 表status=0(已取消), pay_status=3(已退费), cancel_time=当前时间, cancel_reason='诊前退号'
orderMainMapper.updateOrderCancelStatus(orderId, 0, 3, cancelTime, "诊前退号");
// 3. 更新 adm_schedule_pool 表
// version = version + 1 (乐观锁/并发控制), booked_num = booked_num - 1 (库存回滚)
Long scheduleId = orderMainMapper.getScheduleIdByOrderId(orderId);
if (scheduleId != null) {
schedulePoolMapper.decrementBookedAndIncrementVersion(scheduleId);
}
// 2. 回滚 adm_schedule_slot 表status=0(待约), order_id=NULL (释放号源供再次预约)
scheduleSlotMapper.rollbackSlotByOrderId(orderId, 0, null);
// 4. 记录 refund_log 表,确保 order_id 严格关联 order_main.id
refundLogMapper.insertRefundLog(orderId, cancelTime);
// 3. 更新 adm_schedule_pool 表version=version+1, booked_num=booked_num-1 (保证并发控制与号源计数准确)
schedulePoolMapper.updatePoolVersionAndBookedNum(orderId);
// 4. 写入 refund_log 表order_id 严格关联 order_main.id (确保后台业务数据可追溯)
refundLogMapper.insertRefundLog(orderId, cancelTime, "诊前退号");
return true;
}
/**
* 预约签到缴费成功后调用,确保号源状态流转为 3已取号/待就诊)
*
* @param orderId 挂号订单 ID
*/
@Transactional(rollbackFor = Exception.class)
public void confirmAppointment(Long orderId) {
// 省略实现...
}
}