Browse Source

Merge remote-tracking branch 'origin/release-201831-wangcz' into release-201831-wangcz

yujia 7 years ago
parent
commit
bafe629da8

+ 1 - 0
src/main/java/com/uas/platform/b2c/prod/commodity/model/Goods.java

@@ -1685,6 +1685,7 @@ public class Goods implements Serializable {
 		goods.setPackaging(product.getPackaging());
 		goods.setProduceDate(product.getProduceDate());
 		goods.setUuid(product.getCmpUuId());
+		goods.setMinPackQty(product.getMinPackQty());
 		return goods;
 	}
 

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

@@ -2441,6 +2441,8 @@ public class ProductServiceImpl implements ProductService {
         }
         Product productInfo = new Product();
         CommodityInOutbound inOutbound = null;
+        // 是否需要增加出入库记录
+        boolean needAddInventory = false;
         // 物料存在,更新
         List<V_ProductPrivate> existProducts = v_productPrivateDao.findProductByPcmpcodeAndPbrandenAndEnUU(product.getCmpCode(), product.getBrand(), enUU);
         if (CollectionUtils.isNotEmpty(existProducts)) {
@@ -2451,10 +2453,16 @@ public class ProductServiceImpl implements ProductService {
         } else {
             // 物料不存在,新增操作
             productInfo = product;
-            inOutbound = recordInventory(product, null);
+            needAddInventory = true;
         }
         if (null == productInfo.getStandard()) {
-            productInfo.setStandard(IntegerConstant.NO_SHORT);
+            // 判断传入的数据是否是标准的
+            ResultMap criterionResultMap = checkCriterion(product);
+            if (Objects.equals(CodeType.ERROR.code(), criterionResultMap.getCode())) {
+                productInfo.setStandard(IntegerConstant.NO_SHORT);
+            } else {
+                productInfo.setStandard(IntegerConstant.YES_SHORT);
+            }
         }
         if (StringUtilB2C.isEmpty(productInfo.getProdNum())) {
             String code = "PNUM" + createNumberService.getTimeNumber("trade$product_import_num", 8);
@@ -2471,17 +2479,9 @@ public class ProductServiceImpl implements ProductService {
         // 设置库存信息
         assignmentGoods(goods, productInfo);
         // 保存到商城私有库
-        List<ProductPrivate> productPrivates = productPrivateDao.findByPrId(productInfo.getId());
-        if (CollectionUtils.isEmpty(productPrivates)) {
-            ProductPrivate productPrivate = new ProductPrivate(productInfo.getId());
-            productPrivate.setAttach(product.getAttachment());
-            productPrivateDao.save(productPrivate);
-        } else  {
-            ProductPrivate productPrivate = productPrivates.get(0);
-            if (null == productPrivate.getB2cEnabled() || Objects.equals(IntegerConstant.NO_SHORT, productPrivate.getB2cEnabled())) {
-                productPrivate.setB2cEnabled(IntegerConstant.YES_SHORT);
-                productPrivateDao.save(productPrivate);
-            }
+        addToPrivate(productInfo, product);
+        if (needAddInventory) {
+            inOutbound = initCommodityInOut(productInfo);
         }
         // 保存出入库信息
         if (null != inOutbound) {
@@ -2496,6 +2496,47 @@ public class ProductServiceImpl implements ProductService {
         return ResultMap.success();
     }
 
+    /**
+     * 新增库存记录
+     *
+     * @param productInfo 物料信息
+     * @return CommodityInOutbound
+     */
+    private CommodityInOutbound initCommodityInOut(Product productInfo) {
+        CommodityInOutbound inOutbound = new CommodityInOutbound(InOutBoundType.OTHER_INBOUND);
+        Goods goods = new Goods();
+        goods = Goods.productConvertGoods(goods, productInfo);
+        goods.setReserve(productInfo.getErpReserve());
+        goods = goodsDao.save(goods);
+        logger.info("上架商品库存操作", "卖家中心单个物料上传进行入库操作", "增加库存: " + productInfo.getErpReserve(), goods.getCode(), goods.getId());
+        InOutboundDetail inOutboundDetail = new InOutboundDetail(productInfo);
+        Set<InOutboundDetail> detailSet = new HashSet<>();
+        detailSet.add(inOutboundDetail);
+        inOutbound.setInOutboundDetails(detailSet);
+        return inOutbound;
+    }
+
+    /**
+     * 保存到商城私有库
+     *
+     * @param productInfo
+     * @param product
+     */
+    private void addToPrivate(Product productInfo, Product product) {
+        List<ProductPrivate> productPrivates = productPrivateDao.findByPrId(productInfo.getId());
+        if (CollectionUtils.isEmpty(productPrivates)) {
+            ProductPrivate productPrivate = new ProductPrivate(productInfo.getId());
+            productPrivate.setAttach(product.getAttachment());
+            productPrivateDao.save(productPrivate);
+        } else  {
+            ProductPrivate productPrivate = productPrivates.get(0);
+            if (null == productPrivate.getB2cEnabled() || Objects.equals(IntegerConstant.NO_SHORT, productPrivate.getB2cEnabled())) {
+                productPrivate.setB2cEnabled(IntegerConstant.YES_SHORT);
+                productPrivateDao.save(productPrivate);
+            }
+        }
+    }
+
     /**
      * 校验传入的物料信息
      *
@@ -2583,7 +2624,7 @@ public class ProductServiceImpl implements ProductService {
         String type;
         CommodityInOutbound inOutbound;
         // 原库存不存在或者当前库存大于原库存,入库
-        if (null == existProduct || existProduct.getErpReserve() == null || product.getErpReserve() > existProduct.getErpReserve()) {
+        if (existProduct.getErpReserve() == null || product.getErpReserve() > existProduct.getErpReserve()) {
             type = InOutBoundType.OTHER_INBOUND;
             inOutbound = new CommodityInOutbound(type);
             goodsInventory(product.getErpReserve(), type, existProduct.getId());
@@ -2621,7 +2662,7 @@ public class ProductServiceImpl implements ProductService {
                 Goods goods = goodsList.get(0);
                 Double reserve = goods.getReserve() != null ? goods.getReserve() : 0D + addQty;
                 goods.setReserve(reserve);
-                goodsDao.save(goods);
+                goods = goodsDao.save(goods);
                 logger.info("上架商品库存操作", "卖家中心单个物料上传进行入库操作", "增加库存: " + addQty, goods.getCode(), goods.getId());
             } else if (InOutBoundType.OTHER_OUTBOUND.equals(type)) {
                 // 出库