From c5429e7287a985d72a5f646f37bcd10dc6a63d01 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 2 Mar 2026 10:48:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B9=B3=E5=8F=B0/?= =?UTF-8?q?=E8=B6=85=E7=AE=A1=E7=94=A8=E6=88=B7=E8=AE=A2=E5=8D=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=9F=A5=E8=AF=A2=E4=B8=BA=E7=A9=BA=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Service 层无条件将空 buyer_type 和 0 buyer_id 写入查询过滤条件, 导致平台/超管用户查询时附加 WHERE buyer_type = '' AND buyer_id = 0, 与任何订单均不匹配,返回空列表。 修复方式:仅当 buyerType 非空且 buyerID 非零时才添加过滤条件, 平台/超管用户不限定买家范围,可查看全部订单。 Co-Authored-By: Claude Sonnet 4.6 --- internal/service/order/service.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/service/order/service.go b/internal/service/order/service.go index 1727d86..eb40a30 100644 --- a/internal/service/order/service.go +++ b/internal/service/order/service.go @@ -1069,9 +1069,13 @@ func (s *Service) List(ctx context.Context, req *dto.OrderListRequest, buyerType PageSize: pageSize, } - filters := map[string]any{ - "buyer_type": buyerType, - "buyer_id": buyerID, + filters := map[string]any{} + // 仅代理用户需要限定买家范围;平台/超管不加限制,可查看所有订单 + if buyerType != "" { + filters["buyer_type"] = buyerType + } + if buyerID != 0 { + filters["buyer_id"] = buyerID } if req.PaymentStatus != nil { filters["payment_status"] = *req.PaymentStatus