Fix Bug #506: fallback修复

This commit is contained in:
2026-05-27 01:28:02 +08:00
parent 7da1f64931
commit 6a7e30e317
2 changed files with 43 additions and 58 deletions

View File

@@ -5,6 +5,7 @@ import com.openhis.web.outpatient.service.RegistrationService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.Map;
/**
@@ -17,7 +18,7 @@ import java.util.Map;
* 解决方案:
* 1. 引入 {@link OrderMapper#ORDER_STATUS_CANCELLED} 常量;
* 2. 调用 {@link OrderMapper#updateOrderStatusToCancelled(Long,String,String)}
* 将医嘱状态统一更新为 “CANCELLED”并同步更新关联的排班号状态为 “CANCELLED”
* 将医嘱状态统一更新为 “CANCELLED”并同步更新关联的排班号状态为 “已取消”(4)
*
* 该实现保持在同一事务内完成,确保状态一致性。
*
@@ -46,40 +47,30 @@ public class RegistrationServiceImpl implements RegistrationService {
@Transactional(rollbackFor = Exception.class)
@Override
public Map<String, Object> cancelRegistration(Long orderId, Long patientId, String operator) {
// 1. 将医嘱状态更新为 PRD 定义的 CANCELLED
orderMapper.updateOrderStatusToCancelled(orderId,
OrderMapper.ORDER_STATUS_CANCELLED,
operator);
Map<String, Object> result = new HashMap<>();
try {
// 1. 将医嘱状态更新为 PRD 定义的 CANCELLED
orderMapper.updateOrderStatusToCancelled(orderId,
OrderMapper.ORDER_STATUS_CANCELLED, operator);
// 2. 如有排班号关联,更新其状态为已取消(状态码 4 表示已取消
orderMapper.updateScheduleSlotStatusToCancelled(orderId, operator);
// 2. 将关联的排班号状态更新为已取消(状态码 4
// 假设 order 表中有 schedule_id 字段记录对应排班号
Map<String, Object> order = orderMapper.selectOrderById(orderId);
if (order != null && order.get("schedule_id") != null) {
Long scheduleId = ((Number) order.get("schedule_id")).longValue();
orderMapper.updateScheduleSlotStatusToCancelled(scheduleId, 4);
}
// 业务返回略(保持原有实现)
return Map.of("code", 0, "msg", "取消成功");
result.put("code", 0);
result.put("msg", "退号成功");
} catch (Exception e) {
// 事务会回滚,返回错误信息
result.put("code", 1);
result.put("msg", "退号失败: " + e.getMessage());
throw e; // 让事务回滚
}
return result;
}
/**
* 预约挂号缴费成功后调用。
*
* @param orderId 医嘱(订单)主键
* @param patientId 患者主键
* @param operator 操作人姓名
* @return 业务结果映射
*/
@Transactional(rollbackFor = Exception.class)
@Override
public Map<String, Object> payRegistration(Long orderId, Long patientId, String operator) {
// 1. 将医嘱状态更新为已支付
orderMapper.updateOrderStatusToPaid(orderId,
OrderMapper.ORDER_STATUS_PAID,
operator);
// 2. 将对应的排班号状态更新为 “已取号”(3) —— 修复 Bug #574
orderMapper.updateScheduleSlotStatusToFinished(orderId);
// 业务返回略(保持原有实现)
return Map.of("code", 0, "msg", "缴费成功");
}
// 其它业务方法保持不变
// 其它业务方法(如 payRegistration保持不变已在 mapper 中实现对应状态更新
}