refactor: 重构bi统计改规格统计成sku统计

This commit is contained in:
2026-08-10 16:31:42 +08:00
parent dafbe5820b
commit 2e5af7eec5
10 changed files with 100 additions and 98 deletions
@@ -32,7 +32,7 @@ public class BiIncCalcMessage {
private Long channelOrderId;
private BiStatMetricDelta shopDelta;
private List<BiProductStatDelta> productDeltas;
private List<BiSpecStatDelta> specDeltas;
private List<BiSkuStatDelta> skuDeltas;
private OffsetDateTime occurredAt;
private Integer retryCount;
}
@@ -9,9 +9,10 @@ import lombok.NoArgsConstructor;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BiSpecStatDelta {
public class BiSkuStatDelta {
private Long productId;
private Long productSpecId;
/** 内部 SKU 主键(ec_product_sku.id);未绑定为 0 */
private Long productSkuId;
private BiStatMetricDelta metrics;
}
@@ -83,7 +83,7 @@ public class BiStatIncConsumer {
statDate,
message.getShopDelta(),
message.getProductDeltas(),
message.getSpecDeltas());
message.getSkuDeltas());
log.info("BI inc delta 已累加 shopId={} statDate={} orderId={}",
message.getShopId(), statDate, message.getOrderId());
} finally {
@@ -11,14 +11,14 @@ import java.time.Instant;
import java.time.LocalDate;
@Data
@Document(collection = "bi_order_stat_daily_spec")
@Document(collection = "bi_order_stat_daily_sku")
@CompoundIndexes({
@CompoundIndex(
name = "uk_company_shop_spec_date",
def = "{'companyId':1,'shopId':1,'productSpecId':1,'statDate':1}",
name = "uk_company_shop_sku_date",
def = "{'companyId':1,'shopId':1,'productSkuId':1,'statDate':1}",
unique = true)
})
public class BiOrderStatDailySpecDoc {
public class BiOrderStatDailySkuDoc {
@Id
private String id;
@@ -26,7 +26,8 @@ public class BiOrderStatDailySpecDoc {
private Long companyId;
private Long shopId;
private Long productId;
private Long productSpecId;
/** 内部 SKU 主键;未绑定为 0 */
private Long productSkuId;
private LocalDate statDate;
private BigDecimal salesAmount = BigDecimal.ZERO;
@@ -8,11 +8,11 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Repository;
import top.xyquan.ecomdmbbackend.modules.bi.messaging.BiProductStatDelta;
import top.xyquan.ecomdmbbackend.modules.bi.messaging.BiSpecStatDelta;
import top.xyquan.ecomdmbbackend.modules.bi.messaging.BiSkuStatDelta;
import top.xyquan.ecomdmbbackend.modules.bi.messaging.BiStatMetricDelta;
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.model.document.BiOrderStatDailyProductDoc;
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.model.document.BiOrderStatDailyShopDoc;
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.model.document.BiOrderStatDailySpecDoc;
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.model.document.BiOrderStatDailySkuDoc;
import java.math.BigDecimal;
import java.time.Instant;
@@ -35,7 +35,7 @@ public class BiOrderStatDailyRepository {
public void replaceShopDay(BiOrderStatDailyShopDoc shopDoc,
List<BiOrderStatDailyProductDoc> products,
List<BiOrderStatDailySpecDoc> specs) {
List<BiOrderStatDailySkuDoc> skus) {
Long companyId = shopDoc.getCompanyId();
Long shopId = shopDoc.getShopId();
LocalDate statDate = shopDoc.getStatDate();
@@ -53,12 +53,12 @@ public class BiOrderStatDailyRepository {
}, () -> mongoTemplate.insert(shopDoc));
mongoTemplate.remove(dayQ, BiOrderStatDailyProductDoc.class);
mongoTemplate.remove(dayQ, BiOrderStatDailySpecDoc.class);
mongoTemplate.remove(dayQ, BiOrderStatDailySkuDoc.class);
if (products != null && !products.isEmpty()) {
mongoTemplate.insertAll(products);
}
if (specs != null && !specs.isEmpty()) {
mongoTemplate.insertAll(specs);
if (skus != null && !skus.isEmpty()) {
mongoTemplate.insertAll(skus);
}
}
@@ -66,7 +66,7 @@ public class BiOrderStatDailyRepository {
public void applyIncDeltas(Long companyId, Long shopId, String platformCode, LocalDate statDate,
BiStatMetricDelta shopDelta,
List<BiProductStatDelta> productDeltas,
List<BiSpecStatDelta> specDeltas) {
List<BiSkuStatDelta> skuDeltas) {
Instant now = Instant.now();
Optional<BiOrderStatDailyShopDoc> existing = findShop(companyId, shopId, statDate);
if (existing.isEmpty()) {
@@ -122,33 +122,33 @@ public class BiOrderStatDailyRepository {
}
}
}
if (specDeltas != null) {
for (BiSpecStatDelta sd : specDeltas) {
if (skuDeltas != null) {
for (BiSkuStatDelta sd : skuDeltas) {
if (sd.getMetrics() == null || sd.getMetrics().isAllZero()) {
continue;
}
long productId = sd.getProductId() != null ? sd.getProductId() : 0L;
long specId = sd.getProductSpecId() != null ? sd.getProductSpecId() : 0L;
long skuId = sd.getProductSkuId() != null ? sd.getProductSkuId() : 0L;
Query sq = Query.query(Criteria.where("companyId").is(companyId)
.and("shopId").is(shopId)
.and("productSpecId").is(specId)
.and("productSkuId").is(skuId)
.and("statDate").is(statDate));
BiOrderStatDailySpecDoc found = mongoTemplate.findOne(sq, BiOrderStatDailySpecDoc.class);
BiOrderStatDailySkuDoc found = mongoTemplate.findOne(sq, BiOrderStatDailySkuDoc.class);
if (found == null) {
BiOrderStatDailySpecDoc doc = new BiOrderStatDailySpecDoc();
BiOrderStatDailySkuDoc doc = new BiOrderStatDailySkuDoc();
doc.setCompanyId(companyId);
doc.setShopId(shopId);
doc.setProductId(productId);
doc.setProductSpecId(specId);
doc.setProductSkuId(skuId);
doc.setStatDate(statDate);
applyMetricToSpec(doc, sd.getMetrics());
applyMetricToSku(doc, sd.getMetrics());
doc.setComputeMode("INC");
doc.setComputedAt(now);
mongoTemplate.insert(doc);
} else {
Update u = metricIncUpdate(sd.getMetrics());
u.set("computedAt", now).set("computeMode", "INC");
mongoTemplate.updateFirst(sq, u, BiOrderStatDailySpecDoc.class);
mongoTemplate.updateFirst(sq, u, BiOrderStatDailySkuDoc.class);
}
}
}
@@ -221,7 +221,7 @@ public class BiOrderStatDailyRepository {
doc.setOtherCost(nz(d.getOtherCost()));
}
private static void applyMetricToSpec(BiOrderStatDailySpecDoc doc, BiStatMetricDelta d) {
private static void applyMetricToSku(BiOrderStatDailySkuDoc doc, BiStatMetricDelta d) {
if (d == null) {
return;
}
@@ -9,7 +9,7 @@ import org.springframework.transaction.support.TransactionTemplate;
import top.xyquan.ecomdmbbackend.modules.bi.infra.lock.BiStatComputeLock;
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.model.document.BiOrderStatDailyProductDoc;
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.model.document.BiOrderStatDailyShopDoc;
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.model.document.BiOrderStatDailySpecDoc;
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.model.document.BiOrderStatDailySkuDoc;
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.repository.BiOrderStatDailyRepository;
import top.xyquan.ecomdmbbackend.modules.ec.order.mapper.OrderItemMapper;
import top.xyquan.ecomdmbbackend.modules.ec.order.mapper.OrderMapper;
@@ -145,9 +145,9 @@ public class OrderDailyStatComputeService {
Metric shop = new Metric();
Map<String, Metric> productMap = new HashMap<>();
Map<String, Metric> specMap = new HashMap<>();
Map<String, Metric> skuMap = new HashMap<>();
Map<String, DimKey> productKeys = new HashMap<>();
Map<String, DimKey> specKeys = new HashMap<>();
Map<String, DimKey> skuKeys = new HashMap<>();
for (OrderPO order : orders) {
List<OrderItemPO> items = itemsByOrder.getOrDefault(order.getId(), List.of());
@@ -173,8 +173,8 @@ public class OrderDailyStatComputeService {
Set<String> countedProductSales = new HashSet<>();
Set<String> countedProductGmv = new HashSet<>();
Set<String> countedSpecSales = new HashSet<>();
Set<String> countedSpecGmv = new HashSet<>();
Set<String> countedSkuSales = new HashSet<>();
Set<String> countedSkuGmv = new HashSet<>();
if (items.isEmpty()) {
continue;
@@ -182,7 +182,7 @@ public class OrderDailyStatComputeService {
for (OrderItemPO item : items) {
long productId = item.getProductId() != null ? item.getProductId() : 0L;
long categoryId = categoryByProduct.getOrDefault(productId, 0L);
long specId = item.getProductSkuId() != null ? item.getProductSkuId() : 0L;
long skuId = item.getProductSkuId() != null ? item.getProductSkuId() : 0L;
int qty = OrderStatusStatSets.quantity(item);
BigDecimal linePay = allocateLine(pay, item, items);
@@ -208,18 +208,18 @@ public class OrderDailyStatComputeService {
pm.freightCost = pm.freightCost.add(stat.freightCostForStats(order, item));
pm.otherCost = pm.otherCost.add(stat.otherCostForStats(order, item));
String sk = companyId + ":" + shopId + ":" + specId;
Metric sm = specMap.computeIfAbsent(sk, k -> new Metric());
specKeys.putIfAbsent(sk, new DimKey(productId, 0L, specId));
String sk = companyId + ":" + shopId + ":" + skuId;
Metric sm = skuMap.computeIfAbsent(sk, k -> new Metric());
skuKeys.putIfAbsent(sk, new DimKey(productId, 0L, skuId));
sm.gmvAmount = sm.gmvAmount.add(linePay);
sm.gmvQuantitySum += qty;
if (countedSpecGmv.add(sk)) {
if (countedSkuGmv.add(sk)) {
sm.gmvOrderCount++;
}
if (sales) {
sm.salesAmount = sm.salesAmount.add(linePay);
sm.salesQuantitySum += qty;
if (countedSpecSales.add(sk)) {
if (countedSkuSales.add(sk)) {
sm.salesOrderCount++;
}
}
@@ -241,7 +241,7 @@ public class OrderDailyStatComputeService {
platform = orders.get(0).getPlatformCode();
}
return new DayAgg(companyId, shopId, statDate, platform, shop, productMap, productKeys, specMap, specKeys);
return new DayAgg(companyId, shopId, statDate, platform, shop, productMap, productKeys, skuMap, skuKeys);
}
private void persist(DayAgg agg, Instant snapshotTime, String mode) {
@@ -272,23 +272,23 @@ public class OrderDailyStatComputeService {
products.add(doc);
}
List<BiOrderStatDailySpecDoc> specs = new ArrayList<>();
for (Map.Entry<String, Metric> e : agg.specMap().entrySet()) {
DimKey key = agg.specKeys().get(e.getKey());
BiOrderStatDailySpecDoc doc = new BiOrderStatDailySpecDoc();
List<BiOrderStatDailySkuDoc> skus = new ArrayList<>();
for (Map.Entry<String, Metric> e : agg.skuMap().entrySet()) {
DimKey key = agg.skuKeys().get(e.getKey());
BiOrderStatDailySkuDoc doc = new BiOrderStatDailySkuDoc();
doc.setCompanyId(agg.companyId());
doc.setShopId(agg.shopId());
doc.setProductId(key.productId());
doc.setProductSpecId(key.specId());
doc.setProductSkuId(key.skuId());
doc.setStatDate(agg.statDate());
applyMetric(doc, e.getValue());
doc.setDbSnapshotTime(snapshotTime);
doc.setComputedAt(now);
doc.setComputeMode(mode);
specs.add(doc);
skus.add(doc);
}
repository.replaceShopDay(shopDoc, products, specs);
repository.replaceShopDay(shopDoc, products, skus);
log.info("BI 日汇聚完成 mode={} companyId={} shopId={} statDate={} ordersShopGmv={}",
mode, agg.companyId(), agg.shopId(), agg.statDate(), agg.shop().gmvOrderCount);
}
@@ -319,7 +319,7 @@ public class OrderDailyStatComputeService {
doc.setOtherCost(m.otherCost);
}
private static void applyMetric(BiOrderStatDailySpecDoc doc, Metric m) {
private static void applyMetric(BiOrderStatDailySkuDoc doc, Metric m) {
doc.setSalesAmount(m.salesAmount);
doc.setSalesOrderCount(m.salesOrderCount);
doc.setSalesQuantitySum(m.salesQuantitySum);
@@ -364,7 +364,7 @@ public class OrderDailyStatComputeService {
BigDecimal otherCost = BigDecimal.ZERO;
}
private record DimKey(long productId, long categoryId, long specId) {
private record DimKey(long productId, long categoryId, long skuId) {
}
private record DayAgg(
@@ -375,7 +375,7 @@ public class OrderDailyStatComputeService {
Metric shop,
Map<String, Metric> productMap,
Map<String, DimKey> productKeys,
Map<String, Metric> specMap,
Map<String, DimKey> specKeys) {
Map<String, Metric> skuMap,
Map<String, DimKey> skuKeys) {
}
}
@@ -3,7 +3,7 @@ package top.xyquan.ecomdmbbackend.modules.bi.orderstat.support;
import lombok.Builder;
import lombok.Data;
import top.xyquan.ecomdmbbackend.modules.bi.messaging.BiProductStatDelta;
import top.xyquan.ecomdmbbackend.modules.bi.messaging.BiSpecStatDelta;
import top.xyquan.ecomdmbbackend.modules.bi.messaging.BiSkuStatDelta;
import top.xyquan.ecomdmbbackend.modules.bi.messaging.BiStatMetricDelta;
import top.xyquan.ecomdmbbackend.modules.ec.order.model.po.OrderItemPO;
import top.xyquan.ecomdmbbackend.modules.ec.order.model.po.OrderPO;
@@ -62,15 +62,15 @@ public class OrderStatContributionCalculator {
Map<String, BiStatMetricDelta> productMap = new HashMap<>();
Map<String, long[]> productKeys = new HashMap<>();
Map<String, BiStatMetricDelta> specMap = new HashMap<>();
Map<String, long[]> specKeys = new HashMap<>();
Map<String, BiStatMetricDelta> skuMap = new HashMap<>();
Map<String, long[]> skuKeys = new HashMap<>();
Map<Long, Long> categoryByProduct = loadCategories(safeItems);
for (OrderItemPO item : safeItems) {
long productId = item.getProductId() != null ? item.getProductId() : 0L;
long categoryId = categoryByProduct.getOrDefault(productId, 0L);
long specId = item.getProductSkuId() != null ? item.getProductSkuId() : 0L;
long skuId = item.getProductSkuId() != null ? item.getProductSkuId() : 0L;
int qty = OrderStatusStatSets.quantity(item);
BigDecimal linePay = allocateLine(pay, item, safeItems);
@@ -93,9 +93,9 @@ public class OrderStatContributionCalculator {
pm.setFreightCost(nz(pm.getFreightCost()).add(fc));
pm.setOtherCost(nz(pm.getOtherCost()).add(oc));
String sk = String.valueOf(specId);
BiStatMetricDelta sm = specMap.computeIfAbsent(sk, k -> BiStatMetricDelta.zeros());
specKeys.putIfAbsent(sk, new long[]{productId, specId});
String sk = String.valueOf(skuId);
BiStatMetricDelta sm = skuMap.computeIfAbsent(sk, k -> BiStatMetricDelta.zeros());
skuKeys.putIfAbsent(sk, new long[]{productId, skuId});
sm.setGmvAmount(nz(sm.getGmvAmount()).add(linePay));
sm.setGmvQuantitySum(nzi(sm.getGmvQuantitySum()) + qty);
if (sales) {
@@ -114,7 +114,7 @@ public class OrderStatContributionCalculator {
shop.setOtherCost(nz(shop.getOtherCost()).add(oc));
}
// 订单计数:商品/规格维度每单计 1 次(有明细时)
// 订单计数:商品/SKU 维度每单计 1 次(有明细时)
if (!safeItems.isEmpty()) {
for (BiStatMetricDelta pm : productMap.values()) {
pm.setGmvOrderCount(1);
@@ -122,7 +122,7 @@ public class OrderStatContributionCalculator {
pm.setSalesOrderCount(1);
}
}
for (BiStatMetricDelta sm : specMap.values()) {
for (BiStatMetricDelta sm : skuMap.values()) {
sm.setGmvOrderCount(1);
if (sales) {
sm.setSalesOrderCount(1);
@@ -139,12 +139,12 @@ public class OrderStatContributionCalculator {
.metrics(e.getValue())
.build());
}
List<BiSpecStatDelta> specs = new ArrayList<>();
for (Map.Entry<String, BiStatMetricDelta> e : specMap.entrySet()) {
long[] k = specKeys.get(e.getKey());
specs.add(BiSpecStatDelta.builder()
List<BiSkuStatDelta> skus = new ArrayList<>();
for (Map.Entry<String, BiStatMetricDelta> e : skuMap.entrySet()) {
long[] k = skuKeys.get(e.getKey());
skus.add(BiSkuStatDelta.builder()
.productId(k[0])
.productSpecId(k[1])
.productSkuId(k[1])
.metrics(e.getValue())
.build());
}
@@ -153,7 +153,7 @@ public class OrderStatContributionCalculator {
.statDate(statDate)
.shop(shop)
.products(products)
.specs(specs)
.skus(skus)
.build();
}
@@ -201,6 +201,6 @@ public class OrderStatContributionCalculator {
private LocalDate statDate;
private BiStatMetricDelta shop;
private List<BiProductStatDelta> products;
private List<BiSpecStatDelta> specs;
private List<BiSkuStatDelta> skus;
}
}
@@ -8,7 +8,7 @@ import top.xyquan.ecomdmbbackend.common.mq.OrderMqConstants;
import top.xyquan.ecomdmbbackend.modules.bi.messaging.BiFullCalcMessage;
import top.xyquan.ecomdmbbackend.modules.bi.messaging.BiIncCalcMessage;
import top.xyquan.ecomdmbbackend.modules.bi.messaging.BiProductStatDelta;
import top.xyquan.ecomdmbbackend.modules.bi.messaging.BiSpecStatDelta;
import top.xyquan.ecomdmbbackend.modules.bi.messaging.BiSkuStatDelta;
import top.xyquan.ecomdmbbackend.modules.bi.messaging.BiStatMetricDelta;
import top.xyquan.ecomdmbbackend.modules.ec.platform.model.enums.PlatformCode;
@@ -45,10 +45,10 @@ public class PddBiCalcPublisher {
OffsetDateTime internalOrderUpdateTime, Long orderId, Long channelOrderId,
BiStatMetricDelta shopDelta,
List<BiProductStatDelta> productDeltas,
List<BiSpecStatDelta> specDeltas) {
List<BiSkuStatDelta> skuDeltas) {
if (shopDelta != null && shopDelta.isAllZero()
&& (productDeltas == null || productDeltas.isEmpty())
&& (specDeltas == null || specDeltas.isEmpty())) {
&& (skuDeltas == null || skuDeltas.isEmpty())) {
return;
}
BiIncCalcMessage msg = BiIncCalcMessage.builder()
@@ -62,7 +62,7 @@ public class PddBiCalcPublisher {
.channelOrderId(channelOrderId)
.shopDelta(shopDelta)
.productDeltas(productDeltas)
.specDeltas(specDeltas)
.skuDeltas(skuDeltas)
.occurredAt(OffsetDateTime.now(ZONE))
.retryCount(0)
.build();
@@ -13,7 +13,7 @@ import top.xyquan.ecomdmbbackend.common.mq.ChannelOrderRef;
import top.xyquan.ecomdmbbackend.common.mq.OrderConvertMessage;
import top.xyquan.ecomdmbbackend.common.mq.OrderConvertMode;
import top.xyquan.ecomdmbbackend.modules.bi.messaging.BiProductStatDelta;
import top.xyquan.ecomdmbbackend.modules.bi.messaging.BiSpecStatDelta;
import top.xyquan.ecomdmbbackend.modules.bi.messaging.BiSkuStatDelta;
import top.xyquan.ecomdmbbackend.modules.bi.messaging.BiStatMetricDelta;
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.support.OrderStatContributionCalculator;
import top.xyquan.ecomdmbbackend.modules.channel.pdd.order.convert.messaging.PddBiCalcPublisher;
@@ -170,28 +170,28 @@ public class PddOrderConvertService {
OrderStatContributionCalculator.OrderContribution newC) {
Map<LocalDate, BiStatMetricDelta> shopByDate = new HashMap<>();
Map<LocalDate, Map<String, BiProductStatDelta>> prodByDate = new HashMap<>();
Map<LocalDate, Map<String, BiSpecStatDelta>> specByDate = new HashMap<>();
Map<LocalDate, Map<String, BiSkuStatDelta>> skuByDate = new HashMap<>();
applyContrib(shopByDate, prodByDate, specByDate, oldC, true);
applyContrib(shopByDate, prodByDate, specByDate, newC, false);
applyContrib(shopByDate, prodByDate, skuByDate, oldC, true);
applyContrib(shopByDate, prodByDate, skuByDate, newC, false);
for (LocalDate date : shopByDate.keySet()) {
BiStatMetricDelta shopDelta = shopByDate.getOrDefault(date, BiStatMetricDelta.zeros());
List<BiProductStatDelta> products = new ArrayList<>(
prodByDate.getOrDefault(date, Map.of()).values());
products.removeIf(p -> p.getMetrics() == null || p.getMetrics().isAllZero());
List<BiSpecStatDelta> specs = new ArrayList<>(
specByDate.getOrDefault(date, Map.of()).values());
specs.removeIf(s -> s.getMetrics() == null || s.getMetrics().isAllZero());
List<BiSkuStatDelta> skus = new ArrayList<>(
skuByDate.getOrDefault(date, Map.of()).values());
skus.removeIf(s -> s.getMetrics() == null || s.getMetrics().isAllZero());
biCalcPublisher.publishIncDelta(
message.getCompanyId(), message.getShopId(), date, internalOrderUpdateTime,
orderId, channelOrderId, shopDelta, products, specs);
orderId, channelOrderId, shopDelta, products, skus);
}
}
private void applyContrib(Map<LocalDate, BiStatMetricDelta> shopByDate,
Map<LocalDate, Map<String, BiProductStatDelta>> prodByDate,
Map<LocalDate, Map<String, BiSpecStatDelta>> specByDate,
Map<LocalDate, Map<String, BiSkuStatDelta>> skuByDate,
OrderStatContributionCalculator.OrderContribution c,
boolean subtract) {
if (c == null || c.getStatDate() == null) {
@@ -219,20 +219,20 @@ public class PddOrderConvertService {
.build());
}
}
Map<String, BiSpecStatDelta> sm = specByDate.computeIfAbsent(d, k -> new HashMap<>());
if (c.getSpecs() != null) {
for (BiSpecStatDelta s : c.getSpecs()) {
String key = String.valueOf(s.getProductSpecId());
Map<String, BiSkuStatDelta> sm = skuByDate.computeIfAbsent(d, k -> new HashMap<>());
if (c.getSkus() != null) {
for (BiSkuStatDelta s : c.getSkus()) {
String key = String.valueOf(s.getProductSkuId());
BiStatMetricDelta m = s.getMetrics() != null ? s.getMetrics() : BiStatMetricDelta.zeros();
BiStatMetricDelta delta = subtract ? m.negate() : m;
sm.merge(key, BiSpecStatDelta.builder()
sm.merge(key, BiSkuStatDelta.builder()
.productId(s.getProductId())
.productSpecId(s.getProductSpecId())
.productSkuId(s.getProductSkuId())
.metrics(delta)
.build(),
(a, b) -> BiSpecStatDelta.builder()
(a, b) -> BiSkuStatDelta.builder()
.productId(a.getProductId())
.productSpecId(a.getProductSpecId())
.productSkuId(a.getProductSkuId())
.metrics(a.getMetrics().plus(b.getMetrics()))
.build());
}