fix: 修复平台/超管用户订单列表查询为空的问题
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m5s

Service 层无条件将空 buyer_type 和 0 buyer_id 写入查询过滤条件,
导致平台/超管用户查询时附加 WHERE buyer_type = '' AND buyer_id = 0,
与任何订单均不匹配,返回空列表。

修复方式:仅当 buyerType 非空且 buyerID 非零时才添加过滤条件,
平台/超管用户不限定买家范围,可查看全部订单。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-02 10:48:11 +08:00
parent e661b59bb9
commit c5429e7287

View File

@@ -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