新增退款待审核角标提醒

This commit is contained in:
yml2213
2026-08-28 23:10:07 +08:00
parent 41a5b49450
commit a9a9127076
8 changed files with 176 additions and 1 deletions
@@ -248,6 +248,15 @@ func (h *Handler) ListPendingRefund(c *gin.Context) {
response.OK(c, gin.H{"items": items})
}
func (h *Handler) PendingRefundCount(c *gin.Context) {
count, err := h.service.PendingRefundCount(c.Request.Context())
if err != nil {
writeOrderError(c, err)
return
}
response.OK(c, gin.H{"pending_refund_count": count})
}
func (h *Handler) adminAction(c *gin.Context, fn func(context.Context, uint64, uint64, AdminActionRequest, AuditMeta) error, okData gin.H) {
adminID, ok := currentAdminID(c)
if !ok {
@@ -2,6 +2,8 @@ package order
import (
"context"
"hfb_sys/backend/internal/model"
)
// ListPendingRefund 查询所有待客服审核退款的订单。
@@ -26,3 +28,13 @@ func (r *Repository) ListPendingRefund(ctx context.Context) ([]OrderDTO, error)
}
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
}
@@ -351,6 +351,13 @@ func (s *Service) ListPendingRefund(ctx context.Context) ([]OrderDTO, error) {
return s.repo.ListPendingRefund(ctx)
}
func (s *Service) PendingRefundCount(ctx context.Context) (int64, error) {
if s.repo == nil {
return 0, ErrDependencyUnavailable
}
return s.repo.PendingRefundCount(ctx)
}
func (s *Service) FindForUser(ctx context.Context, userID uint64, orderID uint64) (*OrderDTO, error) {
if s.repo == nil {
return nil, ErrDependencyUnavailable