|
@@ -1574,6 +1574,111 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
return nowGoods;
|
|
return nowGoods;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public Goods updateGoodsByERP(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());
|
|
|
|
|
+ nowGoods.setTag(oldGoods.getTag());
|
|
|
|
|
+ //判断是否切换了销售方式
|
|
|
|
|
+ Boolean isChangeSaleType = false;
|
|
|
|
|
+ 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());
|
|
|
|
|
+ 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) {
|
|
|
|
|
+ if(!storeIn.getUuid().equals(nowGoods.getStoreid())) {
|
|
|
|
|
+ isChangeSaleType = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ nowGoods.setStoreid(storeIn.getUuid());
|
|
|
|
|
+ nowGoods.setStoreName(storeIn.getStoreName());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new IllegalOperatorException("您还未开店铺,不能选择自营");
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new IllegalOperatorException("您选择的销售方式不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(nowGoods.getProductid() != null) {
|
|
|
|
|
+ Product product = productDao.findOne(nowGoods.getProductid());
|
|
|
|
|
+ if(product != null) {
|
|
|
|
|
+ if (StringConstant.ERP.equals(product.getSourceApp())) {
|
|
|
|
|
+ List<Goods> goodses = goodsDao.findByProductId(product.getId());
|
|
|
|
|
+ Double reserve = productService.getGoodsReserveByErpReserve(product.getErpReserve(), goodses);
|
|
|
|
|
+ reserve = NumberUtil.add(reserve, nowGoods.getReserve());
|
|
|
|
|
+ reserve = NumberUtil.sub(reserve, oldGoods.getReserve());
|
|
|
|
|
+ if (NumberUtil.compare(reserve, DoubleConstant.zero) < 0) {
|
|
|
|
|
+ throw new IllegalOperatorException("总在售库存量超过空闲库存量");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 设置货到香港,货到大陆的延长时间
|
|
|
|
|
+ setB2CDelayTime(nowGoods);
|
|
|
|
|
+
|
|
|
|
|
+ nowGoods.setUpdateDate(new Date());
|
|
|
|
|
+ nowGoods.setImg(oldGoods.getImg());
|
|
|
|
|
+ nowGoods.setMinBuyQty(oldGoods.getMinBuyQty());
|
|
|
|
|
+ nowGoods.setMinPackQty(oldGoods.getMinPackQty());
|
|
|
|
|
+ nowGoods.setBreakUp(oldGoods.getBreakUp());
|
|
|
|
|
+ nowGoods.setPerQty();
|
|
|
|
|
+ nowGoods.setReserve(oldGoods);
|
|
|
|
|
+ nowGoods.setPackaging(oldGoods.getPackaging());
|
|
|
|
|
+ nowGoods.setProduceDate(oldGoods.getProduceDate());
|
|
|
|
|
+ // 用含税单价同步未含税单价
|
|
|
|
|
+ oldGoods.setWithOutTaxRMBPrice();
|
|
|
|
|
+ oldGoods.setWithOutTaxUSDPrice();
|
|
|
|
|
+ //保留六位有效数字
|
|
|
|
|
+ oldGoods.setSixFraction();
|
|
|
|
|
+ nowGoods.setQtyPrice(oldGoods.getQtyPrice());
|
|
|
|
|
+ // 更新本批次最小最大价格信息
|
|
|
|
|
+ nowGoods.setMinPriceRMB(GoodsUtil.getMinPriceRMB(nowGoods.getPrices()));
|
|
|
|
|
+ nowGoods.setMaxPriceRMB(GoodsUtil.getMaxPriceRMB(nowGoods.getPrices()));
|
|
|
|
|
+ nowGoods.setMinPriceUSD(GoodsUtil.getMinPriceUSD(nowGoods.getPrices()));
|
|
|
|
|
+ nowGoods.setMaxPriceUSD(GoodsUtil.getMaxPriceUSD(nowGoods.getPrices()));
|
|
|
|
|
+ if((nowGoods.getStatus().intValue() != Status.REMOVED.value()) && (nowGoods.getStatus().intValue() != Status.NO_SHELVE.value())) {
|
|
|
|
|
+ if (NumberUtil.compare(nowGoods.getReserve(), nowGoods.getMinBuyQty()) > -1) {
|
|
|
|
|
+ nowGoods.setStatus(Status.AVAILABLE.value());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ nowGoods.setStatus(Status.UNAVAILABLE.value());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ GoodsHistory history =
|
|
|
|
|
+ goodsHistoryService
|
|
|
|
|
+ .converTGoodsHist
|
|
|
|
|
+ (nowGoods,
|
|
|
|
|
+ OperateType.Update.getPhrase());
|
|
|
|
|
+ List<Order> orders = detailService.updateOrderDetailsByGoods(nowGoods);
|
|
|
|
|
+ //更新购物车信息
|
|
|
|
|
+ List<Cart> cartList = cartService.updateCartByGoods(nowGoods);
|
|
|
|
|
+ //更新浏览历史
|
|
|
|
|
+ List<GoodsBrowsingHistory> browsingHistories = browsingHistoryService.updateGoodsBrowsingHistoryByGoods(nowGoods);
|
|
|
|
|
+// ProductStandardPutOnInfo putOnInfo = productStandardPutOnInfoService.updateProductStandardPutOnInfoByGoods(nowGoods);
|
|
|
|
|
+// Product product = productService.updateProduct(putOnInfo);
|
|
|
|
|
+ updateGoodsRelateInfo(orders, cartList, browsingHistories, null, null, history, nowGoods);
|
|
|
|
|
+ //更新店铺推荐的信息
|
|
|
|
|
+ if(isChangeSaleType) { // 如果切换了销售方式
|
|
|
|
|
+ Set<String> uuids = new HashSet<>();
|
|
|
|
|
+ uuids.add(nowGoods.getBatchCode());
|
|
|
|
|
+ recommendProductService.deleteProductsWhenSellerUpdateReserve(storeuuid, uuids);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ recommendProductService.updateRecommendProductInfo(nowGoods);
|
|
|
|
|
+ }
|
|
|
|
|
+ return nowGoods;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 添加商品操作记录,保存商品信息
|
|
* 添加商品操作记录,保存商品信息
|
|
|
*
|
|
*
|