feat(mohong): 新增摸红商城后台四页
This commit is contained in:
@@ -129,6 +129,11 @@ import type {
|
||||
AdminInviteRebateSummary,
|
||||
AdminBackupStatus,
|
||||
AdminBackupSchedule,
|
||||
AdminCrashCategory,
|
||||
AdminCrashProduct,
|
||||
AdminCrashOrder,
|
||||
AdminCrashConfig,
|
||||
AdminPaged,
|
||||
ManualDisbursementPayload,
|
||||
OperatingExpensePage,
|
||||
OperatingExpensePayload,
|
||||
@@ -1900,3 +1905,124 @@ export async function updateAdminBackupSchedule(payload: AdminBackupSchedule) {
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function fetchCrashCategories() {
|
||||
const { data } = await adminClient.get<ApiResponse<AdminCrashCategory[]>>(
|
||||
'/admin/crash/categories'
|
||||
)
|
||||
return data.data ?? []
|
||||
}
|
||||
|
||||
export async function createCrashCategory(payload: {
|
||||
name: string
|
||||
code?: string
|
||||
sort_order?: number
|
||||
status?: string
|
||||
}) {
|
||||
const { data } = await adminClient.post<ApiResponse<AdminCrashCategory>>(
|
||||
'/admin/crash/categories',
|
||||
payload
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function updateCrashCategory(
|
||||
id: number,
|
||||
payload: { name?: string; sort_order?: number; status?: string }
|
||||
) {
|
||||
const { data } = await adminClient.put<ApiResponse<AdminCrashCategory>>(
|
||||
`/admin/crash/categories/${id}`,
|
||||
payload
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function deleteCrashCategory(id: number) {
|
||||
await adminClient.delete(`/admin/crash/categories/${id}`)
|
||||
}
|
||||
|
||||
export async function fetchCrashProducts(query: {
|
||||
keyword?: string
|
||||
status?: string
|
||||
category_id?: number
|
||||
page?: number
|
||||
page_size?: number
|
||||
}) {
|
||||
const { data } = await adminClient.get<ApiResponse<Partial<AdminPaged<AdminCrashProduct>>>>(
|
||||
'/admin/crash/products',
|
||||
{ params: compactParams(query) }
|
||||
)
|
||||
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 createCrashProduct(payload: Record<string, unknown>) {
|
||||
const { data } = await adminClient.post<ApiResponse<AdminCrashProduct>>(
|
||||
'/admin/crash/products',
|
||||
payload
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function updateCrashProduct(id: number, payload: Record<string, unknown>) {
|
||||
const { data } = await adminClient.put<ApiResponse<AdminCrashProduct>>(
|
||||
`/admin/crash/products/${id}`,
|
||||
payload
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function deleteCrashProduct(id: number) {
|
||||
await adminClient.delete(`/admin/crash/products/${id}`)
|
||||
}
|
||||
|
||||
export async function fetchCrashOrders(query: {
|
||||
keyword?: string
|
||||
status?: string
|
||||
page?: number
|
||||
page_size?: number
|
||||
}) {
|
||||
const { data } = await adminClient.get<ApiResponse<Partial<AdminPaged<AdminCrashOrder>>>>(
|
||||
'/admin/crash/orders',
|
||||
{ params: compactParams(query) }
|
||||
)
|
||||
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 receiveCrashOrder(id: number, remark = '') {
|
||||
await adminClient.post(`/admin/crash/orders/${id}/receive`, { remark })
|
||||
}
|
||||
|
||||
export async function completeCrashOrder(id: number, remark = '') {
|
||||
await adminClient.post(`/admin/crash/orders/${id}/complete`, { remark })
|
||||
}
|
||||
|
||||
export async function cancelCrashOrder(id: number, reason: string) {
|
||||
await adminClient.post(`/admin/crash/orders/${id}/cancel`, { reason })
|
||||
}
|
||||
|
||||
export async function refundCrashOrder(id: number, payload: { reason?: string; amount_cent?: number }) {
|
||||
await adminClient.post(`/admin/crash/orders/${id}/refund`, payload)
|
||||
}
|
||||
|
||||
export async function fetchCrashConfig() {
|
||||
const { data } = await adminClient.get<ApiResponse<AdminCrashConfig>>('/admin/crash/config')
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function updateCrashConfig(payload: Partial<AdminCrashConfig>) {
|
||||
const { data } = await adminClient.put<ApiResponse<AdminCrashConfig>>(
|
||||
'/admin/crash/config',
|
||||
payload
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user