|
@@ -204,22 +204,22 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void addGoods(List<GoodsWrapper.Goods> goodsList, Integer operatorId) {
|
|
|
- List<String> snList = goodsList.stream().map(GoodsWrapper.Goods::getSn).collect(Collectors.toList());
|
|
|
- if (snList.size() != new HashSet<>(snList).size()) {
|
|
|
- throw new BizException("商品货号重复");
|
|
|
- }
|
|
|
- List<Goods> bySns = goodsDao.findBySns(snList);
|
|
|
- if (!CollectionUtils.isEmpty(bySns)) {
|
|
|
- throw new BizException("商品货号重复");
|
|
|
- }
|
|
|
+// List<String> snList = goodsList.stream().map(GoodsWrapper.Goods::getSn).collect(Collectors.toList());
|
|
|
+// if (snList.size() != new HashSet<>(snList).size()) {
|
|
|
+// throw new BizException("商品货号重复");
|
|
|
+// }
|
|
|
+// List<Goods> bySns = goodsDao.findBySns(snList);
|
|
|
+// if (!CollectionUtils.isEmpty(bySns)) {
|
|
|
+// throw new BizException("商品货号重复");
|
|
|
+// }
|
|
|
for (GoodsWrapper.Goods goods : goodsList) {
|
|
|
if (StringUtils.isBlank(goods.getSn())) {
|
|
|
throw new BizException("请指定商品货号");
|
|
|
}
|
|
|
- Goods existsGood = goodsDao.lockBySn(goods.getSn());
|
|
|
- if (Objects.nonNull(existsGood)) {
|
|
|
- throw new BizException("商品货号重复");
|
|
|
- }
|
|
|
+// Goods existsGood = goodsDao.lockBySn(goods.getSn());
|
|
|
+// if (Objects.nonNull(existsGood)) {
|
|
|
+// throw new BizException("商品货号重复");
|
|
|
+// }
|
|
|
List<GoodsWrapper.GoodsSub> goodsSubList = goods.getGoodsSubList();
|
|
|
//获取最小的库存数
|
|
|
String skuIds = goodsSubList.stream().map(e -> e.getSku().toString()).collect(Collectors.joining(","));
|
|
@@ -666,12 +666,12 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
});
|
|
|
|
|
|
// excel中所有的sn
|
|
|
- List<String> snSet = firstSheet.stream().map(next -> next.get("组合商品货号").toString()).filter(StringUtils::isNotEmpty).collect(Collectors.toList());
|
|
|
+// 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());
|
|
|
+// 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));
|
|
|
|
|
@@ -705,6 +705,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
String sn = row.get("组合商品货号").toString();
|
|
|
if (StringUtils.isNotEmpty(sn)) {
|
|
|
beforeGoods.clear();
|
|
|
+ snSubGoodsMap.clear();
|
|
|
}
|
|
|
String subGoodsName = null;
|
|
|
String subGoodsSku = null;
|
|
@@ -749,16 +750,17 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
}
|
|
|
beforeGoods.put(fieldCode, value);
|
|
|
}
|
|
|
- if ("sn".equals(fieldCode)) {
|
|
|
- if (existSnList.contains(value.toString())) {
|
|
|
- lineErrList.add("货号[" + value + "]已存在");
|
|
|
- } else {
|
|
|
- if (repeatSnList.contains(value.toString())) {
|
|
|
- lineErrList.add("货号[" + value + "]重复");
|
|
|
- }
|
|
|
- }
|
|
|
- objectMap.put(fieldCode, value);
|
|
|
- } else if ("marketPrice".equals(fieldCode)
|
|
|
+// if ("sn".equals(fieldCode)) {
|
|
|
+// if (existSnList.contains(value.toString())) {
|
|
|
+// lineErrList.add("货号[" + value + "]已存在");
|
|
|
+// } else {
|
|
|
+// if (repeatSnList.contains(value.toString())) {
|
|
|
+// lineErrList.add("货号[" + value + "]重复");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// objectMap.put(fieldCode, value);
|
|
|
+// } else
|
|
|
+ if ("marketPrice".equals(fieldCode)
|
|
|
|| "discountPrice".equals(fieldCode)
|
|
|
|| "groupPurchasePrice".equals(fieldCode)) {
|
|
|
if (NumberUtils.isNumber(value.toString())) {
|
|
@@ -1270,6 +1272,11 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
}
|
|
|
GoodsWrapper.Goods detail = JSON.parseObject(JSON.toJSONString(goods), GoodsWrapper.Goods.class);
|
|
|
detail.setGoodsSubList(queryGoodsSubByGoodId(goodsId));
|
|
|
+ String brand = detail.getBrand();
|
|
|
+ if (StringUtils.isNotEmpty(brand) && NumberUtils.isNumber(brand)) {
|
|
|
+ Map<Long, String> brandIdNameMap = queryGoodsBrandList().stream().collect(Collectors.toMap(BrandDto::getId, BrandDto::getName));
|
|
|
+ detail.setBrandName(brandIdNameMap.getOrDefault(Long.valueOf(brand), ""));
|
|
|
+ }
|
|
|
return detail;
|
|
|
}
|
|
|
|
|
@@ -1298,15 +1305,6 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
goodsInfo = JSON.parseObject(JSON.toJSONString(goods), Goods.class);
|
|
|
goodsInfo.setStatus(null);
|
|
|
if (!goodsSubList.isEmpty()) {
|
|
|
- goodsInfo.setComplementGoodsIdList(null);
|
|
|
- UpdateWrapper<GoodsSub> delWrapper = new UpdateWrapper<>();
|
|
|
- delWrapper.eq("goods_id_", goods.getId());
|
|
|
- goodsSubService.getBaseMapper().delete(delWrapper);
|
|
|
-
|
|
|
- List<GoodsSub> goodsSubs = JSON.parseArray(JSON.toJSONString(goodsSubList), GoodsSub.class);
|
|
|
- goodsSubs.forEach(next -> next.setGoodsId(goods.getId()));
|
|
|
- goodsSubService.saveBatch(goodsSubs);
|
|
|
-
|
|
|
BigDecimal organCostPrice = goodsSubList.stream().map(GoodsWrapper.GoodsSub::getGoodsPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
goodsInfo.setOrganCostPrice(organCostPrice);
|
|
|
|
|
@@ -1321,6 +1319,24 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
if(CollectionUtils.isEmpty(productList)){
|
|
|
throw new BizException("子商品不存在");
|
|
|
}
|
|
|
+ Map<Integer, Long> skuIdGoodIdMap = productList.stream().collect(Collectors.toMap(PmsProductDto::getSkuStockId, PmsProductDto::getGoodsId));
|
|
|
+
|
|
|
+ List<GoodsSub> goodsSubs = JSON.parseArray(JSON.toJSONString(goodsSubList), GoodsSub.class);
|
|
|
+ for (GoodsSub next : goodsSubs) {
|
|
|
+ next.setGoodsId(goods.getId());
|
|
|
+ if (skuIdGoodIdMap.containsKey(next.getSku())) {
|
|
|
+ next.setMallGoodsId(skuIdGoodIdMap.get(next.getSku()).intValue());
|
|
|
+ } else {
|
|
|
+ throw new BizException("存在删除的子商品");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ UpdateWrapper<GoodsSub> delWrapper = new UpdateWrapper<>();
|
|
|
+ delWrapper.eq("goods_id_", goods.getId());
|
|
|
+ goodsSubService.getBaseMapper().delete(delWrapper);
|
|
|
+ goodsSubService.saveBatch(goodsSubs);
|
|
|
+
|
|
|
+ goodsInfo.setComplementGoodsIdList(null);
|
|
|
//获取最小库存数量
|
|
|
Integer stock = productList.stream().map(PmsProductDto::getStock).min(Integer::compareTo).get();
|
|
|
goodsInfo.setStockCount(stock);
|