From ffbc1c83c29ea344203d2a47476472d6482a004f Mon Sep 17 00:00:00 2001 From: haomingming Date: Tue, 6 Jan 2026 15:33:38 +0800 Subject: [PATCH] 11 --- api/dao/orderProduct.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api/dao/orderProduct.go b/api/dao/orderProduct.go index 1569540..d9e1586 100644 --- a/api/dao/orderProduct.go +++ b/api/dao/orderProduct.go @@ -210,7 +210,12 @@ func (r *OrderProductDao) GetOrderProductPageSearch(req requests.GetOrderProduct // 处方编号 if req.PrescriptionCode != "" { - query = query.Where("prescription_code = ?", req.PrescriptionCode) + // 处方编号存在于处方表中,这里通过处方表查询出对应的处方ID,再反查商品订单 + subQuery := global.Db.Model(&model.OrderPrescription{}). + Select("order_prescription_id"). + Where("prescription_code = ?", req.PrescriptionCode) + + query = query.Where("order_prescription_id IN (?)", subQuery) } // 订单编号