|
@@ -1287,11 +1287,23 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
public ResultMap updateGoods(Goods goods) {
|
|
public ResultMap updateGoods(Goods goods) {
|
|
|
Goods resultGoods = null;
|
|
Goods resultGoods = null;
|
|
|
Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
|
|
+ if (goods.getProductid() == null) {
|
|
|
|
|
+ throw new IllegalOperatorException("关联的物料信息为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ Goods nowGoods = null;
|
|
|
if (!StringUtils.isEmpty(goods.getBatchCode())) {
|
|
if (!StringUtils.isEmpty(goods.getBatchCode())) {
|
|
|
- Goods nowGoods = goodsDao.findByBatchCode(goods.getBatchCode());
|
|
|
|
|
- if (nowGoods == null) {
|
|
|
|
|
- return new ResultMap(CodeType.NOT_PERMIT.code(), "找不到对应的在售信息");
|
|
|
|
|
|
|
+ nowGoods = goodsDao.findByBatchCode(goods.getBatchCode());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (nowGoods == null) {
|
|
|
|
|
+ List<Goods> goodsList = goodsDao.findByProductIdOrderByGoodsId(goods.getProductid());
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(goodsList)) {
|
|
|
|
|
+ nowGoods = goodsList.get(0);
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
+ if (nowGoods == null) {
|
|
|
|
|
+ //根据物料信息,生成在售产品
|
|
|
|
|
+ publish(goods, "NORMAL");
|
|
|
|
|
+ } else {
|
|
|
// 检查身份
|
|
// 检查身份
|
|
|
if (!nowGoods.getEnUU().equals(enUU)) {
|
|
if (!nowGoods.getEnUU().equals(enUU)) {
|
|
|
return new ResultMap(CodeType.NOT_PERMIT.code(), "您提交的批次号不属于您当前登陆公司");
|
|
return new ResultMap(CodeType.NOT_PERMIT.code(), "您提交的批次号不属于您当前登陆公司");
|
|
@@ -1302,9 +1314,6 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
// 比较两个goods编辑信息
|
|
// 比较两个goods编辑信息
|
|
|
compareGoodsWithModify(nowGoods, goods);
|
|
compareGoodsWithModify(nowGoods, goods);
|
|
|
resultGoods = updateGoods(nowGoods, goods);
|
|
resultGoods = updateGoods(nowGoods, goods);
|
|
|
- } else {
|
|
|
|
|
- //根据物料信息,生成在售产品
|
|
|
|
|
- publish(goods, "NORMAL");
|
|
|
|
|
}
|
|
}
|
|
|
return ResultMap.success(resultGoods);
|
|
return ResultMap.success(resultGoods);
|
|
|
}
|
|
}
|
|
@@ -1342,46 +1351,18 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
*/
|
|
*/
|
|
|
private void compareGoodsWithModify(Goods beforeGoods, Goods afterGoods) {
|
|
private void compareGoodsWithModify(Goods beforeGoods, Goods afterGoods) {
|
|
|
List<ModifyInfo> infoList = new ArrayList<>();
|
|
List<ModifyInfo> infoList = new ArrayList<>();
|
|
|
- String beforeImg = beforeGoods.getImg();
|
|
|
|
|
- String afterImg = afterGoods.getImg();
|
|
|
|
|
- if (StringUtils.isEmpty(beforeImg) && StringUtils.hasText(afterImg)) {
|
|
|
|
|
- ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_IMG.getPhrase(), beforeGoods.getBatchCode(), StringConstant.DEFAULT_IMG, StringConstant.NEW_IMG, ModifyInfo.TYPE_BASIC);
|
|
|
|
|
- infoList.add(info);
|
|
|
|
|
- }
|
|
|
|
|
- if (StringUtils.hasText(beforeImg) && !beforeImg.equals(afterImg)) {
|
|
|
|
|
- ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_IMG.getPhrase(), beforeGoods.getBatchCode(), StringConstant.OLD_IMG, StringConstant.NEW_IMG, ModifyInfo.TYPE_BASIC);
|
|
|
|
|
- infoList.add(info);
|
|
|
|
|
- }
|
|
|
|
|
- String beforePackage = beforeGoods.getPackaging();
|
|
|
|
|
- String afterPackage = afterGoods.getPackaging();
|
|
|
|
|
- if (!StringUtilB2C.equals(beforePackage, afterPackage)) {
|
|
|
|
|
- ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_PACKAGE.getPhrase(),beforeGoods.getBatchCode(), beforePackage, afterPackage, ModifyInfo.TYPE_BASIC);
|
|
|
|
|
- infoList.add(info);
|
|
|
|
|
- }
|
|
|
|
|
- String beforeProduce = beforeGoods.getProduceDate();
|
|
|
|
|
- String afterProduce = afterGoods.getProduceDate();
|
|
|
|
|
- if (!StringUtilB2C.equals(beforeProduce, afterProduce)) {
|
|
|
|
|
- ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_PRODUCE_DATE.getPhrase(), beforeGoods.getBatchCode(), StringUtilB2C.valueOf(beforeProduce), StringUtilB2C.valueOf(beforeProduce), ModifyInfo.TYPE_BASIC);
|
|
|
|
|
- infoList.add(info);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// String beforeProduce = beforeGoods.getProduceDate();
|
|
|
|
|
+// String afterProduce = afterGoods.getProduceDate();
|
|
|
|
|
+// if (!StringUtilB2C.equals(beforeProduce, afterProduce)) {
|
|
|
|
|
+// ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_PRODUCE_DATE.getPhrase(), beforeGoods.getBatchCode(), StringUtilB2C.valueOf(beforeProduce), StringUtilB2C.valueOf(beforeProduce), ModifyInfo.TYPE_BASIC);
|
|
|
|
|
+// infoList.add(info);
|
|
|
|
|
+// }
|
|
|
Boolean beforeBreak = beforeGoods.getBreakUp();
|
|
Boolean beforeBreak = beforeGoods.getBreakUp();
|
|
|
Boolean afterBreak = afterGoods.getBreakUp();
|
|
Boolean afterBreak = afterGoods.getBreakUp();
|
|
|
if (!beforeBreak.equals(afterBreak)) {
|
|
if (!beforeBreak.equals(afterBreak)) {
|
|
|
ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_BREAK_UP.getPhrase(),beforeGoods.getBatchCode(), StringUtilB2C.valueOf(beforeBreak),StringUtilB2C.valueOf(afterBreak), ModifyInfo.TYPE_SALE);
|
|
ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_BREAK_UP.getPhrase(),beforeGoods.getBatchCode(), StringUtilB2C.valueOf(beforeBreak),StringUtilB2C.valueOf(afterBreak), ModifyInfo.TYPE_SALE);
|
|
|
infoList.add(info);
|
|
infoList.add(info);
|
|
|
}
|
|
}
|
|
|
- Double beforeReserve = beforeGoods.getReserve();
|
|
|
|
|
- Double afterReserve = afterGoods.getReserve();
|
|
|
|
|
- if (!beforeReserve.equals(afterReserve)) {
|
|
|
|
|
- ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_RESERVE.getPhrase(), beforeGoods.getBatchCode(), StringUtilB2C.valueOf(beforeReserve), StringUtilB2C.valueOf(afterReserve), ModifyInfo.TYPE_SALE);
|
|
|
|
|
- infoList.add(info);
|
|
|
|
|
- }
|
|
|
|
|
- Double beforePackQty = beforeGoods.getMinPackQty();
|
|
|
|
|
- Double afterPackQty = afterGoods.getMinPackQty();
|
|
|
|
|
- if (NumberUtil.compare(beforePackQty, afterPackQty) != 0) {
|
|
|
|
|
- ModifyInfo info = new ModifyInfo(ModifyConstant.MODIFY_PACKAGE_QTY.getPhrase(), beforeGoods.getBatchCode(), StringUtilB2C.valueOf(beforePackQty), StringUtilB2C.valueOf(afterPackQty), ModifyInfo.TYPE_BASIC);
|
|
|
|
|
- infoList.add(info);
|
|
|
|
|
- }
|
|
|
|
|
Double beforeBuyQty = beforeGoods.getMinBuyQty();
|
|
Double beforeBuyQty = beforeGoods.getMinBuyQty();
|
|
|
Double afterBuyQty = afterGoods.getMinBuyQty();
|
|
Double afterBuyQty = afterGoods.getMinBuyQty();
|
|
|
if (NumberUtil.compare(beforeBuyQty, afterBuyQty) != 0) {
|
|
if (NumberUtil.compare(beforeBuyQty, afterBuyQty) != 0) {
|
|
@@ -1595,29 +1576,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
//判断是否切换了销售方式
|
|
//判断是否切换了销售方式
|
|
|
Boolean isChangeSaleType = false;
|
|
Boolean isChangeSaleType = false;
|
|
|
String storeuuid = oldGoods.getStoreid();
|
|
String storeuuid = oldGoods.getStoreid();
|
|
|
- if (Integer.valueOf(oldGoods.getSelfSale()).equals(IntegerConstant.B2C_SALE)) {
|
|
|
|
|
- if(!sysConf.getStoreid().equals(nowGoods.getStoreid())) {
|
|
|
|
|
- isChangeSaleType = true;
|
|
|
|
|
- }
|
|
|
|
|
- nowGoods.setStoreid(sysConf.getStoreid());
|
|
|
|
|
- StoreIn storeIn = storeInService.findByUuid(sysConf.getStoreid());
|
|
|
|
|
- if (storeIn != null){
|
|
|
|
|
- nowGoods.setStoreName(storeIn.getStoreName());
|
|
|
|
|
- }
|
|
|
|
|
- } else if (Integer.valueOf(oldGoods.getSelfSale()).equals(IntegerConstant.SELF_SALE)) {
|
|
|
|
|
- StoreIn storeIn = storeInService.findByEnUU(nowGoods.getEnUU());
|
|
|
|
|
- if (storeIn != null && storeIn.getStatus() == StoreStatus.OPENED) {
|
|
|
|
|
- if(!storeIn.getUuid().equals(nowGoods.getStoreid())) {
|
|
|
|
|
- isChangeSaleType = true;
|
|
|
|
|
- }
|
|
|
|
|
- nowGoods.setStoreid(storeIn.getUuid());
|
|
|
|
|
- nowGoods.setStoreName(storeIn.getStoreName());
|
|
|
|
|
- } else {
|
|
|
|
|
- throw new IllegalOperatorException("您还未开店铺,不能选择自营");
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- throw new IllegalOperatorException("您选择的销售方式不存在");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ isChangeSaleType = setStoreName(nowGoods, oldGoods);
|
|
|
|
|
|
|
|
if(nowGoods.getProductid() != null) {
|
|
if(nowGoods.getProductid() != null) {
|
|
|
Product product = productDao.findOne(nowGoods.getProductid());
|
|
Product product = productDao.findOne(nowGoods.getProductid());
|
|
@@ -1710,6 +1669,32 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return nowGoods;
|
|
return nowGoods;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 用户更新在售产品的信息, 设置店铺名称
|
|
|
|
|
+ * @param nowGoods 持久化的在售产品
|
|
|
|
|
+ * @param oldGoods 传入的在售产品
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private Boolean setStoreName(Goods nowGoods, Goods oldGoods) {
|
|
|
|
|
+ Boolean isChangeSaleType = false;
|
|
|
|
|
+ StoreIn storeIn = null;
|
|
|
|
|
+ if (Integer.valueOf(oldGoods.getSelfSale()).equals(IntegerConstant.SELF_SALE)) {
|
|
|
|
|
+ storeIn = storeInService.findByEnUU(nowGoods.getEnUU());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ storeIn = storeInService.findByUuid(sysConf.getStoreid());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (storeIn != null && storeIn.getStatus() == StoreStatus.OPENED) {
|
|
|
|
|
+ if(!storeIn.getUuid().equals(nowGoods.getStoreid())) {
|
|
|
|
|
+ isChangeSaleType = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ nowGoods.setStoreid(storeIn.getUuid());
|
|
|
|
|
+ nowGoods.setStoreName(storeIn.getStoreName());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new IllegalOperatorException("您还未开店铺,不能选择自营");
|
|
|
|
|
+ }
|
|
|
|
|
+ return isChangeSaleType;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public Goods updateGoodsByERP(Goods nowGoods, Goods oldGoods) {
|
|
public Goods updateGoodsByERP(Goods nowGoods, Goods oldGoods) {
|
|
@@ -1720,29 +1705,7 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
//判断是否切换了销售方式
|
|
//判断是否切换了销售方式
|
|
|
Boolean isChangeSaleType = false;
|
|
Boolean isChangeSaleType = false;
|
|
|
String storeuuid = oldGoods.getStoreid();
|
|
String storeuuid = oldGoods.getStoreid();
|
|
|
- if (Integer.valueOf(oldGoods.getSelfSale()).equals(IntegerConstant.B2C_SALE)) {
|
|
|
|
|
- if(!sysConf.getStoreid().equals(nowGoods.getStoreid())) {
|
|
|
|
|
- isChangeSaleType = true;
|
|
|
|
|
- }
|
|
|
|
|
- nowGoods.setStoreid(sysConf.getStoreid());
|
|
|
|
|
- StoreIn storeIn = storeInService.findByUuid(sysConf.getStoreid());
|
|
|
|
|
- if (storeIn != null) {
|
|
|
|
|
- nowGoods.setStoreName(storeIn.getStoreName());
|
|
|
|
|
- }
|
|
|
|
|
- } else if (Integer.valueOf(oldGoods.getSelfSale()).equals(IntegerConstant.SELF_SALE)) {
|
|
|
|
|
- StoreIn storeIn = storeInService.findByEnUU(nowGoods.getEnUU());
|
|
|
|
|
- if (storeIn != null && storeIn.getStatus() == StoreStatus.OPENED) {
|
|
|
|
|
- if(!storeIn.getUuid().equals(nowGoods.getStoreid())) {
|
|
|
|
|
- isChangeSaleType = true;
|
|
|
|
|
- }
|
|
|
|
|
- nowGoods.setStoreid(storeIn.getUuid());
|
|
|
|
|
- nowGoods.setStoreName(storeIn.getStoreName());
|
|
|
|
|
- } else {
|
|
|
|
|
- throw new IllegalOperatorException("您还未开店铺,不能选择自营");
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- throw new IllegalOperatorException("您选择的销售方式不存在");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ isChangeSaleType = setStoreName(nowGoods, oldGoods);
|
|
|
|
|
|
|
|
if(nowGoods.getProductid() != null) {
|
|
if(nowGoods.getProductid() != null) {
|
|
|
Product product = productDao.findOne(nowGoods.getProductid());
|
|
Product product = productDao.findOne(nowGoods.getProductid());
|