|
|
@@ -16,10 +16,12 @@ import com.uas.platform.b2c.core.utils.DoubleArith;
|
|
|
import com.uas.platform.b2c.core.utils.NumberUtil;
|
|
|
import com.uas.platform.b2c.external.erp.commodity.util.ModelConverter;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.IntegerConstant;
|
|
|
+import com.uas.platform.b2c.prod.commodity.constant.StringConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.*;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.*;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.GoodsHistory.OperateType;
|
|
|
import com.uas.platform.b2c.prod.commodity.service.*;
|
|
|
+import com.uas.platform.b2c.prod.commodity.type.ModifyConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.util.GoodsUtil;
|
|
|
import com.uas.platform.b2c.prod.product.common.service.CreateNumberService;
|
|
|
import com.uas.platform.b2c.prod.product.component.dao.ComponentDao;
|
|
|
@@ -183,6 +185,9 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
@Autowired
|
|
|
private ProductDetailDao productDetailDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private GoodsModifyInfoDao goodsModifyInfoDao;
|
|
|
+
|
|
|
@Autowired
|
|
|
public GoodsServiceImpl(KindService kindService, StoreInDao storeInDao, StoreInService storeInService, ProductStandardPutOnInfoDao productStandardPutOnInfoDao, ProductDao productDao, BrowsingHistoryService browsingHistoryService, RecommendProductService recommendProductService) {
|
|
|
this.kindService = kindService;
|
|
|
@@ -1102,11 +1107,133 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
// return new ResultMap(CodeType.INFO_UPDATE.code(), "数据已经被更新了请刷新之后重新操作");
|
|
|
// }
|
|
|
// }
|
|
|
+ compareGoodsWithModify(nowGoods, goods);
|
|
|
resultGoods = updateGoods(nowGoods, goods);
|
|
|
updateComponentTradeInfos(nowGoods.getUuid());
|
|
|
return ResultMap.success(resultGoods);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 比较两个Goods,得出修改后的信息
|
|
|
+ * @param beforeGoods
|
|
|
+ * @param afterGoods
|
|
|
+ */
|
|
|
+ private void compareGoodsWithModify(Goods beforeGoods, Goods afterGoods) {
|
|
|
+ Set<ModifyInfo> infoSet = new HashSet<>();
|
|
|
+ String beforeImg = beforeGoods.getImg();
|
|
|
+ String afterImg = afterGoods.getImg();
|
|
|
+ if (StringUtils.isEmpty(beforeImg) && StringUtils.hasText(afterImg)) {
|
|
|
+ ModifyInfo info = new ModifyInfo();
|
|
|
+ info.setModifyField(ModifyConstant.MODIFY_IMG.getPhrase());
|
|
|
+ info.setBefore(StringConstant.defaultImg);
|
|
|
+ info.setAfter(StringConstant.newImg);
|
|
|
+ infoSet.add(info);
|
|
|
+ }
|
|
|
+ if (StringUtils.hasText(beforeImg) && !beforeImg.equals(afterImg)) {
|
|
|
+ ModifyInfo info = new ModifyInfo();
|
|
|
+ info.setModifyField(ModifyConstant.MODIFY_IMG.getPhrase());
|
|
|
+ info.setBefore(StringConstant.oldImg);
|
|
|
+ info.setAfter(StringConstant.newImg);
|
|
|
+ infoSet.add(info);
|
|
|
+ }
|
|
|
+ String beforePackage = beforeGoods.getPackaging();
|
|
|
+ String afterPackage = afterGoods.getPackaging();
|
|
|
+ if (!beforePackage.equals(afterPackage)) {
|
|
|
+ ModifyInfo info = new ModifyInfo();
|
|
|
+ info.setModifyField(ModifyConstant.MODIFY_PACKAGE.getPhrase());
|
|
|
+ info.setBefore(beforePackage);
|
|
|
+ info.setAfter(afterPackage);
|
|
|
+ infoSet.add(info);
|
|
|
+ }
|
|
|
+ String beforeProduce = beforeGoods.getProduceDate();
|
|
|
+ String afterProduce = afterGoods.getProduceDate();
|
|
|
+ if (!beforeProduce.equals(afterProduce)) {
|
|
|
+ ModifyInfo info = new ModifyInfo();
|
|
|
+ info.setModifyField(ModifyConstant.MODIFY_PRODUCE_DATE.getPhrase());
|
|
|
+ info.setBefore(beforeProduce);
|
|
|
+ info.setAfter(afterProduce);
|
|
|
+ infoSet.add(info);
|
|
|
+ }
|
|
|
+ Boolean beforeBreak = beforeGoods.getBreakUp();
|
|
|
+ Boolean afterBreak = afterGoods.getBreakUp();
|
|
|
+ if (!beforeBreak.equals(afterBreak)) {
|
|
|
+ ModifyInfo info = new ModifyInfo();
|
|
|
+ info.setModifyField(ModifyConstant.MODIFY_BREAK_UP.getPhrase());
|
|
|
+ info.setBefore(beforeBreak.toString());
|
|
|
+ info.setAfter(afterBreak.toString());
|
|
|
+ infoSet.add(info);
|
|
|
+ }
|
|
|
+ Double beforeReserve = beforeGoods.getReserve();
|
|
|
+ Double afterReserve = afterGoods.getReserve();
|
|
|
+ if (!beforeReserve.equals(afterReserve)) {
|
|
|
+ ModifyInfo info = new ModifyInfo();
|
|
|
+ info.setModifyField(ModifyConstant.MODIFY_RESERVE.getPhrase());
|
|
|
+ info.setBefore(beforeReserve.toString());
|
|
|
+ info.setAfter(afterReserve.toString());
|
|
|
+ infoSet.add(info);
|
|
|
+ }
|
|
|
+ Double beforePackQty = beforeGoods.getMinPackQty();
|
|
|
+ Double afterPackQty = afterGoods.getMinPackQty();
|
|
|
+ if (!beforePackQty.equals(afterPackQty)) {
|
|
|
+ ModifyInfo info = new ModifyInfo();
|
|
|
+ info.setModifyField(ModifyConstant.MODIFY_PACKAGE_QTY.getPhrase());
|
|
|
+ info.setBefore(beforePackQty.toString());
|
|
|
+ info.setAfter(afterPackQty.toString());
|
|
|
+ infoSet.add(info);
|
|
|
+ }
|
|
|
+ Double beforeBuyQty = beforeGoods.getMinBuyQty();
|
|
|
+ Double afterBuyQty = afterGoods.getMinBuyQty();
|
|
|
+ if (!beforeBuyQty.equals(afterBuyQty)) {
|
|
|
+ ModifyInfo info = new ModifyInfo();
|
|
|
+ info.setModifyField(ModifyConstant.MODIFY_BUY_QTY.getPhrase());
|
|
|
+ info.setBefore(beforeBuyQty.toString());
|
|
|
+ info.setAfter(afterBuyQty.toString());
|
|
|
+ infoSet.add(info);
|
|
|
+ }
|
|
|
+ Short beforeMinDelivery = beforeGoods.getMinDelivery();
|
|
|
+ Short afterMinDelivery = afterGoods.getMinDelivery();
|
|
|
+ if (!beforeMinDelivery.equals(afterMinDelivery)) {
|
|
|
+ ModifyInfo info = new ModifyInfo();
|
|
|
+ info.setModifyField(ModifyConstant.MODIFY_MIN_DELIVERY.getPhrase());
|
|
|
+ info.setBefore(beforeMinDelivery.toString());
|
|
|
+ info.setAfter(afterMinDelivery.toString());
|
|
|
+ infoSet.add(info);
|
|
|
+ }
|
|
|
+ Short beforeMaxDelivery = beforeGoods.getMaxDelivery();
|
|
|
+ Short afterMaxDelivery = afterGoods.getMaxDelivery();
|
|
|
+ if (!beforeMaxDelivery.equals(afterMaxDelivery)) {
|
|
|
+ ModifyInfo info = new ModifyInfo();
|
|
|
+ info.setModifyField(ModifyConstant.MODIFY_MAX_DELIVERY.getPhrase());
|
|
|
+ info.setBefore(beforeMaxDelivery.toString());
|
|
|
+ info.setAfter(afterMaxDelivery.toString());
|
|
|
+ infoSet.add(info);
|
|
|
+ }
|
|
|
+ String beforeStore = beforeGoods.getStoreid();
|
|
|
+ String afterStore = afterGoods.getStoreid();
|
|
|
+ if (!beforeStore.equals(afterStore)) {
|
|
|
+ ModifyInfo info = new ModifyInfo();
|
|
|
+ info.setModifyField(ModifyConstant.MODIFY_SALE_METHOD.getPhrase());
|
|
|
+ if (beforeStore.equals(sysConf.getStoreid())) {
|
|
|
+ info.setBefore(StringConstant.consignment);
|
|
|
+ info.setAfter(StringConstant.saleSelf);
|
|
|
+ } else {
|
|
|
+ info.setBefore(StringConstant.saleSelf);
|
|
|
+ info.setAfter(StringConstant.consignment);
|
|
|
+ }
|
|
|
+ infoSet.add(info);
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(infoSet)) {
|
|
|
+ GoodsModifyInfo modifyInfo = new GoodsModifyInfo();
|
|
|
+ modifyInfo.setEnuu(SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ modifyInfo.setUseruu(SystemSession.getUser().getUserUU());
|
|
|
+ modifyInfo.setBatchCode(beforeGoods.getBatchCode());
|
|
|
+ modifyInfo.setStatus(ShortConstant.YES_SHORT);
|
|
|
+ modifyInfo.setUpdateTime(new Date());
|
|
|
+ modifyInfo.setInfoSet(infoSet);
|
|
|
+ goodsModifyInfoDao.save(modifyInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据前端修改的库存(oldGoods)更新数据库中的库存。
|
|
|
* @param nowGoods 数据库中的库存。
|