feat(admin): implement order management and statistics with real database integration

This commit is contained in:
comlibmb
2026-02-10 21:59:30 +08:00
parent 47968565a5
commit 1d9915cd77
9 changed files with 567 additions and 129 deletions

View File

@@ -1,5 +1,33 @@
import { rpcOrNull, rpcOrEmptyArray, rpcOrValue } from '@/services/analytics/rpc.uts'
export async function fetchOrderPage(
page: number,
pageSize: number,
orderStatus: number | null = null,
search: string | null = null,
startTime: string | null = null,
endTime: string | null = null
): Promise<{ total: number; items: Array<any> }> {
const res = await rpcOrNull('rpc_admin_order_list', {
p_page: page,
p_page_size: pageSize,
p_order_status: orderStatus,
p_search: search,
p_start_time: startTime,
p_end_time: endTime
} as any)
if (res == null) return { total: 0, items: [] as Array<any> }
const anyTotal = (res as any).total
const anyItems = (res as any).items
const total = typeof anyTotal === 'number' ? anyTotal : parseInt(String(anyTotal ?? '0'))
const items = Array.isArray(anyItems) ? (anyItems as Array<any>) : ([] as Array<any>)
return { total, items }
}
export async function fetchRefundOrderPage(
page: number,
pageSize: number,
@@ -70,6 +98,22 @@ export async function fetchCashierOrderPage(
return { total, items }
}
export async function fetchOrderStats(startTime: string, endTime: string): Promise<any | null> {
const res = await rpcOrNull('rpc_admin_order_stats', {
p_start_time: startTime,
p_end_time: endTime
} as any)
return res as any
}
export async function fetchOrderTrend(startTime: string, endTime: string, groupBy: string = 'day'): Promise<Array<any>> {
return (await rpcOrEmptyArray('rpc_admin_order_trend', {
p_start_time: startTime,
p_end_time: endTime,
p_group_by: groupBy
} as any)) as any
}
export async function fetchOrderSourceStats(startTime: string, endTime: string): Promise<Array<any>> {
return (await rpcOrEmptyArray('rpc_admin_order_source_stats', {
p_start_time: startTime,