Fix Bug #574: fallback修复
This commit is contained in:
28
com/openhis/web/outpatient/mapper/RegistrationMapper.java
Normal file
28
com/openhis/web/outpatient/mapper/RegistrationMapper.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package com.openhis.web.outpatient.mapper;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门诊挂号业务数据访问层
|
||||||
|
*
|
||||||
|
* 新增:
|
||||||
|
* 1. updateSlotStatusToPaid – 预约签到缴费成功后,将对应号源状态更新为 “3”(已取号)。
|
||||||
|
*
|
||||||
|
* 该方法在支付成功后调用,确保号源状态及时流转,修复 Bug #574。
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface RegistrationMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约签到缴费成功后,将号源状态置为已取号(status = 3)。
|
||||||
|
*
|
||||||
|
* @param orderId 关联的订单ID
|
||||||
|
* @return 受影响的行数
|
||||||
|
*/
|
||||||
|
@Update("UPDATE adm_schedule_slot " +
|
||||||
|
"SET status = 3 " +
|
||||||
|
"WHERE order_id = #{orderId}")
|
||||||
|
int updateSlotStatusToPaid(@Param("orderId") Long orderId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.openhis.web.outpatient.service.impl;
|
||||||
|
|
||||||
|
import com.openhis.web.outpatient.mapper.RegistrationMapper;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门诊挂号业务实现
|
||||||
|
*
|
||||||
|
* 修复 Bug #574:在预约签到缴费成功后,调用 {@link RegistrationMapper#updateSlotStatusToPaid}
|
||||||
|
* 将对应的 adm_schedule_slot.status 状态及时流转为 “3”(已取号)。
|
||||||
|
*
|
||||||
|
* 该方法假设在支付成功的业务流程中被调用,确保状态同步。
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class RegistrationServiceImpl implements RegistrationService {
|
||||||
|
|
||||||
|
private final RegistrationMapper registrationMapper;
|
||||||
|
private final OrderMapper orderMapper;
|
||||||
|
|
||||||
|
public RegistrationServiceImpl(RegistrationMapper registrationMapper,
|
||||||
|
OrderMapper orderMapper) {
|
||||||
|
this.registrationMapper = registrationMapper;
|
||||||
|
this.orderMapper = orderMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预约签到缴费成功后处理逻辑
|
||||||
|
*
|
||||||
|
* @param orderId 订单ID
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void handlePaymentSuccess(Long orderId) {
|
||||||
|
if (orderId == null) {
|
||||||
|
throw new IllegalArgumentException("订单ID不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. 更新订单状态为已支付(此处假设已有对应的 SQL)
|
||||||
|
int orderUpdated = orderMapper.updateOrderStatusToPaid(orderId);
|
||||||
|
if (orderUpdated == 0) {
|
||||||
|
throw new RuntimeException("订单状态更新为已支付失败,orderId=" + orderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 将对应的号源状态更新为已取号(status = 3),修复 Bug #574
|
||||||
|
int slotUpdated = registrationMapper.updateSlotStatusToPaid(orderId);
|
||||||
|
if (slotUpdated == 0) {
|
||||||
|
// 如果未更新到任何号源,说明数据异常,抛异常回滚事务
|
||||||
|
throw new RuntimeException("号源状态未更新为已取号,orderId=" + orderId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user