From f6803bcdaea6df4c46736c3f2542aa3df920bb2d Mon Sep 17 00:00:00 2001 From: ah-max150 Date: Sun, 6 Sep 2026 10:50:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B7=A5=E4=BD=9C=E5=8F=B0SKU=E6=B1=87?= =?UTF-8?q?=E6=80=BB=E5=88=97=E5=B1=95=E7=A4=BA=E5=95=86=E5=93=81=E5=90=8D?= =?UTF-8?q?/=E8=A7=84=E6=A0=BC=E5=90=8D=E5=B9=B6=E6=82=AC=E5=81=9C?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../overview/model/vo/CompanyOverviewVO.java | 8 +++- .../impl/CompanyOverviewServiceImpl.java | 40 ++++++++++++++++--- .../src/api/bi/overview/types/types.vo.ts | 4 ++ .../components/CategorySummaryTable.vue | 18 ++++++--- .../finance/components/OverviewTables.vue | 2 +- 5 files changed, 58 insertions(+), 14 deletions(-) diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/bi/overview/model/vo/CompanyOverviewVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/bi/overview/model/vo/CompanyOverviewVO.java index f7916b35..7d319e3b 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/bi/overview/model/vo/CompanyOverviewVO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/bi/overview/model/vo/CompanyOverviewVO.java @@ -117,7 +117,7 @@ public class CompanyOverviewVO { private PlatformOverview platformTable; private CategoryOverview categoryTable; private CategoryOverview productTable; - /** SKU 汇总(复用 CategoryOverview;categoryId=skuId,categoryName=sku 名) */ + /** SKU 汇总(复用 CategoryOverview;categoryId=skuId,categoryName=商品名/规格名) */ private CategoryOverview skuTable; } @@ -289,6 +289,12 @@ public class CompanyOverviewVO { private String categoryName; + /** SKU 汇总行:所属商品名(展示用) */ + private String productName; + + /** SKU 汇总行:规格编码(悬停展示) */ + private String skuCode; + private BigDecimal salesAmount; private BigDecimal dealAmount; diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/bi/overview/service/impl/CompanyOverviewServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/bi/overview/service/impl/CompanyOverviewServiceImpl.java index 820ad346..f665a0ef 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/bi/overview/service/impl/CompanyOverviewServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/bi/overview/service/impl/CompanyOverviewServiceImpl.java @@ -472,7 +472,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService { } } - Map skuNames = loadSkuNameMap(bySku.keySet()); + Map skuLabels = loadSkuLabelMap(bySku.keySet()); + Map productNames = loadProductNameMap(new java.util.HashSet<>(skuProductId.values())); List list = new ArrayList<>(); for (Map.Entry e : bySku.entrySet()) { Long skuId = e.getKey(); @@ -484,8 +485,22 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService { ? productPromo.multiply(m.sales).divide(productSkuSalesPool, 4, RoundingMode.HALF_UP) : BigDecimal.ZERO; BigDecimal brush = allocBrushShare(skuSalesByShop.get(skuId), brushByShop); - String name = skuId <= 0 ? "未绑定规格" : skuNames.getOrDefault(skuId, "规格" + skuId); - list.add(toCategorySummaryFromAgg(skuId, name, m, promo, brush)); + SkuLabel label = skuId != null && skuId > 0 ? skuLabels.get(skuId) : null; + String skuName = skuId == null || skuId <= 0 + ? "未绑定规格" + : (label != null && label.name() != null && !label.name().isBlank() + ? label.name() + : "规格" + skuId); + String productName = productId != null && productId > 0 + ? productNames.getOrDefault(productId, "商品" + productId) + : null; + String displayName = productName != null ? productName + "/" + skuName : skuName; + CompanyOverviewVO.CategorySummary row = toCategorySummaryFromAgg(skuId, displayName, m, promo, brush); + row.setProductName(productName); + if (label != null && label.code() != null && !label.code().isBlank()) { + row.setSkuCode(label.code()); + } + list.add(row); } list.sort(Comparator.comparing(CompanyOverviewVO.CategorySummary::getSalesAmount, Comparator.nullsFirst(BigDecimal::compareTo)).reversed()); @@ -820,13 +835,26 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService { .stream().collect(Collectors.toMap(ProductPO::getId, ProductPO::getName, (a, b) -> a)); } - private Map loadSkuNameMap(java.util.Set skuKeys) { + /** SKU 展示标签:规格名 + 编码 */ + private Map loadSkuLabelMap(java.util.Set skuKeys) { List ids = skuKeys.stream().filter(id -> id != null && id > 0).distinct().toList(); if (ids.isEmpty()) { return Map.of(); } - return productSkuMapper.selectList(new LambdaQueryWrapper().in(ProductSkuPO::getId, ids)) - .stream().collect(Collectors.toMap(ProductSkuPO::getId, ProductSkuPO::getName, (a, b) -> a)); + Map map = new HashMap<>(); + for (ProductSkuPO sku : productSkuMapper.selectList( + new LambdaQueryWrapper().in(ProductSkuPO::getId, ids))) { + if (sku.getId() == null) { + continue; + } + map.put(sku.getId(), new SkuLabel( + sku.getName() != null ? sku.getName() : ("规格" + sku.getId()), + sku.getSkuCode())); + } + return map; + } + + private record SkuLabel(String name, String code) { } private Map> loadTargetsByShop(Long companyId, LocalDate start, LocalDate end) { diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/bi/overview/types/types.vo.ts b/ecom-dmb-frontend/apps/web-antd/src/api/bi/overview/types/types.vo.ts index 28eac729..0c35d049 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/bi/overview/types/types.vo.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/bi/overview/types/types.vo.ts @@ -136,6 +136,10 @@ export namespace CompanyOverviewVO { export interface CategorySummary { categoryId?: number | null; categoryName?: string; + /** SKU 汇总:所属商品名 */ + productName?: string; + /** SKU 汇总:规格编码(悬停) */ + skuCode?: string; salesAmount?: number; dealAmount?: number; salesOrderCount?: number; diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/CategorySummaryTable.vue b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/CategorySummaryTable.vue index 0dc21f65..b36c99ea 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/CategorySummaryTable.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/CategorySummaryTable.vue @@ -4,6 +4,8 @@ import type { CompanyOverviewVO } from '#/api/bi/overview'; import { createIconifyIcon } from '@vben/icons'; import { computed } from 'vue'; +import { Tooltip } from 'ant-design-vue'; + import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio'; import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells'; @@ -361,14 +363,18 @@ const cellRoi = (v: number | null | undefined) => {{ cat.categoryName }} - - {{ cat.categoryName }} - - + + {{ cat.categoryName || '-' }} + + +