122 lines
2.5 KiB
TypeScript
122 lines
2.5 KiB
TypeScript
/**
|
|
* Dashboard API - 仪表盘 API
|
|
* @module api/business/dashboard
|
|
* @description 提供仪表盘数据统计相关接口,包括今日统计、累计统计、趋势数据和待办事项
|
|
*/
|
|
import { request, type ApiResponse } from '@/utils/request'
|
|
|
|
// ============ Types ============
|
|
|
|
/**
|
|
* 今日统计数据
|
|
*/
|
|
export interface TodayStatistics {
|
|
/** 今日新增用户数 */
|
|
newUsers: number
|
|
/** 今日新增订单数 */
|
|
newOrders: number
|
|
/** 今日收入 */
|
|
revenue: number
|
|
}
|
|
|
|
/**
|
|
* 累计统计数据
|
|
*/
|
|
export interface TotalStatistics {
|
|
/** 总用户数 */
|
|
totalUsers: number
|
|
/** 总订单数 */
|
|
totalOrders: number
|
|
/** 总收入 */
|
|
totalRevenue: number
|
|
}
|
|
|
|
/**
|
|
* 仪表盘概览数据
|
|
*/
|
|
export interface DashboardOverview {
|
|
/** 今日统计 */
|
|
today: TodayStatistics
|
|
/** 累计统计 */
|
|
total: TotalStatistics
|
|
}
|
|
|
|
/**
|
|
* 趋势数据项
|
|
*/
|
|
export interface TrendItem {
|
|
/** 日期 (格式: YYYY-MM-DD) */
|
|
date: string
|
|
/** 数值 */
|
|
value: number
|
|
}
|
|
|
|
/**
|
|
* 趋势数据
|
|
*/
|
|
export interface TrendsData {
|
|
/** 用户增长趋势 */
|
|
userTrend: TrendItem[]
|
|
/** 订单趋势 */
|
|
orderTrend: TrendItem[]
|
|
/** 收入趋势 */
|
|
revenueTrend: TrendItem[]
|
|
}
|
|
|
|
/**
|
|
* 趋势查询参数
|
|
*/
|
|
export interface TrendsQuery {
|
|
/** 开始日期 (格式: YYYY-MM-DD) */
|
|
startDate: string
|
|
/** 结束日期 (格式: YYYY-MM-DD) */
|
|
endDate: string
|
|
}
|
|
|
|
/**
|
|
* 待办事项
|
|
*/
|
|
export interface PendingItems {
|
|
/** 待审核提现数量 */
|
|
pendingWithdrawals: number
|
|
/** 待联系预约数量 */
|
|
pendingBookings: number
|
|
}
|
|
|
|
// ============ API Functions ============
|
|
|
|
/**
|
|
* 获取概览数据
|
|
* @returns 仪表盘概览数据,包含今日统计和累计统计
|
|
*/
|
|
export function getOverview(): Promise<ApiResponse<DashboardOverview>> {
|
|
return request<DashboardOverview>({
|
|
url: '/admin/dashboard/getOverview',
|
|
method: 'get'
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 获取趋势数据
|
|
* @param params 趋势查询参数,包含开始日期和结束日期
|
|
* @returns 趋势数据,包含用户增长、订单趋势和收入趋势
|
|
*/
|
|
export function getTrends(params: TrendsQuery): Promise<ApiResponse<TrendsData>> {
|
|
return request<TrendsData>({
|
|
url: '/admin/dashboard/getTrends',
|
|
method: 'get',
|
|
params
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 获取待办事项
|
|
* @returns 待办事项数据,包含待审核提现和待联系预约数量
|
|
*/
|
|
export function getPendingItems(): Promise<ApiResponse<PendingItems>> {
|
|
return request<PendingItems>({
|
|
url: '/admin/dashboard/getPendingItems',
|
|
method: 'get'
|
|
})
|
|
}
|