From 00523bae4c48b694457fbe545dd34296bb6381fd Mon Sep 17 00:00:00 2001 From: 18278715334 <18278715334@163.com> Date: Mon, 29 Dec 2025 16:13:31 +0800 Subject: [PATCH] fix and add --- apps/web-antd/src/api/agent/agent.ts | 28 ++- .../src/api/order/order-statistics.ts | 28 +++ apps/web-antd/src/api/order/order.ts | 15 +- .../analytics/analytics-visits-source.vue | 128 ++++++----- .../dashboard/analytics/analytics-visits.vue | 210 +++++++++++++----- .../src/views/dashboard/analytics/index.vue | 46 ++-- .../dashboard/analysis/analysis-overview.vue | 26 ++- .../common-ui/src/ui/dashboard/typing.ts | 4 + 8 files changed, 353 insertions(+), 132 deletions(-) create mode 100644 apps/web-antd/src/api/order/order-statistics.ts diff --git a/apps/web-antd/src/api/agent/agent.ts b/apps/web-antd/src/api/agent/agent.ts index 199a98c..ac17fad 100644 --- a/apps/web-antd/src/api/agent/agent.ts +++ b/apps/web-antd/src/api/agent/agent.ts @@ -134,14 +134,14 @@ export namespace AgentApi { agent_id?: number; status?: number; withdraw_no?: string; - status?: number; - withdraw_no?: string; } // 提现统计数据 export interface WithdrawalStatistics { total_withdrawal_amount: number; today_withdrawal_amount: number; + total_actual_amount: number; + total_tax_amount: number; } // 代理订单统计数据 @@ -156,6 +156,20 @@ export interface AgentStatistics { today_agent_count: number; // 今日新增代理数 } +// 代理链接产品统计项 +export interface AgentLinkProductStatisticsItem { + product_name: string; + link_count: number; +} + +// 代理链接产品统计响应 +export interface AgentLinkProductStatisticsResp { + items: AgentLinkProductStatisticsItem[]; +} + +// 代理链接产品统计请求参数 +export interface GetAgentLinkProductStatisticsParams {} + // 代理上级抽佣相关接口 export interface AgentCommissionDeductionListItem { id: number; @@ -517,10 +531,20 @@ async function getAgentStatistics() { ); } +/** + * 获取代理链接产品统计数据 + */ +async function getAgentLinkProductStatistics() { + return requestClient.get( + '/agent/agent-link/product-statistics', + ); +} + export { getAgentCommissionDeductionList, getAgentCommissionList, getAgentLinkList, + getAgentLinkProductStatistics, getAgentList, getAgentMembershipConfigList, getAgentOrderStatistics, diff --git a/apps/web-antd/src/api/order/order-statistics.ts b/apps/web-antd/src/api/order/order-statistics.ts new file mode 100644 index 0000000..11814de --- /dev/null +++ b/apps/web-antd/src/api/order/order-statistics.ts @@ -0,0 +1,28 @@ +import { requestClient } from '#/api/request'; + +export namespace OrderStatisticsApi { + // 订单统计数据项 + export interface OrderStatisticsItem { + date: string; // 日期 + count: number; // 订单数量 + amount: number; // 订单金额 + } + + // 订单统计响应 + export interface OrderStatisticsResponse { + items: OrderStatisticsItem[]; + } + + // 时间维度类型 + export type TimeDimension = 'day' | 'month' | 'year' | 'all'; +} + +/** + * 获取订单统计数据 + * @param dimension 时间维度:day-日(当月1号到今天),month-月(今年1月到当月),year-年(过去5年),all-全部(按日统计) + */ +export function getOrderStatistics(dimension: OrderStatisticsApi.TimeDimension) { + return requestClient.get('/order/statistics', { + params: { dimension } + }); +} diff --git a/apps/web-antd/src/api/order/order.ts b/apps/web-antd/src/api/order/order.ts index 1457626..086817d 100644 --- a/apps/web-antd/src/api/order/order.ts +++ b/apps/web-antd/src/api/order/order.ts @@ -49,6 +49,12 @@ export namespace OrderApi { total_profit_amount: number; today_profit_amount: number; } + + // 订单来源统计数据 + export interface OrderSourceStatistics { + product_name: string; + order_count: number; + } } /** @@ -86,4 +92,11 @@ async function getIncomeStatistics() { return requestClient.get('/order/revenue-statistics'); } -export { getOrderList, refundOrder, getRefundStatistics, getIncomeStatistics }; +/** + * 获取订单来源统计数据 + */ +async function getOrderSourceStatistics() { + return requestClient.get<{ items: OrderApi.OrderSourceStatistics[] }>('/order/source-statistics'); +} + +export { getOrderList, refundOrder, getRefundStatistics, getIncomeStatistics, getOrderSourceStatistics }; diff --git a/apps/web-antd/src/views/dashboard/analytics/analytics-visits-source.vue b/apps/web-antd/src/views/dashboard/analytics/analytics-visits-source.vue index 0269ec7..6ca9a67 100644 --- a/apps/web-antd/src/views/dashboard/analytics/analytics-visits-source.vue +++ b/apps/web-antd/src/views/dashboard/analytics/analytics-visits-source.vue @@ -4,63 +4,91 @@ import type { EchartsUIType } from '@vben/plugins/echarts'; import { onMounted, ref } from 'vue'; import { EchartsUI, useEcharts } from '@vben/plugins/echarts'; +import { getOrderSourceStatistics } from '#/api/order/order'; const chartRef = ref(); const { renderEcharts } = useEcharts(chartRef); +const loading = ref(false); + +// 获取订单来源统计数据 +async function fetchOrderSourceStatistics() { + try { + loading.value = true; + const response = await getOrderSourceStatistics(); + + // 提取产品名称和订单数量 + const data = response.items.map(item => ({ + name: item.product_name, + value: item.order_count, + })); + + // 如果有数据,则渲染图表 + if (data && data.length > 0) { + renderEcharts({ + legend: { + bottom: '2%', + left: 'center', + data: data.map(item => item.name), + }, + series: [ + { + animationDelay() { + return Math.random() * 100; + }, + animationEasing: 'exponentialInOut', + animationType: 'scale', + avoidLabelOverlap: false, + color: [ + '#5ab1ef', '#b6a2de', '#67e0e3', '#2ec7c9', + '#ffb980', '#d87a80', '#8d98b3', '#e5cf0d', + '#97b552', '#95706d', '#dc69aa', '#07a2a4', + '#9a7fd1', '#588dd5', '#f5994e', '#c05050' + ], + data: data, + emphasis: { + label: { + fontSize: '12', + fontWeight: 'bold', + show: true, + }, + }, + itemStyle: { + borderRadius: 10, + borderWidth: 2, + }, + label: { + position: 'center', + show: false, + }, + labelLine: { + show: false, + }, + name: '订单来源', + radius: ['40%', '65%'], + type: 'pie', + }, + ], + tooltip: { + trigger: 'item', + formatter: '{b}: {c} ({d}%)', + }, + }); + } + } catch (error) { + console.error('获取订单来源统计数据失败:', error); + } finally { + loading.value = false; + } +} onMounted(() => { - renderEcharts({ - legend: { - bottom: '2%', - left: 'center', - data: ['产品A', '产品B', '产品C', '产品D'], - }, - series: [ - { - animationDelay() { - return Math.random() * 100; - }, - animationEasing: 'exponentialInOut', - animationType: 'scale', - avoidLabelOverlap: false, - color: ['#5ab1ef', '#b6a2de', '#67e0e3', '#2ec7c9'], - data: [ - { name: '产品A', value: 1048 }, - { name: '产品B', value: 735 }, - { name: '产品C', value: 580 }, - { name: '产品D', value: 484 }, - ], - emphasis: { - label: { - fontSize: '12', - fontWeight: 'bold', - show: true, - }, - }, - itemStyle: { - // borderColor: '#fff', - borderRadius: 10, - borderWidth: 2, - }, - label: { - position: 'center', - show: false, - }, - labelLine: { - show: false, - }, - name: '订单来源', - radius: ['40%', '65%'], - type: 'pie', - }, - ], - tooltip: { - trigger: 'item', - }, - }); + fetchOrderSourceStatistics(); }); diff --git a/apps/web-antd/src/views/dashboard/analytics/analytics-visits.vue b/apps/web-antd/src/views/dashboard/analytics/analytics-visits.vue index 6c90219..796868c 100644 --- a/apps/web-antd/src/views/dashboard/analytics/analytics-visits.vue +++ b/apps/web-antd/src/views/dashboard/analytics/analytics-visits.vue @@ -1,59 +1,59 @@ +
+
+ + + + +
+ +
+ \ No newline at end of file diff --git a/apps/web-antd/src/views/dashboard/analytics/index.vue b/apps/web-antd/src/views/dashboard/analytics/index.vue index c834843..bddfb24 100644 --- a/apps/web-antd/src/views/dashboard/analytics/index.vue +++ b/apps/web-antd/src/views/dashboard/analytics/index.vue @@ -22,7 +22,7 @@ import AnalyticsVisitsSales from './analytics-visits-sales.vue'; import AnalyticsVisitsSource from './analytics-visits-source.vue'; import AnalyticsVisits from './analytics-visits.vue'; -import { getAgentList, getAgentStatistics, getWithdrawalStatistics, getAgentOrderStatistics } from '#/api/agent'; +import { getAgentStatistics, getWithdrawalStatistics, getAgentOrderStatistics } from '#/api/agent'; import { getOrderList, getRefundStatistics, getIncomeStatistics } from '#/api/order/order'; import { getPlatformUserList } from '#/api/platform-user'; @@ -63,26 +63,30 @@ const overviewItems = ref([ }, { icon: SvgBellIcon, - title: '总提现金额', - value: 0, - todaytitle: '今日新增提现金额', - todayValue: 0, - Subtitle: '总退款金额', - SubValue: 0, - todaySubtitle: '今日新增退款金额', - todaySubValue: 0, + title: '总提现金额', + value: 0, + SubValue: 0, + todaySubtitle: '总实际到账金额', + todaySubValue: 0, + extraTitle: '总扣税金额', + extraValue: 0, + todaytitle: '今日新增提现金额', + todayValue: 0, + Subtitle: '总退款金额', + extra2Title: '今日新增退款金额', + extra2Value: 0, }, ]); const chartTabs: TabOption[] = [ - { - label: '推广访问趋势', - value: 'trends', - }, { label: '订单趋势', value: 'visits', }, + { + label: '推广访问趋势', + value: 'trends', + }, ]; // 获取统计数据 @@ -138,6 +142,8 @@ async function fetchStatistics() { const withdrawalStatsResponse = await getWithdrawalStatistics(); const totalWithdrawalAmount = withdrawalStatsResponse.total_withdrawal_amount || 0; const todayWithdrawalAmount = withdrawalStatsResponse.today_withdrawal_amount || 0; + const totalActualAmount = withdrawalStatsResponse.total_actual_amount || 0; + const totalTaxAmount = withdrawalStatsResponse.total_tax_amount || 0; // 获取退款统计数据 const refundStatsResponse = await getRefundStatistics(); @@ -192,10 +198,14 @@ async function fetchStatistics() { value: totalWithdrawalAmount, todaytitle: '今日新增提现金额', todayValue: todayWithdrawalAmount, + extra2Title: '今日新增退款金额', + extra2Value: todayRefundAmount, Subtitle: '总退款金额', SubValue: totalRefundAmount, - todaySubtitle: '今日新增退款金额', - todaySubValue: todayRefundAmount, + todaySubtitle: '总实际到账金额', + todaySubValue: totalActualAmount, + extraTitle: '总扣税金额', + extraValue: totalTaxAmount, }, ]; } catch (error) { @@ -213,12 +223,12 @@ onMounted(() => {
- +
diff --git a/packages/effects/common-ui/src/ui/dashboard/analysis/analysis-overview.vue b/packages/effects/common-ui/src/ui/dashboard/analysis/analysis-overview.vue index 8878a0f..510497c 100644 --- a/packages/effects/common-ui/src/ui/dashboard/analysis/analysis-overview.vue +++ b/packages/effects/common-ui/src/ui/dashboard/analysis/analysis-overview.vue @@ -28,13 +28,13 @@ withDefaults(defineProps(), { - {{ item.title }} + {{ item.title }}
- +

{{ item.todaytitle }} @@ -50,11 +50,23 @@ withDefaults(defineProps(), {

- {{ item.todaySubtitle }} - - + - -

+ {{ item.todaySubtitle }} + + + + +

+

+ {{ item.extraTitle }} + + + +

+

+ {{ item.extra2Title }} + + + + +

diff --git a/packages/effects/common-ui/src/ui/dashboard/typing.ts b/packages/effects/common-ui/src/ui/dashboard/typing.ts index 6bcd865..b5d4e70 100644 --- a/packages/effects/common-ui/src/ui/dashboard/typing.ts +++ b/packages/effects/common-ui/src/ui/dashboard/typing.ts @@ -10,6 +10,10 @@ interface AnalysisOverviewItem { SubValue: number; todaySubtitle: string; todaySubValue: number; + extraTitle?: string; + extraValue?: number; + extra2Title?: string; + extra2Value?: number; } interface WorkbenchProjectItem {