|
|
@@ -206,6 +206,9 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
@Autowired
|
|
|
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private GoodsModifyInfoDao goodsModifyInfoDao;
|
|
|
+
|
|
|
private final Logger logger = Logger.getLogger(getClass());
|
|
|
|
|
|
@Autowired
|
|
|
@@ -220,21 +223,6 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
ExecutorService executorService = Executors.newCachedThreadPool();
|
|
|
executor = new BoundedExecutor(executorService, 1600);
|
|
|
}
|
|
|
- @Autowired
|
|
|
- private GoodsModifyInfoDao goodsModifyInfoDao;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- public GoodsServiceImpl(KindService kindService, StoreInDao storeInDao, StoreInService storeInService, ProductStandardPutOnInfoDao productStandardPutOnInfoDao, ProductDao productDao, BrowsingHistoryService browsingHistoryService, RecommendProductService recommendProductService) {
|
|
|
- this.kindService = kindService;
|
|
|
- this.storeInDao = storeInDao;
|
|
|
- this.storeInService = storeInService;
|
|
|
- this.productStandardPutOnInfoDao = productStandardPutOnInfoDao;
|
|
|
- this.productDao = productDao;
|
|
|
- this.browsingHistoryService = browsingHistoryService;
|
|
|
- this.recommendProductService = recommendProductService;
|
|
|
- ExecutorService executorService = Executors.newCachedThreadPool();
|
|
|
- executor = new BoundedExecutor(executorService, 1600);
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 检测批次各属性的正确性
|
|
|
@@ -1292,161 +1280,128 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return ResultMap.success(resultGoods);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 比较两个Goods,得出修改后的信息
|
|
|
- * @param beforeGoods 原有的Goods
|
|
|
- * @param afterGoods 修改的Goods
|
|
|
- */
|
|
|
- private void compareGoodsWithModify(Goods beforeGoods, Goods afterGoods) {
|
|
|
- List<ModifyInfo> infoList = new ArrayList<>();
|
|
|
- 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);
|
|
|
- infoList.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);
|
|
|
- infoList.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);
|
|
|
- infoList.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);
|
|
|
- infoList.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());
|
|
|
- infoList.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());
|
|
|
- infoList.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());
|
|
|
- infoList.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());
|
|
|
- infoList.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());
|
|
|
- infoList.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());
|
|
|
- infoList.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);
|
|
|
- }
|
|
|
- infoList.add(info);
|
|
|
- }
|
|
|
- if (!CollectionUtils.isEmpty(infoList)) {
|
|
|
- beforeGoods.setAudited(ShortConstant.NO_SHORT);
|
|
|
- GoodsModifyInfo modifyInfo = new GoodsModifyInfo();
|
|
|
- modifyInfo.setEnuu(SystemSession.getUser().getEnterprise().getUu());
|
|
|
- modifyInfo.setUseruu(SystemSession.getUser().getUserUU());
|
|
|
- modifyInfo.setBatchCode(beforeGoods.getBatchCode());
|
|
|
- modifyInfo.setStatus(ModifyInfoStatus.TO_BE_AUDITED.getCode());
|
|
|
- modifyInfo.setUpdateTime(new Date());
|
|
|
- modifyInfo.setInfoList(infoList);
|
|
|
- goodsModifyInfoDao.save(modifyInfo);
|
|
|
- }
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 比较两个Goods,得出修改后的信息
|
|
|
+ * @param beforeGoods 原有的Goods
|
|
|
+ * @param afterGoods 修改的Goods
|
|
|
+ */
|
|
|
+ private void compareGoodsWithModify(Goods beforeGoods, Goods afterGoods) {
|
|
|
+ List<ModifyInfo> infoList = new ArrayList<>();
|
|
|
+ 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.DEFAULT_IMG);
|
|
|
+ info.setAfter(StringConstant.NEW_IMG);
|
|
|
+ infoList.add(info);
|
|
|
+ }
|
|
|
+ if (StringUtils.hasText(beforeImg) && !beforeImg.equals(afterImg)) {
|
|
|
+ ModifyInfo info = new ModifyInfo();
|
|
|
+ info.setModifyField(ModifyConstant.MODIFY_IMG.getPhrase());
|
|
|
+ info.setBefore(StringConstant.OLD_IMG);
|
|
|
+ info.setAfter(StringConstant.NEW_IMG);
|
|
|
+ infoList.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);
|
|
|
+ infoList.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);
|
|
|
+ infoList.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());
|
|
|
+ infoList.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());
|
|
|
+ infoList.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());
|
|
|
+ infoList.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());
|
|
|
+ infoList.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());
|
|
|
+ infoList.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());
|
|
|
+ infoList.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.SALE_SELF);
|
|
|
+ } else {
|
|
|
+ info.setBefore(StringConstant.SALE_SELF);
|
|
|
+ info.setAfter(StringConstant.CONSIGNMENT);
|
|
|
+ }
|
|
|
+ infoList.add(info);
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(infoList)) {
|
|
|
+ beforeGoods.setAudited(ShortConstant.NO_SHORT);
|
|
|
+ GoodsModifyInfo modifyInfo = new GoodsModifyInfo();
|
|
|
+ modifyInfo.setEnuu(SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ modifyInfo.setUseruu(SystemSession.getUser().getUserUU());
|
|
|
+ modifyInfo.setBatchCode(beforeGoods.getBatchCode());
|
|
|
+ modifyInfo.setStatus(ModifyInfoStatus.TO_BE_AUDITED.getCode());
|
|
|
+ modifyInfo.setUpdateTime(new Date());
|
|
|
+ modifyInfo.setInfoList(infoList);
|
|
|
+ goodsModifyInfoDao.save(modifyInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 根据前端修改的库存(oldGoods)更新数据库中的库存。
|
|
|
- * @param nowGoods 数据库中的库存。
|
|
|
- * @param oldGoods 前端修改的库存。
|
|
|
- * @return 更新之后的库存。
|
|
|
- */
|
|
|
- @Override
|
|
|
- @Transactional
|
|
|
- public Goods updateGoods(Goods nowGoods, Goods oldGoods) {
|
|
|
- Goods resultGoods = null;
|
|
|
- nowGoods.setMaxDelivery(oldGoods.getMaxDelivery());
|
|
|
- nowGoods.setMinDelivery(oldGoods.getMinDelivery());
|
|
|
- nowGoods.setSelfDeliveryDemMaxTime(oldGoods.getSelfDeliveryDemMaxTime());
|
|
|
- nowGoods.setSelfDeliveryDemMinTime(oldGoods.getSelfDeliveryDemMinTime());
|
|
|
- nowGoods.setSelfDeliveryHKMaxTime(oldGoods.getSelfDeliveryHKMaxTime());
|
|
|
- nowGoods.setSelfDeliveryHKMinTime(oldGoods.getSelfDeliveryHKMinTime());
|
|
|
-
|
|
|
- if(Integer.valueOf(oldGoods.getSelfSale()).equals(IntegerConstant.B2C_SALE)) {
|
|
|
- nowGoods.setStoreid(sysConf.getStoreid());
|
|
|
- nowGoods.setStoreName(sysConf.getEnName());
|
|
|
- }else if(Integer.valueOf(oldGoods.getSelfSale()).equals(IntegerConstant.SELF_SALE)){
|
|
|
- StoreIn storeIn = storeInService.findByEnUU(nowGoods.getEnUU());
|
|
|
- if(storeIn != null && storeIn.getStatus() == StoreStatus.OPENED) {
|
|
|
- nowGoods.setStoreid(storeIn.getUuid());
|
|
|
- nowGoods.setStoreName(storeIn.getStoreName());
|
|
|
- }else {
|
|
|
- throw new IllegalOperatorException("您还未开店铺,不能选择自营");
|
|
|
- }
|
|
|
- }else {
|
|
|
- throw new IllegalOperatorException("您选择的销售方式不存在");
|
|
|
- }
|
|
|
- // 设置货到香港,货到大陆的延长时间
|
|
|
- setB2CDelayTime(nowGoods);
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public ResultMap putOn(Long id) {
|
|
|
@@ -1467,12 +1422,11 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
updateComponentTradeInfos(goods.getUuid());
|
|
|
}
|
|
|
return ResultMap.success(persistGoods);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return new ResultMap(CodeType.NO_INFO, "找不到对应的在售产品信息");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 添加保存的产品信息
|
|
|
* @param goods
|
|
|
@@ -3311,8 +3265,6 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goodsDao.save(goodses);
|
|
|
return String.valueOf(goodses.size());
|
|
|
}
|
|
|
- goodsDao.addVisitCount(batchCode);
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public Page<Goods> getPageDataOfBackground(final PageInfo info, GoodsFilter goodsFilter) {
|