退款订单列表增加金额汇总
refundOrder/list 响应增加 totalMoney(单位:分),走 $sum 聚合统计 整个筛选结果的退款金额,而不是当前这一页 —— 按渠道搜出几百笔时 只汇总当页会得出错误金额。 命中数为 0 时直接返回,不再多跑一次聚合和列表查询。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,14 @@ func List(ctx context.Context, req *proto.RefundOrderListReq) (*proto.RefundOrde
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if total == 0 {
|
||||
return resp, nil // 没有命中,汇总和列表都不用再查
|
||||
}
|
||||
// 汇总整个筛选结果的退款金额,与分页无关
|
||||
totalMoney, err := refundOrderMod.SumRefundOrderMoney(ctx, filter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
opt := &options.FindOptions{}
|
||||
opt.SetSort(bson.D{{Key: refundOrderMod.FN.RefundOrder.CreatedAt, Value: -1}})
|
||||
opt.SetSkip((req.PageNum - 1) * req.PageSize)
|
||||
@@ -60,6 +68,7 @@ func List(ctx context.Context, req *proto.RefundOrderListReq) (*proto.RefundOrde
|
||||
return nil, err
|
||||
}
|
||||
resp.Total = total
|
||||
resp.TotalMoney = totalMoney
|
||||
resp.List = list
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user