Commit bbe01152 by 崔彦峰

refactor(goods): 优化商品套餐去重逻辑和自动分账开关处理

- 移除套餐签名计数Map,直接在套餐内部进行商品去重校验
- 将套餐内商品去重逻辑从buildCommodityPositionKey改为buildPackageGoodsUniqueKey
- 根据场景码区分商品唯一性校验策略:权益按商品ID,精品升级按商品ID+部位
- 统一自动分账开关判断逻辑,仅识别"是"/"否"中文文案
- 修复重复商品错误提示的索引位置显示问题
1 parent 9a086022
...@@ -791,7 +791,6 @@ public class GoodsListingSubmitService { ...@@ -791,7 +791,6 @@ public class GoodsListingSubmitService {
return; return;
} }
Map<String, Integer> packageSignatureCount = new LinkedHashMap<>();
for (List<Integer> goodsIndexList : packageGoodsIndexList) { for (List<Integer> goodsIndexList : packageGoodsIndexList) {
if (CollectionUtils.isEmpty(goodsIndexList)) { if (CollectionUtils.isEmpty(goodsIndexList)) {
continue; continue;
...@@ -827,26 +826,15 @@ public class GoodsListingSubmitService { ...@@ -827,26 +826,15 @@ public class GoodsListingSubmitService {
} }
}*/ }*/
Set<String> innerCommodityPositionSet = new HashSet<>(); Set<String> innerPackageGoodsKeySet = new HashSet<>();
for (Integer index : goodsIndexList) { for (Integer index : goodsIndexList) {
if (index == null || index < 0 || index >= list.size()) { if (index == null || index < 0 || index >= list.size()) {
continue; continue;
} }
String key = buildCommodityPositionKey(list.get(index)); // 重复商品只校验套餐内部:权益按商品ID,精品升级按商品ID+部位。
if (!innerCommodityPositionSet.add(key)) { String key = buildPackageGoodsUniqueKey(list.get(index), submitDTO.getBaseSceneCode());
setLineError(errorList, "套餐内商品重复", firstIndex); if (!innerPackageGoodsKeySet.add(key)) {
break; setLineError(errorList, "套餐内商品重复", index);
}
}
List<String> sortedSignatureList = new ArrayList<>(innerCommodityPositionSet);
sortedSignatureList.sort(Comparator.naturalOrder());
String signature = String.join(",", sortedSignatureList);
if (StringUtils.isNotBlank(signature)) {
Integer count = packageSignatureCount.getOrDefault(signature, 0) + 1;
packageSignatureCount.put(signature, count);
if (count > 1) {
setLineError(errorList, "检测到重复套餐", firstIndex);
} }
} }
} }
...@@ -3146,11 +3134,12 @@ public class GoodsListingSubmitService { ...@@ -3146,11 +3134,12 @@ public class GoodsListingSubmitService {
if (StringUtils.isBlank(value)) { if (StringUtils.isBlank(value)) {
return null; return null;
} }
String normalized = value.trim().toUpperCase(); // 自动分账开关对齐旧链路中文文案判断,只识别“是/否”。
if ("Y".equals(normalized) || "YES".equals(normalized) || "1".equals(normalized) || value.contains("是")) { String normalized = value.trim();
if (Objects.equals(normalized, "是")) {
return Boolean.TRUE; return Boolean.TRUE;
} }
if ("N".equals(normalized) || "NO".equals(normalized) || "0".equals(normalized) || value.contains("否")) { if (Objects.equals(normalized, "否")) {
return Boolean.FALSE; return Boolean.FALSE;
} }
return null; return null;
...@@ -3661,7 +3650,7 @@ public class GoodsListingSubmitService { ...@@ -3661,7 +3650,7 @@ public class GoodsListingSubmitService {
if (StringUtils.isBlank(value)) { if (StringUtils.isBlank(value)) {
return "N"; return "N";
} }
if ("Y".equalsIgnoreCase(value) || "YES".equalsIgnoreCase(value) || "1".equals(value) || value.contains("是")) { if (Objects.equals(value.trim(), "是")) {
return "Y"; return "Y";
} }
return "N"; return "N";
...@@ -3768,8 +3757,12 @@ public class GoodsListingSubmitService { ...@@ -3768,8 +3757,12 @@ public class GoodsListingSubmitService {
return "G|" + defaultIfBlank(normalize(row.getUpgradeCommodityCode()), String.valueOf(index + 1)); return "G|" + defaultIfBlank(normalize(row.getUpgradeCommodityCode()), String.valueOf(index + 1));
} }
private String buildCommodityPositionKey(CreateBusinessApproveAllImportVo row) { private String buildPackageGoodsUniqueKey(CreateBusinessApproveAllImportVo row, String baseSceneCode) {
return defaultIfBlank(normalize(row.getUpgradeCommodityCode()), "") + defaultIfBlank(normalize(row.getPosition()), ""); String commodityCode = defaultIfBlank(normalize(row.getUpgradeCommodityCode()), "");
if (isSceneBoutique(baseSceneCode)) {
return commodityCode + "|" + defaultIfBlank(normalize(row.getPosition()), "");
}
return commodityCode;
} }
private Integer parsePosition(String value) { private Integer parsePosition(String value) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!