Prechádzať zdrojové kódy

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

zouxuan 5 rokov pred
rodič
commit
46b9860db7

+ 13 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Goods.java

@@ -64,13 +64,16 @@ public class Goods {
 	private BigDecimal marketPrice;
 
 	/** 折扣价 */
-	@ApiModelProperty(value = "折扣价",required = false)
+	@ApiModelProperty(value = "商品零售价",required = false)
 	private BigDecimal discountPrice;
 
 	/** 团购价 */
 	@ApiModelProperty(value = "团购价",required = false)
 	private BigDecimal groupPurchasePrice;
 
+	@ApiModelProperty(value = "商品价格1")
+	private BigDecimal costPrice;
+
 	/** 协议成本价 */
 	@ApiModelProperty(value = "协议成本价",required = false)
 	private BigDecimal agreeCostPrice;
@@ -174,7 +177,15 @@ public class Goods {
         this.subjectIds = subjectIds;
     }
 
-    public String getGoodsCategoryName() {
+	public BigDecimal getCostPrice() {
+		return costPrice;
+	}
+
+	public void setCostPrice(BigDecimal costPrice) {
+		this.costPrice = costPrice;
+	}
+
+	public String getGoodsCategoryName() {
 		return goodsCategoryName;
 	}
 

+ 20 - 36
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java

@@ -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);
 		}
 	}
 

+ 4 - 2
mec-web/src/main/resources/columnMapper.ini

@@ -5,9 +5,10 @@
 商品类型 = type
 商品分类 = goodsCategoryName
 具体型号 = specification
-商品价格(元) = marketPrice
+商品市场价(元) = marketPrice
+商品零售价 = discountPrice
 商品团购价(元) = groupPurchasePrice
-商品采购价1(元) = discountPrice
+商品采购价1(元) = costPrice
 商品图片(插入一张图片) = image
 商品明细 = desc
 商品采购价2(元) = agreeCostPrice
@@ -19,6 +20,7 @@
 商品详情 = desc
 库存预警 = stockWarning
 
+
 [财务支出导入模板]
 财务流程编号 = financialProcessNo
 钉钉流程编号 = dingtalkProcessNo

BIN
mec-web/src/main/resources/excelTemplate/商品导入模板.xls