Fix Bug #561: fallback修复

This commit is contained in:
2026-05-27 02:31:35 +08:00
parent db99ec2244
commit dc0c36731e

View File

@@ -8,12 +8,42 @@ import java.util.Map;
* 预约订单数据访问层
*
* 新增方法用于门诊诊前退号时更新订单状态。
*
* 修复 Bug #561
* 医嘱录入后总量单位total_unit在前端显示为 “null”。根因是查询医嘱明细时直接返回
* 数据库字段值,若诊疗目录中未配置单位则返回 null前端未做空值处理导致显示 “null”。
* 通过在 SQL 中使用 COALESCE 将 null 替换为诊疗目录配置的默认单位(若仍为 null 则返回空字符串),
* 从而保证前端始终得到合法的字符串,避免 “null” 文本展示。
*/
@Mapper
public interface OrderMapper {
// 现有方法省略 ...
/**
* 查询门诊医嘱明细(包括总量单位)
*
* @param orderId 订单ID
* @return 医嘱明细列表
*
* 说明:
* - 诊疗目录表diagnosis_catalog中字段 total_unit 保存默认单位;
* - 医嘱明细表outpatient_order_item中字段 total_unit 可能为空;
* - 使用 COALESCE 优先取医嘱明细的 total_unit若为空则取目录默认单位
* 再为空时返回空字符串,防止前端出现 “null”。
*/
@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);
/**
* 更新订单支付状态
*