|
@@ -86,20 +86,20 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
existsGood=goods;
|
|
|
}
|
|
|
|
|
|
- String batchNo = idGeneratorService.generatorId("payment") + "";
|
|
|
-
|
|
|
- GoodsProcurement gp = new GoodsProcurement();
|
|
|
- gp.setGoodsId(existsGood.getId());
|
|
|
- gp.setGoodsCategoryId(goods.getGoodsCategoryId());
|
|
|
- gp.setSupplyChannel(goods.getSupplyChannel());
|
|
|
- gp.setDiscountPrice(goods.getDiscountPrice());
|
|
|
- gp.setAgreeCostPrice(goods.getAgreeCostPrice());
|
|
|
- gp.setStockCount(goods.getStockCount());
|
|
|
- gp.setTaxStockCount(goods.getTaxStockCount());
|
|
|
- gp.setOperatorId(operatorId);
|
|
|
- gp.setBatchNo(batchNo);
|
|
|
-
|
|
|
- goodsProcurementDao.insert(gp);
|
|
|
+ if(StringUtils.isNotBlank(existsGood.getComplementGoodsIdList())){
|
|
|
+ String batchNo = idGeneratorService.generatorId("payment") + "";
|
|
|
+ GoodsProcurement gp = new GoodsProcurement();
|
|
|
+ gp.setGoodsId(existsGood.getId());
|
|
|
+ gp.setGoodsCategoryId(goods.getGoodsCategoryId());
|
|
|
+ gp.setSupplyChannel(goods.getSupplyChannel());
|
|
|
+ gp.setDiscountPrice(goods.getDiscountPrice());
|
|
|
+ gp.setAgreeCostPrice(goods.getAgreeCostPrice());
|
|
|
+ gp.setStockCount(goods.getStockCount());
|
|
|
+ gp.setTaxStockCount(goods.getTaxStockCount());
|
|
|
+ gp.setOperatorId(operatorId);
|
|
|
+ gp.setBatchNo(batchNo);
|
|
|
+ goodsProcurementDao.insert(gp);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -260,7 +260,8 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
gp.setGoodsId(existsSnIdMap.get(goods.getSn()));
|
|
|
gp.setGoodsCategoryId(goods.getGoodsCategoryId());
|
|
|
gp.setSupplyChannel(goods.getSupplyChannel());
|
|
|
- gp.setDiscountPrice(goods.getDiscountPrice());
|
|
|
+ gp.setDiscountPrice(goods.getCostPrice()
|
|
|
+ );
|
|
|
gp.setAgreeCostPrice(goods.getAgreeCostPrice());
|
|
|
gp.setStockCount(goods.getStockCount());
|
|
|
gp.setTaxStockCount(goods.getTaxStockCount());
|
|
@@ -349,8 +350,6 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
|
|
|
- Map<Integer, Long> goodsSellNumMap = goodsIds.stream().collect(Collectors.groupingBy(s -> s, Collectors.counting()));
|
|
|
-
|
|
|
List<Goods> tempGoodsList = goodsDao.lockGoods(new ArrayList<>(goodsIds));
|
|
|
Map<Integer, Goods> idTempGoodsMap = tempGoodsList.stream().collect(Collectors.toMap(Goods::getId, g -> g));
|
|
|
List<GoodsProcurement> goodsProcurements = new ArrayList<>();
|
|
@@ -363,7 +362,6 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
List<Integer> complementGoodsIds = Arrays.stream(tempGoods.getComplementGoodsIdList().split(",")).map(s -> Integer.valueOf(s)).collect(Collectors.toList());
|
|
|
childGoods = goodsDao.getGoodies(complementGoodsIds);
|
|
|
}
|
|
|
- tempGoods.setSellCount((int) (tempGoods.getSellCount() + goodsSellNumMap.get(tempGoods.getId())));
|
|
|
for (Goods goods : childGoods) {
|
|
|
GoodsProcurement goodsProcurement = null;
|
|
|
if(StockType.INTERNAL.equals(goods.getStockType())||(StockType.ALL.equals(goods.getStockType())&&AccountType.INTERNAL.equals(accountType))){
|
|
@@ -380,6 +378,8 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ goods.setSellCount(new AtomicInteger(goods.getSellCount()).incrementAndGet());
|
|
|
+
|
|
|
goodsDao.update(goods);
|
|
|
if(Objects.nonNull(goodsProcurement)){
|
|
|
goodsProcurementDao.update(goodsProcurement);
|
|
@@ -392,9 +392,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
|
|
|
goodsProcurements.add(goodsProcurement);
|
|
|
}
|
|
|
-// goodsDao.update(tempGoods);
|
|
|
}
|
|
|
- goodsDao.batchUpdate(tempGoodsList);
|
|
|
|
|
|
List<SellOrder> sellOrders = new ArrayList<>();
|
|
|
|
|
@@ -455,9 +453,6 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- List<Goods> goodsList = goodsDao.lockGoods(new ArrayList<>(goodsIdList));
|
|
|
- Map<Integer, Goods> idGoodsMap = goodsList.stream().collect(Collectors.toMap(Goods::getId, g -> g));
|
|
|
-
|
|
|
for (SellOrder sellOrder : sellOrders) {
|
|
|
Goods goods = goodsDao.get(sellOrder.getGoodsId());
|
|
|
GoodsProcurement goodsProcurement = goodsProcurementDao.getWithGoodsAndBatchNo(sellOrder.getGoodsId(), sellOrder.getBatchNo());
|
|
@@ -472,21 +467,10 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
goodsProcurement.setTaxStockSoldNum(new AtomicInteger(goodsProcurement.getTaxStockSoldNum()).addAndGet(-sellOrder.getNum()));
|
|
|
}
|
|
|
}
|
|
|
- if(Objects.isNull(sellOrder.getParentGoodsId())){
|
|
|
- goods.setSellCount(new AtomicInteger(goods.getSellCount()).addAndGet(-sellOrder.getNum()));
|
|
|
- }
|
|
|
- goodsDao.update(goods);
|
|
|
- goodsProcurementDao.update(goodsProcurement);
|
|
|
- }
|
|
|
+ goods.setSellCount(new AtomicInteger(goods.getSellCount()).addAndGet(-sellOrder.getNum()));
|
|
|
|
|
|
- //处理组合商品
|
|
|
- Map<Integer, Long> goodsNumMap = sellOrders.stream().filter(so -> Objects.nonNull(so.getParentGoodsId())).collect(Collectors.groupingBy(SellOrder::getParentGoodsId, Collectors.counting()));
|
|
|
- for (Map.Entry<Integer, Long> goodsIdNumMapEntry : goodsNumMap.entrySet()) {
|
|
|
- Goods goods = idGoodsMap.get(goodsIdNumMapEntry.getKey());
|
|
|
- int childGoodsNum = sellOrders.stream().filter(so -> goodsIdNumMapEntry.getKey().equals(so.getParentGoodsId())).map(SellOrder::getGoodsId).collect(Collectors.toSet()).size();
|
|
|
- int sellNum = (int) (goodsIdNumMapEntry.getValue()/childGoodsNum);
|
|
|
- goods.setSellCount(new AtomicInteger(goods.getSellCount()).addAndGet(-sellNum));
|
|
|
goodsDao.update(goods);
|
|
|
+ goodsProcurementDao.update(goodsProcurement);
|
|
|
}
|
|
|
}
|
|
|
|