feat(admin): merge stash changes into comclib-analytics (order/finance/product + rpc sql)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { rpcOrNull, rpcOrEmptyArray } from '@/services/analytics/rpc.uts'
|
||||
import { rpcOrNull, rpcOrEmptyArray, rpcOrValue } from '@/services/analytics/rpc.uts'
|
||||
|
||||
export async function fetchRefundOrderPage(
|
||||
page: number,
|
||||
@@ -24,6 +24,28 @@ export async function fetchRefundOrderPage(
|
||||
return { total, items }
|
||||
}
|
||||
|
||||
export async function fetchWriteOffRecordPage(
|
||||
page: number,
|
||||
pageSize: number,
|
||||
search: string | null = null
|
||||
): Promise<{ total: number; items: Array<any> }> {
|
||||
const res = await rpcOrNull('rpc_admin_write_off_record_list', {
|
||||
p_page: page,
|
||||
p_page_size: pageSize,
|
||||
p_search: search
|
||||
} 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 fetchCashierOrderPage(
|
||||
page: number,
|
||||
pageSize: number,
|
||||
@@ -48,31 +70,24 @@ export async function fetchCashierOrderPage(
|
||||
return { total, items }
|
||||
}
|
||||
|
||||
export async function fetchWriteOffRecordPage(
|
||||
page: number,
|
||||
pageSize: number,
|
||||
search: string | null = null
|
||||
): Promise<{ total: number; items: Array<any> }> {
|
||||
const res = await rpcOrNull('rpc_admin_write_off_record_list', {
|
||||
p_page: page,
|
||||
p_page_size: pageSize,
|
||||
p_search: search
|
||||
} 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 fetchOrderSourceStats(startTime: string, endTime: string): Promise<Array<any>> {
|
||||
return (await rpcOrEmptyArray('rpc_admin_order_source_stats', {
|
||||
p_start_time: startTime,
|
||||
p_end_time: endTime
|
||||
} as any)) as any
|
||||
}
|
||||
|
||||
export async function getOrderSettings(): Promise<UTSJSONObject | null> {
|
||||
const res = await rpcOrValue('rpc_admin_system_config_get', {
|
||||
p_key: 'order_settings'
|
||||
} as any)
|
||||
return res as any
|
||||
}
|
||||
|
||||
export async function saveOrderSettings(config: UTSJSONObject): Promise<boolean> {
|
||||
const res = await rpcOrValue('rpc_admin_system_config_save', {
|
||||
p_key: 'order_settings',
|
||||
p_value: config
|
||||
} as any)
|
||||
return res === true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user