mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 04:29:20 +08:00
feat(store-overview): 全店大盘新增销售额与单量趋势平滑曲线
- CompanyOverviewVO 新增 TrendData / TrendDataItem 结构及 salesAmountTrend / orderCountTrend 字段 - CompanyOverviewServiceImpl 新增按日汇总销售额和单量的趋势计算逻辑 - ShopCharts.vue 重构:左侧替换为趋势平滑曲线(双Y轴),右侧保留店铺销售贡献排行柱状图,移除店铺经营健康度散点图 - 前端类型定义同步更新
This commit is contained in:
+39
@@ -1,9 +1,11 @@
|
|||||||
package top.xyquan.ecomdmbbackend.modules.ecom.overview.model.vo;
|
package top.xyquan.ecomdmbbackend.modules.ecom.overview.model.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,6 +69,18 @@ public class CompanyOverviewVO {
|
|||||||
@Schema(description = "店铺效率象限")
|
@Schema(description = "店铺效率象限")
|
||||||
private List<ShopEfficiencyQuadrant> shopEfficiencyQuadrants;
|
private List<ShopEfficiencyQuadrant> shopEfficiencyQuadrants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 销售额趋势分析
|
||||||
|
*/
|
||||||
|
@Schema(description = "销售额趋势分析")
|
||||||
|
private TrendData salesAmountTrend;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单量趋势分析
|
||||||
|
*/
|
||||||
|
@Schema(description = "单量趋势分析")
|
||||||
|
private TrendData orderCountTrend;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多店铺数据横向汇总(包含合计行和店铺列表)
|
* 多店铺数据横向汇总(包含合计行和店铺列表)
|
||||||
*/
|
*/
|
||||||
@@ -160,6 +174,31 @@ public class CompanyOverviewVO {
|
|||||||
@Schema(description = "销售额目标达成率", example = "83.33")
|
@Schema(description = "销售额目标达成率", example = "83.33")
|
||||||
private BigDecimal salesAmountAchievementRate;
|
private BigDecimal salesAmountAchievementRate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 趋势数据
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "趋势数据")
|
||||||
|
public static class TrendData {
|
||||||
|
@Schema(description = "时间范围的总值")
|
||||||
|
private BigDecimal total;
|
||||||
|
@Schema(description = "每日数据列表")
|
||||||
|
private List<TrendDataItem> dailyDataList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 趋势数据项
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "趋势数据项")
|
||||||
|
public static class TrendDataItem {
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@Schema(description = "日期", example = "2024-01-01")
|
||||||
|
private LocalDate date;
|
||||||
|
@Schema(description = "对应的值")
|
||||||
|
private BigDecimal value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 店铺销售占比
|
* 店铺销售占比
|
||||||
*/
|
*/
|
||||||
|
|||||||
+64
-1
@@ -209,7 +209,13 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
List<CompanyOverviewVO.ShopSalesRatio> shopSalesRatios = calculateShopSalesRatios(shops, orders, totalSalesAmount);
|
List<CompanyOverviewVO.ShopSalesRatio> shopSalesRatios = calculateShopSalesRatios(shops, orders, totalSalesAmount);
|
||||||
overviewVO.setShopSalesRatios(shopSalesRatios);
|
overviewVO.setShopSalesRatios(shopSalesRatios);
|
||||||
|
|
||||||
// 8. 计算店铺效率象限(ROI vs 净利)
|
// 8. 计算销售额与单量趋势
|
||||||
|
CompanyOverviewVO.TrendData salesAmountTrend = calculateSalesAmountTrend(orders, startDate, endDate);
|
||||||
|
CompanyOverviewVO.TrendData orderCountTrend = calculateOrderCountTrend(orders, startDate, endDate);
|
||||||
|
overviewVO.setSalesAmountTrend(salesAmountTrend);
|
||||||
|
overviewVO.setOrderCountTrend(orderCountTrend);
|
||||||
|
|
||||||
|
// 9. 计算店铺效率象限(ROI vs 净利)
|
||||||
List<CompanyOverviewVO.ShopEfficiencyQuadrant> shopEfficiencyQuadrants = calculateShopEfficiencyQuadrants(
|
List<CompanyOverviewVO.ShopEfficiencyQuadrant> shopEfficiencyQuadrants = calculateShopEfficiencyQuadrants(
|
||||||
shops, orders, promotionFees, brushOrders, refundStatusIds);
|
shops, orders, promotionFees, brushOrders, refundStatusIds);
|
||||||
overviewVO.setShopEfficiencyQuadrants(shopEfficiencyQuadrants);
|
overviewVO.setShopEfficiencyQuadrants(shopEfficiencyQuadrants);
|
||||||
@@ -1496,5 +1502,62 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
PlatformPO platform = platformMapper.selectOne(wrapper);
|
PlatformPO platform = platformMapper.selectOne(wrapper);
|
||||||
return platform != null ? platform.getPlatformName() : null;
|
return platform != null ? platform.getPlatformName() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CompanyOverviewVO.TrendData calculateSalesAmountTrend(List<OrderPO> orders, LocalDate startDate, LocalDate endDate) {
|
||||||
|
CompanyOverviewVO.TrendData trendData = new CompanyOverviewVO.TrendData();
|
||||||
|
Map<LocalDate, List<OrderPO>> ordersByDate = orders.stream()
|
||||||
|
.collect(Collectors.groupingBy(order -> order.getOrderTime().toLocalDate()));
|
||||||
|
BigDecimal total = orders.stream()
|
||||||
|
.map(order -> order.getReceivedAmount() != null ? order.getReceivedAmount() : BigDecimal.ZERO)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
trendData.setTotal(total);
|
||||||
|
List<LocalDate> dateList = new ArrayList<>();
|
||||||
|
LocalDate currentDate = startDate;
|
||||||
|
while (!currentDate.isAfter(endDate)) {
|
||||||
|
dateList.add(currentDate);
|
||||||
|
currentDate = currentDate.plusDays(1);
|
||||||
|
}
|
||||||
|
List<CompanyOverviewVO.TrendDataItem> dailyDataList = dateList.stream()
|
||||||
|
.map(date -> {
|
||||||
|
CompanyOverviewVO.TrendDataItem item = new CompanyOverviewVO.TrendDataItem();
|
||||||
|
item.setDate(date);
|
||||||
|
List<OrderPO> dayOrders = ordersByDate.getOrDefault(date, List.of());
|
||||||
|
BigDecimal dayTotal = dayOrders.stream()
|
||||||
|
.map(order -> order.getReceivedAmount() != null ? order.getReceivedAmount() : BigDecimal.ZERO)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
item.setValue(dayTotal);
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
.sorted(Comparator.comparing(CompanyOverviewVO.TrendDataItem::getDate))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
trendData.setDailyDataList(dailyDataList);
|
||||||
|
return trendData;
|
||||||
|
}
|
||||||
|
|
||||||
|
private CompanyOverviewVO.TrendData calculateOrderCountTrend(List<OrderPO> orders, LocalDate startDate, LocalDate endDate) {
|
||||||
|
CompanyOverviewVO.TrendData trendData = new CompanyOverviewVO.TrendData();
|
||||||
|
Map<LocalDate, List<OrderPO>> ordersByDate = orders.stream()
|
||||||
|
.collect(Collectors.groupingBy(order -> order.getOrderTime().toLocalDate()));
|
||||||
|
int total = orders.size();
|
||||||
|
trendData.setTotal(new BigDecimal(total));
|
||||||
|
List<LocalDate> dateList = new ArrayList<>();
|
||||||
|
LocalDate currentDate = startDate;
|
||||||
|
while (!currentDate.isAfter(endDate)) {
|
||||||
|
dateList.add(currentDate);
|
||||||
|
currentDate = currentDate.plusDays(1);
|
||||||
|
}
|
||||||
|
List<CompanyOverviewVO.TrendDataItem> dailyDataList = dateList.stream()
|
||||||
|
.map(date -> {
|
||||||
|
CompanyOverviewVO.TrendDataItem item = new CompanyOverviewVO.TrendDataItem();
|
||||||
|
item.setDate(date);
|
||||||
|
List<OrderPO> dayOrders = ordersByDate.getOrDefault(date, List.of());
|
||||||
|
item.setValue(new BigDecimal(dayOrders.size()));
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
.sorted(Comparator.comparing(CompanyOverviewVO.TrendDataItem::getDate))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
trendData.setDailyDataList(dailyDataList);
|
||||||
|
return trendData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ export namespace CompanyOverviewVO {
|
|||||||
shopSalesRatios?: ShopSalesRatio[];
|
shopSalesRatios?: ShopSalesRatio[];
|
||||||
/** 店铺效率象限(ROI vs 净利) */
|
/** 店铺效率象限(ROI vs 净利) */
|
||||||
shopEfficiencyQuadrants?: ShopEfficiencyQuadrant[];
|
shopEfficiencyQuadrants?: ShopEfficiencyQuadrant[];
|
||||||
|
/** 销售额趋势分析 */
|
||||||
|
salesAmountTrend?: TrendData;
|
||||||
|
/** 单量趋势分析 */
|
||||||
|
orderCountTrend?: TrendData;
|
||||||
/** 多店铺数据横向汇总 */
|
/** 多店铺数据横向汇总 */
|
||||||
shopComparisons?: ShopOverview;
|
shopComparisons?: ShopOverview;
|
||||||
/** 多品类数据横向汇总 */
|
/** 多品类数据横向汇总 */
|
||||||
@@ -43,6 +47,22 @@ export namespace CompanyOverviewVO {
|
|||||||
salesAmountAchievementRate?: number;
|
salesAmountAchievementRate?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 趋势数据 */
|
||||||
|
export interface TrendData {
|
||||||
|
/** 时间范围的总值 */
|
||||||
|
total?: number;
|
||||||
|
/** 每日数据列表 */
|
||||||
|
dailyDataList?: TrendDataItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 趋势数据项 */
|
||||||
|
export interface TrendDataItem {
|
||||||
|
/** 日期 */
|
||||||
|
date: string;
|
||||||
|
/** 对应的值 */
|
||||||
|
value: number;
|
||||||
|
}
|
||||||
|
|
||||||
/** 店铺销售占比 */
|
/** 店铺销售占比 */
|
||||||
export interface ShopSalesRatio {
|
export interface ShopSalesRatio {
|
||||||
/** 店铺ID */
|
/** 店铺ID */
|
||||||
|
|||||||
+110
-152
@@ -5,21 +5,23 @@ import type { CompanyOverviewVO } from '#/api/ecommerce/store-overview';
|
|||||||
|
|
||||||
import { nextTick, onMounted, ref, watch } from 'vue';
|
import { nextTick, onMounted, ref, watch } from 'vue';
|
||||||
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
defineOptions({ name: 'ShopCharts' });
|
defineOptions({ name: 'ShopCharts' });
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
shopSalesRatios?: CompanyOverviewVO.ShopSalesRatio[];
|
shopSalesRatios?: CompanyOverviewVO.ShopSalesRatio[];
|
||||||
shopComparisons?: CompanyOverviewVO.ShopOverview;
|
shopComparisons?: CompanyOverviewVO.ShopOverview;
|
||||||
shopEfficiencyQuadrants?: CompanyOverviewVO.ShopEfficiencyQuadrant[];
|
salesAmountTrend?: CompanyOverviewVO.TrendData;
|
||||||
|
orderCountTrend?: CompanyOverviewVO.TrendData;
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<Props>();
|
const props = defineProps<Props>();
|
||||||
|
|
||||||
const barChartRef = ref<EchartsUIType>();
|
const barChartRef = ref<EchartsUIType>();
|
||||||
const scatterChartRef = ref<EchartsUIType>();
|
const trendChartRef = ref<EchartsUIType>();
|
||||||
const { renderEcharts: renderBarChart } = useEcharts(barChartRef);
|
const { renderEcharts: renderBarChart } = useEcharts(barChartRef);
|
||||||
const { renderEcharts: renderScatterChart } = useEcharts(scatterChartRef);
|
const { renderEcharts: renderTrendChart } = useEcharts(trendChartRef);
|
||||||
|
|
||||||
const formatAmount = (amount: number) => {
|
const formatAmount = (amount: number) => {
|
||||||
return `¥${amount.toLocaleString('zh-CN')}`;
|
return `¥${amount.toLocaleString('zh-CN')}`;
|
||||||
@@ -38,6 +40,8 @@ const renderShopBarChart = () => {
|
|||||||
const shopNames = ratios.map((r) => r.shopName).reverse();
|
const shopNames = ratios.map((r) => r.shopName).reverse();
|
||||||
const salesAmounts = ratios.map((r) => r.salesAmount).reverse();
|
const salesAmounts = ratios.map((r) => r.salesAmount).reverse();
|
||||||
|
|
||||||
|
const isDark = document.documentElement.classList.contains('dark');
|
||||||
|
|
||||||
renderBarChart({
|
renderBarChart({
|
||||||
grid: {
|
grid: {
|
||||||
left: '3%',
|
left: '3%',
|
||||||
@@ -48,6 +52,8 @@ const renderShopBarChart = () => {
|
|||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
trigger: 'axis',
|
trigger: 'axis',
|
||||||
|
backgroundColor: isDark ? 'hsl(222.34deg 10.43% 12.27%)' : '#fff',
|
||||||
|
textStyle: { color: isDark ? 'hsl(0deg 0% 95%)' : '#000' },
|
||||||
formatter: (params: any) => {
|
formatter: (params: any) => {
|
||||||
const param = Array.isArray(params) ? params[0] : params;
|
const param = Array.isArray(params) ? params[0] : params;
|
||||||
const index = param.dataIndex;
|
const index = param.dataIndex;
|
||||||
@@ -68,7 +74,7 @@ const renderShopBarChart = () => {
|
|||||||
axisTick: { show: false },
|
axisTick: { show: false },
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
color: 'hsl(240deg 5% 64.9%)',
|
color: isDark ? 'hsl(240deg 5% 64.9%)' : '#64748b',
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -97,50 +103,29 @@ const renderShopBarChart = () => {
|
|||||||
formatter: (params: any) =>
|
formatter: (params: any) =>
|
||||||
`¥${params.value.toLocaleString('zh-CN')}`,
|
`¥${params.value.toLocaleString('zh-CN')}`,
|
||||||
fontWeight: 900,
|
fontWeight: 900,
|
||||||
color:
|
color: isDark ? 'hsl(0deg 0% 95%)' : '#334155',
|
||||||
document.documentElement.classList.contains('dark')
|
|
||||||
? 'hsl(0deg 0% 95%)'
|
|
||||||
: '#334155',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 渲染店铺经营健康度分层图(效率 × 结果 × 规模)
|
// 渲染销售额与单量趋势平滑曲线
|
||||||
const renderShopScatterChart = () => {
|
const renderTrendLineChart = () => {
|
||||||
if (!scatterChartRef.value || !props.shopComparisons) return;
|
if (!trendChartRef.value) return;
|
||||||
|
|
||||||
const source = props.shopComparisons?.shops || [];
|
const salesTrend = props.salesAmountTrend;
|
||||||
|
const orderTrend = props.orderCountTrend;
|
||||||
|
|
||||||
const data: Array<[number, number, string, number, number, number, number]> =
|
if (!salesTrend?.dailyDataList?.length && !orderTrend?.dailyDataList?.length) {
|
||||||
source.map((shop) => [
|
const isDark = document.documentElement.classList.contains('dark');
|
||||||
// x: 销售额达成率(%)
|
renderTrendChart({
|
||||||
safeNumber(shop.salesAmountAchievementRate),
|
|
||||||
// y: 税后盈亏(万元)
|
|
||||||
safeNumber(shop.profitAfterTax) / 10_000,
|
|
||||||
// label: 店铺名
|
|
||||||
shop.shopName,
|
|
||||||
// size: 销售额(元)
|
|
||||||
safeNumber(shop.salesAmount),
|
|
||||||
// color metric: 费比(0~1)
|
|
||||||
safeNumber(shop.feeRatio),
|
|
||||||
// tooltip metric: ROI
|
|
||||||
safeNumber(shop.roi),
|
|
||||||
// tooltip metric: 订单达成率
|
|
||||||
safeNumber(shop.orderCountAchievementRate),
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (data.length === 0) {
|
|
||||||
renderScatterChart({
|
|
||||||
title: {
|
title: {
|
||||||
text: '暂无店铺经营数据',
|
text: '暂无趋势数据',
|
||||||
left: 'center',
|
left: 'center',
|
||||||
top: 'middle',
|
top: 'middle',
|
||||||
textStyle: {
|
textStyle: {
|
||||||
color: document.documentElement.classList.contains('dark')
|
color: isDark ? 'hsl(240deg 5% 64.9%)' : '#64748b',
|
||||||
? 'hsl(240deg 5% 64.9%)'
|
|
||||||
: '#64748b',
|
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
},
|
},
|
||||||
@@ -152,101 +137,95 @@ const renderShopScatterChart = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const achieveValues = data.map((item) => item[0]);
|
const dates = (salesTrend?.dailyDataList || orderTrend?.dailyDataList || []).map(
|
||||||
const profitValues = data.map((item) => item[1]);
|
(item) => dayjs(item.date).format('MM-DD'),
|
||||||
const salesValues = data.map((item) => item[3]);
|
);
|
||||||
const minAchieve = Math.min(...achieveValues);
|
const salesData = (salesTrend?.dailyDataList || []).map((item) => item.value);
|
||||||
const maxAchieve = Math.max(...achieveValues);
|
const orderData = (orderTrend?.dailyDataList || []).map((item) => item.value);
|
||||||
const minProfit = Math.min(...profitValues);
|
|
||||||
const maxProfit = Math.max(...profitValues);
|
|
||||||
const minSales = Math.min(...salesValues);
|
|
||||||
const maxSales = Math.max(...salesValues);
|
|
||||||
const achievePadding =
|
|
||||||
minAchieve === maxAchieve ? 10 : (maxAchieve - minAchieve) * 0.2;
|
|
||||||
const profitPadding =
|
|
||||||
minProfit === maxProfit ? 1 : (maxProfit - minProfit) * 0.2;
|
|
||||||
|
|
||||||
const calcBubbleSize = (salesAmount: number) => {
|
const isDark = document.documentElement.classList.contains('dark');
|
||||||
if (maxSales === minSales) return 36;
|
|
||||||
const ratio = (salesAmount - minSales) / (maxSales - minSales);
|
|
||||||
return 28 + ratio * 26;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getFeeRatioColor = (feeRatio: number) => {
|
renderTrendChart({
|
||||||
if (feeRatio <= 0.08) return '#10b981'; // 低费比-健康
|
|
||||||
if (feeRatio <= 0.15) return '#6366f1'; // 中费比-可控
|
|
||||||
return '#f43f5e'; // 高费比-风险
|
|
||||||
};
|
|
||||||
|
|
||||||
renderScatterChart({
|
|
||||||
grid: {
|
grid: {
|
||||||
left: '6%',
|
left: '3%',
|
||||||
right: '4%',
|
right: '3%',
|
||||||
top: '8%',
|
bottom: '3%',
|
||||||
bottom: '16%',
|
top: '5%',
|
||||||
containLabel: true,
|
containLabel: true,
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
trigger: 'item',
|
trigger: 'axis',
|
||||||
formatter: (params: any) => {
|
backgroundColor: isDark ? 'hsl(222.34deg 10.43% 12.27%)' : '#fff',
|
||||||
const item = params.data;
|
textStyle: { color: isDark ? 'hsl(0deg 0% 95%)' : '#000' },
|
||||||
if (!item) return '';
|
|
||||||
const feeRatioPercent = (item[4] * 100).toFixed(2);
|
|
||||||
return `<div style="padding:4px; font-weight:bold">${item[2]}</div><hr/>销售额达成率: ${item[0].toFixed(2)}%<br/>税后盈亏: ¥${item[1].toFixed(2)}万<br/>销售额: ¥${item[3].toLocaleString('zh-CN')}<br/>费比: ${feeRatioPercent}%<br/>ROI: ${item[5].toFixed(2)}<br/>订单达成率: ${item[6].toFixed(2)}%`;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: 'value',
|
type: 'category',
|
||||||
min: Math.min(minAchieve - achievePadding, 0),
|
boundaryGap: false,
|
||||||
max: Math.max(maxAchieve + achievePadding, 120),
|
data: dates,
|
||||||
name: '销售额达成率 (%)',
|
axisLine: {
|
||||||
nameLocation: 'middle',
|
lineStyle: { color: isDark ? 'hsl(240deg 3.7% 22%)' : '#e2e8f0' },
|
||||||
nameGap: 35,
|
|
||||||
axisLabel: {
|
|
||||||
fontWeight: 'bold',
|
|
||||||
formatter: '{value}%',
|
|
||||||
},
|
|
||||||
splitLine: {
|
|
||||||
lineStyle: { type: 'dashed' },
|
|
||||||
},
|
},
|
||||||
|
axisLabel: { color: isDark ? 'hsl(240deg 5% 64.9%)' : undefined },
|
||||||
},
|
},
|
||||||
yAxis: {
|
yAxis: [
|
||||||
type: 'value',
|
{
|
||||||
min: minProfit - profitPadding,
|
type: 'value',
|
||||||
max: maxProfit + profitPadding,
|
name: '销售额',
|
||||||
name: '税后盈亏 (单位: 万元)',
|
nameTextStyle: { color: isDark ? 'hsl(240deg 5% 64.9%)' : undefined },
|
||||||
nameLocation: 'middle',
|
axisLabel: { color: isDark ? 'hsl(240deg 5% 64.9%)' : undefined },
|
||||||
nameGap: 50,
|
splitLine: {
|
||||||
axisLabel: { fontWeight: 'bold' },
|
lineStyle: {
|
||||||
splitLine: {
|
type: 'dashed',
|
||||||
lineStyle: { type: 'dashed' },
|
color: isDark ? 'hsl(240deg 3.7% 22%)' : undefined,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
|
type: 'value',
|
||||||
|
name: '单量',
|
||||||
|
position: 'right',
|
||||||
|
nameTextStyle: { color: isDark ? 'hsl(240deg 5% 64.9%)' : undefined },
|
||||||
|
axisLabel: { color: isDark ? 'hsl(240deg 5% 64.9%)' : undefined },
|
||||||
|
splitLine: { show: false },
|
||||||
|
},
|
||||||
|
],
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
type: 'scatter',
|
name: '销售额',
|
||||||
symbolSize: (val: any) => calcBubbleSize(Number(val[3] ?? 0)),
|
type: 'line',
|
||||||
data,
|
smooth: true,
|
||||||
label: {
|
symbol: 'none',
|
||||||
show: true,
|
lineStyle: { width: 3, color: '#3b82f6' },
|
||||||
position: 'top',
|
areaStyle: {
|
||||||
color:
|
color: {
|
||||||
document.documentElement.classList.contains('dark')
|
type: 'linear',
|
||||||
? 'hsl(0deg 0% 95%)'
|
x: 0, y: 0, x2: 0, y2: 1,
|
||||||
: '#334155',
|
colorStops: [
|
||||||
fontWeight: 700,
|
{ offset: 0, color: 'rgba(59, 130, 246, 0.4)' },
|
||||||
formatter: (params: any) => params.data?.[2] ?? '',
|
{ offset: 1, color: 'rgba(59, 130, 246, 0)' },
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
itemStyle: {
|
data: salesData,
|
||||||
color: (params: any) => getFeeRatioColor(Number(params.data?.[4] ?? 0)),
|
},
|
||||||
shadowBlur: 15,
|
{
|
||||||
shadowColor: 'rgba(0,0,0,0.1)',
|
name: '日单量',
|
||||||
},
|
type: 'line',
|
||||||
markLine: {
|
yAxisIndex: 1,
|
||||||
silent: true,
|
smooth: true,
|
||||||
lineStyle: { type: 'dashed', color: '#94a3b8' },
|
symbol: 'none',
|
||||||
data: [{ xAxis: 100 }, { yAxis: 0 }],
|
lineStyle: { width: 3, color: '#10b981' },
|
||||||
|
areaStyle: {
|
||||||
|
color: {
|
||||||
|
type: 'linear',
|
||||||
|
x: 0, y: 0, x2: 0, y2: 1,
|
||||||
|
colorStops: [
|
||||||
|
{ offset: 0, color: 'rgba(16, 185, 129, 0.2)' },
|
||||||
|
{ offset: 1, color: 'rgba(16, 185, 129, 0)' },
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
data: orderData,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@@ -255,11 +234,11 @@ const renderShopScatterChart = () => {
|
|||||||
const rerenderCharts = async () => {
|
const rerenderCharts = async () => {
|
||||||
await nextTick();
|
await nextTick();
|
||||||
renderShopBarChart();
|
renderShopBarChart();
|
||||||
renderShopScatterChart();
|
renderTrendLineChart();
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [props.shopSalesRatios, props.shopComparisons],
|
() => [props.shopSalesRatios, props.salesAmountTrend, props.orderCountTrend],
|
||||||
() => {
|
() => {
|
||||||
rerenderCharts();
|
rerenderCharts();
|
||||||
},
|
},
|
||||||
@@ -270,13 +249,23 @@ onMounted(() => {
|
|||||||
rerenderCharts();
|
rerenderCharts();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 暴露方法给父组件调用
|
defineExpose({ renderShopBarChart, renderShopScatterChart: renderTrendLineChart });
|
||||||
defineExpose({ renderShopBarChart, renderShopScatterChart });
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="grid grid-cols-1 gap-6 xl:grid-cols-2">
|
<div class="grid grid-cols-1 gap-6 xl:grid-cols-2">
|
||||||
<!-- 销售占比排行 -->
|
<!-- 销售额与单量趋势分析 -->
|
||||||
|
<div
|
||||||
|
class="rounded-2xl border border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] bg-white/90 dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-8 shadow-[0_4px_12px_rgba(0,0,0,0.03)] dark:shadow-none backdrop-blur-[10px] xl:col-span-1"
|
||||||
|
>
|
||||||
|
<h3 class="mb-6 text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
||||||
|
销售额与单量趋势分析
|
||||||
|
</h3>
|
||||||
|
<div class="h-[380px] w-full">
|
||||||
|
<EchartsUI ref="trendChartRef" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- 各店铺销售贡献排行 -->
|
||||||
<div
|
<div
|
||||||
class="rounded-2xl border border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] bg-white/90 dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-8 shadow-[0_4px_12px_rgba(0,0,0,0.03)] dark:shadow-none backdrop-blur-[10px]"
|
class="rounded-2xl border border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] bg-white/90 dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-8 shadow-[0_4px_12px_rgba(0,0,0,0.03)] dark:shadow-none backdrop-blur-[10px]"
|
||||||
>
|
>
|
||||||
@@ -287,36 +276,5 @@ defineExpose({ renderShopBarChart, renderShopScatterChart });
|
|||||||
<EchartsUI ref="barChartRef" />
|
<EchartsUI ref="barChartRef" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 效率象限图 -->
|
|
||||||
<div
|
|
||||||
class="rounded-2xl border border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] bg-white/90 dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-8 shadow-[0_4px_12px_rgba(0,0,0,0.03)] dark:shadow-none backdrop-blur-[10px]"
|
|
||||||
>
|
|
||||||
<h3 class="mb-6 text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
|
||||||
店铺经营健康度分层 (达成率 vs 税后盈亏)
|
|
||||||
</h3>
|
|
||||||
<div class="h-[380px] w-full">
|
|
||||||
<EchartsUI ref="scatterChartRef" />
|
|
||||||
</div>
|
|
||||||
<div class="mt-4 flex justify-center gap-6">
|
|
||||||
<div
|
|
||||||
class="flex items-center gap-2 text-xs font-bold text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]"
|
|
||||||
>
|
|
||||||
<span class="h-3 w-3 rounded-full bg-emerald-500"></span>
|
|
||||||
低费比(健康)
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="flex items-center gap-2 text-xs font-bold text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]"
|
|
||||||
>
|
|
||||||
<span class="h-3 w-3 rounded-full bg-blue-500"></span>
|
|
||||||
中费比(可控)
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="flex items-center gap-2 text-xs font-bold text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]"
|
|
||||||
>
|
|
||||||
<span class="h-3 w-3 rounded-full bg-rose-500"></span>
|
|
||||||
高费比(风险)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -596,7 +596,8 @@ const navigateToShopOverview = (shopId: number) => {
|
|||||||
ref="shopChartsRef"
|
ref="shopChartsRef"
|
||||||
:shop-sales-ratios="overviewData?.shopSalesRatios"
|
:shop-sales-ratios="overviewData?.shopSalesRatios"
|
||||||
:shop-comparisons="overviewData?.shopComparisons"
|
:shop-comparisons="overviewData?.shopComparisons"
|
||||||
:shop-efficiency-quadrants="overviewData?.shopEfficiencyQuadrants"
|
:sales-amount-trend="overviewData?.salesAmountTrend"
|
||||||
|
:order-count-trend="overviewData?.orderCountTrend"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 第三层:平台/店铺/品类明细切换 -->
|
<!-- 第三层:平台/店铺/品类明细切换 -->
|
||||||
|
|||||||
Reference in New Issue
Block a user