91 lines
3.9 KiB
Go
91 lines
3.9 KiB
Go
package dto
|
||
|
||
import (
|
||
"strings"
|
||
"time"
|
||
|
||
"quyun/v2/app/requests"
|
||
"quyun/v2/database/models"
|
||
"quyun/v2/pkg/consts"
|
||
)
|
||
|
||
// AdminOrderListFilter 租户管理员分页查询订单的过滤条件。
|
||
type AdminOrderListFilter struct {
|
||
// Pagination 分页参数:page/limit(通用)。
|
||
requests.Pagination `json:",inline" query:",inline"`
|
||
|
||
// SortQueryFilter 排序参数:asc/desc(逗号分隔字段名);字段白名单在 service 层统一校验。
|
||
requests.SortQueryFilter `json:",inline" query:",inline"`
|
||
|
||
// UserID 下单用户ID(可选):按买家用户ID精确过滤。
|
||
UserID *int64 `json:"user_id,omitempty" query:"user_id"`
|
||
|
||
// Username 下单用户用户名关键字(可选):模糊匹配 users.username(like)。
|
||
Username *string `json:"username,omitempty" query:"username"`
|
||
|
||
// ContentID 内容ID(可选):通过 order_items 关联过滤。
|
||
ContentID *int64 `json:"content_id,omitempty" query:"content_id"`
|
||
|
||
// ContentTitle 内容标题关键字(可选):通过 order_items + contents 关联,模糊匹配 contents.title(like)。
|
||
ContentTitle *string `json:"content_title,omitempty" query:"content_title"`
|
||
|
||
// Type 订单类型(可选):content_purchase/topup 等。
|
||
Type *consts.OrderType `json:"type,omitempty" query:"type"`
|
||
|
||
// Status 订单状态(可选):created/paid/refunding/refunded/canceled/failed。
|
||
Status *consts.OrderStatus `json:"status,omitempty" query:"status"`
|
||
|
||
// CreatedAtFrom 创建时间起(可选):created_at >= 该时间(用于按创建时间筛选)。
|
||
CreatedAtFrom *time.Time `json:"created_at_from,omitempty" query:"created_at_from"`
|
||
|
||
// CreatedAtTo 创建时间止(可选):created_at <= 该时间(用于按创建时间筛选)。
|
||
CreatedAtTo *time.Time `json:"created_at_to,omitempty" query:"created_at_to"`
|
||
|
||
// PaidAtFrom 支付时间起(可选):paid_at >= 该时间(用于按支付时间筛选)。
|
||
PaidAtFrom *time.Time `json:"paid_at_from,omitempty" query:"paid_at_from"`
|
||
|
||
// PaidAtTo 支付时间止(可选):paid_at <= 该时间(用于按支付时间筛选)。
|
||
PaidAtTo *time.Time `json:"paid_at_to,omitempty" query:"paid_at_to"`
|
||
|
||
// AmountPaidMin 实付金额下限(可选):amount_paid >= 该值(单位分)。
|
||
AmountPaidMin *int64 `json:"amount_paid_min,omitempty" query:"amount_paid_min"`
|
||
|
||
// AmountPaidMax 实付金额上限(可选):amount_paid <= 该值(单位分)。
|
||
AmountPaidMax *int64 `json:"amount_paid_max,omitempty" query:"amount_paid_max"`
|
||
}
|
||
|
||
// UsernameTrimmed 对 username 做统一处理,避免空白与大小写差异导致查询不一致。
|
||
func (f *AdminOrderListFilter) UsernameTrimmed() string {
|
||
if f == nil || f.Username == nil {
|
||
return ""
|
||
}
|
||
return strings.TrimSpace(*f.Username)
|
||
}
|
||
|
||
// ContentTitleTrimmed 对 content_title 做统一处理,避免空白与大小写差异导致查询不一致。
|
||
func (f *AdminOrderListFilter) ContentTitleTrimmed() string {
|
||
if f == nil || f.ContentTitle == nil {
|
||
return ""
|
||
}
|
||
return strings.TrimSpace(*f.ContentTitle)
|
||
}
|
||
|
||
// AdminOrderRefundForm 租户管理员退款的请求参数。
|
||
type AdminOrderRefundForm struct {
|
||
// Force indicates bypassing the default refund window check (paid_at + 24h).
|
||
// 强制退款:true 表示绕过默认退款时间窗限制(需审计)。
|
||
Force bool `json:"force,omitempty"`
|
||
// Reason is the human-readable refund reason used for audit.
|
||
// 退款原因:建议必填(由业务侧校验);用于审计与追责。
|
||
Reason string `json:"reason,omitempty"`
|
||
// IdempotencyKey ensures refund request is processed at most once.
|
||
// 幂等键:同一笔退款重复请求时返回一致结果,避免重复退款/重复回滚。
|
||
IdempotencyKey string `json:"idempotency_key,omitempty"`
|
||
}
|
||
|
||
// AdminOrderDetail 租户管理员订单详情返回结构。
|
||
type AdminOrderDetail struct {
|
||
// Order is the order with items preloaded.
|
||
Order *models.Order `json:"order,omitempty"`
|
||
}
|