Fix Bug #575: fallback修复
This commit is contained in:
@@ -48,29 +48,38 @@ public class OutpatientRegistrationServiceImpl implements OutpatientRegistration
|
|||||||
if (order.getSlotId() != null) {
|
if (order.getSlotId() != null) {
|
||||||
AdmScheduleSlot updateSlot = new AdmScheduleSlot();
|
AdmScheduleSlot updateSlot = new AdmScheduleSlot();
|
||||||
updateSlot.setId(order.getSlotId());
|
updateSlot.setId(order.getSlotId());
|
||||||
updateSlot.setStatus(0); // 状态回滚至 0(待约)
|
// 将已预约的号源状态回滚为“可预约”(status = 1)
|
||||||
updateSlot.setOrderId(null); // 清空关联订单ID
|
updateSlot.setStatus(1);
|
||||||
admScheduleSlotMapper.updateById(updateSlot);
|
admScheduleSlotMapper.updateById(updateSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 更新 adm_schedule_pool 表 (号源池计数与版本控制)
|
// 4. 更新 adm_schedule_pool 表 (已预约数回滚)
|
||||||
if (order.getPoolId() != null) {
|
if (order.getPoolId() != null) {
|
||||||
AdmSchedulePool pool = admSchedulePoolMapper.selectById(order.getPoolId());
|
// 已预约数 -1
|
||||||
if (pool != null) {
|
admSchedulePoolMapper.decrementBookedNum(order.getPoolId());
|
||||||
AdmSchedulePool updatePool = new AdmSchedulePool();
|
}
|
||||||
updatePool.setId(pool.getId());
|
}
|
||||||
updatePool.setVersion(pool.getVersion() + 1); // version 累加 1
|
|
||||||
updatePool.setBookedNum(pool.getBookedNum() - 1); // booked_num 减 1
|
@Override
|
||||||
admSchedulePoolMapper.updateById(updatePool);
|
@Transactional(rollbackFor = Exception.class)
|
||||||
}
|
public void registerOutpatient(OrderMain order, Long poolId, Long slotId) {
|
||||||
|
// 保存挂号订单
|
||||||
|
orderMainMapper.insert(order);
|
||||||
|
|
||||||
|
// 5. 更新号源槽状态为“已预约”(status = 2)
|
||||||
|
if (slotId != null) {
|
||||||
|
AdmScheduleSlot slot = new AdmScheduleSlot();
|
||||||
|
slot.setId(slotId);
|
||||||
|
slot.setStatus(2); // 已预约
|
||||||
|
admScheduleSlotMapper.updateById(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. 写入 refund_log 表 (确保 order_id 关联 order_main.id)
|
// 6. 实时累加号源池的已预约数 (booked_num)
|
||||||
RefundLog refundLog = new RefundLog();
|
if (poolId != null) {
|
||||||
refundLog.setOrderId(orderId); // 严格关联 order_main.id
|
// 这里使用乐观锁/原子更新,确保并发安全
|
||||||
refundLog.setRefundAmount(order.getPayAmount());
|
admSchedulePoolMapper.incrementBookedNum(poolId);
|
||||||
refundLog.setRefundTime(new Date());
|
}
|
||||||
refundLog.setReason("诊前退号");
|
|
||||||
refundLogMapper.insert(refundLog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 其它业务方法保持不变...
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user