From cf581f3bb3d3cc38ac5c9f7559ddd4b10c4f119c Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 20 Nov 2025 11:05:51 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E3=80=90antd/ele=E3=80=91?= =?UTF-8?q?=E3=80=90mall/stat=E3=80=91=E4=BC=98=E5=8C=96=20api=20=E7=9A=84?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web-antd/src/api/mall/statistics/trade.ts | 68 ++++++--------- .../src/views/mall/statistics/trade/index.vue | 2 +- .../statistics/trade/modules/trend-card.vue | 2 +- .../trade/modules/trend-chart-options.ts | 2 +- apps/web-ele/src/api/mall/statistics/trade.ts | 82 +++++++------------ .../src/views/mall/statistics/trade/index.vue | 2 +- .../statistics/trade/modules/trend-card.vue | 2 +- .../trade/modules/trend-chart-options.ts | 2 +- 8 files changed, 63 insertions(+), 99 deletions(-) diff --git a/apps/web-antd/src/api/mall/statistics/trade.ts b/apps/web-antd/src/api/mall/statistics/trade.ts index 17b20e709..05dc7f3ef 100644 --- a/apps/web-antd/src/api/mall/statistics/trade.ts +++ b/apps/web-antd/src/api/mall/statistics/trade.ts @@ -1,25 +1,25 @@ import type { DataComparisonRespVO } from './common'; -import { formatDate, formatDateTime } from '@vben/utils'; +import { formatDateTime } from '@vben/utils'; import { requestClient } from '#/api/request'; export namespace MallTradeStatisticsApi { + /** 交易状况 Request */ + export interface TradeTrendReqVO { + times: [Date, Date]; + } + /** 交易统计 Response */ - export interface TradeSummary { + export interface TradeSummaryRespVO { yesterdayOrderCount: number; monthOrderCount: number; yesterdayPayPrice: number; monthPayPrice: number; } - /** 交易状况 Request */ - export interface TradeTrendReq { - times: [Date, Date]; - } - /** 交易状况统计 Response */ - export interface TradeTrendSummary { + export interface TradeTrendSummaryRespVO { time: string; turnoverPrice: number; orderPayPrice: number; @@ -31,60 +31,46 @@ export namespace MallTradeStatisticsApi { } /** 交易订单数量 Response */ - export interface TradeOrderCount { - /** 待发货 */ - undelivered?: number; - /** 待核销 */ - pickUp?: number; - /** 退款中 */ - afterSaleApply?: number; - /** 提现待审核 */ - auditingWithdraw?: number; + export interface TradeOrderCountRespVO { + undelivered?: number; // 待发货 + pickUp?: number; // 待核销 + afterSaleApply?: number; // 退款中 + auditingWithdraw?: number; // 提现待审核 } /** 交易订单统计 Response */ export interface TradeOrderSummaryRespVO { - /** 支付订单商品数 */ - orderPayCount?: number; - /** 总支付金额,单位:分 */ - orderPayPrice?: number; + orderPayCount?: number; // 支付订单商品数 + orderPayPrice?: number; // 总支付金额,单位:分 } /** 订单量趋势统计 Response */ - export interface TradeOrderTrend { - /** 日期 */ - date: string; - /** 订单数量 */ - orderPayCount: number; - /** 订单支付金额 */ - orderPayPrice: number; + export interface TradeOrderTrendRespVO { + date: string; // 日期 + orderPayCount: number; // 订单数量 + orderPayPrice: number; // 订单支付金额 } } -/** 时间参数需要格式化, 确保接口能识别 */ -const formatDateParam = (params: MallTradeStatisticsApi.TradeTrendReq) => { - return { - times: [formatDate(params.times[0]), formatDate(params.times[1])], - } as MallTradeStatisticsApi.TradeTrendReq; -}; - /** 查询交易统计 */ export function getTradeStatisticsSummary() { return requestClient.get< - DataComparisonRespVO + DataComparisonRespVO >('/statistics/trade/summary'); } /** 获得交易状况统计 */ -export function getTradeStatisticsAnalyse(params: any) { +export function getTradeStatisticsAnalyse( + params: MallTradeStatisticsApi.TradeTrendReqVO, +) { return requestClient.get< - DataComparisonRespVO + DataComparisonRespVO >('/statistics/trade/analyse', { params }); } /** 获得交易状况明细 */ export function getTradeStatisticsList(params: any) { - return requestClient.get( + return requestClient.get( '/statistics/trade/list', { params }, ); @@ -97,7 +83,7 @@ export function exportTradeStatisticsExcel(params: any) { /** 获得交易订单数量 */ export function getOrderCount() { - return requestClient.get( + return requestClient.get( '/statistics/trade/order-count', ); } @@ -116,7 +102,7 @@ export function getOrderCountTrendComparison( endTime: Date, ) { return requestClient.get< - DataComparisonRespVO[] + DataComparisonRespVO[] >('/statistics/trade/order-count-trend', { params: { type, diff --git a/apps/web-antd/src/views/mall/statistics/trade/index.vue b/apps/web-antd/src/views/mall/statistics/trade/index.vue index 6e87786f9..09fb18be0 100644 --- a/apps/web-antd/src/views/mall/statistics/trade/index.vue +++ b/apps/web-antd/src/views/mall/statistics/trade/index.vue @@ -18,7 +18,7 @@ defineOptions({ name: 'TradeStatistics' }); const loading = ref(true); // 加载中 const summary = - ref>(); // 交易统计数据 + ref>(); // 交易统计数据 /** 计算环比百分比 */ function calculateRelativeRate(value?: number, reference?: number): string { diff --git a/apps/web-antd/src/views/mall/statistics/trade/modules/trend-card.vue b/apps/web-antd/src/views/mall/statistics/trade/modules/trend-card.vue index 1dd4fc24b..3d300dfca 100644 --- a/apps/web-antd/src/views/mall/statistics/trade/modules/trend-card.vue +++ b/apps/web-antd/src/views/mall/statistics/trade/modules/trend-card.vue @@ -37,7 +37,7 @@ defineOptions({ name: 'TradeTrendCard' }); const trendLoading = ref(true); // 交易状态加载中 const exportLoading = ref(false); // 导出的加载中 const trendSummary = - ref>(); // 交易状况统计数据 + ref>(); // 交易状况统计数据 const searchTimes = ref([]); const chartRef = ref(); diff --git a/apps/web-antd/src/views/mall/statistics/trade/modules/trend-chart-options.ts b/apps/web-antd/src/views/mall/statistics/trade/modules/trend-chart-options.ts index 5c85460fb..899a6a32a 100644 --- a/apps/web-antd/src/views/mall/statistics/trade/modules/trend-chart-options.ts +++ b/apps/web-antd/src/views/mall/statistics/trade/modules/trend-chart-options.ts @@ -4,7 +4,7 @@ import { fenToYuan } from '@vben/utils'; /** 交易趋势折线图配置 */ export function getTradeTrendChartOptions( - data: MallTradeStatisticsApi.TradeTrendSummary[], + data: MallTradeStatisticsApi.TradeTrendSummaryRespVO[], ): any { // 处理数据:将分转换为元 const processedData = data.map((item) => ({ diff --git a/apps/web-ele/src/api/mall/statistics/trade.ts b/apps/web-ele/src/api/mall/statistics/trade.ts index 3f8d1cb82..05dc7f3ef 100644 --- a/apps/web-ele/src/api/mall/statistics/trade.ts +++ b/apps/web-ele/src/api/mall/statistics/trade.ts @@ -1,25 +1,25 @@ import type { DataComparisonRespVO } from './common'; -import { formatDate, formatDateTime } from '@vben/utils'; +import { formatDateTime } from '@vben/utils'; import { requestClient } from '#/api/request'; export namespace MallTradeStatisticsApi { + /** 交易状况 Request */ + export interface TradeTrendReqVO { + times: [Date, Date]; + } + /** 交易统计 Response */ - export interface TradeSummary { + export interface TradeSummaryRespVO { yesterdayOrderCount: number; monthOrderCount: number; yesterdayPayPrice: number; monthPayPrice: number; } - /** 交易状况 Request */ - export interface TradeTrendReq { - times: [Date, Date]; - } - /** 交易状况统计 Response */ - export interface TradeTrendSummary { + export interface TradeTrendSummaryRespVO { time: string; turnoverPrice: number; orderPayPrice: number; @@ -31,81 +31,59 @@ export namespace MallTradeStatisticsApi { } /** 交易订单数量 Response */ - export interface TradeOrderCount { - /** 待发货 */ - undelivered?: number; - /** 待核销 */ - pickUp?: number; - /** 退款中 */ - afterSaleApply?: number; - /** 提现待审核 */ - auditingWithdraw?: number; + export interface TradeOrderCountRespVO { + undelivered?: number; // 待发货 + pickUp?: number; // 待核销 + afterSaleApply?: number; // 退款中 + auditingWithdraw?: number; // 提现待审核 } /** 交易订单统计 Response */ export interface TradeOrderSummaryRespVO { - /** 支付订单商品数 */ - orderPayCount?: number; - /** 总支付金额,单位:分 */ - orderPayPrice?: number; + orderPayCount?: number; // 支付订单商品数 + orderPayPrice?: number; // 总支付金额,单位:分 } /** 订单量趋势统计 Response */ - export interface TradeOrderTrend { - /** 日期 */ - date: string; - /** 订单数量 */ - orderPayCount: number; - /** 订单支付金额 */ - orderPayPrice: number; + export interface TradeOrderTrendRespVO { + date: string; // 日期 + orderPayCount: number; // 订单数量 + orderPayPrice: number; // 订单支付金额 } } -/** 时间参数需要格式化, 确保接口能识别 */ -const formatDateParam = (params: MallTradeStatisticsApi.TradeTrendReq) => { - return { - times: [formatDate(params.times[0]), formatDate(params.times[1])], - } as MallTradeStatisticsApi.TradeTrendReq; -}; - /** 查询交易统计 */ export function getTradeStatisticsSummary() { return requestClient.get< - DataComparisonRespVO + DataComparisonRespVO >('/statistics/trade/summary'); } /** 获得交易状况统计 */ export function getTradeStatisticsAnalyse( - params: MallTradeStatisticsApi.TradeTrendReq, + params: MallTradeStatisticsApi.TradeTrendReqVO, ) { return requestClient.get< - DataComparisonRespVO - >('/statistics/trade/analyse', { params: formatDateParam(params) }); + DataComparisonRespVO + >('/statistics/trade/analyse', { params }); } /** 获得交易状况明细 */ -export function getTradeStatisticsList( - params: MallTradeStatisticsApi.TradeTrendReq, -) { - return requestClient.get( +export function getTradeStatisticsList(params: any) { + return requestClient.get( '/statistics/trade/list', - { params: formatDateParam(params) }, + { params }, ); } /** 导出交易状况明细 */ -export function exportTradeStatisticsExcel( - params: MallTradeStatisticsApi.TradeTrendReq, -) { - return requestClient.download('/statistics/trade/export-excel', { - params: formatDateParam(params), - }); +export function exportTradeStatisticsExcel(params: any) { + return requestClient.download('/statistics/trade/export-excel', { params }); } /** 获得交易订单数量 */ export function getOrderCount() { - return requestClient.get( + return requestClient.get( '/statistics/trade/order-count', ); } @@ -124,7 +102,7 @@ export function getOrderCountTrendComparison( endTime: Date, ) { return requestClient.get< - DataComparisonRespVO[] + DataComparisonRespVO[] >('/statistics/trade/order-count-trend', { params: { type, diff --git a/apps/web-ele/src/views/mall/statistics/trade/index.vue b/apps/web-ele/src/views/mall/statistics/trade/index.vue index 334c95b95..0207bde48 100644 --- a/apps/web-ele/src/views/mall/statistics/trade/index.vue +++ b/apps/web-ele/src/views/mall/statistics/trade/index.vue @@ -18,7 +18,7 @@ defineOptions({ name: 'TradeStatistics' }); const loading = ref(true); // 加载中 const summary = - ref>(); // 交易统计数据 + ref>(); // 交易统计数据 /** 计算环比百分比 */ function calculateRelativeRate(value?: number, reference?: number): string { diff --git a/apps/web-ele/src/views/mall/statistics/trade/modules/trend-card.vue b/apps/web-ele/src/views/mall/statistics/trade/modules/trend-card.vue index 9aa2d279a..8dd3f2759 100644 --- a/apps/web-ele/src/views/mall/statistics/trade/modules/trend-card.vue +++ b/apps/web-ele/src/views/mall/statistics/trade/modules/trend-card.vue @@ -37,7 +37,7 @@ defineOptions({ name: 'TradeTrendCard' }); const trendLoading = ref(true); // 交易状态加载中 const exportLoading = ref(false); // 导出的加载中 const trendSummary = - ref>(); // 交易状况统计数据 + ref>(); // 交易状况统计数据 const searchTimes = ref([]); const chartRef = ref(); diff --git a/apps/web-ele/src/views/mall/statistics/trade/modules/trend-chart-options.ts b/apps/web-ele/src/views/mall/statistics/trade/modules/trend-chart-options.ts index 5c85460fb..899a6a32a 100644 --- a/apps/web-ele/src/views/mall/statistics/trade/modules/trend-chart-options.ts +++ b/apps/web-ele/src/views/mall/statistics/trade/modules/trend-chart-options.ts @@ -4,7 +4,7 @@ import { fenToYuan } from '@vben/utils'; /** 交易趋势折线图配置 */ export function getTradeTrendChartOptions( - data: MallTradeStatisticsApi.TradeTrendSummary[], + data: MallTradeStatisticsApi.TradeTrendSummaryRespVO[], ): any { // 处理数据:将分转换为元 const processedData = data.map((item) => ({