|
@@ -249,6 +249,21 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements Go
|
|
|
//1.获取商品规格值
|
|
//1.获取商品规格值
|
|
|
List<GoodsAttrValue> attr = goodsAttr.getAttrValue();
|
|
List<GoodsAttrValue> attr = goodsAttr.getAttrValue();
|
|
|
int attrSize = attr.size();
|
|
int attrSize = attr.size();
|
|
|
|
|
+
|
|
|
|
|
+ // 临时校验规则总组合数
|
|
|
|
|
+ final long MAX_ALLOW_SKU = 5000;
|
|
|
|
|
+ long totalCombination = 1L;
|
|
|
|
|
+ for (GoodsAttrValue goodsAttrValue : attr) {
|
|
|
|
|
+ String detail = goodsAttrValue.getDetail();
|
|
|
|
|
+ int optionCount = detail.split(",").length;
|
|
|
|
|
+ // 每个规格的选项数相乘,得到总组合数
|
|
|
|
|
+ totalCombination = totalCombination * optionCount;
|
|
|
|
|
+ // 超过阈值直接返回错误,避免继续生成撑爆内存
|
|
|
|
|
+ if (totalCombination > MAX_ALLOW_SKU) {
|
|
|
|
|
+ throw new SqxException("SKU规格选项过多,总组合数超过上限" + MAX_ALLOW_SKU + ",请减少规格/规格选项数量");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//2.准备返回值
|
|
//2.准备返回值
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
List<String> header = new ArrayList<>(); //表头
|
|
List<String> header = new ArrayList<>(); //表头
|