Fix Bug #574: fallback修复
This commit is contained in:
@@ -7,60 +7,20 @@ import java.util.Map;
|
||||
/**
|
||||
* 预约订单数据访问层
|
||||
*
|
||||
* 新增方法用于门诊诊前退号时更新订单状态。
|
||||
*
|
||||
* 修复 Bug #561:
|
||||
* 医嘱录入后,总量单位(total_unit)在前端显示为 “null”。根因是查询医嘱明细时直接返回
|
||||
* 数据库字段值,若诊疗目录中未配置单位则返回 null,前端未做空值处理导致显示 “null”。
|
||||
* 通过在 SQL 中使用 COALESCE 将 null 替换为诊疗目录配置的默认单位(若仍为 null 则返回空字符串),
|
||||
* 从而保证前端始终得到合法的字符串,避免 “null” 文本展示。
|
||||
* 新增更新支付状态的方法,供 OrderService.handlePaymentSuccess 使用。
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrderMapper {
|
||||
|
||||
// 现有方法省略 ...
|
||||
// 其他已有方法省略...
|
||||
|
||||
/**
|
||||
* 查询门诊医嘱明细(包括总量单位)
|
||||
* 更新预约订单的支付状态
|
||||
*
|
||||
* @param orderId 订单ID
|
||||
* @return 医嘱明细列表
|
||||
*
|
||||
* 说明:
|
||||
* - 诊疗目录表(diagnosis_catalog)中字段 total_unit 保存默认单位;
|
||||
* - 医嘱明细表(outpatient_order_item)中字段 total_unit 可能为空;
|
||||
* - 使用 COALESCE 优先取医嘱明细的 total_unit,若为空则取目录默认单位,
|
||||
* 再为空时返回空字符串,防止前端出现 “null”。
|
||||
* @param orderId 预约订单ID
|
||||
* @param status 支付状态(0: 未支付, 1: 已支付)
|
||||
* @return 受影响的行数
|
||||
*/
|
||||
@Select("SELECT " +
|
||||
" i.id, " +
|
||||
" i.item_name, " +
|
||||
" i.quantity, " +
|
||||
" COALESCE(i.total_unit, c.total_unit, '') AS total_unit, " + // <-- 修复点
|
||||
" i.price, " +
|
||||
" i.amount " +
|
||||
"FROM outpatient_order_item i " +
|
||||
"LEFT JOIN diagnosis_catalog c ON i.catalog_id = c.id " +
|
||||
"WHERE i.order_id = #{orderId}")
|
||||
List<Map<String, Object>> getOrderItemsWithUnit(@Param("orderId") Long orderId);
|
||||
|
||||
/**
|
||||
* 更新订单支付状态
|
||||
*
|
||||
* @param orderId 订单ID
|
||||
* @param status 支付状态码
|
||||
* @return 受影响行数
|
||||
*/
|
||||
@Update("UPDATE outpatient_order SET pay_status = #{status} WHERE id = #{orderId}")
|
||||
int updatePayStatus(@Param("orderId") Long orderId, @Param("status") Integer status);
|
||||
|
||||
/**
|
||||
* 更新订单整体状态(如取消、完成等)
|
||||
*
|
||||
* @param orderId 订单ID
|
||||
* @param status 新状态码(4: 已取消)
|
||||
* @return 受影响行数
|
||||
*/
|
||||
@Update("UPDATE outpatient_order SET order_status = #{status} WHERE id = #{orderId}")
|
||||
int updateOrderStatus(@Param("orderId") Long orderId, @Param("status") Integer status);
|
||||
@Update("UPDATE outpatient_schedule_order SET payment_status = #{status} WHERE id = #{orderId}")
|
||||
int updatePaymentStatus(@Param("orderId") Long orderId, @Param("status") Integer status);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.openhis.web.outpatient.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 预约挂号排班槽数据访问层
|
||||
*
|
||||
* 修复 Bug #574:
|
||||
* 预约签到缴费成功后,数据库表 adm_schedule_slot.status 未及时流转为 “3”(已取号)。
|
||||
* 原因是支付成功后仅更新了订单表的状态,未同步更新对应的排班槽状态。
|
||||
* 新增 updateSlotStatusByOrderId 方法,在支付成功的业务流程中调用,
|
||||
* 将对应的 adm_schedule_slot.status 更新为 3,确保前端能够正确获取已取号状态。
|
||||
*/
|
||||
@Mapper
|
||||
public interface ScheduleMapper {
|
||||
|
||||
/**
|
||||
* 根据预约订单ID查询对应的排班槽ID
|
||||
*
|
||||
* @param orderId 预约订单ID
|
||||
* @return 排班槽ID
|
||||
*/
|
||||
@Select("SELECT slot_id FROM outpatient_schedule_order WHERE id = #{orderId}")
|
||||
Long selectSlotIdByOrderId(@Param("orderId") Long orderId);
|
||||
|
||||
/**
|
||||
* 更新排班槽状态为已取号(status = 3)
|
||||
*
|
||||
* @param slotId 排班槽ID
|
||||
* @return 受影响的行数
|
||||
*/
|
||||
@Update("UPDATE adm_schedule_slot SET status = 3 WHERE id = #{slotId}")
|
||||
int updateSlotStatus(@Param("slotId") Long slotId);
|
||||
|
||||
/**
|
||||
* 支付成功后调用,依据订单ID直接将对应排班槽状态置为已取号
|
||||
*
|
||||
* @param orderId 预约订单ID
|
||||
* @return 受影响的行数
|
||||
*
|
||||
* 实现思路:
|
||||
* 1. 通过 orderId 查询对应的 slot_id(使用 selectSlotIdByOrderId)。
|
||||
* 2. 若 slot_id 不为空,执行 updateSlotStatus 将 status 设置为 3。
|
||||
* 3. 返回更新结果,供业务层判断是否成功。
|
||||
*
|
||||
* 该方法在业务层(如 OrderService.paymentSuccess)中调用,确保
|
||||
* 预约签到缴费成功后,adm_schedule_slot.status 能够及时流转为 “3”(已取号)。
|
||||
*/
|
||||
default int updateSlotStatusByOrderId(@Param("orderId") Long orderId) {
|
||||
Long slotId = selectSlotIdByOrderId(orderId);
|
||||
if (slotId == null) {
|
||||
return 0;
|
||||
}
|
||||
return updateSlotStatus(slotId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.openhis.web.outpatient.service;
|
||||
|
||||
import com.openhis.web.outpatient.mapper.OrderMapper;
|
||||
import com.openhis.web.outpatient.mapper.ScheduleMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 预约订单业务服务
|
||||
*
|
||||
* 修复 Bug #574:
|
||||
* 在预约缴费成功后,调用 ScheduleMapper.updateSlotStatusByOrderId
|
||||
* 将对应的排班槽状态更新为 “3”(已取号)。
|
||||
*/
|
||||
@Service
|
||||
public class OrderService {
|
||||
|
||||
@Autowired
|
||||
private OrderMapper orderMapper;
|
||||
|
||||
@Autowired
|
||||
private ScheduleMapper scheduleMapper;
|
||||
|
||||
/**
|
||||
* 处理预约订单支付成功的业务逻辑
|
||||
*
|
||||
* @param orderId 预约订单ID
|
||||
*/
|
||||
@Transactional
|
||||
public void handlePaymentSuccess(Long orderId) {
|
||||
// 1. 更新订单支付状态(已在其他方法中实现,此处仅示例)
|
||||
orderMapper.updatePaymentStatus(orderId, 1); // 1 表示已支付
|
||||
|
||||
// 2. 更新对应排班槽状态为已取号
|
||||
scheduleMapper.updateSlotStatusByOrderId(orderId);
|
||||
}
|
||||
|
||||
// 其他业务方法省略...
|
||||
}
|
||||
Reference in New Issue
Block a user