trade.ts 1.9 KB

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