From 13af3223e7088e95617fdd2889fc4ae8ef5e0c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=9F=91=E8=9E=82?= Date: Thu, 7 May 2026 00:20:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=85=A8=E5=BA=97=E6=A6=82=E8=A7=88?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=95=86=E5=93=81=E9=94=80=E9=87=8F=20Top10?= =?UTF-8?q?=20=E6=A6=9C=E5=8D=95=EF=BC=8C=E7=A7=BB=E9=99=A4=E5=86=97?= =?UTF-8?q?=E4=BD=99=E7=9A=84=E7=A8=8E=E5=90=8E=E7=9B=88=E4=BA=8F=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ShopOverviewStatisticsVO:移除 totalProfitAfterTax,新增 productSalesTop10(按单量排序的销量 Top10 列表) - ShopOverviewStatisticsServiceImpl:新增 fillProductSalesTop10(),从商品横向汇总中按单量取 Top10 - 前端 types.vo.ts:同步更新字段替换 - 前端:移除 FinancialPanel.vue,新增 ProductSalesTop10Panel.vue 商品销量榜单组件 --- .../model/vo/ShopOverviewStatisticsVO.java | 28 ++++++- .../ShopOverviewStatisticsServiceImpl.java | 34 +++++++- .../src/api/ecommerce/shop/types/types.vo.ts | 13 ++- .../overview/components/FinancialPanel.vue | 78 ------------------ .../components/ProductSalesTop10Panel.vue | 81 +++++++++++++++++++ .../views/ecommerce/shop/overview/index.vue | 6 +- 6 files changed, 152 insertions(+), 88 deletions(-) delete mode 100644 ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/components/FinancialPanel.vue create mode 100644 ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/components/ProductSalesTop10Panel.vue diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/model/vo/ShopOverviewStatisticsVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/model/vo/ShopOverviewStatisticsVO.java index e4c43050..9e769fad 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/model/vo/ShopOverviewStatisticsVO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/model/vo/ShopOverviewStatisticsVO.java @@ -118,10 +118,10 @@ public class ShopOverviewStatisticsVO { private BigDecimal totalProfitBeforeTax; /** - * 总税后盈亏 + * 各商品按单量排序的销量 Top10(与当前筛选时间范围一致) */ - @Schema(description = "总税后盈亏", example = "80000.00") - private BigDecimal totalProfitAfterTax; + @Schema(description = "各商品销量 Top10") + private List productSalesTop10; /** * 销售额趋势分析 @@ -147,6 +147,28 @@ public class ShopOverviewStatisticsVO { @Schema(description = "品类多维度数据汇总") private CategoryOverview categoryOverview; + /** + * 商品销量排行项(概览 Top10) + */ + @Data + @Schema(description = "商品销量排行项") + public static class ProductSalesRankItem { + @Schema(description = "商品ID", example = "1") + private Long productId; + + @Schema(description = "商品名称", example = "iPhone 15 Pro") + private String productName; + + @Schema(description = "商品编码", example = "IPHONE15PRO") + private String productCode; + + @Schema(description = "单量", example = "500") + private Integer orderCount; + + @Schema(description = "销售额", example = "50000.00") + private BigDecimal salesAmount; + } + /** * 商品概览(含合计行和商品列表) */ diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/ShopOverviewStatisticsServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/ShopOverviewStatisticsServiceImpl.java index 1eadf66d..452cc53e 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/ShopOverviewStatisticsServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/ShopOverviewStatisticsServiceImpl.java @@ -237,10 +237,9 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics // 7. 计算目标维度的数据 calculateTargetData(overviewVO, companyId, queryDTO.getShopId(), startDate, endDate, totalSalesAmount, totalOrderCount); - // 8. 汇总ROI和总税后盈亏 + // 8. 汇总ROI BigDecimal totalROI = calculateTotalROI(orders, promotionFees, brushOrders, stat); overviewVO.setTotalROI(totalROI); - overviewVO.setTotalProfitAfterTax(totalNetProfitAfterTax); // 9. 计算趋势分析数据 ShopOverviewStatisticsVO.TrendData salesAmountTrend = calculateSalesAmountTrend(orders, startDate, endDate, stat); @@ -258,9 +257,40 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics orders, promotionFees, brushOrders, stat); overviewVO.setCategoryOverview(categoryOverview); + fillProductSalesTop10(overviewVO); + return overviewVO; } + /** + * 从商品横向汇总中按单量取 Top10,供概览榜单展示(不重复计算订单) + */ + private void fillProductSalesTop10(ShopOverviewStatisticsVO vo) { + ShopOverviewStatisticsVO.ProductOverview po = vo.getProductOverview(); + if (po == null || po.getProducts() == null || po.getProducts().isEmpty()) { + vo.setProductSalesTop10(Collections.emptyList()); + return; + } + List top10 = po.getProducts().stream() + .sorted(Comparator.comparing( + (ShopOverviewStatisticsVO.ProductComparison p) -> + p.getOrderCount() != null ? p.getOrderCount() : 0, + Comparator.reverseOrder())) + .limit(10) + .map(p -> { + ShopOverviewStatisticsVO.ProductSalesRankItem item = + new ShopOverviewStatisticsVO.ProductSalesRankItem(); + item.setProductId(p.getProductId()); + item.setProductName(p.getProductName()); + item.setProductCode(p.getProductCode()); + item.setOrderCount(p.getOrderCount()); + item.setSalesAmount(p.getSalesAmount()); + return item; + }) + .collect(Collectors.toList()); + vo.setProductSalesTop10(top10); + } + /** * 订单维度毛利(税前、未扣推广费/刷单费),全店税前盈亏需再减推广费与刷单费 */ diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/types/types.vo.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/types/types.vo.ts index 34e507b5..4d024a67 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/types/types.vo.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/types/types.vo.ts @@ -91,8 +91,8 @@ export namespace ShopVO { refundAmount?: number; /** 店铺税前盈亏(扣销售额税额前) */ totalProfitBeforeTax?: number; - /** 总税后盈亏 */ - totalProfitAfterTax?: number; + /** 各商品按单量排序的销量 Top10 */ + productSalesTop10?: ProductSalesRankItem[]; /** 销售额趋势分析 */ salesAmountTrend?: TrendData; /** 单量趋势分析 */ @@ -103,6 +103,15 @@ export namespace ShopVO { categoryOverview?: CategoryOverview; } + /** 商品销量排行项(店铺概览 Top10) */ + export interface ProductSalesRankItem { + productId?: number; + productName?: string; + productCode?: string; + orderCount?: number; + salesAmount?: number; + } + /** 商品汇总数据 */ export interface ProductComparison { /** 商品ID */ diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/components/FinancialPanel.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/components/FinancialPanel.vue deleted file mode 100644 index d81c16f1..00000000 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/components/FinancialPanel.vue +++ /dev/null @@ -1,78 +0,0 @@ - - - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/components/ProductSalesTop10Panel.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/components/ProductSalesTop10Panel.vue new file mode 100644 index 00000000..b5429974 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/components/ProductSalesTop10Panel.vue @@ -0,0 +1,81 @@ + + + diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/index.vue index 889f9313..243909f1 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/index.vue @@ -21,7 +21,7 @@ import { exportByPost } from '#/utils/export'; import TimeRangeBar from './components/TimeRangeBar.vue'; import StatCards from './components/StatCards.vue'; import SalesTrendChart from './components/SalesTrendChart.vue'; -import FinancialPanel from './components/FinancialPanel.vue'; +import ProductSalesTop10Panel from './components/ProductSalesTop10Panel.vue'; import ProductCategorySwitcher from './components/ProductCategorySwitcher.vue'; defineOptions({ name: 'ShopOverview' }); @@ -354,10 +354,10 @@ onActivated(async () => { - +
- +