trade.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import request from '@/config/axios'
  2. import dayjs from 'dayjs'
  3. import { formatDate } from '@/utils/formatTime'
  4. // todo @疯狂:挪到 mall 里哈
  5. /** 交易统计对照 Response VO */
  6. export interface TradeStatisticsComparisonRespVO<T> {
  7. value: T
  8. reference: T
  9. }
  10. /** 交易统计 Response VO */
  11. export interface TradeSummaryRespVO {
  12. yesterdayOrderCount: number
  13. monthOrderCount: number
  14. yesterdayPayPrice: number
  15. monthPayPrice: number
  16. }
  17. /** 交易状况 Request VO */
  18. export interface TradeTrendReqVO {
  19. times: [dayjs.ConfigType, dayjs.ConfigType]
  20. }
  21. /** 交易状况统计 Response VO */
  22. export interface TradeTrendSummaryRespVO {
  23. time: string
  24. turnover: number
  25. orderPayPrice: number
  26. rechargePrice: number
  27. expensePrice: number
  28. balancePrice: number
  29. brokerageSettlementPrice: number
  30. orderRefundPrice: number
  31. }
  32. // 查询交易统计
  33. export const getTradeStatisticsSummary = () => {
  34. return request.get<TradeStatisticsComparisonRespVO<TradeSummaryRespVO>>({
  35. url: '/statistics/trade/summary'
  36. })
  37. }
  38. // 获得交易状况统计
  39. export const getTradeTrendSummary = (params: TradeTrendReqVO) => {
  40. return request.get<TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO>>({
  41. url: '/statistics/trade/trend/summary',
  42. params: formatDateParam(params)
  43. })
  44. }
  45. // 获得交易状况明细
  46. export const getTradeTrendList = (params: TradeTrendReqVO) => {
  47. return request.get<TradeTrendSummaryRespVO[]>({
  48. url: '/statistics/trade/trend/list',
  49. params: formatDateParam(params)
  50. })
  51. }
  52. // 导出交易状况明细
  53. export const exportTradeTrend = (params: TradeTrendReqVO) => {
  54. return request.download({
  55. url: '/statistics/trade/trend/export-excel',
  56. params: formatDateParam(params)
  57. })
  58. }
  59. /** 时间参数需要格式化, 确保接口能识别 */
  60. const formatDateParam = (params: TradeTrendReqVO) => {
  61. return { times: [formatDate(params.times[0]), formatDate(params.times[1])] } as TradeTrendReqVO
  62. }