feat(admin): 新增后台用户列表与详情操作
This commit is contained in:
@@ -10,6 +10,9 @@ import type {
|
||||
AdminOrderPage,
|
||||
AdminOrderQuery,
|
||||
AdminUser,
|
||||
AdminUserItem,
|
||||
AdminUserPage,
|
||||
AdminUserQuery,
|
||||
DashboardData,
|
||||
} from '@/features/admin/types'
|
||||
|
||||
@@ -130,3 +133,87 @@ export async function markAbnormalAdminListing(id: number | string, reason: stri
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function fetchAdminUsers(query: AdminUserQuery) {
|
||||
const params: Record<string, unknown> = { ...compactParams(query) }
|
||||
if (query.has_deposit_free_quota) {
|
||||
params.has_deposit_free_quota = true
|
||||
} else {
|
||||
delete params.has_deposit_free_quota
|
||||
}
|
||||
const { data } = await adminClient.get<ApiResponse<Partial<AdminUserPage>>>('/admin/users', {
|
||||
params,
|
||||
})
|
||||
return {
|
||||
items: data.data.items ?? [],
|
||||
total: data.data.total ?? 0,
|
||||
page: data.data.page ?? query.page ?? 1,
|
||||
page_size: data.data.page_size ?? query.page_size ?? 20,
|
||||
}
|
||||
}
|
||||
|
||||
export async function freezeAdminUser(id: number | string, reason: string) {
|
||||
const { data } = await adminClient.post<ApiResponse<AdminUserItem>>(
|
||||
`/admin/users/${id}/freeze`,
|
||||
{ reason }
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function unfreezeAdminUser(id: number | string, reason: string) {
|
||||
const { data } = await adminClient.post<ApiResponse<AdminUserItem>>(
|
||||
`/admin/users/${id}/unfreeze`,
|
||||
{ reason }
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function setAdminUserDepositFreeQuota(id: number | string, amountCent: number) {
|
||||
const { data } = await adminClient.post<ApiResponse<AdminUserItem>>(
|
||||
`/admin/users/${id}/deposit-free-quota`,
|
||||
{ amount_cent: amountCent }
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function adjustAdminUserGrowthPoints(
|
||||
id: number | string,
|
||||
targetPoints: number,
|
||||
reason: string
|
||||
) {
|
||||
const { data } = await adminClient.post<ApiResponse<AdminUserItem>>(
|
||||
`/admin/users/${id}/growth-points`,
|
||||
{ target_points: targetPoints, reason }
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function manualAdminUserRealname(
|
||||
id: number | string,
|
||||
payload: { name: string; id_no: string; reason: string }
|
||||
) {
|
||||
const { data } = await adminClient.post<ApiResponse<AdminUserItem>>(
|
||||
`/admin/users/${id}/manual-realname`,
|
||||
payload
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function revokeAdminUserRealname(id: number | string, reason: string) {
|
||||
const { data } = await adminClient.post<ApiResponse<AdminUserItem>>(
|
||||
`/admin/users/${id}/revoke-realname`,
|
||||
{ reason }
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function adjustAdminUserWallet(
|
||||
id: number | string,
|
||||
payload: { direction: 'in' | 'out'; amount_cent: number; reason: string; reference_no?: string }
|
||||
) {
|
||||
const { data } = await adminClient.post<ApiResponse<AdminUserItem>>(
|
||||
`/admin/users/${id}/wallet/adjust`,
|
||||
payload
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user