trade.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import request from '@/config/axios'
  2. import dayjs from 'dayjs'
  3. import { formatDate } from '@/utils/formatTime'
  4. import { DataComparisonRespVO } from '@/api/mall/statistics/common'
  5. /** 交易统计 Response VO */
  6. export interface TradeSummaryRespVO {
  7. yesterdayOrderCount: number
  8. monthOrderCount: number
  9. yesterdayPayPrice: number
  10. monthPayPrice: number
  11. }
  12. /** 交易状况 Request VO */
  13. export interface TradeTrendReqVO {
  14. times: [dayjs.ConfigType, dayjs.ConfigType]
  15. }
  16. /** 交易状况统计 Response VO */
  17. export interface TradeTrendSummaryRespVO {
  18. time: string
  19. turnoverPrice: number
  20. orderPayPrice: number
  21. rechargePrice: number
  22. expensePrice: number
  23. orderWalletPayPrice: number
  24. brokerageSettlementPrice: number
  25. afterSaleRefundPrice: number
  26. }
  27. /** 交易订单数量 Response VO */
  28. export interface TradeOrderCountRespVO {
  29. /** 待发货 */
  30. undelivered?: number
  31. /** 待核销 */
  32. pickUp?: number
  33. /** 退款中 */
  34. afterSaleApply?: number
  35. /** 提现待审核 */
  36. auditingWithdraw?: number
  37. }
  38. /** 交易订单统计 Response VO */
  39. export interface TradeOrderSummaryRespVO {
  40. /** 支付订单商品数 */
  41. orderPayCount?: number
  42. /** 总支付金额,单位:分 */
  43. orderPayPrice?: number
  44. }
  45. /** 订单量趋势统计 Response VO */
  46. export interface TradeOrderTrendRespVO {
  47. /** 日期 */
  48. date: string
  49. /** 订单数量 */
  50. orderPayCount: number
  51. /** 订单支付金额 */
  52. orderPayPrice: number
  53. }
  54. // 查询交易统计
  55. export const getTradeStatisticsSummary = () => {
  56. return request.get<DataComparisonRespVO<TradeSummaryRespVO>>({
  57. url: '/statistics/trade/summary'
  58. })
  59. }
  60. // 获得交易状况统计
  61. export const getTradeTrendSummary = (params: TradeTrendReqVO) => {
  62. return request.get<DataComparisonRespVO<TradeTrendSummaryRespVO>>({
  63. url: '/statistics/trade/trend/summary',
  64. params: formatDateParam(params)
  65. })
  66. }
  67. // 获得交易状况明细
  68. export const getTradeStatisticsList = (params: TradeTrendReqVO) => {
  69. return request.get<TradeTrendSummaryRespVO[]>({
  70. url: '/statistics/trade/list',
  71. params: formatDateParam(params)
  72. })
  73. }
  74. // 导出交易状况明细
  75. export const exportTradeStatisticsExcel = (params: TradeTrendReqVO) => {
  76. return request.download({
  77. url: '/statistics/trade/export-excel',
  78. params: formatDateParam(params)
  79. })
  80. }
  81. // 获得交易订单数量
  82. export const getOrderCount = async () => {
  83. return await request.get<TradeOrderCountRespVO>({ url: `/statistics/trade/order-count` })
  84. }
  85. // 获得交易订单数量对照
  86. export const getOrderComparison = async () => {
  87. return await request.get<DataComparisonRespVO<TradeOrderSummaryRespVO>>({
  88. url: `/statistics/trade/order-comparison`
  89. })
  90. }
  91. // 获得订单量趋势统计
  92. export const getOrderCountTrendComparison = (
  93. type: number,
  94. beginTime: dayjs.ConfigType,
  95. endTime: dayjs.ConfigType
  96. ) => {
  97. return request.get<DataComparisonRespVO<TradeOrderTrendRespVO>[]>({
  98. url: '/statistics/trade/order-count-trend',
  99. params: { type, beginTime: formatDate(beginTime), endTime: formatDate(endTime) }
  100. })
  101. }
  102. /** 时间参数需要格式化, 确保接口能识别 */
  103. const formatDateParam = (params: TradeTrendReqVO) => {
  104. return { times: [formatDate(params.times[0]), formatDate(params.times[1])] } as TradeTrendReqVO
  105. }