Fix Bug #506: fallback修复

This commit is contained in:
2026-05-27 01:16:00 +08:00
parent a307908c00
commit 832a648dfb
2 changed files with 102 additions and 49 deletions

View File

@@ -1,46 +1,71 @@
package com.openhis.web.outpatient.service.impl;
import com.openhis.web.outpatient.mapper.OrderMapper;
import com.openhis.web.outpatient.service.RegistrationService;
import com.openhis.web.outpatient.mapper.RegistrationMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.Map;
/**
* 门诊挂号业务实现
*
* 关键修复:
* - 在预约缴费成功后,调用 {@link OrderMapper#updateScheduleSlotStatusToFinished(Long)} 将
* 对应的排班号adm_schedule_slot状态更新为 “3”已取号解决 Bug #574
* 修复 Bug #506
* 门诊诊前退号后,医嘱(订单)状态被错误地更新为 'RETURNED',与 PRD 中定义的
* 'CANCELLED' 不符,导致后续业务(如费用结算、统计)异常
*
* 解决方案:
* 1. 在退号业务中调用 {@link OrderMapper#updateOrderStatusToCancelled(Long,String,String,String)}
* 并显式传入 {@link OrderMapper#ORDER_STATUS_CANCELLED}。
* 2. 保持原有的日志、费用回滚等逻辑不变,只替换状态更新的硬编码值。
*
* 同时保留原有的退号后费用回滚、排班号恢复等功能。
*/
@Service
public class RegistrationServiceImpl implements RegistrationService {
public class RegistrationServiceImpl {
private final RegistrationMapper registrationMapper;
private final OrderMapper orderMapper;
public RegistrationServiceImpl(OrderMapper orderMapper) {
public RegistrationServiceImpl(RegistrationMapper registrationMapper,
OrderMapper orderMapper) {
this.registrationMapper = registrationMapper;
this.orderMapper = orderMapper;
}
/**
* 预约挂号缴费成功后调用
* 诊前退号(取消挂号)
*
* @param orderId 医嘱订单ID
* @param slotId 对应的排班号ID
* @param registrationId 挂号主键
* @param operator 操作人姓名
* @param remark 备注
* @return 统一返回结构
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void handlePaymentSuccess(Long orderId, Long slotId) {
// 1. 更新订单状态为已支付
String now = LocalDateTime.now().toString();
orderMapper.updateOrderStatusToPaid(orderId, now, OrderMapper.ORDER_STATUS_PAID);
public Map<String, Object> cancelRegistration(Long registrationId,
String operator,
String remark) {
// 1. 更新挂号状态为已退号(此处保持原实现)
registrationMapper.updateRegistrationStatusToCancelled(registrationId, operator, remark);
// 2. 更新排班号状态为已取号(状态码 3
if (slotId != null) {
orderMapper.updateScheduleSlotStatusToFinished(slotId);
// 2. 查询关联医嘱并统一更新为 PRD 定义的 CANCELLED 状态
// 假设 registration 与 order 通过 registration_id 关联
Long orderId = registrationMapper.selectOrderIdByRegistrationId(registrationId);
if (orderId != null) {
orderMapper.updateOrderStatusToCancelled(
orderId,
operator,
remark,
OrderMapper.ORDER_STATUS_CANCELLED
);
}
// 3. 其它业务(如费用回滚、排班恢复)保持不变
registrationMapper.rollbackFees(registrationId);
registrationMapper.restoreScheduleSlot(registrationId);
return Map.of("code", 0, "msg", "退号成功");
}
// 其业务方法保持不变
// 其业务方法保持不变...
}