feat(tenant): 增加双站订单视图与租户统计
This commit is contained in:
@@ -2,14 +2,12 @@ package order
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"hfb_sys/backend/internal/model"
|
||||
)
|
||||
|
||||
// ListPendingRefund 查询所有待客服审核退款的订单。
|
||||
func (r *Repository) ListPendingRefund(ctx context.Context) ([]OrderDTO, error) {
|
||||
var rows []orderRow
|
||||
err := r.adminQuery(ctx).
|
||||
err := applyBuyerTenantOrderScope(r.adminQuery(ctx), ctx).
|
||||
Where("o.refund_status = ?", refundStatusPendingReview).
|
||||
Order("o.updated_at ASC, o.id ASC").
|
||||
Limit(200).
|
||||
@@ -23,6 +21,7 @@ func (r *Repository) ListPendingRefund(ctx context.Context) ([]OrderDTO, error)
|
||||
items := make([]OrderDTO, 0, len(rows))
|
||||
for _, row := range rows {
|
||||
dto := row.toAdminDTO()
|
||||
dto.SiteRole = tenantOrderRole(ctx, row.RentalOrder)
|
||||
applyPaymentDeadline(&dto, row.RentalOrder, paymentTimeoutMinutes)
|
||||
items = append(items, dto)
|
||||
}
|
||||
@@ -32,9 +31,10 @@ func (r *Repository) ListPendingRefund(ctx context.Context) ([]OrderDTO, error)
|
||||
// PendingRefundCount 返回待客服审核退款数量,用于后台导航角标。
|
||||
func (r *Repository) PendingRefundCount(ctx context.Context) (int64, error) {
|
||||
var count int64
|
||||
err := r.db.WithContext(ctx).
|
||||
Model(&model.RentalOrder{}).
|
||||
Where("refund_status = ?", refundStatusPendingReview).
|
||||
Count(&count).Error
|
||||
query := r.db.WithContext(ctx).
|
||||
Table("rental_orders AS o").
|
||||
Where("refund_status = ?", refundStatusPendingReview)
|
||||
query = applyBuyerTenantOrderScope(query, ctx)
|
||||
err := query.Count(&count).Error
|
||||
return count, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user