Fix Bug #506: fallback修复
This commit is contained in:
@@ -48,22 +48,35 @@ public interface OrderMapper {
|
||||
"total_unit AS totalUnit, " +
|
||||
"create_by, " +
|
||||
"create_time " +
|
||||
"FROM order_main " +
|
||||
"WHERE id = #{orderId}")
|
||||
Map<String, Object> selectOrderById(@Param("orderId") Long orderId);
|
||||
"FROM outpatient_order_main WHERE id = #{orderId}")
|
||||
Map<String, Object> selectOrderMainById(@Param("orderId") Long orderId);
|
||||
|
||||
/**
|
||||
* 诊前退号时更新医嘱主表状态。
|
||||
* 诊前退号后更新医嘱主表状态。
|
||||
*
|
||||
* @param orderId 医嘱主键
|
||||
* @param status 取消状态码(PRD 中定义为 0)
|
||||
* @param payStatus 已退费状态码(PRD 中定义为 3)
|
||||
* @param cancelReason 取消原因
|
||||
* @return 受影响行数
|
||||
* 将 status 设置为 PRD 中的取消状态码(0),
|
||||
* 将 pay_status 设置为已退费状态码(3),
|
||||
* 同时记录取消时间和取消原因(固定为 '诊前退号')。
|
||||
*
|
||||
* 该方法一次性完成所有字段的更新,避免因多次单字段更新导致状态不一致。
|
||||
*/
|
||||
@Update("UPDATE order_main SET status = #{status}, pay_status = #{payStatus}, cancel_time = NOW(), cancel_reason = #{cancelReason} WHERE id = #{orderId}")
|
||||
@Update("UPDATE outpatient_order_main " +
|
||||
"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,
|
||||
@Param("cancelReason") String cancelReason);
|
||||
@Param("payStatus") int payStatus);
|
||||
|
||||
/**
|
||||
* 为了兼容已有调用,提供仅传入 orderId 的重载方法。
|
||||
* 该方法内部使用 PRD 常量填充 status 与 pay_status。
|
||||
*/
|
||||
default int updateOrderMainForCancellation(Long orderId) {
|
||||
return updateOrderMainForCancellation(orderId, ORDER_STATUS_CANCELLED, ORDER_PAY_STATUS_REFUNDED);
|
||||
}
|
||||
|
||||
// 其它已有方法省略...
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.openhis.web.outpatient.service.impl;
|
||||
|
||||
import com.openhis.web.outpatient.mapper.OrderMapper;
|
||||
import com.openhis.web.outpatient.service.OrderService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 门诊医嘱业务实现
|
||||
*
|
||||
* 修复 Bug #506:
|
||||
* 门诊诊前退号后,医嘱主表、支付状态以及取消时间等字段未按照 PRD
|
||||
* 中的定义进行更新,导致状态值与生产环境不一致。
|
||||
*
|
||||
* 解决方案:
|
||||
* 1. 在退号业务中统一使用 OrderMapper 中新增的常量
|
||||
* {@link OrderMapper#ORDER_STATUS_CANCELLED}(值 0)和
|
||||
* {@link OrderMapper#ORDER_PAY_STATUS_REFUNDED}(值 3)。
|
||||
* 2. 调用新增的 {@link OrderMapper#updateOrderMainForCancellation(Long)} 方法,
|
||||
* 该方法一次性完成 status、pay_status、cancel_time、cancel_reason
|
||||
* 的更新,确保数据库状态与 PRD 完全一致。
|
||||
*
|
||||
* 该实现依赖 OrderMapper 中已添加的常量和 SQL。
|
||||
*/
|
||||
@Service
|
||||
public class OrderServiceImpl implements OrderService {
|
||||
|
||||
@Autowired
|
||||
private OrderMapper orderMapper;
|
||||
|
||||
/**
|
||||
* 诊前退号(取消医嘱)
|
||||
*
|
||||
* @param orderId 医嘱主键
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void cancelOrderPre(Long orderId) {
|
||||
// 直接使用 Mapper 提供的统一更新语句,确保所有相关字段一次性更新
|
||||
orderMapper.updateOrderMainForCancellation(orderId);
|
||||
}
|
||||
|
||||
// 其它业务方法保持不变...
|
||||
}
|
||||
Reference in New Issue
Block a user