feat: 更新租户和订单相关功能,添加租户成员列表接口,优化数据处理和前端展示
This commit is contained in:
@@ -11,7 +11,7 @@ type OrderStatisticsRow struct {
|
||||
}
|
||||
|
||||
type OrderStatisticsResponse struct {
|
||||
TotalCount int64 `json:"total_count"`
|
||||
TotalAmountPaidSum int64 `json:"total_amount_paid_sum"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
TotalAmountPaidSum int64 `json:"total_amount_paid_sum"`
|
||||
ByStatus []*OrderStatisticsRow `json:"by_status"`
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package dto
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"quyun/v2/app/requests"
|
||||
@@ -10,19 +11,59 @@ import (
|
||||
)
|
||||
|
||||
type TenantFilter struct {
|
||||
requests.Pagination
|
||||
requests.SortQueryFilter
|
||||
// Pagination page/limit.
|
||||
requests.Pagination `json:",inline" query:",inline"`
|
||||
|
||||
// SortQueryFilter defines asc/desc ordering.
|
||||
requests.SortQueryFilter `json:",inline" query:",inline"`
|
||||
|
||||
Name *string `json:"name,omitempty" query:"name"`
|
||||
Code *string `json:"code,omitempty" query:"code"`
|
||||
ID *int64 `json:"id,omitempty" query:"id"`
|
||||
UserID *int64 `json:"user_id,omitempty" query:"user_id"`
|
||||
Status *consts.TenantStatus `json:"status,omitempty" query:"status"`
|
||||
|
||||
ExpiredAtFrom *time.Time `json:"expired_at_from,omitempty" query:"expired_at_from"`
|
||||
ExpiredAtTo *time.Time `json:"expired_at_to,omitempty" query:"expired_at_to"`
|
||||
|
||||
CreatedAtFrom *time.Time `json:"created_at_from,omitempty" query:"created_at_from"`
|
||||
CreatedAtTo *time.Time `json:"created_at_to,omitempty" query:"created_at_to"`
|
||||
}
|
||||
|
||||
func (f *TenantFilter) NameTrimmed() string {
|
||||
if f == nil || f.Name == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(*f.Name)
|
||||
}
|
||||
|
||||
func (f *TenantFilter) CodeTrimmed() string {
|
||||
if f == nil || f.Code == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.ToLower(strings.TrimSpace(*f.Code))
|
||||
}
|
||||
|
||||
type TenantItem struct {
|
||||
*models.Tenant
|
||||
|
||||
UserCount int64 `json:"user_count"`
|
||||
UserBalance int64 `json:"user_balance"`
|
||||
StatusDescription string `json:"status_description"`
|
||||
UserCount int64 `json:"user_count"`
|
||||
// IncomeAmountPaidSum 累计收入金额(单位:分,CNY):按 orders 聚合得到的已支付净收入(不含退款中/已退款订单)。
|
||||
IncomeAmountPaidSum int64 `json:"income_amount_paid_sum"`
|
||||
StatusDescription string `json:"status_description"`
|
||||
|
||||
Owner *TenantOwnerUserLite `json:"owner,omitempty"`
|
||||
AdminUsers []*TenantAdminUserLite `json:"admin_users,omitempty"`
|
||||
}
|
||||
|
||||
type TenantOwnerUserLite struct {
|
||||
ID int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type TenantAdminUserLite struct {
|
||||
ID int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type TenantCreateForm struct {
|
||||
|
||||
26
backend/app/http/super/dto/tenant_user.go
Normal file
26
backend/app/http/super/dto/tenant_user.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"quyun/v2/database/models"
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"go.ipao.vip/gen/types"
|
||||
)
|
||||
|
||||
type SuperUserLite struct {
|
||||
ID int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Status consts.UserStatus `json:"status"`
|
||||
Roles types.Array[consts.Role] `json:"roles"`
|
||||
VerifiedAt time.Time `json:"verified_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
StatusDescription string `json:"status_description,omitempty"`
|
||||
}
|
||||
|
||||
type SuperTenantUserItem struct {
|
||||
TenantUser *models.TenantUser `json:"tenant_user,omitempty"`
|
||||
User *SuperUserLite `json:"user,omitempty"`
|
||||
}
|
||||
@@ -22,4 +22,3 @@ type order struct{}
|
||||
func (*order) statistics(ctx fiber.Ctx) (*dto.OrderStatisticsResponse, error) {
|
||||
return services.Order.SuperStatistics(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ package super
|
||||
|
||||
import (
|
||||
"quyun/v2/app/http/super/dto"
|
||||
tenantdto "quyun/v2/app/http/tenant/dto"
|
||||
"quyun/v2/app/middlewares"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
@@ -70,6 +71,12 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
r.tenant.create,
|
||||
Body[dto.TenantCreateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/tenants/:tenantID/users -> tenant.users")
|
||||
router.Get("/super/v1/tenants/:tenantID/users"[len(r.Path()):], DataFunc2(
|
||||
r.tenant.users,
|
||||
PathParam[int64]("tenantID"),
|
||||
Query[tenantdto.AdminTenantUserListFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/tenants/statuses -> tenant.statusList")
|
||||
router.Get("/super/v1/tenants/statuses"[len(r.Path()):], DataFunc0(
|
||||
r.tenant.statusList,
|
||||
|
||||
@@ -3,6 +3,7 @@ package super
|
||||
import (
|
||||
"quyun/v2/app/errorx"
|
||||
"quyun/v2/app/http/super/dto"
|
||||
tenantdto "quyun/v2/app/http/tenant/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
"quyun/v2/database/models"
|
||||
@@ -44,6 +45,23 @@ func (*tenant) create(ctx fiber.Ctx, form *dto.TenantCreateForm) (*models.Tenant
|
||||
return services.Tenant.SuperCreateTenant(ctx, form)
|
||||
}
|
||||
|
||||
// users
|
||||
//
|
||||
// @Summary 租户成员列表(平台侧)
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenantID path int64 true "TenantID"
|
||||
// @Param filter query tenantdto.AdminTenantUserListFilter true "Filter"
|
||||
// @Success 200 {object} requests.Pager{items=dto.SuperTenantUserItem}
|
||||
//
|
||||
// @Router /super/v1/tenants/:tenantID/users [get]
|
||||
// @Bind tenantID path
|
||||
// @Bind filter query
|
||||
func (*tenant) users(ctx fiber.Ctx, tenantID int64, filter *tenantdto.AdminTenantUserListFilter) (*requests.Pager, error) {
|
||||
return services.Tenant.SuperTenantUsersPage(ctx, tenantID, filter)
|
||||
}
|
||||
|
||||
// updateExpire
|
||||
//
|
||||
// @Summary 更新过期时间
|
||||
|
||||
Reference in New Issue
Block a user