Procházet zdrojové kódy

处理销售方式异常以及出入库单号为空的问题

hejq před 7 roky
rodič
revize
b0bcaf5846

+ 15 - 13
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ProductServiceImpl.java

@@ -2525,13 +2525,14 @@ public class ProductServiceImpl implements ProductService {
      * @return CommodityInOutbound
      */
     private CommodityInOutbound initCommodityInOut(Product productInfo, Goods goods) {
+        goods = Goods.productConvertGoods(goods, productInfo);
+        goods.setReserve(productInfo.getErpReserve());
+        goodsService.setGoodsDefault(goods);
+        goods = goodsDao.save(goods);
+        logger.info("上架商品库存操作", "卖家中心单个物料上传进行入库操作", "增加库存: " + productInfo.getErpReserve(), goods.getCode(), goods.getId());
         CommodityInOutbound inOutbound = new CommodityInOutbound(InOutBoundType.OTHER_INBOUND);
-        if (!StringUtils.isEmpty(goods.getQtyPrice())) {
-            goods = Goods.productConvertGoods(goods, productInfo);
-            goods.setReserve(productInfo.getErpReserve());
-            goods = goodsDao.save(goods);
-            logger.info("上架商品库存操作", "卖家中心单个物料上传进行入库操作", "增加库存: " + productInfo.getErpReserve(), goods.getCode(), goods.getId());
-        }
+        String inOutboundId = createNumberService.generateOrderNumber(com.uas.platform.b2c.core.constant.EncodingRulesConstant.INOUTBOUND_NUM, "trade$commodity_in_outbound", 8);
+        inOutbound.setInOutId(inOutboundId);
         InOutboundDetail inOutboundDetail = new InOutboundDetail(productInfo);
         Set<InOutboundDetail> detailSet = new HashSet<>();
         detailSet.add(inOutboundDetail);
@@ -2657,6 +2658,8 @@ public class ProductServiceImpl implements ProductService {
             inOutbound = new CommodityInOutbound(InOutBoundType.OTHER_OUTBOUND);
             goodsInventory(product.getErpReserve(), type, existProduct.getId());
         }
+        String inOutboundId = createNumberService.generateOrderNumber(com.uas.platform.b2c.core.constant.EncodingRulesConstant.INOUTBOUND_NUM, "trade$commodity_in_outbound", 8);
+        inOutbound.setInOutId(inOutboundId);
         InOutboundDetail inOutboundDetail = new InOutboundDetail(product);
         Set<InOutboundDetail> detailSet = new HashSet<>();
         detailSet.add(inOutboundDetail);
@@ -2786,7 +2789,7 @@ public class ProductServiceImpl implements ProductService {
                 throw new IllegalOperatorException("第 " + errMsg.toString() + " 行价格未填写");
             }
         }
-        if (!StringUtils.isEmpty(qtyPrices) && !StringUtils.isEmpty(goods.getQtyPrice())) {
+        if (!StringUtils.isEmpty(qtyPrices)) {
             if (CollectionUtils.isNotEmpty(goods.getOriginalPrices())) {
                 qtyPrices.forEach(qtyPrice -> {
                     // 分段数量不能超过最大数量
@@ -2798,12 +2801,11 @@ public class ProductServiceImpl implements ProductService {
                 Double startQty = NumberUtil.compare(minBuyQty, qtyPrices.get(0).getStart()) == 1 ? qtyPrices.get(0).getStart() : minBuyQty;
                 qtyPrices.get(0).setStart(startQty);
             }
-            goods.setQtyPrice(JSON.toJSONString(qtyPrices));
-            goodsService.setGoodsDefault(goods);
-            boolean autoPublish = goods.getAutoPublish() == null ? true : goods.getAutoPublish();
-            goods.setAutoPublish(autoPublish);
-            goods = goodsDao.save(goods);
-            logger.info("上架商品", "新增上架商品", "通过卖家中心单个物料上传新增上架商品", goods.getCode(), goods.getId());
         }
+        goodsService.setGoodsDefault(goods);
+        boolean autoPublish = goods.getAutoPublish() == null ? true : goods.getAutoPublish();
+        goods.setAutoPublish(autoPublish);
+        goods = goodsDao.save(goods);
+        logger.info("上架商品", "新增上架商品", "通过卖家中心单个物料上传新增上架商品", goods.getCode(), goods.getId());
     }
 }