feat: add superadmin wallet view
This commit is contained in:
@@ -203,6 +203,36 @@ type UserItem struct {
|
||||
JoinedTenantCount int64 `json:"joined_tenant_count"`
|
||||
}
|
||||
|
||||
type SuperWalletResponse struct {
|
||||
// Balance 账户可用余额(分)。
|
||||
Balance int64 `json:"balance"`
|
||||
// BalanceFrozen 账户冻结余额(分)。
|
||||
BalanceFrozen int64 `json:"balance_frozen"`
|
||||
// Transactions 最近交易记录。
|
||||
Transactions []SuperWalletTransaction `json:"transactions"`
|
||||
}
|
||||
|
||||
type SuperWalletTransaction struct {
|
||||
// ID 订单ID。
|
||||
ID int64 `json:"id"`
|
||||
// OrderType 订单类型。
|
||||
OrderType consts.OrderType `json:"order_type"`
|
||||
// Title 交易标题。
|
||||
Title string `json:"title"`
|
||||
// Amount 交易金额(分)。
|
||||
Amount int64 `json:"amount"`
|
||||
// Type 交易流向(income/expense)。
|
||||
Type string `json:"type"`
|
||||
// Date 交易时间(RFC3339)。
|
||||
Date string `json:"date"`
|
||||
// TenantID 交易所属租户ID(充值为0)。
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
// TenantCode 租户编码。
|
||||
TenantCode string `json:"tenant_code"`
|
||||
// TenantName 租户名称。
|
||||
TenantName string `json:"tenant_name"`
|
||||
}
|
||||
|
||||
type UserStatistics struct {
|
||||
// Status 用户状态枚举。
|
||||
Status consts.UserStatus `json:"status"`
|
||||
|
||||
@@ -185,6 +185,11 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
PathParam[int64]("id"),
|
||||
Query[dto.SuperUserTenantListFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/users/:id<int>/wallet -> users.Wallet")
|
||||
router.Get("/super/v1/users/:id<int>/wallet"[len(r.Path()):], DataFunc1(
|
||||
r.users.Wallet,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/users/statistics -> users.Statistics")
|
||||
router.Get("/super/v1/users/statistics"[len(r.Path()):], DataFunc0(
|
||||
r.users.Statistics,
|
||||
|
||||
@@ -43,6 +43,21 @@ func (c *users) Get(ctx fiber.Ctx, id int64) (*dto.UserItem, error) {
|
||||
return services.Super.GetUser(ctx, id)
|
||||
}
|
||||
|
||||
// Get user wallet
|
||||
//
|
||||
// @Router /super/v1/users/:id<int>/wallet [get]
|
||||
// @Summary Get user wallet
|
||||
// @Description Get user wallet balance and transactions
|
||||
// @Tags User
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "User ID"
|
||||
// @Success 200 {object} dto.SuperWalletResponse
|
||||
// @Bind id path
|
||||
func (c *users) Wallet(ctx fiber.Ctx, id int64) (*dto.SuperWalletResponse, error) {
|
||||
return services.Super.GetUserWallet(ctx, id)
|
||||
}
|
||||
|
||||
// List user tenants
|
||||
//
|
||||
// @Router /super/v1/users/:id<int>/tenants [get]
|
||||
|
||||
Reference in New Issue
Block a user