|  | @@ -2,18 +2,14 @@ package com.ym.mec.biz.service.impl;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  import com.alibaba.fastjson.JSON;
 |  |  import com.alibaba.fastjson.JSON;
 | 
											
												
													
														|  |  import com.alibaba.fastjson.JSONObject;
 |  |  import com.alibaba.fastjson.JSONObject;
 | 
											
												
													
														|  | -import com.ym.mec.auth.api.client.SysUserFeignService;
 |  | 
 | 
											
												
													
														|  | -import com.ym.mec.auth.api.entity.SysUser;
 |  | 
 | 
											
												
													
														|  |  import com.ym.mec.biz.dal.dao.*;
 |  |  import com.ym.mec.biz.dal.dao.*;
 | 
											
												
													
														|  |  import com.ym.mec.biz.dal.dto.BasicUserDto;
 |  |  import com.ym.mec.biz.dal.dto.BasicUserDto;
 | 
											
												
													
														|  | -import com.ym.mec.biz.dal.dto.GoodsBatchNoDto;
 |  | 
 | 
											
												
													
														|  |  import com.ym.mec.biz.dal.dto.GoodsSellDto;
 |  |  import com.ym.mec.biz.dal.dto.GoodsSellDto;
 | 
											
												
													
														|  |  import com.ym.mec.biz.dal.entity.Goods;
 |  |  import com.ym.mec.biz.dal.entity.Goods;
 | 
											
												
													
														|  |  import com.ym.mec.biz.dal.entity.GoodsProcurement;
 |  |  import com.ym.mec.biz.dal.entity.GoodsProcurement;
 | 
											
												
													
														|  |  import com.ym.mec.biz.dal.entity.SellOrder;
 |  |  import com.ym.mec.biz.dal.entity.SellOrder;
 | 
											
												
													
														|  |  import com.ym.mec.biz.dal.enums.*;
 |  |  import com.ym.mec.biz.dal.enums.*;
 | 
											
												
													
														|  |  import com.ym.mec.biz.service.GoodsService;
 |  |  import com.ym.mec.biz.service.GoodsService;
 | 
											
												
													
														|  | -import com.ym.mec.biz.service.SellOrderService;
 |  | 
 | 
											
												
													
														|  |  import com.ym.mec.biz.service.SysMessageService;
 |  |  import com.ym.mec.biz.service.SysMessageService;
 | 
											
												
													
														|  |  import com.ym.mec.biz.service.UploadFileService;
 |  |  import com.ym.mec.biz.service.UploadFileService;
 | 
											
												
													
														|  |  import com.ym.mec.common.dal.BaseDAO;
 |  |  import com.ym.mec.common.dal.BaseDAO;
 | 
											
										
											
												
													
														|  | @@ -24,7 +20,6 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 | 
											
												
													
														|  |  import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 |  |  import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 | 
											
												
													
														|  |  import com.ym.mec.util.excel.IniFileUtil;
 |  |  import com.ym.mec.util.excel.IniFileUtil;
 | 
											
												
													
														|  |  import com.ym.mec.util.excel.POIUtil;
 |  |  import com.ym.mec.util.excel.POIUtil;
 | 
											
												
													
														|  | -import org.apache.commons.lang3.ArrayUtils;
 |  | 
 | 
											
												
													
														|  |  import org.apache.commons.lang3.StringUtils;
 |  |  import org.apache.commons.lang3.StringUtils;
 | 
											
												
													
														|  |  import org.apache.poi.ss.usermodel.PictureData;
 |  |  import org.apache.poi.ss.usermodel.PictureData;
 | 
											
												
													
														|  |  import org.slf4j.Logger;
 |  |  import org.slf4j.Logger;
 | 
											
										
											
												
													
														|  | @@ -71,17 +66,10 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  	@Override
 |  |  	@Override
 | 
											
												
													
														|  | -	@Transactional(rollbackFor = Exception.class)
 |  | 
 | 
											
												
													
														|  | -	public void addGoodsProcurement(Goods goods, Integer operatorId) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +	public void addGoods(Goods goods, Integer operatorId) {
 | 
											
												
													
														|  |  		Goods existsGood = goodsDao.findBySn(goods.getSn());
 |  |  		Goods existsGood = goodsDao.findBySn(goods.getSn());
 | 
											
												
													
														|  |  		if(Objects.nonNull(existsGood)){
 |  |  		if(Objects.nonNull(existsGood)){
 | 
											
												
													
														|  | -			if(Objects.nonNull(existsGood.getComplementGoodsIdList())){
 |  | 
 | 
											
												
													
														|  | -				throw new BizException("此货号组合商品已存在");
 |  | 
 | 
											
												
													
														|  | -			}
 |  | 
 | 
											
												
													
														|  | -			existsGood.setStockCount(existsGood.getStockCount()+goods.getStockCount());
 |  | 
 | 
											
												
													
														|  | -			existsGood.setTaxStockCount(existsGood.getTaxStockCount()+existsGood.getTaxStockCount());
 |  | 
 | 
											
												
													
														|  | -			existsGood.setSellCount(0);
 |  | 
 | 
											
												
													
														|  | -			goodsDao.update(existsGood);
 |  | 
 | 
											
												
													
														|  | 
 |  | +			throw new BizException("商品货号重复");
 | 
											
												
													
														|  |  		}else{
 |  |  		}else{
 | 
											
												
													
														|  |  			if(Objects.isNull(goods.getStockCount())){
 |  |  			if(Objects.isNull(goods.getStockCount())){
 | 
											
												
													
														|  |  				goods.setStockCount(0);
 |  |  				goods.setStockCount(0);
 | 
											
										
											
												
													
														|  | @@ -95,6 +83,37 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  	@Override
 |  |  	@Override
 | 
											
												
													
														|  | 
 |  | +	@Transactional(rollbackFor = Exception.class)
 | 
											
												
													
														|  | 
 |  | +	public void addGoodsProcurement(GoodsProcurement goodsProcurement) {
 | 
											
												
													
														|  | 
 |  | +		Goods existsGood = goodsDao.get(goodsProcurement.getGoodsId());
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		if(Objects.isNull(existsGood)){
 | 
											
												
													
														|  | 
 |  | +			throw new BizException("商品不存在");
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		if(StringUtils.isNotBlank(existsGood.getComplementGoodsIdList())){
 | 
											
												
													
														|  | 
 |  | +			throw new BizException("此商品为组合商品");
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		if(Objects.isNull(goodsProcurement.getStockCount())){
 | 
											
												
													
														|  | 
 |  | +			goodsProcurement.setStockCount(0);
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +		if(Objects.isNull(goodsProcurement.getTaxStockCount())){
 | 
											
												
													
														|  | 
 |  | +			goodsProcurement.setTaxStockCount(0);
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		existsGood.setStockCount(existsGood.getStockCount()+goodsProcurement.getStockCount());
 | 
											
												
													
														|  | 
 |  | +		existsGood.setTaxStockCount(existsGood.getTaxStockCount()+goodsProcurement.getTaxStockCount());
 | 
											
												
													
														|  | 
 |  | +		goodsDao.update(existsGood);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		String batchNo = idGeneratorService.generatorId("payment") + "";
 | 
											
												
													
														|  | 
 |  | +		goodsProcurement.setBatchNo(batchNo);
 | 
											
												
													
														|  | 
 |  | +		goodsProcurementDao.insert(goodsProcurement);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		sellOrderBatchNoAllot();
 | 
											
												
													
														|  | 
 |  | +	}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +	@Override
 | 
											
												
													
														|  |  	public void updateGoodsStatus(Integer goodsId, Integer status) {
 |  |  	public void updateGoodsStatus(Integer goodsId, Integer status) {
 | 
											
												
													
														|  |  		if(Objects.isNull(goodsId)){
 |  |  		if(Objects.isNull(goodsId)){
 | 
											
												
													
														|  |  			throw new BizException("请指定商品");
 |  |  			throw new BizException("请指定商品");
 | 
											
										
											
												
													
														|  | @@ -231,6 +250,40 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 | 
											
												
													
														|  |  			int taxStockCount = goods.stream().mapToInt(Goods::getTaxStockCount).sum();
 |  |  			int taxStockCount = goods.stream().mapToInt(Goods::getTaxStockCount).sum();
 | 
											
												
													
														|  |  			existsGood.setStockCount((Objects.isNull(existsGood.getStockCount())?0:existsGood.getStockCount()) + stockCount);
 |  |  			existsGood.setStockCount((Objects.isNull(existsGood.getStockCount())?0:existsGood.getStockCount()) + stockCount);
 | 
											
												
													
														|  |  			existsGood.setTaxStockCount((Objects.isNull(existsGood.getTaxStockCount())?0:existsGood.getTaxStockCount()) + taxStockCount);
 |  |  			existsGood.setTaxStockCount((Objects.isNull(existsGood.getTaxStockCount())?0:existsGood.getTaxStockCount()) + taxStockCount);
 | 
											
												
													
														|  | 
 |  | +			Goods newGoods = goods.get(0);
 | 
											
												
													
														|  | 
 |  | +			if(Objects.nonNull(newGoods.getGoodsCategoryId())&&!newGoods.getGoodsCategoryId().equals(existsGood.getGoodsCategoryId())){
 | 
											
												
													
														|  | 
 |  | +				existsGood.setGoodsCategoryId(newGoods.getGoodsCategoryId());
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			if(Objects.nonNull(newGoods.getName())&&!newGoods.getName().equals(existsGood.getName())){
 | 
											
												
													
														|  | 
 |  | +				existsGood.setName(newGoods.getName());
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			if(Objects.nonNull(newGoods.getType())&&!newGoods.getType().equals(existsGood.getType())){
 | 
											
												
													
														|  | 
 |  | +				existsGood.setType(newGoods.getType());
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			if(Objects.nonNull(newGoods.getSpecification())&&!newGoods.getSpecification().equals(existsGood.getSpecification())){
 | 
											
												
													
														|  | 
 |  | +				existsGood.setSpecification(newGoods.getSpecification());
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			if(Objects.nonNull(newGoods.getMarketPrice())&&!newGoods.getMarketPrice().equals(existsGood.getMarketPrice())){
 | 
											
												
													
														|  | 
 |  | +				existsGood.setMarketPrice(newGoods.getMarketPrice());
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			if(Objects.nonNull(newGoods.getDiscountPrice())&&!newGoods.getDiscountPrice().equals(existsGood.getDiscountPrice())){
 | 
											
												
													
														|  | 
 |  | +				existsGood.setDiscountPrice(newGoods.getDiscountPrice());
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			if(Objects.nonNull(newGoods.getGroupPurchasePrice())&&!newGoods.getGroupPurchasePrice().equals(existsGood.getGroupPurchasePrice())){
 | 
											
												
													
														|  | 
 |  | +				existsGood.setGroupPurchasePrice(newGoods.getGroupPurchasePrice());
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			if(Objects.nonNull(newGoods.getImage())&&!newGoods.getImage().equals(existsGood.getImage())){
 | 
											
												
													
														|  | 
 |  | +				existsGood.setImage(newGoods.getImage());
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			if(Objects.nonNull(newGoods.getStockType())&&!newGoods.getStockType().equals(existsGood.getStockType())){
 | 
											
												
													
														|  | 
 |  | +				existsGood.setStockType(newGoods.getStockType());
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			if(Objects.nonNull(newGoods.getBrief())&&!newGoods.getBrief().equals(existsGood.getBrief())){
 | 
											
												
													
														|  | 
 |  | +				existsGood.setBrief(newGoods.getBrief());
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			if(Objects.nonNull(newGoods.getStockWarning())&&!newGoods.getStockWarning().equals(existsGood.getStockWarning())){
 | 
											
												
													
														|  | 
 |  | +				existsGood.setStockWarning(newGoods.getStockWarning());
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		if(!CollectionUtils.isEmpty(existsGoods)){
 |  |  		if(!CollectionUtils.isEmpty(existsGoods)){
 | 
											
										
											
												
													
														|  | @@ -252,8 +305,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 | 
											
												
													
														|  |  			gp.setGoodsId(existsSnIdMap.get(goods.getSn()));
 |  |  			gp.setGoodsId(existsSnIdMap.get(goods.getSn()));
 | 
											
												
													
														|  |  			gp.setGoodsCategoryId(goods.getGoodsCategoryId());
 |  |  			gp.setGoodsCategoryId(goods.getGoodsCategoryId());
 | 
											
												
													
														|  |  			gp.setSupplyChannel(goods.getSupplyChannel());
 |  |  			gp.setSupplyChannel(goods.getSupplyChannel());
 | 
											
												
													
														|  | -			gp.setDiscountPrice(goods.getCostPrice()
 |  | 
 | 
											
												
													
														|  | -			);
 |  | 
 | 
											
												
													
														|  | 
 |  | +			gp.setDiscountPrice(goods.getCostPrice());
 | 
											
												
													
														|  |  			gp.setAgreeCostPrice(goods.getAgreeCostPrice());
 |  |  			gp.setAgreeCostPrice(goods.getAgreeCostPrice());
 | 
											
												
													
														|  |  			gp.setStockCount(goods.getStockCount());
 |  |  			gp.setStockCount(goods.getStockCount());
 | 
											
												
													
														|  |  			gp.setTaxStockCount(goods.getTaxStockCount());
 |  |  			gp.setTaxStockCount(goods.getTaxStockCount());
 | 
											
										
											
												
													
														|  | @@ -402,7 +454,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 | 
											
												
													
														|  |  					sellOrder.setAccountType(accountType);
 |  |  					sellOrder.setAccountType(accountType);
 | 
											
												
													
														|  |  					sellOrder.setBatchNo(batchNoGoodsIdMapEntry.getKey());
 |  |  					sellOrder.setBatchNo(batchNoGoodsIdMapEntry.getKey());
 | 
											
												
													
														|  |  					GoodsProcurement goodsProcurement = goodsProcurementDao.getWithGoodsAndBatchNo(sellOrder.getGoodsId(), sellOrder.getBatchNo());
 |  |  					GoodsProcurement goodsProcurement = goodsProcurementDao.getWithGoodsAndBatchNo(sellOrder.getGoodsId(), sellOrder.getBatchNo());
 | 
											
												
													
														|  | -					sellOrder.setSellCost(goodsProcurement.getDiscountPrice().multiply(new BigDecimal(sellOrder.getNum())));
 |  | 
 | 
											
												
													
														|  | 
 |  | +					sellOrder.setSellCost(goodsProcurement.getDiscountPrice());
 | 
											
												
													
														|  |  					Map<String, BigDecimal> CostMap = new HashMap<>();
 |  |  					Map<String, BigDecimal> CostMap = new HashMap<>();
 | 
											
												
													
														|  |  					CostMap.put("sellCost", goodsProcurement.getDiscountPrice());
 |  |  					CostMap.put("sellCost", goodsProcurement.getDiscountPrice());
 | 
											
												
													
														|  |  					if (Objects.nonNull(goodsProcurement.getAgreeCostPrice())) {
 |  |  					if (Objects.nonNull(goodsProcurement.getAgreeCostPrice())) {
 | 
											
										
											
												
													
														|  | @@ -426,7 +478,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 | 
											
												
													
														|  |  				sellOrder.setAccountType(accountType);
 |  |  				sellOrder.setAccountType(accountType);
 | 
											
												
													
														|  |  				sellOrder.setBatchNo(goodsProcurement.getBatchNo());
 |  |  				sellOrder.setBatchNo(goodsProcurement.getBatchNo());
 | 
											
												
													
														|  |  				if(Objects.nonNull(goodsProcurement.getBatchNo())){
 |  |  				if(Objects.nonNull(goodsProcurement.getBatchNo())){
 | 
											
												
													
														|  | -					sellOrder.setSellCost(goodsProcurement.getDiscountPrice().multiply(new BigDecimal(sellOrder.getNum())));
 |  | 
 | 
											
												
													
														|  | 
 |  | +					sellOrder.setSellCost(goodsProcurement.getDiscountPrice());
 | 
											
												
													
														|  |  					Map<String, BigDecimal> CostMap = new HashMap<>();
 |  |  					Map<String, BigDecimal> CostMap = new HashMap<>();
 | 
											
												
													
														|  |  					CostMap.put("sellCost", goodsProcurement.getDiscountPrice());
 |  |  					CostMap.put("sellCost", goodsProcurement.getDiscountPrice());
 | 
											
												
													
														|  |  					if (Objects.nonNull(goodsProcurement.getAgreeCostPrice())) {
 |  |  					if (Objects.nonNull(goodsProcurement.getAgreeCostPrice())) {
 |