|
@@ -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,8 +66,7 @@ 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())){
|
|
if(Objects.nonNull(existsGood.getComplementGoodsIdList())){
|
|
@@ -80,26 +74,56 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
}
|
|
}
|
|
existsGood.setStockCount(existsGood.getStockCount()+goods.getStockCount());
|
|
existsGood.setStockCount(existsGood.getStockCount()+goods.getStockCount());
|
|
existsGood.setTaxStockCount(existsGood.getTaxStockCount()+existsGood.getTaxStockCount());
|
|
existsGood.setTaxStockCount(existsGood.getTaxStockCount()+existsGood.getTaxStockCount());
|
|
|
|
+ existsGood.setSellCount(0);
|
|
goodsDao.update(existsGood);
|
|
goodsDao.update(existsGood);
|
|
}else{
|
|
}else{
|
|
|
|
+ if(Objects.isNull(goods.getStockCount())){
|
|
|
|
+ goods.setStockCount(0);
|
|
|
|
+ }
|
|
|
|
+ if(Objects.isNull(goods.getTaxStockCount())){
|
|
|
|
+ goods.setTaxStockCount(0);
|
|
|
|
+ }
|
|
|
|
+ goods.setSellCount(0);
|
|
goodsDao.insert(goods);
|
|
goodsDao.insert(goods);
|
|
- existsGood=goods;
|
|
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- if(StringUtils.isBlank(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
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public void addGoodsProcurement(Goods goods, Integer operatorId) {
|
|
|
|
+ Goods existsGood = goodsDao.findBySn(goods.getSn());
|
|
|
|
+
|
|
|
|
+ if(Objects.isNull(existsGood)){
|
|
|
|
+ throw new BizException("商品不存在");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(StringUtils.isNotBlank(existsGood.getComplementGoodsIdList())){
|
|
|
|
+ throw new BizException("此商品为组合商品");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(Objects.isNull(goods.getStockCount())){
|
|
|
|
+ goods.setStockCount(0);
|
|
|
|
+ }
|
|
|
|
+ if(Objects.isNull(goods.getTaxStockCount())){
|
|
|
|
+ goods.setTaxStockCount(0);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ existsGood.setStockCount(existsGood.getStockCount()+goods.getStockCount());
|
|
|
|
+ existsGood.setTaxStockCount(existsGood.getTaxStockCount()+existsGood.getTaxStockCount());
|
|
|
|
+ goodsDao.update(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.setStockCount(goods.getStockCount());
|
|
|
|
+ gp.setTaxStockCount(goods.getTaxStockCount());
|
|
|
|
+ gp.setOperatorId(operatorId);
|
|
|
|
+ gp.setBatchNo(batchNo);
|
|
|
|
+ goodsProcurementDao.insert(gp);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -410,7 +434,13 @@ 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<>();
|
|
|
|
+ CostMap.put("sellCost", goodsProcurement.getDiscountPrice());
|
|
|
|
+ if (Objects.nonNull(goodsProcurement.getAgreeCostPrice())) {
|
|
|
|
+ CostMap.put("SellCost2", goodsProcurement.getAgreeCostPrice());
|
|
|
|
+ }
|
|
|
|
+ sellOrder.setSellCost2(JSON.toJSONString(CostMap));
|
|
sellOrders.add(sellOrder);
|
|
sellOrders.add(sellOrder);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -428,7 +458,13 @@ 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<>();
|
|
|
|
+ CostMap.put("sellCost", goodsProcurement.getDiscountPrice());
|
|
|
|
+ if (Objects.nonNull(goodsProcurement.getAgreeCostPrice())) {
|
|
|
|
+ CostMap.put("SellCost2", goodsProcurement.getAgreeCostPrice());
|
|
|
|
+ }
|
|
|
|
+ sellOrder.setSellCost2(JSON.toJSONString(CostMap));
|
|
}
|
|
}
|
|
sellOrders.add(sellOrder);
|
|
sellOrders.add(sellOrder);
|
|
}
|
|
}
|