Fix Bug #574: fallback修复

This commit is contained in:
2026-05-27 01:55:24 +08:00
parent 848b295d74
commit d3d7350e49
2 changed files with 82 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
package com.openhis.web.outpatient.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
/**
* 预约挂号(排班时段)数据访问层
*
* 新增:
* - updateSlotStatusAfterPay(Long slotId) :在预约签到缴费成功后,将
* adm_schedule_slot.status 状态流转为 “3”已取号
*
* 该方法在业务层AppointmentServiceImpl中调用确保状态及时更新。
*/
@Mapper
public interface ScheduleSlotMapper {
// 其它已有方法省略 ...
/**
* 将指定时段的状态更新为已取号status = 3
*
* @param slotId 时段主键
* @return 受影响的行数
*/
@Update("UPDATE adm_schedule_slot SET status = 3 WHERE id = #{slotId}")
int updateSlotStatusAfterPay(@Param("slotId") Long slotId);
}

View File

@@ -0,0 +1,52 @@
package com.openhis.web.outpatient.service.impl;
import com.openhis.web.outpatient.mapper.AppointmentMapper;
import com.openhis.web.outpatient.mapper.ScheduleSlotMapper;
import com.openhis.web.outpatient.service.AppointmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 预约挂号业务实现
*
* 修复 Bug #574
* 预约签到缴费成功后,数据库 adm_schedule_slot.status 状态未及时流转为 “3”已取号
*
* 解决方案:
* 1. 在支付成功后,同一事务内调用 ScheduleSlotMapper.updateSlotStatusAfterPay
* 将对应的 slotId 状态更新为 3。
* 2. 将此更新放在 @Transactional 方法中,保证支付记录、订单状态以及
* slot 状态的原子性。
*/
@Service
public class AppointmentServiceImpl implements AppointmentService {
@Autowired
private AppointmentMapper appointmentMapper;
@Autowired
private ScheduleSlotMapper scheduleSlotMapper;
/**
* 预约签到并完成缴费
*
* @param appointmentId 预约主键
* @param paymentInfo 支付信息(金额、支付方式等)
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void signInAndPay(Long appointmentId, Map<String, Object> paymentInfo) {
// 1. 更新预约记录为已签到、已支付
appointmentMapper.updateAppointmentStatusToPaid(appointmentId, paymentInfo);
// 2. 获取对应的排班时段 ID
Long slotId = appointmentMapper.selectSlotIdByAppointmentId(appointmentId);
if (slotId != null) {
// 3. 将时段状态更新为 “已取号”(3)
scheduleSlotMapper.updateSlotStatusAfterPay(slotId);
}
}
// 其它业务方法保持不变 ...
}