Browse Source

处理了入库的bug

yujia 7 years ago
parent
commit
18f27043ec

+ 1 - 1
src/main/java/com/uas/platform/b2c/logistics/service/impl/InvoiceServiceImpl.java

@@ -871,7 +871,7 @@ public class InvoiceServiceImpl implements InvoiceService {
         if(NumberUtil.compare(purchase.getQty(), purchase.getShipQty()) < 1) {
             Set<PurchaseDetail> purchaseDetails = purchase.getPurchaseDetails();
             for (PurchaseDetail purchaseDetail : purchaseDetails) {
-                if (Status.TOBESHIPPED.value() == purchaseDetail.getStatus()) {
+                if (Status.TOBESHIPPED.value() == purchaseDetail.getStatus() || Status.CONFIRMED.value() == purchaseDetail.getStatus()) {
                     purchaseDetail.setStatusInBound(userUU);
                 }
             }

+ 12 - 3
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/CommodityInOutboundServiceImpl.java

@@ -197,10 +197,19 @@ public class CommodityInOutboundServiceImpl implements CommodityInOutboundServic
                         if (inOutboundDetail.getProductId().longValue() == product.getId().longValue()) {
                             if (InOutBoundType.INBOUND.equals(type) || InOutBoundType.OTHER_INBOUND.equals(type) || InOutBoundType.PURCHASE_INBOUND.equals(type)) {
                                 //只有入库会影响成本单价
-                                if (NumberUtil.compare(product.getPrice(), DoubleConstant.zero) < 1) {
-                                    product.setPrice(DoubleConstant.zero);
+                                Double totalQty = 0.0d;
+                                Double price = 0.0d;
+                                if (NumberUtil.compare(product.getPrice(), DoubleConstant.zero) > 0 && NumberUtil.compare(product.getErpReserve(), DoubleConstant.zero) > 0) {
+                                    price = NumberUtil.add(price, NumberUtil.mul(product.getErpReserve(), inOutboundDetail.getQty()));
+                                    totalQty = NumberUtil.add(totalQty, product.getErpReserve());
+                                }
+                                if (NumberUtil.compare(inOutboundDetail.getPrice(), DoubleConstant.zero) > 0 && NumberUtil.compare(inOutboundDetail.getQty(), DoubleConstant.zero) > 0) {
+                                    price = NumberUtil.add(price, NumberUtil.mul(inOutboundDetail.getPrice(),inOutboundDetail.getQty()));
+                                    totalQty = NumberUtil.add(totalQty, inOutboundDetail.getQty());
+                                }
+                                if (NumberUtil.compare(totalQty, DoubleConstant.zero) > 0) {
+                                    product.setPrice(NumberUtil.div(price, totalQty));
                                 }
-                                product.setPrice(NumberUtil.div(NumberUtil.add(NumberUtil.mul(product.getPrice(), product.getErpReserve()), NumberUtil.mul(inOutboundDetail.getPrice(), inOutboundDetail.getQty())), NumberUtil.add(product.getErpReserve(), inOutboundDetail.getQty())));
                                 product.setErpReserve(NumberUtil.add(product.getErpReserve(), inOutboundDetail.getQty()));
                                 productSet.add(product);
                             } else {