mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 19:09:19 +08:00
feat: 工作台SKU汇总列展示商品名/规格名并悬停显示编码
This commit is contained in:
+7
-1
@@ -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;
|
||||
|
||||
+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<>();
|
||||
for (Map.Entry<Long, AggMetrics> 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<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();
|
||||
if (ids.isEmpty()) {
|
||||
return Map.of();
|
||||
}
|
||||
return productSkuMapper.selectList(new LambdaQueryWrapper<ProductSkuPO>().in(ProductSkuPO::getId, ids))
|
||||
.stream().collect(Collectors.toMap(ProductSkuPO::getId, ProductSkuPO::getName, (a, b) -> a));
|
||||
Map<Long, SkuLabel> map = new HashMap<>();
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user