Fix Bug #574: fallback修复
This commit is contained in:
@@ -6,6 +6,8 @@ import com.openhis.web.outpatient.service.RegistrationService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 门诊挂号业务实现
|
||||
*
|
||||
@@ -41,18 +43,33 @@ public class RegistrationServiceImpl implements RegistrationService {
|
||||
throw new IllegalArgumentException("订单ID不能为空");
|
||||
}
|
||||
|
||||
// 1. 更新订单状态为已支付(此处使用 OrderMapper 中新增的常量)
|
||||
// 1. 更新订单状态为已支付(使用 OrderMapper 中新增的常量)
|
||||
int orderUpdated = orderMapper.updateOrderStatusToPaid(orderId, OrderMapper.ORDER_STATUS_PAID);
|
||||
if (orderUpdated == 0) {
|
||||
throw new RuntimeException("订单状态更新为已支付失败,orderId=" + orderId);
|
||||
}
|
||||
|
||||
// 2. 将对应的号源状态更新为已取号(status = 3),修复 Bug #574
|
||||
int slotUpdated = registrationMapper.updateSlotStatusToPaid(orderId);
|
||||
// 2. 获取订单关联的号源 slot_id
|
||||
Map<String, Object> order = orderMapper.selectOrderById(orderId);
|
||||
if (order == null) {
|
||||
throw new RuntimeException("未找到对应订单,orderId=" + orderId);
|
||||
}
|
||||
Object slotIdObj = order.get("slot_id");
|
||||
if (slotIdObj == null) {
|
||||
throw new RuntimeException("订单未关联号源,无法更新号源状态,orderId=" + orderId);
|
||||
}
|
||||
Long slotId = Long.valueOf(String.valueOf(slotIdObj));
|
||||
|
||||
// 3. 将对应的号源状态更新为已取号(status = 3),修复 Bug #574
|
||||
int slotUpdated = registrationMapper.updateSlotStatusToPaid(slotId);
|
||||
if (slotUpdated == 0) {
|
||||
throw new RuntimeException("号源状态更新为已取号失败,orderId=" + orderId);
|
||||
throw new RuntimeException("号源状态更新为已取号失败,slotId=" + slotId);
|
||||
}
|
||||
|
||||
// 3. (可选)如果还有其他业务,如发送通知等,可在此继续处理
|
||||
// 4. 同步累加排班池已预约数量,修复 Bug #575
|
||||
int poolUpdated = registrationMapper.incrementBookedNumByOrderId(orderId);
|
||||
if (poolUpdated == 0) {
|
||||
throw new RuntimeException("排班池已预约数量累加失败,orderId=" + orderId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user