mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 04:29:20 +08:00
feat: 工作台SKU汇总列展示商品名/规格名并悬停显示编码
This commit is contained in:
+7
-1
@@ -117,7 +117,7 @@ public class CompanyOverviewVO {
|
|||||||
private PlatformOverview platformTable;
|
private PlatformOverview platformTable;
|
||||||
private CategoryOverview categoryTable;
|
private CategoryOverview categoryTable;
|
||||||
private CategoryOverview productTable;
|
private CategoryOverview productTable;
|
||||||
/** SKU 汇总(复用 CategoryOverview;categoryId=skuId,categoryName=sku 名) */
|
/** SKU 汇总(复用 CategoryOverview;categoryId=skuId,categoryName=商品名/规格名) */
|
||||||
private CategoryOverview skuTable;
|
private CategoryOverview skuTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,6 +289,12 @@ public class CompanyOverviewVO {
|
|||||||
|
|
||||||
private String categoryName;
|
private String categoryName;
|
||||||
|
|
||||||
|
/** SKU 汇总行:所属商品名(展示用) */
|
||||||
|
private String productName;
|
||||||
|
|
||||||
|
/** SKU 汇总行:规格编码(悬停展示) */
|
||||||
|
private String skuCode;
|
||||||
|
|
||||||
private BigDecimal salesAmount;
|
private BigDecimal salesAmount;
|
||||||
|
|
||||||
private BigDecimal dealAmount;
|
private BigDecimal dealAmount;
|
||||||
|
|||||||
+34
-6
@@ -472,7 +472,8 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Long, String> skuNames = loadSkuNameMap(bySku.keySet());
|
Map<Long, SkuLabel> skuLabels = loadSkuLabelMap(bySku.keySet());
|
||||||
|
Map<Long, String> productNames = loadProductNameMap(new java.util.HashSet<>(skuProductId.values()));
|
||||||
List<CompanyOverviewVO.CategorySummary> list = new ArrayList<>();
|
List<CompanyOverviewVO.CategorySummary> list = new ArrayList<>();
|
||||||
for (Map.Entry<Long, AggMetrics> e : bySku.entrySet()) {
|
for (Map.Entry<Long, AggMetrics> e : bySku.entrySet()) {
|
||||||
Long skuId = e.getKey();
|
Long skuId = e.getKey();
|
||||||
@@ -484,8 +485,22 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
|
|||||||
? productPromo.multiply(m.sales).divide(productSkuSalesPool, 4, RoundingMode.HALF_UP)
|
? productPromo.multiply(m.sales).divide(productSkuSalesPool, 4, RoundingMode.HALF_UP)
|
||||||
: BigDecimal.ZERO;
|
: BigDecimal.ZERO;
|
||||||
BigDecimal brush = allocBrushShare(skuSalesByShop.get(skuId), brushByShop);
|
BigDecimal brush = allocBrushShare(skuSalesByShop.get(skuId), brushByShop);
|
||||||
String name = skuId <= 0 ? "未绑定规格" : skuNames.getOrDefault(skuId, "规格" + skuId);
|
SkuLabel label = skuId != null && skuId > 0 ? skuLabels.get(skuId) : null;
|
||||||
list.add(toCategorySummaryFromAgg(skuId, name, m, promo, brush));
|
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,
|
list.sort(Comparator.comparing(CompanyOverviewVO.CategorySummary::getSalesAmount,
|
||||||
Comparator.nullsFirst(BigDecimal::compareTo)).reversed());
|
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));
|
.stream().collect(Collectors.toMap(ProductPO::getId, ProductPO::getName, (a, b) -> a));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Long, String> loadSkuNameMap(java.util.Set<Long> skuKeys) {
|
/** SKU 展示标签:规格名 + 编码 */
|
||||||
|
private Map<Long, SkuLabel> loadSkuLabelMap(java.util.Set<Long> skuKeys) {
|
||||||
List<Long> ids = skuKeys.stream().filter(id -> id != null && id > 0).distinct().toList();
|
List<Long> ids = skuKeys.stream().filter(id -> id != null && id > 0).distinct().toList();
|
||||||
if (ids.isEmpty()) {
|
if (ids.isEmpty()) {
|
||||||
return Map.of();
|
return Map.of();
|
||||||
}
|
}
|
||||||
return productSkuMapper.selectList(new LambdaQueryWrapper<ProductSkuPO>().in(ProductSkuPO::getId, ids))
|
Map<Long, SkuLabel> map = new HashMap<>();
|
||||||
.stream().collect(Collectors.toMap(ProductSkuPO::getId, ProductSkuPO::getName, (a, b) -> a));
|
for (ProductSkuPO sku : productSkuMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<ProductSkuPO>().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<Long, List<ShopMonthlyTargetPO>> loadTargetsByShop(Long companyId, LocalDate start, LocalDate end) {
|
private Map<Long, List<ShopMonthlyTargetPO>> loadTargetsByShop(Long companyId, LocalDate start, LocalDate end) {
|
||||||
|
|||||||
@@ -136,6 +136,10 @@ export namespace CompanyOverviewVO {
|
|||||||
export interface CategorySummary {
|
export interface CategorySummary {
|
||||||
categoryId?: number | null;
|
categoryId?: number | null;
|
||||||
categoryName?: string;
|
categoryName?: string;
|
||||||
|
/** SKU 汇总:所属商品名 */
|
||||||
|
productName?: string;
|
||||||
|
/** SKU 汇总:规格编码(悬停) */
|
||||||
|
skuCode?: string;
|
||||||
salesAmount?: number;
|
salesAmount?: number;
|
||||||
dealAmount?: number;
|
dealAmount?: number;
|
||||||
salesOrderCount?: number;
|
salesOrderCount?: number;
|
||||||
|
|||||||
+10
-4
@@ -4,6 +4,8 @@ import type { CompanyOverviewVO } from '#/api/bi/overview';
|
|||||||
import { createIconifyIcon } from '@vben/icons';
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
|
|
||||||
|
import { Tooltip } from 'ant-design-vue';
|
||||||
|
|
||||||
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
|
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
|
||||||
import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells';
|
import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells';
|
||||||
|
|
||||||
@@ -361,14 +363,18 @@ const cellRoi = (v: number | null | undefined) =>
|
|||||||
{{ cat.categoryName }}
|
{{ cat.categoryName }}
|
||||||
<JumpIcon class="text-xs" />
|
<JumpIcon class="text-xs" />
|
||||||
</span>
|
</span>
|
||||||
<span
|
<Tooltip
|
||||||
v-else-if="skuNavigate && cat.categoryId != null"
|
v-else-if="skuNavigate && cat.categoryId != null"
|
||||||
class="inline-flex cursor-pointer items-center gap-1 rounded-full bg-blue-50 px-3 py-1 text-sm font-bold text-blue-600 transition-colors hover:text-blue-300 hover:underline dark:bg-blue-900/30 dark:text-blue-400"
|
:title="cat.skuCode ? `SKU编码:${cat.skuCode}` : undefined"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="inline-flex max-w-full cursor-pointer items-center gap-1 rounded-full bg-blue-50 px-3 py-1 text-sm font-bold text-blue-600 transition-colors hover:text-blue-300 hover:underline dark:bg-blue-900/30 dark:text-blue-400"
|
||||||
@click="emit('navigate-sku', cat.categoryId!)"
|
@click="emit('navigate-sku', cat.categoryId!)"
|
||||||
>
|
>
|
||||||
{{ cat.categoryName }}
|
<span class="truncate">{{ cat.categoryName || '-' }}</span>
|
||||||
<JumpIcon class="text-xs" />
|
<JumpIcon class="shrink-0 text-xs" />
|
||||||
</span>
|
</span>
|
||||||
|
</Tooltip>
|
||||||
<span
|
<span
|
||||||
v-else
|
v-else
|
||||||
class="inline-block rounded-full bg-blue-50 px-3 py-1 text-sm font-bold text-blue-600 dark:bg-blue-900/30 dark:text-blue-400"
|
class="inline-block rounded-full bg-blue-50 px-3 py-1 text-sm font-bold text-blue-600 dark:bg-blue-900/30 dark:text-blue-400"
|
||||||
|
|||||||
+1
-1
@@ -258,7 +258,7 @@ function handleSkuExport() {
|
|||||||
v-if="activeMode === 'sku'"
|
v-if="activeMode === 'sku'"
|
||||||
column-prefs-key="sku"
|
column-prefs-key="sku"
|
||||||
heading-title="各 SKU 多维度经营明细汇总"
|
heading-title="各 SKU 多维度经营明细汇总"
|
||||||
heading-subtitle="数据来自 Mongo SKU 日汇聚;推广按所属商品推广占比分摊;点击规格名可跳转 SKU 概览"
|
heading-subtitle="数据来自 Mongo SKU 日汇聚;推广按所属商品推广占比分摊;列显示为「商品名/规格名」,悬停可看 SKU 编码;点击可跳转 SKU 概览"
|
||||||
first-column-label="SKU"
|
first-column-label="SKU"
|
||||||
:sku-navigate="true"
|
:sku-navigate="true"
|
||||||
:category-summary="skuSummary ?? undefined"
|
:category-summary="skuSummary ?? undefined"
|
||||||
|
|||||||
Reference in New Issue
Block a user