package com.openhis.web.outpatient.service.impl; import com.openhis.web.outpatient.mapper.OrderMapper; import com.openhis.web.outpatient.service.RegistrationService; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; /** * 门诊挂号业务实现 * * 关键修复: * - 在预约缴费成功后,调用 {@link OrderMapper#updateScheduleSlotStatusToFinished(Long)} 将 * 对应的排班号(adm_schedule_slot)状态更新为 “3”(已取号),解决 Bug #574。 */ @Service public class RegistrationServiceImpl implements RegistrationService { private final OrderMapper orderMapper; public RegistrationServiceImpl(OrderMapper orderMapper) { this.orderMapper = orderMapper; } /** * 预约挂号缴费成功后调用。 * * @param orderId 医嘱(订单)ID * @param slotId 对应的排班号ID */ @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); // 2. 更新排班号状态为已取号(状态码 3) if (slotId != null) { orderMapper.updateScheduleSlotStatusToFinished(slotId); } } // 其余业务方法保持不变 }