Kaynağa Gözat

update 改为调用统一计算扣亏量

chenlin 2 yıl önce
ebeveyn
işleme
8cf663c86a

+ 10 - 21
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/ManagementWaybillOrderService.java

@@ -188,28 +188,17 @@ public class ManagementWaybillOrderService {
                 BigDecimal deficitAmount = waybillOrder.getDeficitAmount() == null ?
                         BigDecimal.valueOf(0) : waybillOrder.getDeficitAmount();
                 vo.setDeficitAmount(String.valueOf(deficitAmount));
-                // 存在装卸货差时 计算扣亏量
-                BigDecimal lossAmount = BigDecimal.valueOf(0);
-                BigDecimal loss = waybillOrder.getLoss() == null ? new BigDecimal("0.00") : waybillOrder.getLoss();
-                if (deficitAmount.compareTo(new BigDecimal("0.00")) > 0 && loss.compareTo(new BigDecimal("0.00")) > 0) {
-                    String lossUnit = waybillOrder.getLossUnit();
-                    Map<String, String> LossUnitType = commonService.getDictData(DictTypeEnum.TAX_RATE_TYPE.getType());
-                    String lossUnitString = LossUnitType.get(lossUnit);
+                // 计算扣亏量
+                BigDecimal loadAmount = waybillOrder.getLoadAmount() == null ? new BigDecimal("0.00") : waybillOrder.getLoadAmount();
+                BigDecimal unloadAmount = waybillOrder.getUnloadAmount() == null ? new BigDecimal("0.00") : waybillOrder.getUnloadAmount();
+                BigDecimal deficitRealAmount = commonService.deficitPrice(
+                        waybillOrder.getLoadAmount(),
+                        loadAmount.subtract(unloadAmount),
+                        waybillOrder.getLoss(),
+                        waybillOrder.getLossUnit()
+                );
+                vo.setDeficitRealAmount(deficitRealAmount.setScale(2, RoundingMode.HALF_UP).toString());
 
-                    if (lossUnitString.equals("%")) {
-                        // 百分比
-                        lossAmount = loss.multiply(waybillOrder.getLoadAmount()).divide(BigDecimal.valueOf(100));
-                    } else {
-                        // 千分比
-                        lossAmount = loss.multiply(waybillOrder.getLoadAmount()).divide(BigDecimal.valueOf(1000));
-                    }
-                    lossAmount = deficitAmount.subtract(lossAmount);
-                    if (lossAmount.compareTo(new BigDecimal("0.00")) < 0) {
-                        lossAmount = new BigDecimal("0.00");
-                    }
-                }
-                // 实际扣亏量
-                vo.setDeficitRealAmount(lossAmount.setScale(2, RoundingMode.HALF_UP).toString());
                 vo.setGoodsPriceUnit(waybillOrder.getGoodsPriceUnit() == null ?
                         null : String.valueOf(waybillOrder.getGoodsPriceUnit()));
                 returnList.add(vo);

+ 7 - 6
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/WaybillManagementService.java

@@ -187,15 +187,16 @@ public class WaybillManagementService {
                 }
             }
             waybillTicketVO.setDeficitAmount(String.valueOf(info.getDeficitAmount()));
+            // 计算扣亏量
             BigDecimal deficitLoss = info.getLoss() == null ? BigDecimal.valueOf(0) : info.getLoss();
-            BigDecimal deficitAmount = info.getDeficitAmount() == null ? BigDecimal.valueOf(0) : info.getDeficitAmount();
-//            BigDecimal deficitRealAmount = BigDecimal.valueOf(0);
-//            if (deficitAmount.compareTo(BigDecimal.valueOf(0)) > 0) {
-//                deficitRealAmount = deficitLoss.subtract(deficitAmount);
-//            }
             BigDecimal loadAmount = info.getLoadAmount() == null ? new BigDecimal("0.00") : info.getLoadAmount();
             BigDecimal unloadAmount = info.getUnloadAmount() == null ? new BigDecimal("0.00") : info.getUnloadAmount();
-            BigDecimal deficitRealAmount = commonService.deficitPrice(info.getLoadAmount(), loadAmount.subtract(unloadAmount), deficitLoss, info.getLossUnit());
+            BigDecimal deficitRealAmount = commonService.deficitPrice(
+                    info.getLoadAmount(),
+                    loadAmount.subtract(unloadAmount),
+                    deficitLoss,
+                    info.getLossUnit()
+            );
             waybillTicketVO.setDeficitRealAmount(deficitRealAmount.toString());
         }