Fix Bug #574: fallback修复

This commit is contained in:
2026-05-26 23:50:34 +08:00
parent 3d1cc001dc
commit d040dd36e0
4 changed files with 90 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
package com.openhis.web.outpatient.controller;
import com.openhis.web.outpatient.service.AppointmentService;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 门诊预约相关接口
*
* 新增:/confirm 接口用于预约签到缴费成功后状态流转Bug #574
*/
@RestController
@RequestMapping("/api/outpatient/appointment")
public class AppointmentController {
private final AppointmentService appointmentService;
public AppointmentController(AppointmentService appointmentService) {
this.appointmentService = appointmentService;
}
@PostMapping("/book")
public Map<String, Object> book(@RequestParam Long slotId, @RequestParam Long orderId) {
appointmentService.bookSlot(slotId, orderId);
return Map.of("success", true);
}
/**
* 预约签到缴费成功后调用
*/
@PostMapping("/confirm")
public Map<String, Object> confirm(@RequestParam Long slotId) {
appointmentService.confirmPaymentAndTake(slotId);
return Map.of("success", true);
}
}

View File

@@ -10,6 +10,7 @@ import java.util.Map;
/**
* 门诊号源预约 Mapper
* 修复 Bug #570规范号源状态流转移除“已锁定”状态确保预约成功后状态正确落库为 2(已预约)
* 新增:状态流转至已取号(3) 的接口解决预约签到缴费成功后状态未及时流转的问题Bug #574
*/
@Mapper
public interface AppointmentSlotMapper {
@@ -22,6 +23,16 @@ public interface AppointmentSlotMapper {
"WHERE id = #{slotId} AND status = 1")
int updateSlotToBooked(@Param("slotId") Long slotId, @Param("orderId") Long orderId);
/**
* 预约签到缴费成功后,将号源状态流转为已取号(3)
*
* @param slotId 号源主键
* @return 受影响行数
*/
@Update("UPDATE adm_schedule_slot SET status = 3, update_time = NOW() " +
"WHERE id = #{slotId} AND status = 2")
int updateSlotToTaken(@Param("slotId") Long slotId);
/**
* 根据状态查询号源列表
* 修复点:支持按 status=2 精确查询,兼容前端“已预约”筛选条件

View File

@@ -0,0 +1,24 @@
package com.openhis.web.outpatient.service;
/**
* 门诊预约业务接口
*
* 新增confirmPaymentAndTake 用于处理预约签到缴费成功后状态流转Bug #574
*/
public interface AppointmentService {
/**
* 预约号源
*
* @param slotId 号源ID
* @param orderId 预约订单ID
*/
void bookSlot(Long slotId, Long orderId);
/**
* 预约签到缴费成功后,将号源状态更新为已取号(3)
*
* @param slotId 号源ID
*/
void confirmPaymentAndTake(Long slotId);
}

View File

@@ -7,6 +7,7 @@ import org.springframework.transaction.annotation.Transactional;
/**
* 门诊预约服务实现
* 修复 Bug #570简化预约状态流转确保事务内直接落库为“已预约”状态
* 新增:预约签到缴费成功后状态流转为“已取号”(3) 的业务Bug #574
*/
@Service
public class AppointmentServiceImpl implements AppointmentService {
@@ -30,4 +31,21 @@ public class AppointmentServiceImpl implements AppointmentService {
throw new RuntimeException("号源状态异常或已被他人预约,请刷新后重试");
}
}
/**
* 预约签到缴费成功后调用,完成状态流转至已取号(3)
*
* @param slotId 号源主键
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void confirmPaymentAndTake(Long slotId) {
if (slotId == null) {
throw new IllegalArgumentException("号源ID不能为空");
}
int updated = slotMapper.updateSlotToTaken(slotId);
if (updated == 0) {
throw new RuntimeException("号源状态异常,可能未完成预约或已被其他操作修改");
}
}
}