Ver código fonte

售后问题处理

yzc 1 ano atrás
pai
commit
62761916b8

+ 5 - 0
hx-jxst/src/main/java/com/fjhx/jxst/entity/statement/bo/SettlementBo.java

@@ -45,6 +45,11 @@ public class SettlementBo {
      * 合同金额
      */
     private BigDecimal contractAmount;
+
+    /**
+     * 合同到账金额
+     */
+    private BigDecimal contractClaimAmount;
     /**
      * 物料成本
      */

+ 23 - 32
hx-jxst/src/main/java/com/fjhx/jxst/service/sales/impl/SalesContractServiceImpl.java

@@ -204,29 +204,8 @@ public class SalesContractServiceImpl extends ServiceImpl<SalesContractMapper, S
 
         //计算 总支出 毛利 毛利率
         for (SettlementBo record : records) {
-            //总支出
-            BigDecimal totalExpenditure = BigDecimal.ZERO;
-            totalExpenditure.add(record.getMaterialFee());//物料费
-            totalExpenditure.add(record.getAfterSalesFee());//售后费用
-            totalExpenditure.add(record.getTrailerFee());//拖车费
-            totalExpenditure.add(record.getInspectionRedPackFee());//验货红包
-            totalExpenditure.add(record.getCommissionFee());//佣金
-            totalExpenditure.add(record.getOtherFee());//其他费用
-            record.setTotalExpenditure(totalExpenditure);
-
-            //毛利(总收入-总支出)
-            record.setGrossProfit(record.getTotalIncome().subtract(record.getTotalExpenditure()));
-
-            //毛利率(毛利/总收入*100%)
-            BigDecimal grossProfitMargin = BigDecimal.ZERO;
-            if (record.getGrossProfit().compareTo(BigDecimal.ZERO) > 0) {
-                grossProfitMargin = record.getGrossProfit()
-                        .divide(record.getTotalIncome(), 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
-            }
-            record.setGrossProfitMargin(grossProfitMargin);
-
-            //变成科学计数法问题处理
-            record.setMaterialFee(record.getMaterialFee().setScale(4, RoundingMode.HALF_UP));
+            //调用公共代码计算
+            profitClearingConn(record);
         }
 
         return profitClearingPage;
@@ -240,15 +219,28 @@ public class SalesContractServiceImpl extends ServiceImpl<SalesContractMapper, S
         IWrapper<SalesContract> wrapper = getProfitClearingWrapper(dto);
         SettlementBo record = baseMapper.getProfitSettlementHead(wrapper);
 
+        //调用公共代码计算
+        profitClearingConn(record);
+
+        return record;
+    }
+
+    /**
+     * 公共的计算代码块
+     */
+    SettlementBo profitClearingConn(SettlementBo record){
+        //总收入
+        record.setTotalIncome(record.getContractClaimAmount().setScale(4, RoundingMode.HALF_UP));
+
         //总支出
         BigDecimal totalExpenditure = BigDecimal.ZERO;
-        totalExpenditure.add(record.getMaterialFee());//物料费
-        totalExpenditure.add(record.getAfterSalesFee());//售后费用
-        totalExpenditure.add(record.getTrailerFee());//拖车费
-        totalExpenditure.add(record.getInspectionRedPackFee());//验货红包
-        totalExpenditure.add(record.getCommissionFee());//佣金
-        totalExpenditure.add(record.getOtherFee());//其他费用
-        record.setTotalExpenditure(totalExpenditure);
+        totalExpenditure = totalExpenditure.add(record.getMaterialFee());//物料费
+        totalExpenditure = totalExpenditure.add(record.getAfterSalesFee());//售后费用
+        totalExpenditure = totalExpenditure.add(record.getTrailerFee());//拖车费
+        totalExpenditure = totalExpenditure.add(record.getInspectionRedPackFee());//验货红包
+        totalExpenditure = totalExpenditure.add(record.getCommissionFee());//佣金
+        totalExpenditure = totalExpenditure.add(record.getOtherFee());//其他费用
+        record.setTotalExpenditure(totalExpenditure.setScale(4, RoundingMode.HALF_UP));
 
         //毛利(总收入-总支出)
         record.setGrossProfit(record.getTotalIncome().subtract(record.getTotalExpenditure()));
@@ -257,13 +249,12 @@ public class SalesContractServiceImpl extends ServiceImpl<SalesContractMapper, S
         BigDecimal grossProfitMargin = BigDecimal.ZERO;
         if (record.getGrossProfit().compareTo(BigDecimal.ZERO) > 0) {
             grossProfitMargin = record.getGrossProfit()
-                    .divide(record.getTotalIncome(), 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
+                    .divide(record.getTotalIncome(), 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
         }
         record.setGrossProfitMargin(grossProfitMargin);
 
         //变成科学计数法问题处理
         record.setMaterialFee(record.getMaterialFee().setScale(4, RoundingMode.HALF_UP));
-
         return record;
     }
 

+ 1 - 2
hx-jxst/src/main/resources/mapper/sales/SalesContractMapper.xml

@@ -26,7 +26,6 @@
     </select>
     <select id="getProfitSettlementHead" resultType="com.fjhx.jxst.entity.statement.bo.SettlementBo">
         SELECT
-            IFNULL( sum( totalIncome ), 0 ) AS totalIncome,
             IFNULL( sum( materialFee ), 0 ) AS materialFee,
             IFNULL( sum( afterSalesFee ), 0 ) AS afterSalesFee,
             IFNULL( sum( trailerFee ), 0 ) AS trailerFee,
@@ -46,7 +45,7 @@
             sc.`code` AS salesContractCode,
             sc.customer_id,
             cu.`name` AS customerName,
-            ( SELECT IFNULL( sum( cc.contract_money ), 0 ) FROM bytesailing_sale.claim_contract cc WHERE cc.contract_id = sc.id ) AS totalIncome,
+            ( SELECT IFNULL( sum( cc.contract_money ), 0 ) FROM bytesailing_sale.claim_contract cc WHERE cc.contract_id = sc.id ) AS contractClaimAmount,
             sc.contract_amount AS contractAmount,
             (
                 SELECT