Prechádzať zdrojové kódy

处理批量上架的bug

yuj 7 rokov pred
rodič
commit
e7520b7252

+ 9 - 2
src/main/java/com/uas/platform/b2c/prod/commodity/model/Goods.java

@@ -1740,8 +1740,11 @@ public class Goods implements Serializable {
 	 * 根据最小起订量 调整分段信息
 	 */
 	public void adjustFragmentPrice() {
-		if (!StringUtils.isEmpty(this.minBuyQty) && org.apache.commons.lang.StringUtils.isNotEmpty(this.qtyPrice)) {
-			List<GoodsQtyPrice> array = FastjsonUtils.fromJsonArray(this.qtyPrice, GoodsQtyPrice.class);
+		List<GoodsQtyPrice> array = new ArrayList<>();
+		if (org.apache.commons.lang.StringUtils.isNotEmpty(this.qtyPrice)) {
+			array = FastjsonUtils.fromJsonArray(this.qtyPrice, GoodsQtyPrice.class);
+		}
+		if (!StringUtils.isEmpty(this.minBuyQty) && CollectionUtils.isNotEmpty(array)) {
 			GoodsQtyPrice price = array.get(0);
 			if (NumberUtil.compare(price.getStart(), this.minBuyQty) > 0) {
 				price.setStart(this.minBuyQty);
@@ -1838,6 +1841,8 @@ public class Goods implements Serializable {
 		if (this.autoPublish == null) {
 			this.autoPublish = Boolean.TRUE;
 		}
+		setMinBuyQtyByMinPackQty(this.minBuyQty);
+		adjustFragmentPrice();
 		this.setStatus();
 		return this;
 	}
@@ -1930,6 +1935,8 @@ public class Goods implements Serializable {
 		if (this.autoPublish == null) {
 			this.autoPublish = Boolean.TRUE;
 		}
+		setMinBuyQtyByMinPackQty(this.minBuyQty);
+		adjustFragmentPrice();
 		this.setStatus();
 
 		return this;

+ 4 - 2
src/main/java/com/uas/platform/b2c/prod/commodity/service/InOutboundDetailService.java

@@ -1,11 +1,10 @@
 package com.uas.platform.b2c.prod.commodity.service;
 
 import com.uas.platform.b2c.logistics.model.InvoiceDetail;
-import com.uas.platform.b2c.logistics.model.InvoiceFOrderDetail;
-import com.uas.platform.b2c.logistics.model.InvoiceFPurchaseDetail;
 import com.uas.platform.b2c.prod.commodity.model.InOutboundDetail;
 
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -26,4 +25,7 @@ public interface InOutboundDetailService {
      * @return
      */
     Set<InOutboundDetail> produceInOutboundDetailByInvoiceDetail(Set<InvoiceDetail> details);
+
+
+    Map<String, Set<InOutboundDetail>> initInOutboundDetailByQty (Set<InOutboundDetail> newInOutboundDetail);
 }

+ 1 - 2
src/main/java/com/uas/platform/b2c/prod/commodity/service/ProductService.java

@@ -341,9 +341,8 @@ public interface ProductService {
      * @param reList 临时表的id
      * @param ignoreImport 1表示忽略导入,0代表覆盖导入
      * @param newInOutboundDetail 出入库明细
-     * @param inOutMap 出入库的map
      */
-    void updateProductsByReleaseProductByBatch(Set<Long> prIds, List<ReleaseProductByBatch> reList, Integer ignoreImport, Set<InOutboundDetail> newInOutboundDetail, Map<String, Set<InOutboundDetail>> inOutMap);
+    void updateProductsByReleaseProductByBatch(Set<Long> prIds, List<ReleaseProductByBatch> reList, Integer ignoreImport, Set<InOutboundDetail> newInOutboundDetail);
 
 
     /**

+ 27 - 6
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/InOutboundDetailServiceImpl.java

@@ -1,19 +1,17 @@
 package com.uas.platform.b2c.prod.commodity.service.impl;
 
+import com.uas.platform.b2c.core.utils.NumberUtil;
 import com.uas.platform.b2c.logistics.model.InvoiceDetail;
-import com.uas.platform.b2c.logistics.model.InvoiceFOrderDetail;
-import com.uas.platform.b2c.logistics.model.InvoiceFPurchaseDetail;
+import com.uas.platform.b2c.prod.commodity.constant.DoubleConstant;
 import com.uas.platform.b2c.prod.commodity.model.InOutboundDetail;
 import com.uas.platform.b2c.prod.commodity.dao.InOutboundDetailDao;
 import com.uas.platform.b2c.prod.commodity.service.InOutboundDetailService;
+import com.uas.platform.b2c.prod.commodity.type.InOutBoundType;
 import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 /**
  * description
@@ -66,4 +64,27 @@ public class InOutboundDetailServiceImpl implements InOutboundDetailService {
         }
         return inOutBoundset;
     }
+
+    public Map<String, Set<InOutboundDetail>> initInOutboundDetailByQty (Set<InOutboundDetail> newInOutboundDetail) {
+        Map<String, Set<InOutboundDetail>> inOutMap = new HashMap<>();
+        if (CollectionUtils.isNotEmpty(newInOutboundDetail)) {
+            Set<InOutboundDetail> inBoundDetail = new HashSet<>();
+            Set<InOutboundDetail> outBoundDetail = new HashSet<>();
+            for (InOutboundDetail detail1 : newInOutboundDetail) {
+                if (NumberUtil.compare(detail1.getQty(), DoubleConstant.zero) < 0) {
+                    detail1.setQty(Math.abs(detail1.getQty()));
+                    outBoundDetail.add(detail1);
+                } else if (NumberUtil.compare(detail1.getQty(), DoubleConstant.zero) > 0) {
+                    inBoundDetail.add(detail1);
+                }
+            }
+            if (CollectionUtils.isNotEmpty(inBoundDetail)) {
+                inOutMap.put(InOutBoundType.OTHER_INBOUND, inBoundDetail);
+            }
+            if (CollectionUtils.isNotEmpty(outBoundDetail)) {
+                inOutMap.put(InOutBoundType.OTHER_OUTBOUND, outBoundDetail);
+            }
+        }
+        return inOutMap;
+    }
 }

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

@@ -2261,24 +2261,6 @@ public class ProductServiceImpl implements ProductService {
             }
         }
         productDao.save(freshProducts);
-        if (CollectionUtils.isNotEmpty(newInOutboundDetail)) {
-            Set<InOutboundDetail> inBoundDetail = new HashSet<>();
-            Set<InOutboundDetail> outBoundDetail = new HashSet<>();
-            for (InOutboundDetail detail1 : newInOutboundDetail) {
-                if (NumberUtil.compare(detail1.getQty(), DoubleConstant.zero) < 0) {
-                    detail1.setQty(Math.abs(detail1.getQty()));
-                    outBoundDetail.add(detail1);
-                } else if (NumberUtil.compare(detail1.getQty(), DoubleConstant.zero) > 0) {
-                    inBoundDetail.add(detail1);
-                }
-            }
-            if (CollectionUtils.isNotEmpty(inBoundDetail)) {
-                inOutMap.put(InOutBoundType.OTHER_INBOUND, inBoundDetail);
-            }
-            if (CollectionUtils.isNotEmpty(outBoundDetail)) {
-                inOutMap.put(InOutBoundType.OTHER_OUTBOUND, outBoundDetail);
-            }
-        }
     }
 
 

+ 8 - 2
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ReleaseProductByBatchServiceImpl.java

@@ -142,6 +142,10 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 	@Autowired
 	private CommodityInOutboundService commodityInOutboundService;
 
+	@Autowired
+	private InOutboundDetailService inOutboundDetailService;
+
+
 	private final Logger logger = Logger.getLogger(getClass());
 
 	/**
@@ -2054,8 +2058,10 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
 		}
 		//将本次临时表中的数据更新到物料表中
         if (CollectionUtils.isNotEmpty(updateProducts)) {
-			Map<String, Set<InOutboundDetail>> inOutMap = new HashedMap();
-            productService.updateProductsByReleaseProductByBatch(prIds, releaseProductByBatchList, ignoreImport, newInOutboundDetail, inOutMap);
+            productService.updateProductsByReleaseProductByBatch(prIds, releaseProductByBatchList, ignoreImport, newInOutboundDetail);
+		}
+		if (CollectionUtils.isNotEmpty(newInOutboundDetail)) {
+			Map<String, Set<InOutboundDetail>> inOutMap = inOutboundDetailService.initInOutboundDetailByQty(newInOutboundDetail);
 			Set<String> stringSet = inOutMap.keySet();
 			for (String type : stringSet) {
 				CommodityInOutbound commodityInOutbound = commodityInOutboundService.produceCommodityInOutbound(inOutMap.get(type), type);