From 9b4bb4025bccae63c3f124f440499005c74e1b94 Mon Sep 17 00:00:00 2001 From: owen Date: Fri, 29 Sep 2023 21:08:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=EF=BC=9A=E4=BA=A4=E6=98=93?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit c322fb3d0d6624907fca85a2454a10e7bcc87083) --- src/api/statistics/trade.ts | 70 +++ src/components/CountTo/src/CountTo.vue | 22 +- src/utils/formatTime.ts | 67 ++- .../trade/components/TradeStatisticValue.vue | 41 ++ .../trade/components/TradeTrendValue.vue | 54 +++ src/views/statistics/trade/index.vue | 428 ++++++++++++++++++ 6 files changed, 670 insertions(+), 12 deletions(-) create mode 100644 src/api/statistics/trade.ts create mode 100644 src/views/statistics/trade/components/TradeStatisticValue.vue create mode 100644 src/views/statistics/trade/components/TradeTrendValue.vue create mode 100644 src/views/statistics/trade/index.vue diff --git a/src/api/statistics/trade.ts b/src/api/statistics/trade.ts new file mode 100644 index 00000000..f7829ccb --- /dev/null +++ b/src/api/statistics/trade.ts @@ -0,0 +1,70 @@ +import request from '@/config/axios' +import dayjs from 'dayjs' +import { formatDate } from '@/utils/formatTime' + +/** 交易统计对照 Response VO */ +export interface TradeStatisticsComparisonRespVO { + value: T + reference: T +} + +/** 交易统计 Response VO */ +export interface TradeSummaryRespVO { + yesterdayOrderCount: number + monthOrderCount: number + yesterdayPayPrice: number + monthPayPrice: number +} + +/** 交易状况 Request VO */ +export interface TradeTrendReqVO { + times: [dayjs.ConfigType, dayjs.ConfigType] +} + +/** 交易状况统计 Response VO */ +export interface TradeTrendSummaryRespVO { + time: string + turnover: number + orderPayPrice: number + rechargePrice: number + expensePrice: number + balancePrice: number + brokerageSettlementPrice: number + orderRefundPrice: number +} + +// 查询交易统计 +export const getTradeStatisticsSummary = () => { + return request.get>({ + url: '/statistics/trade/summary' + }) +} + +// 获得交易状况统计 +export const getTradeTrendSummary = (params: TradeTrendReqVO) => { + return request.get>({ + url: '/statistics/trade/trend/summary', + params: formatDateParam(params) + }) +} + +// 获得交易状况明细 +export const getTradeTrendList = (params: TradeTrendReqVO) => { + return request.get({ + url: '/statistics/trade/trend/list', + params: formatDateParam(params) + }) +} + +// 导出交易状况明细 +export const exportTradeTrend = (params: TradeTrendReqVO) => { + return request.download({ + url: '/statistics/trade/trend/export-excel', + params: formatDateParam(params) + }) +} + +/** 时间参数需要格式化, 确保接口能识别 */ +const formatDateParam = (params: TradeTrendReqVO) => { + return { times: [formatDate(params.times[0]), formatDate(params.times[1])] } as TradeTrendReqVO +} diff --git a/src/components/CountTo/src/CountTo.vue b/src/components/CountTo/src/CountTo.vue index 1b1131a0..7a19bec7 100644 --- a/src/components/CountTo/src/CountTo.vue +++ b/src/components/CountTo/src/CountTo.vue @@ -11,21 +11,21 @@ const { getPrefixCls } = useDesign() const prefixCls = getPrefixCls('count-to') const props = defineProps({ - startVal: propTypes.number.def(0), - endVal: propTypes.number.def(2021), - duration: propTypes.number.def(3000), - autoplay: propTypes.bool.def(true), - decimals: propTypes.number.validate((value: number) => value >= 0).def(0), - decimal: propTypes.string.def('.'), - separator: propTypes.string.def(','), - prefix: propTypes.string.def(''), - suffix: propTypes.string.def(''), - useEasing: propTypes.bool.def(true), + startVal: propTypes.number.def(0), // 开始播放值 + endVal: propTypes.number.def(2021), // 最终值 + duration: propTypes.number.def(3000), // 动画时长 + autoplay: propTypes.bool.def(true), // 是否自动播放动画, 默认播放 + decimals: propTypes.number.validate((value: number) => value >= 0).def(0), // 显示的小数位数, 默认不显示小数 + decimal: propTypes.string.def('.'), // 小数分隔符号, 默认为点 + separator: propTypes.string.def(','), // 数字每三位的分隔符, 默认为逗号 + prefix: propTypes.string.def(''), // 前缀, 数值前面显示的内容 + suffix: propTypes.string.def(''), // 后缀, 数值后面显示的内容 + useEasing: propTypes.bool.def(true), // 是否使用缓动效果, 默认启用 easingFn: { type: Function as PropType<(t: number, b: number, c: number, d: number) => number>, default(t: number, b: number, c: number, d: number) { return (c * (-Math.pow(2, (-10 * t) / d) + 1) * 1024) / 1023 + b - } + } // 缓动函数 } }) diff --git a/src/utils/formatTime.ts b/src/utils/formatTime.ts index e3baab7b..8d3ad236 100644 --- a/src/utils/formatTime.ts +++ b/src/utils/formatTime.ts @@ -11,7 +11,7 @@ import dayjs from 'dayjs' * @description format 季度 + 星期 + 几周:"YYYY-mm-dd HH:MM:SS WWW QQQQ ZZZ" * @returns 返回拼接后的时间字符串 */ -export function formatDate(date: Date | number, format?: string): string { +export function formatDate(date: dayjs.ConfigType, format?: string): string { // 日期不存在,则返回空 if (!date) { return '' @@ -268,3 +268,68 @@ export function convertDate(param: Date | string) { } return param } + +/** + * 指定的两个日期, 是否为同一天 + * @param a 日期 A + * @param b 日期 B + */ +export function isSameDay(a: dayjs.ConfigType, b: dayjs.ConfigType): boolean { + if (!a || !b) return false + + const aa = dayjs(a) + const bb = dayjs(b) + return aa.year() == bb.year() && aa.month() == bb.month() && aa.day() == bb.day() +} + +/** + * 获取一天的开始时间、截止时间 + * @param date 日期 + * @param days 天数 + */ +export function getDayRange( + date: dayjs.ConfigType, + days: number +): [dayjs.ConfigType, dayjs.ConfigType] { + const day = dayjs(date).add(days, 'd') + return getDateRange(day, day) +} + +/** + * 获取最近7天的开始时间、截止时间 + */ +export function getLast7Days(): [dayjs.ConfigType, dayjs.ConfigType] { + const lastWeekDay = dayjs().subtract(7, 'd') + const yesterday = dayjs().subtract(1, 'd') + return getDateRange(lastWeekDay, yesterday) +} + +/** + * 获取最近30天的开始时间、截止时间 + */ +export function getLast30Days(): [dayjs.ConfigType, dayjs.ConfigType] { + const lastMonthDay = dayjs().subtract(30, 'd') + const yesterday = dayjs().subtract(1, 'd') + return getDateRange(lastMonthDay, yesterday) +} + +/** + * 获取最近1年的开始时间、截止时间 + */ +export function getLast1Year(): [dayjs.ConfigType, dayjs.ConfigType] { + const lastYearDay = dayjs().subtract(1, 'y') + const yesterday = dayjs().subtract(1, 'd') + return getDateRange(lastYearDay, yesterday) +} + +/** + * 获取指定日期的开始时间、截止时间 + * @param beginDate 开始日期 + * @param endDate 截止日期 + */ +export function getDateRange( + beginDate: dayjs.ConfigType, + endDate: dayjs.ConfigType +): [dayjs.ConfigType, dayjs.ConfigType] { + return [dayjs(beginDate).startOf('d'), dayjs(endDate).endOf('d')] +} diff --git a/src/views/statistics/trade/components/TradeStatisticValue.vue b/src/views/statistics/trade/components/TradeStatisticValue.vue new file mode 100644 index 00000000..475810ee --- /dev/null +++ b/src/views/statistics/trade/components/TradeStatisticValue.vue @@ -0,0 +1,41 @@ + + + diff --git a/src/views/statistics/trade/components/TradeTrendValue.vue b/src/views/statistics/trade/components/TradeTrendValue.vue new file mode 100644 index 00000000..e1e2e4fe --- /dev/null +++ b/src/views/statistics/trade/components/TradeTrendValue.vue @@ -0,0 +1,54 @@ + + + diff --git a/src/views/statistics/trade/index.vue b/src/views/statistics/trade/index.vue new file mode 100644 index 00000000..c6af0f5f --- /dev/null +++ b/src/views/statistics/trade/index.vue @@ -0,0 +1,428 @@ + + +