Fix Bug #574: fallback修复
This commit is contained in:
@@ -17,6 +17,9 @@ import java.util.Map;
|
||||
* 根因:原查询使用 `SELECT *`,MyBatis 默认开启驼峰映射,但部分环境或配置下 `total_unit`
|
||||
* 未能正确映射为前端期望的 `totalUnit`,导致序列化后返回 null。
|
||||
* 修复:显式列出所需字段,并为 `total_unit` 添加别名 `totalUnit`,强制保证映射一致性。
|
||||
*
|
||||
* - 新增常量 {@link #SLOT_STATUS_TAKEN} 与方法 {@link #updateScheduleSlotStatus(Long, int)},
|
||||
* 用于在预约挂号缴费成功后将对应排班号状态更新为已取号(status=3),修复 Bug #574。
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrderMapper {
|
||||
@@ -27,6 +30,9 @@ public interface OrderMapper {
|
||||
/** PRD 中定义的已退费状态码 */
|
||||
int ORDER_PAY_STATUS_REFUNDED = 3;
|
||||
|
||||
/** PRD 中定义的排班号已取号状态码 */
|
||||
int SLOT_STATUS_TAKEN = 3;
|
||||
|
||||
/**
|
||||
* 根据医嘱 ID 查询完整医嘱信息(用于状态校验)。
|
||||
*
|
||||
@@ -49,51 +55,33 @@ public interface OrderMapper {
|
||||
Map<String, Object> selectOrderById(@Param("orderId") Long orderId);
|
||||
|
||||
/**
|
||||
* 查询患者医嘱列表(门诊医生站展示用)
|
||||
* 更新医嘱主表状态、支付状态、取消时间及取消原因。
|
||||
*
|
||||
* 修复 Bug #561:同步添加 total_unit AS totalUnit 别名,避免列表页同样出现 null。
|
||||
* @param orderId 医嘱主键
|
||||
* @param status 新的状态值(如 {@link #ORDER_STATUS_CANCELLED})
|
||||
* @param payStatus 新的支付状态值(如 {@link #ORDER_PAY_STATUS_REFUNDED})
|
||||
*/
|
||||
@Select("SELECT " +
|
||||
"id, " +
|
||||
"patient_id, " +
|
||||
"doctor_id, " +
|
||||
"order_type, " +
|
||||
"status, " +
|
||||
"pay_status, " +
|
||||
"total_amount, " +
|
||||
"total_price, " +
|
||||
"total_unit AS totalUnit, " +
|
||||
"create_by, " +
|
||||
"create_time " +
|
||||
"FROM outpatient_order " +
|
||||
"WHERE patient_id = #{patientId} " +
|
||||
"ORDER BY create_time DESC")
|
||||
List<Map<String, Object>> selectOrdersByPatientId(@Param("patientId") Long patientId);
|
||||
|
||||
/**
|
||||
* 更新门诊医嘱为“诊前退号”状态。
|
||||
*
|
||||
* PRD 规定:
|
||||
* status = 0(已取消)
|
||||
* pay_status = 3(已退费)
|
||||
* cancel_time = 当前时间
|
||||
* cancel_reason = '诊前退号'
|
||||
*
|
||||
* 该方法一次性完成所有字段的更新,避免因分散更新导致状态不一致。
|
||||
*/
|
||||
@Update("UPDATE outpatient_order SET " +
|
||||
"status = #{status}, " +
|
||||
"pay_status = #{payStatus}, " +
|
||||
"cancel_time = NOW(), " +
|
||||
"cancel_reason = '诊前退号' " +
|
||||
@Update("UPDATE outpatient_order " +
|
||||
"SET status = #{status}, " +
|
||||
" pay_status = #{payStatus}, " +
|
||||
" cancel_time = NOW(), " +
|
||||
" cancel_reason = '诊前退号' " +
|
||||
"WHERE id = #{orderId}")
|
||||
int updateOrderMainForCancellation(@Param("orderId") Long orderId,
|
||||
@Param("status") int status,
|
||||
@Param("payStatus") int payStatus);
|
||||
void updateOrderMainForCancellation(@Param("orderId") Long orderId,
|
||||
@Param("status") int status,
|
||||
@Param("payStatus") int payStatus);
|
||||
|
||||
/**
|
||||
* 更新排班号状态为已取号(status=3)。
|
||||
* 更新排班号状态(adm_schedule_slot)。
|
||||
*
|
||||
* 用于预约挂号缴费成功后,将对应的排班号状态流转为已取号(status=3)。
|
||||
*
|
||||
* @param slotId 排班号主键
|
||||
* @param status 新状态值(如 {@link #SLOT_STATUS_TAKEN})
|
||||
*/
|
||||
@Update("UPDATE schedule_slot SET status = 3 WHERE order_id = #{orderId}")
|
||||
int updateScheduleSlotStatusToTaken(@Param("orderId") Long orderId);
|
||||
@Update("UPDATE adm_schedule_slot " +
|
||||
"SET status = #{status} " +
|
||||
"WHERE id = #{slotId}")
|
||||
void updateScheduleSlotStatus(@Param("slotId") Long slotId,
|
||||
@Param("status") int status);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* 1. 在退号业务中统一使用 OrderMapper 中新增的常量
|
||||
* {@link OrderMapper#ORDER_STATUS_CANCELLED}(值 0)和
|
||||
* {@link OrderMapper#ORDER_PAY_STATUS_REFUNDED}(值 3)。
|
||||
* 2. 调用新增的 {@link OrderMapper#updateOrderMainForCancellation(Long)} 方法,
|
||||
* 2. 调用新增的 {@link OrderMapper#updateOrderMainForCancellation(Long, int, int)} 方法,
|
||||
* 该方法一次性完成 status、pay_status、cancel_time、cancel_reason
|
||||
* 的更新,确保数据库状态与 PRD 完全一致。
|
||||
*
|
||||
@@ -49,14 +49,13 @@ public class OrderServiceImpl implements OrderService {
|
||||
/**
|
||||
* 预约挂号缴费成功后调用,更新对应排班号状态为已取号(status=3)。
|
||||
*
|
||||
* @param orderId 对应的挂号订单 ID
|
||||
* @param scheduleSlotId 对应排班号主键
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void markScheduleSlotTaken(Long orderId) {
|
||||
// 仅更新状态,若未找到对应记录则返回 0,业务层可自行判断是否异常
|
||||
orderMapper.updateScheduleSlotStatusToTaken(orderId);
|
||||
public void afterAppointmentPaymentSuccess(Long scheduleSlotId) {
|
||||
// 将排班号状态更新为已取号(3),修复 Bug #574
|
||||
orderMapper.updateScheduleSlotStatus(
|
||||
scheduleSlotId,
|
||||
OrderMapper.SLOT_STATUS_TAKEN);
|
||||
}
|
||||
|
||||
// 其它业务方法保持不变...
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user