|
@@ -1,5 +1,6 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ym.mec.biz.dal.dao.GoodsDao;
|
|
|
import com.ym.mec.biz.dal.dao.GoodsProcurementDao;
|
|
@@ -55,6 +56,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);
|
|
|
}
|
|
@@ -138,7 +167,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);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -190,4 +219,19 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
|
|
|
return goodsList;
|
|
|
}
|
|
|
+
|
|
|
+ @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;
|
|
|
+ }
|
|
|
}
|