|
@@ -630,7 +630,11 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
goodsCategoryQueryInfo.setRows(9999);
|
|
|
|
|
|
List<ProductCategoryDto> categoryList = mallFeignService.listWithChildren();
|
|
|
- List<ProductCategoryDto> allCategoryList = categoryList.stream().map(ProductCategoryDto::getChildren).filter(next->!next.isEmpty()).flatMap(Collection::stream).collect(Collectors.toList());
|
|
|
+ List<ProductCategoryDto> allCategoryList = categoryList.stream().map(next -> {
|
|
|
+ List<ProductCategoryDto> children = next.getChildren();
|
|
|
+ children.forEach(child -> child.setName(next.getName() + "/" + child.getName()));
|
|
|
+ return children;
|
|
|
+ }).filter(next -> !next.isEmpty()).flatMap(Collection::stream).collect(Collectors.toList());
|
|
|
Map<String, Long> categoryIdNameMap = allCategoryList
|
|
|
.stream().collect(Collectors.toMap(ProductCategoryDto::getName, ProductCategoryDto::getId));
|
|
|
Set<String> categoryNames = categoryIdNameMap.keySet();
|
|
@@ -668,8 +672,13 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- List<String> snSet = firstSheet.stream().map(next -> next.get("组合商品货号").toString()).filter(StringUtils::isNotEmpty).distinct().collect(Collectors.toList());
|
|
|
- List<String> existSnList = goodsDao.findBySns(snSet).stream().map(Goods::getSn).distinct().collect(Collectors.toList());
|
|
|
+ // excel中所有的sn
|
|
|
+ List<String> snSet = firstSheet.stream().map(next -> next.get("组合商品货号").toString()).filter(StringUtils::isNotEmpty).collect(Collectors.toList());
|
|
|
+ // 获取重复的货号
|
|
|
+ List<String> repeatSnList = snSet.stream().collect(Collectors.groupingBy(e -> e, Collectors.counting()))
|
|
|
+ .entrySet().stream().filter(e -> e.getValue() > 1)
|
|
|
+ .map(Map.Entry::getKey).collect(Collectors.toList());
|
|
|
+ List<String> existSnList = goodsDao.findBySns(snSet.stream().distinct().collect(Collectors.toList())).stream().map(Goods::getSn).distinct().collect(Collectors.toList());
|
|
|
|
|
|
Map<String, Long> brandNameIdMap = mallFeignService.getList().stream().collect(Collectors.toMap(BrandDto::getName, BrandDto::getId));
|
|
|
|
|
@@ -690,8 +699,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
|
|
|
String lineErrMsg = "错误行号:第%s行,%s";
|
|
|
Map<String, String> beforeGoods = new HashMap<>();
|
|
|
-
|
|
|
- Map<String, String> snNameMap = new HashMap<>();
|
|
|
+ Map<String, Set<String>> snSubGoodsMap = new HashMap<>();
|
|
|
for (int i = 0; i < rows.size(); i++) {
|
|
|
JSONObject objectMap = new JSONObject();
|
|
|
int rowNum = i + 2;
|
|
@@ -699,6 +707,11 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
if (row.size() == 0) {
|
|
|
continue;
|
|
|
}
|
|
|
+ // 新商品标志
|
|
|
+ String sn = row.get("组合商品货号").toString();
|
|
|
+ if (StringUtils.isNotEmpty(sn)) {
|
|
|
+ beforeGoods.clear();
|
|
|
+ }
|
|
|
String subGoodsName = null;
|
|
|
String subGoodsSku = null;
|
|
|
List<String> lineErrList = new ArrayList<>();
|
|
@@ -731,21 +744,16 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
} else {
|
|
|
beforeGoods.put(fieldCode, value);
|
|
|
}
|
|
|
- if("sn".equals(fieldCode)){
|
|
|
+ if ("sn".equals(fieldCode)) {
|
|
|
if (existSnList.contains(value)) {
|
|
|
lineErrList.add("货号[" + value + "]已存在");
|
|
|
} else {
|
|
|
- String goodsName = row.get("组合商品名称").toString();
|
|
|
- if (snNameMap.containsKey(value) && !snNameMap.get(value).equals(goodsName)) {
|
|
|
+ if (repeatSnList.contains(value)) {
|
|
|
lineErrList.add("货号[" + value + "]重复");
|
|
|
- } else {
|
|
|
- snNameMap.put(value, goodsName);
|
|
|
}
|
|
|
- objectMap.put(fieldCode, value);
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- if ("marketPrice".equals(fieldCode)
|
|
|
+ objectMap.put(fieldCode, value);
|
|
|
+ } else if ("marketPrice".equals(fieldCode)
|
|
|
|| "discountPrice".equals(fieldCode)
|
|
|
|| "groupPurchasePrice".equals(fieldCode)) {
|
|
|
if (NumberUtils.isNumber(value)) {
|
|
@@ -842,8 +850,21 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
!objectMap.containsKey("memberFeeShowOrganId") &&
|
|
|
!objectMap.containsKey("freeFeeShowOrganId") &&
|
|
|
!objectMap.containsKey("replacementShowOrganId")) {
|
|
|
- lineErrList.add("可售分部至少需要选择一个");
|
|
|
+ lineErrList.add("可售分部至少需要填写一个");
|
|
|
}
|
|
|
+ // 校验子商品sku是否重复
|
|
|
+ String tempSn = objectMap.get("sn").toString();
|
|
|
+ String tempSku = objectMap.get("sku").toString();
|
|
|
+ if (StringUtils.isNotEmpty(tempSn) && StringUtils.isNotEmpty(tempSku)) {
|
|
|
+ Set<String> set = snSubGoodsMap.getOrDefault(tempSn, new HashSet<>());
|
|
|
+ if (set.contains(tempSku)) {
|
|
|
+ lineErrList.add("子商品SKU重复");
|
|
|
+ } else {
|
|
|
+ set.add(tempSku);
|
|
|
+ snSubGoodsMap.put(tempSn, set);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (!lineErrList.isEmpty()) {
|
|
|
errList.add(String.format(lineErrMsg, rowNum, String.join(",", lineErrList)));
|
|
|
}
|
|
@@ -863,6 +884,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
List<GoodsWrapper.Goods> goodsList = jsonObjectList.stream().map(next -> {
|
|
|
String jsonString = next.toJSONString();
|
|
|
GoodsWrapper.Goods goods = JSON.parseObject(jsonString, GoodsWrapper.Goods.class);
|
|
|
+ goods.setSellCount(0);
|
|
|
GoodsWrapper.GoodsSub goodsSub = JSON.parseObject(jsonString, GoodsWrapper.GoodsSub.class);
|
|
|
ArrayList<GoodsWrapper.GoodsSub> arrayList = new ArrayList<>();
|
|
|
arrayList.add(goodsSub);
|