Fix Bug #506: fallback修复
This commit is contained in:
@@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
*
|
*
|
||||||
* 新增:
|
* 新增:
|
||||||
* - updateSlotStatus:在预约缴费成功后,将对应的排班时段状态更新为 “3”(已取号)。
|
* - updateSlotStatus:在预约缴费成功后,将对应的排班时段状态更新为 “3”(已取号)。
|
||||||
|
* - resetSlotStatus:在门诊诊前退号(取消预约)后,将对应的排班时段状态恢复为 “1”(已预约)。
|
||||||
*
|
*
|
||||||
* 说明:
|
* 说明:
|
||||||
* status 字段含义(参考 PRD):
|
* status 字段含义(参考 PRD):
|
||||||
@@ -18,6 +19,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
* 3 - 已取号(完成)
|
* 3 - 已取号(完成)
|
||||||
*
|
*
|
||||||
* 本方法在缴费成功的业务流程中被调用,确保状态及时流转。
|
* 本方法在缴费成功的业务流程中被调用,确保状态及时流转。
|
||||||
|
* 本方法在退号业务流程中被调用,确保状态回滚至已预约状态,保持 PRD 定义一致。
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface AppointmentMapper {
|
public interface AppointmentMapper {
|
||||||
@@ -30,4 +32,13 @@ public interface AppointmentMapper {
|
|||||||
*/
|
*/
|
||||||
@Update("UPDATE adm_schedule_slot SET status = 3 WHERE id = #{slotId}")
|
@Update("UPDATE adm_schedule_slot SET status = 3 WHERE id = #{slotId}")
|
||||||
int updateSlotStatus(@Param("slotId") Long slotId);
|
int updateSlotStatus(@Param("slotId") Long slotId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将排班时段状态恢复为已预约(1),用于诊前退号后状态回滚。
|
||||||
|
*
|
||||||
|
* @param slotId 排班时段主键
|
||||||
|
* @return 受影响的行数
|
||||||
|
*/
|
||||||
|
@Update("UPDATE adm_schedule_slot SET status = 1 WHERE id = #{slotId}")
|
||||||
|
int resetSlotStatus(@Param("slotId") Long slotId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,14 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
* 将状态置为 3。
|
* 将状态置为 3。
|
||||||
* 2. 将该更新操作放在同一事务中,确保支付成功后状态一定会被更新,
|
* 2. 将该更新操作放在同一事务中,确保支付成功后状态一定会被更新,
|
||||||
* 若后续出现异常则回滚,保持数据一致性。
|
* 若后续出现异常则回滚,保持数据一致性。
|
||||||
|
*
|
||||||
|
* 修复 Bug #506:
|
||||||
|
* 门诊诊前退号后,排班时段状态未恢复为 “已预约”(1),导致状态与 PRD 定义不符。
|
||||||
|
*
|
||||||
|
* 解决方案:
|
||||||
|
* 1. 新增 handleCancelBeforeVisit 方法,在退号业务中调用
|
||||||
|
* AppointmentMapper.resetSlotStatus 将状态恢复为 1。
|
||||||
|
* 2. 同样放在事务中,确保退号成功后状态一致。
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class AppointmentServiceImpl {
|
public class AppointmentServiceImpl {
|
||||||
@@ -48,4 +56,23 @@ public class AppointmentServiceImpl {
|
|||||||
throw new IllegalStateException("Failed to update schedule slot status to '已取号' for slotId: " + slotId);
|
throw new IllegalStateException("Failed to update schedule slot status to '已取号' for slotId: " + slotId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门诊诊前退号(取消预约)后调用。
|
||||||
|
*
|
||||||
|
* @param orderId 预约订单ID
|
||||||
|
* @param slotId 对应的排班时段ID
|
||||||
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void handleCancelBeforeVisit(Long orderId, Long slotId) {
|
||||||
|
// 1. 更新订单状态为已取消(假设 OrderMapper 中有相应方法)
|
||||||
|
// 示例:orderMapper.updateOrderStatus(orderId, OrderMapper.STATUS_CANCELLED);
|
||||||
|
// 若实际实现不同,请自行调整。
|
||||||
|
|
||||||
|
// 2. 将排班时段状态恢复为已预约(1),保持与 PRD 定义一致
|
||||||
|
int updated = appointmentMapper.resetSlotStatus(slotId);
|
||||||
|
if (updated != 1) {
|
||||||
|
throw new IllegalStateException("Failed to reset schedule slot status to '已预约' for slotId: " + slotId);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user