|  | @@ -1,11 +1,14 @@
 | 
	
		
			
				|  |  |  package com.ym.mec.biz.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  |  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.GoodsDao;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dao.GoodsProcurementDao;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dao.SysConfigDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.TeacherDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dto.BasicUserDto;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.entity.Goods;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.entity.GoodsProcurement;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.enums.GoodsType;
 | 
	
	
		
			
				|  | @@ -56,7 +59,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 | 
	
		
			
				|  |  |  	@Autowired
 | 
	
		
			
				|  |  |  	private SysMessageService sysMessageService;
 | 
	
		
			
				|  |  |  	@Autowired
 | 
	
		
			
				|  |  | -	private SysUserFeignService sysUserFeignService;
 | 
	
		
			
				|  |  | +	private TeacherDao teacherDao;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	@Override
 | 
	
		
			
				|  |  |  	public BaseDAO<Integer, Goods> getDAO() {
 | 
	
	
		
			
				|  | @@ -64,6 +67,34 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	@Override
 | 
	
		
			
				|  |  | +	@Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | +	public void addGoodsProcurement(Goods goods, Integer operatorId) {
 | 
	
		
			
				|  |  | +		Goods existsGood = goodsDao.findBySn(goods.getSn());
 | 
	
		
			
				|  |  | +		if(Objects.nonNull(existsGood)){
 | 
	
		
			
				|  |  | +			existsGood.setStockCount(existsGood.getStockCount()+goods.getStockCount());
 | 
	
		
			
				|  |  | +			existsGood.setTaxStockCount(existsGood.getTaxStockCount()+existsGood.getTaxStockCount());
 | 
	
		
			
				|  |  | +			goodsDao.update(existsGood);
 | 
	
		
			
				|  |  | +		}else{
 | 
	
		
			
				|  |  | +			goodsDao.insert(existsGood);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		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.setTotalQuantity(goods.getStockCount());
 | 
	
		
			
				|  |  | +		gp.setTaxQuantity(goods.getTaxStockCount());
 | 
	
		
			
				|  |  | +		gp.setOperatorId(operatorId);
 | 
	
		
			
				|  |  | +		gp.setBatchNo(batchNo);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		goodsProcurementDao.insert(gp);
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	@Override
 | 
	
		
			
				|  |  |  	public List<Goods> findGoodsBySubId(Integer subjectId,String type) {
 | 
	
		
			
				|  |  |  		return goodsDao.findGoodsBySubId(subjectId,type);
 | 
	
		
			
				|  |  |  	}
 | 
	
	
		
			
				|  | @@ -147,7 +178,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 | 
	
		
			
				|  |  |  					goods = JSONObject.parseObject(objectMap.toJSONString(),Goods.class);
 | 
	
		
			
				|  |  |  					goodsList.add(goods);
 | 
	
		
			
				|  |  |  				} catch (Exception ex) {
 | 
	
		
			
				|  |  | -					throw new BizException("导入数据出错");
 | 
	
		
			
				|  |  | +					throw new BizException("导入数据出错", ex);
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  		}
 | 
	
	
		
			
				|  | @@ -207,12 +238,12 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 | 
	
		
			
				|  |  |  		if(StringUtils.isEmpty(repertoryWarnPhone)){
 | 
	
		
			
				|  |  |  			return;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  | -		SysUser sysUser = sysUserFeignService.queryUserByMobile(repertoryWarnPhone);
 | 
	
		
			
				|  |  | -		if(sysUser == null || sysUser.getId() == null){
 | 
	
		
			
				|  |  | +		BasicUserDto sysUser = teacherDao.findUserByPhone(repertoryWarnPhone);
 | 
	
		
			
				|  |  | +		if(sysUser == null || sysUser.getUserId() == null){
 | 
	
		
			
				|  |  |  			throw new BizException("库存预警手机号不存在");
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		Map<Integer, String> receivers = new HashMap<>(1);
 | 
	
		
			
				|  |  | -		receivers.put(sysUser.getId(), repertoryWarnPhone);
 | 
	
		
			
				|  |  | +		receivers.put(sysUser.getUserId(), repertoryWarnPhone);
 | 
	
		
			
				|  |  |  		//内部库存预警
 | 
	
		
			
				|  |  |  		String innerRepertoryWarnNum = sysConfigDao.findConfigValue("inner_repertory_warn_num");
 | 
	
		
			
				|  |  |  		if(StringUtils.isNotEmpty(innerRepertoryWarnNum)){
 | 
	
	
		
			
				|  | @@ -233,4 +264,19 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	@Override
 | 
	
		
			
				|  |  | +	@Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | +	public String subtractStock(List<Integer> goodsIds) {
 | 
	
		
			
				|  |  | +		List result = new ArrayList();
 | 
	
		
			
				|  |  | +		if(CollectionUtils.isEmpty(goodsIds)){
 | 
	
		
			
				|  |  | +			return JSONObject.toJSONString(result);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		List<Goods> tempGoods = goodsDao.getGoodies(goodsIds);
 | 
	
		
			
				|  |  | +		List<Integer> realGoodIds = new ArrayList<>();
 | 
	
		
			
				|  |  | +		for (Goods tempGood : tempGoods) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return null;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  |  }
 |