import request from '@/utils/http'

/**
 * 统计分析 API
 */

/**
 * 获取订阅概览统计
 */
export function fetchSubscriptionOverview() {
  return request.get<Api.Statistics.SubscriptionOverview>({
    url: '/api/admin/v1/statistics/subscriptions/overview'
  })
}

/**
 * 获取配额使用排行
 * @param params 查询参数
 */
export function fetchQuotaUsageRanking(params?: Api.Statistics.QuotaUsageRankingParams) {
  return request.get<Api.Statistics.QuotaUsageRankingResponse>({
    url: '/api/admin/v1/statistics/quota/ranking',
    params
  })
}

/**
 * 获取收入统计
 * @param params 查询参数
 */
export function fetchRevenueStatistics(params?: Api.Statistics.RevenueStatisticsParams) {
  return request.get<Api.Statistics.RevenueStatisticsResponse>({
    url: '/api/admin/v1/statistics/revenue',
    params
  })
}

/**
 * 获取即将到期订阅列表
 * @param params 查询参数
 */
export function fetchExpiringSubscriptions(params?: Api.Statistics.ExpiringSubscriptionsParams) {
  return request.get<Api.Statistics.ExpiringSubscriptionsResponse>({
    url: '/api/admin/v1/statistics/subscriptions/expiring',
    params
  })
}
