Commit cca1dc82 by 崔彦峰

feat(goods): 支持套餐商品关系映射功能

- 新增findPackageRowIndexes方法查找商品所属套餐范围
- 在商品关系映射中增加套餐名称信息存储
- 保留套餐编码和名称供审核发布映射使用
- 维持原有商品品类落库规则不变
- 支持同一商品多行上架时的套餐信息关联
1 parent 6e23c8f3
......@@ -2120,13 +2120,35 @@ public class GoodsListingSubmitService {
// 商品品类关系按Excel行落库,而不是只按升级商品去重。
// 这样同一商品多行上架时,每行都能保留自己的merchant_goods_code和后续旧链路映射关系。
String relationKey = buildGoodsRelationRowKey(rowIndex);
relationMap.computeIfAbsent(relationKey, k -> buildGroupRelation(groupId, rowIndex, row, legalGoodsIndexMap, rowMerchantGoodsCodeMap, null, null, businessCode));
List<Integer> packageRowIndexes = findPackageRowIndexes(rowIndex, globalContext == null ? null : globalContext.getPackageGoodsIndexList());
String packageName = null;
if (CollectionUtils.isNotEmpty(packageRowIndexes)) {
// 商品规则仍按商品品类落库;如果商品来自套餐行,需要保留套餐编码和名称供审核发布映射。
packageName = resolvePackageName(packageRowIndexes, list);
}
String relationPackageName = packageName;
relationMap.computeIfAbsent(relationKey, k -> buildGroupRelation(groupId, rowIndex, row, legalGoodsIndexMap, rowMerchantGoodsCodeMap, null, relationPackageName, businessCode));
}
}
return new ArrayList<>(relationMap.values());
}
/**
* 查找当前商品行所属的套餐合并范围,仅用于商品关系行补写套餐信息,不改变规则的category_type。
*/
private List<Integer> findPackageRowIndexes(Integer rowIndex, List<List<Integer>> packageGoodsIndexList) {
if (rowIndex == null || CollectionUtils.isEmpty(packageGoodsIndexList)) {
return null;
}
for (List<Integer> packageRowIndexes : packageGoodsIndexList) {
if (CollectionUtils.isNotEmpty(packageRowIndexes) && packageRowIndexes.contains(rowIndex)) {
return packageRowIndexes;
}
}
return null;
}
/**
* 构建套餐品类关系行,套餐维度只写套餐编码和套餐名称。
*/
private GoodsListingGoodsTypeGroupRelation buildPackageGroupRelation(Integer groupId,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!