41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
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).
|
|
Where("o.refund_status = ?", refundStatusPendingReview).
|
|
Order("o.updated_at ASC, o.id ASC").
|
|
Limit(200).
|
|
Scan(&rows).Error
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
db := r.db.WithContext(ctx)
|
|
paymentTimeoutMinutes := pendingPaymentTimeoutMinutes(db)
|
|
items := make([]OrderDTO, 0, len(rows))
|
|
for _, row := range rows {
|
|
dto := row.toAdminDTO()
|
|
applyPaymentDeadline(&dto, row.RentalOrder, paymentTimeoutMinutes)
|
|
items = append(items, dto)
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
// 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
|
|
return count, err
|
|
}
|