74 lines
1.9 KiB
TypeScript
74 lines
1.9 KiB
TypeScript
import http from '@/utils/httpRequest'
|
||
import type { ManageResponse } from './types'
|
||
|
||
/**
|
||
* 总览看板统计
|
||
*/
|
||
export interface OverviewStats {
|
||
totalOrders: number
|
||
todayOrders: number
|
||
totalRevenue: number
|
||
todayRevenue: number
|
||
totalPool: number
|
||
availablePool: number
|
||
usedPool: number
|
||
activateFailed: number
|
||
}
|
||
|
||
/**
|
||
* 订单趋势统计项
|
||
*/
|
||
export interface OrderTrendItem {
|
||
date: string
|
||
orderCount: number
|
||
revenue: number
|
||
}
|
||
|
||
/**
|
||
* 库存统计
|
||
* 实际返回:statusStats / activateStats 均为 Map<状态, 数量>
|
||
*/
|
||
export interface PoolStats {
|
||
/** 按库存状态:{ UNUSED: 1, USED: 2 } */
|
||
statusStats: Record<string, number>
|
||
/** 按激活状态:{ PENDING: 2, FAILED: 1 } */
|
||
activateStats: Record<string, number>
|
||
}
|
||
|
||
/**
|
||
* 渠道统计项
|
||
*/
|
||
export interface ChannelStatItem {
|
||
channelOrgId: number
|
||
orderCount: number
|
||
revenue: number
|
||
}
|
||
|
||
/**
|
||
* 订单趋势统计查询参数
|
||
*/
|
||
export interface OrderStatsParams {
|
||
startDate: string
|
||
endDate: string
|
||
}
|
||
|
||
/** 总览看板 */
|
||
export function getOverviewStats(): Promise<ManageResponse<{ overview?: OverviewStats }>> {
|
||
return http.get(http.adornUrl('/manage/stats/overview'), { params: http.adornParams() }).then(res => res.data)
|
||
}
|
||
|
||
/** 订单趋势统计 */
|
||
export function getOrderStats(params: OrderStatsParams): Promise<ManageResponse<{ orderStats?: { list: OrderTrendItem[] } }>> {
|
||
return http.get(http.adornUrl('/manage/stats/orders'), { params: http.adornParams(params) }).then(res => res.data)
|
||
}
|
||
|
||
/** 库存统计 */
|
||
export function getPoolStats(): Promise<ManageResponse<{ poolStats?: PoolStats }>> {
|
||
return http.get(http.adornUrl('/manage/stats/pool'), { params: http.adornParams() }).then(res => res.data)
|
||
}
|
||
|
||
/** 渠道统计 */
|
||
export function getChannelStats(): Promise<ManageResponse<{ channelStats?: { list: ChannelStatItem[] } }>> {
|
||
return http.get(http.adornUrl('/manage/stats/channels'), { params: http.adornParams() }).then(res => res.data)
|
||
}
|