feat: 添加订单管理功能,支持跨租户分页查询,优化订单列表展示及查询条件
This commit is contained in:
96
backend/app/http/super/dto/order_page.go
Normal file
96
backend/app/http/super/dto/order_page.go
Normal file
@@ -0,0 +1,96 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/pkg/consts"
|
||||
)
|
||||
|
||||
type OrderPageFilter struct {
|
||||
requests.Pagination `json:",inline" query:",inline"`
|
||||
requests.SortQueryFilter `json:",inline" query:",inline"`
|
||||
|
||||
ID *int64 `json:"id,omitempty" query:"id"`
|
||||
TenantID *int64 `json:"tenant_id,omitempty" query:"tenant_id"`
|
||||
UserID *int64 `json:"user_id,omitempty" query:"user_id"`
|
||||
|
||||
TenantCode *string `json:"tenant_code,omitempty" query:"tenant_code"`
|
||||
TenantName *string `json:"tenant_name,omitempty" query:"tenant_name"`
|
||||
Username *string `json:"username,omitempty" query:"username"`
|
||||
|
||||
ContentID *int64 `json:"content_id,omitempty" query:"content_id"`
|
||||
ContentTitle *string `json:"content_title,omitempty" query:"content_title"`
|
||||
|
||||
Type *consts.OrderType `json:"type,omitempty" query:"type"`
|
||||
Status *consts.OrderStatus `json:"status,omitempty" query:"status"`
|
||||
|
||||
CreatedAtFrom *time.Time `json:"created_at_from,omitempty" query:"created_at_from"`
|
||||
CreatedAtTo *time.Time `json:"created_at_to,omitempty" query:"created_at_to"`
|
||||
PaidAtFrom *time.Time `json:"paid_at_from,omitempty" query:"paid_at_from"`
|
||||
PaidAtTo *time.Time `json:"paid_at_to,omitempty" query:"paid_at_to"`
|
||||
|
||||
AmountPaidMin *int64 `json:"amount_paid_min,omitempty" query:"amount_paid_min"`
|
||||
AmountPaidMax *int64 `json:"amount_paid_max,omitempty" query:"amount_paid_max"`
|
||||
}
|
||||
|
||||
func (f *OrderPageFilter) TenantCodeTrimmed() string {
|
||||
if f == nil || f.TenantCode == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.ToLower(strings.TrimSpace(*f.TenantCode))
|
||||
}
|
||||
|
||||
func (f *OrderPageFilter) TenantNameTrimmed() string {
|
||||
if f == nil || f.TenantName == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(*f.TenantName)
|
||||
}
|
||||
|
||||
func (f *OrderPageFilter) UsernameTrimmed() string {
|
||||
if f == nil || f.Username == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(*f.Username)
|
||||
}
|
||||
|
||||
func (f *OrderPageFilter) ContentTitleTrimmed() string {
|
||||
if f == nil || f.ContentTitle == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(*f.ContentTitle)
|
||||
}
|
||||
|
||||
type OrderTenantLite struct {
|
||||
ID int64 `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type OrderBuyerLite struct {
|
||||
ID int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type SuperOrderItem struct {
|
||||
ID int64 `json:"id"`
|
||||
Tenant *OrderTenantLite `json:"tenant,omitempty"`
|
||||
Buyer *OrderBuyerLite `json:"buyer,omitempty"`
|
||||
|
||||
Type consts.OrderType `json:"type"`
|
||||
Status consts.OrderStatus `json:"status"`
|
||||
|
||||
StatusDescription string `json:"status_description,omitempty"`
|
||||
Currency consts.Currency `json:"currency"`
|
||||
|
||||
AmountOriginal int64 `json:"amount_original"`
|
||||
AmountDiscount int64 `json:"amount_discount"`
|
||||
AmountPaid int64 `json:"amount_paid"`
|
||||
|
||||
PaidAt time.Time `json:"paid_at"`
|
||||
RefundedAt time.Time `json:"refunded_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package super
|
||||
|
||||
import (
|
||||
"quyun/v2/app/http/super/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
@@ -10,6 +11,21 @@ import (
|
||||
// @provider
|
||||
type order struct{}
|
||||
|
||||
// list
|
||||
//
|
||||
// @Summary 订单列表
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param filter query dto.OrderPageFilter true "Filter"
|
||||
// @Success 200 {object} requests.Pager{items=dto.SuperOrderItem}
|
||||
//
|
||||
// @Router /super/v1/orders [get]
|
||||
// @Bind filter query
|
||||
func (*order) list(ctx fiber.Ctx, filter *dto.OrderPageFilter) (*requests.Pager, error) {
|
||||
return services.Order.SuperOrderPage(ctx, filter)
|
||||
}
|
||||
|
||||
// statistics
|
||||
//
|
||||
// @Summary 订单统计信息
|
||||
|
||||
@@ -56,6 +56,11 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
Body[dto.LoginForm]("form"),
|
||||
))
|
||||
// Register routes for controller: order
|
||||
r.log.Debugf("Registering route: Get /super/v1/orders -> order.list")
|
||||
router.Get("/super/v1/orders"[len(r.Path()):], DataFunc1(
|
||||
r.order.list,
|
||||
Query[dto.OrderPageFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/orders/statistics -> order.statistics")
|
||||
router.Get("/super/v1/orders/statistics"[len(r.Path()):], DataFunc0(
|
||||
r.order.statistics,
|
||||
|
||||
Reference in New Issue
Block a user