wks 2 лет назад
Родитель
Сommit
5b4f45b778

+ 47 - 37
src/main/java/com/ydtech/modules/fee/service/FeeRuleSchemeService.java

@@ -26,6 +26,7 @@ public interface FeeRuleSchemeService {
 
     /**
      * 查询费用明细
+     *
      * @param companyId
      * @return
      */
@@ -35,48 +36,53 @@ public interface FeeRuleSchemeService {
 
     /**
      * 比较和更新总费用比例
+     *
      * @param insOrderNo
      * @param jqCostsProportionStr
      * @param syCostsProportionStr
      */
-    void compareAndUpdateFeeOrderInfo(String insOrderNo ,String jqCostsProportionStr,String syCostsProportionStr,String dealUser);
+    void compareAndUpdateFeeOrderInfo(String insOrderNo, String jqCostsProportionStr, String syCostsProportionStr, String dealUser);
 
     /**
      * 计算入口费用
-     * @param premium    保费
-     * @param superviseCostsProportion  手续费比例
-     * @param otherCostsProportion      跟单比例
+     *
+     * @param premium                  保费
+     * @param superviseCostsProportion 手续费比例
+     * @param otherCostsProportion     跟单比例
      */
     FeeOrderNewVo.EntranceFee calcEntranceFee(BigDecimal premium, BigDecimal superviseCostsProportion, BigDecimal otherCostsProportion, BigDecimal taxRate);
 
     /**
      * 计算机构管理费用
-     * @param premium   保费
-     * @param level1Proportion  一级比例
-     * @param level2Proportion  二级比例
-     * @param level3Proportion  三级比例
-     * @param level4Proportion  四级比例
-     * @param level5Proportion  五级比例
+     *
+     * @param premium          保费
+     * @param level1Proportion 一级比例
+     * @param level2Proportion 二级比例
+     * @param level3Proportion 三级比例
+     * @param level4Proportion 四级比例
+     * @param level5Proportion 五级比例
      * @return
      */
-    public FeeOrderNewVo.DeptManagerFee calcDeptManagerFee(BigDecimal premium, BigDecimal level1Proportion,BigDecimal level2Proportion,
-                                                           BigDecimal level3Proportion,BigDecimal level4Proportion,BigDecimal level5Proportion);
+    public FeeOrderNewVo.DeptManagerFee calcDeptManagerFee(BigDecimal premium, BigDecimal level1Proportion, BigDecimal level2Proportion,
+                                                           BigDecimal level3Proportion, BigDecimal level4Proportion, BigDecimal level5Proportion);
 
     /**
      * 计算出口费用
-     * @param premium   保费
-     * @param superviseCostsProportion  出口手续费
-     * @param entranceTotalProportion   入口总比例
-     * @param deptTotalProportion       机构管理费总比例
-     * @param retailTotalProportion     分销总比例
-     * @param taxRate                   税率
+     *
+     * @param premium                  保费
+     * @param superviseCostsProportion 出口手续费
+     * @param entranceTotalProportion  入口总比例
+     * @param deptTotalProportion      机构管理费总比例
+     * @param retailTotalProportion    分销总比例
+     * @param taxRate                  税率
      * @return
      */
     public FeeOrderNewVo.ExportFee calcExportFee(BigDecimal premium, BigDecimal superviseCostsProportion, BigDecimal entranceTotalProportion,
-                                                 BigDecimal deptTotalProportion,BigDecimal retailTotalProportion,BigDecimal taxRate);
+                                                 BigDecimal deptTotalProportion, BigDecimal retailTotalProportion, BigDecimal taxRate, BigDecimal enterProportion);
 
     /**
      * 计算分销费用
+     *
      * @param jqPremiums
      * @param jqProportion
      * @param syPremiums
@@ -85,38 +91,42 @@ public interface FeeRuleSchemeService {
      * @param noProportion
      * @param jqRetailProportion
      */
-    FeeOrderNewVo.RetailFee calcRetail(BigDecimal jqPremiums,BigDecimal jqProportion, BigDecimal syPremiums,BigDecimal syProportion, BigDecimal noPremiums,
-                                 BigDecimal noProportion, BigDecimal jqRetailProportion, BigDecimal syRetailProportion, BigDecimal noRetailProportion);
+    FeeOrderNewVo.RetailFee calcRetail(BigDecimal jqPremiums, BigDecimal jqProportion, BigDecimal syPremiums, BigDecimal syProportion, BigDecimal noPremiums,
+                                       BigDecimal noProportion, BigDecimal jqRetailProportion, BigDecimal syRetailProportion, BigDecimal noRetailProportion);
 
 
     FeeOrderNewVo newConvertOrderFeeVoData(InsFeeOrderNew insFeeOrderNew, PtlAgreementProductCostsNew ptlAgreementProductCostsNew);
 
 
-    FeeOrderNewVo.EntranceFee assignEntranceFee(String title,BigDecimal premium,BigDecimal superviseCostsProportion,BigDecimal otherCostsProportion,
-                                                BigDecimal costsProportion,BigDecimal superviseCostsPremiums,BigDecimal otherCostsPremiums,
+    FeeOrderNewVo.EntranceFee assignEntranceFee(String title, BigDecimal premium, BigDecimal superviseCostsProportion, BigDecimal otherCostsProportion,
+                                                BigDecimal costsProportion, BigDecimal superviseCostsPremiums, BigDecimal otherCostsPremiums,
                                                 BigDecimal costsPremiums);
 
-    FeeOrderNewVo.DeptManagerFee assignDeptFee(String title,BigDecimal level1Proportion,BigDecimal level1Premium,
-                                               BigDecimal level2Proportion,BigDecimal level2Premium,
-                                               BigDecimal level3Proportion,BigDecimal level3Premium,
-                                               BigDecimal level4Proportion,BigDecimal level4Premium,
-                                               BigDecimal level5Proportion,BigDecimal level5Premium,
-                                               BigDecimal profitMarginPremiums);
+    FeeOrderNewVo.DeptManagerFee assignDeptFee(String title, BigDecimal level1Proportion, BigDecimal level1Premium,
+                                               BigDecimal level2Proportion, BigDecimal level2Premium,
+                                               BigDecimal level3Proportion, BigDecimal level3Premium,
+                                               BigDecimal level4Proportion, BigDecimal level4Premium,
+                                               BigDecimal level5Proportion, BigDecimal level5Premium,
+                                               BigDecimal profitMarginPremiums,
+                                               BigDecimal externalProportion, BigDecimal externalPremiums
+    );
 
-    FeeOrderNewVo.ExportFee assignExportFee(String title,BigDecimal premium,BigDecimal superviseCostsProportion,BigDecimal otherCostsProportion,
-                                            BigDecimal superviseCostsPremiums,BigDecimal otherCostsPremiums);
+    FeeOrderNewVo.ExportFee assignExportFee(String title, BigDecimal premium, BigDecimal superviseCostsProportion, BigDecimal otherCostsProportion,
+                                            BigDecimal superviseCostsPremiums, BigDecimal otherCostsPremiums
+    );
 
 
     /**
      * 推算比例是否正确
-     * @param entranceFee     入口
-     * @param deptManagerFee  机构管理
-     * @param exportFee       出口
-     * @param retailRadio     分销比例
-     * @param premiums        保费
+     *
+     * @param entranceFee    入口
+     * @param deptManagerFee 机构管理
+     * @param exportFee      出口
+     * @param retailRadio    分销比例
+     * @param premiums       保费
      * @return
      */
-    boolean calculateProportion(FeeOrderNewVo.EntranceFee entranceFee,FeeOrderNewVo.DeptManagerFee deptManagerFee,FeeOrderNewVo.ExportFee exportFee,BigDecimal retailRadio,BigDecimal taxRadio,BigDecimal premiums);
+    boolean calculateProportion(FeeOrderNewVo.EntranceFee entranceFee, FeeOrderNewVo.DeptManagerFee deptManagerFee, FeeOrderNewVo.ExportFee exportFee, BigDecimal retailRadio, BigDecimal taxRadio, BigDecimal premiums);
 
     List<DistributionLevelVo> converDistrbutionData(InsFeeOrderNew insFeeOrderNew);
 }

+ 1 - 1
src/main/java/com/ydtech/modules/fee/service/InsFeeOrderConfigService.java

@@ -17,6 +17,6 @@ public interface InsFeeOrderConfigService extends IService<InsFeeOrderConfig> {
      * 获取出单比例
      * @return 出单比例
      */
-    BigDecimal getEnterProportion();
+    BigDecimal getEnterProportion(Integer entryStatus);
 
 }

+ 67 - 47
src/main/java/com/ydtech/modules/fee/service/impl/FeeRuleSchemeServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ydtech.modules.fee.service.impl;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.beust.ah.A;
 import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.model.SysUser;
@@ -27,6 +28,7 @@ import com.ydtech.modules.protocol.service.*;
 import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
 import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsNew;
 import com.ydtech.modules.protocols.service.InsFeeOrderNewService;
+import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.math.NumberUtils;
@@ -1779,10 +1781,10 @@ public class FeeRuleSchemeServiceImpl implements FeeRuleSchemeService {
         detailLevel2FeeResultVo.setSyFeeRateAll(insFeeOrderNew.getSecondDetailProportion().toString());
         detailLevel2FeeResultVo.setFcFeeRateAll(insFeeOrderNew.getSecondDetailProportion().toString());
         BigDecimal jqDetailFeePremium2 =
-         insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal("100")));
+                insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal("100")));
         detailLevel2FeeResultVo.setJqFeeAmountAll(jqDetailFeePremium2.setScale(2, BigDecimal.ROUND_DOWN).toString());
         BigDecimal syDetailFeePremium2 =
-         insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal("100")));
+                insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal("100")));
         detailLevel2FeeResultVo.setSyFeeAmountAll(syDetailFeePremium2.setScale(2, BigDecimal.ROUND_DOWN).toString());
         BigDecimal fcDetailFeePremium2 =
                 insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal("100")));
@@ -1800,10 +1802,10 @@ public class FeeRuleSchemeServiceImpl implements FeeRuleSchemeService {
                 insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal("100")));
         detailLevel3FeeResultVo.setJqFeeAmountAll(jqDetailFeePremium3.setScale(2, BigDecimal.ROUND_DOWN).toString());
         BigDecimal syDetailFeePremium3 =
-         insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal("100")));
+                insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal("100")));
         detailLevel3FeeResultVo.setSyFeeAmountAll(syDetailFeePremium3.setScale(2, BigDecimal.ROUND_DOWN).toString());
         BigDecimal fcDetailFeePremium3 =
-         insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal("100")));
+                insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal("100")));
         detailLevel3FeeResultVo.setFcFeeAmountAll(fcDetailFeePremium3.setScale(2, BigDecimal.ROUND_DOWN).toString());
         queryOrderFeeResultVos.add(detailLevel3FeeResultVo);
 
@@ -2648,7 +2650,7 @@ public class FeeRuleSchemeServiceImpl implements FeeRuleSchemeService {
         FeeOrderNewVo.EntranceFee jqEntranceFee = this.assignEntranceFee("交强险", insFeeOrderNew.getJqPremium(),
                 insFeeOrderNew.getJqSuperviseCostsProportion(),
                 insFeeOrderNew.getJqOtherCostsProportion(), insFeeOrderNew.getJqCostsProportion(),
-                 insFeeOrderNew.getJqSuperviseCostsPremiums(),
+                insFeeOrderNew.getJqSuperviseCostsPremiums(),
                 insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getJqCostsPremiums());
         entranceFeeList.add(jqEntranceFee);
 
@@ -2656,13 +2658,13 @@ public class FeeRuleSchemeServiceImpl implements FeeRuleSchemeService {
         FeeOrderNewVo.EntranceFee syEntranceFee = this.assignEntranceFee("商业险", insFeeOrderNew.getSyPremium(),
                 insFeeOrderNew.getSySuperviseCostsProportion(),
                 insFeeOrderNew.getSyOtherCostsProportion(), insFeeOrderNew.getSyCostsProportion(),
-                 insFeeOrderNew.getSySuperviseCostsPremiums(),
+                insFeeOrderNew.getSySuperviseCostsPremiums(),
                 insFeeOrderNew.getSyOtherCostsPremiums(), insFeeOrderNew.getSyCostsPremiums());
         entranceFeeList.add(syEntranceFee);
 
         //非车
         FeeOrderNewVo.EntranceFee noEntranceFee = this.assignEntranceFee("非车险", insFeeOrderNew.getNoPremium(),
-         insFeeOrderNew.getNoSuperviseCostsProportion(),
+                insFeeOrderNew.getNoSuperviseCostsProportion(),
                 insFeeOrderNew.getNoOtherCostsProportion(), insFeeOrderNew.getNoCostsProportion(),
                 insFeeOrderNew.getNoSuperviseCostsPremiums(),
                 insFeeOrderNew.getNoOtherCostsPremiums(), insFeeOrderNew.getNoCostsPremiums());
@@ -2679,7 +2681,8 @@ public class FeeRuleSchemeServiceImpl implements FeeRuleSchemeService {
                 insFeeOrderNew.getJqDeptProportionLevel3(), insFeeOrderNew.getJqDeptPremiumsLevel3(),
                 insFeeOrderNew.getJqDeptProportionLevel4(), insFeeOrderNew.getJqDeptPremiumsLevel4(),
                 insFeeOrderNew.getJqDeptProportionLevel5(), insFeeOrderNew.getJqDeptPremiumsLevel5(),
-                insFeeOrderNew.getJqProfitMarginPremiums());
+                insFeeOrderNew.getJqProfitMarginPremiums(),
+                insFeeOrderNew.getJqExternalProportion(), insFeeOrderNew.getJqExternalPremiums());
         deptManagerFeeList.add(jqDeptManagerFee);
 
         //商业
@@ -2689,7 +2692,8 @@ public class FeeRuleSchemeServiceImpl implements FeeRuleSchemeService {
                 insFeeOrderNew.getSyDeptProportionLevel3(), insFeeOrderNew.getSyDeptPremiumsLevel3(),
                 insFeeOrderNew.getSyDeptProportionLevel4(), insFeeOrderNew.getSyDeptPremiumsLevel4(),
                 insFeeOrderNew.getSyDeptProportionLevel5(), insFeeOrderNew.getSyDeptPremiumsLevel5(),
-                insFeeOrderNew.getSyProfitMarginPremiums());
+                insFeeOrderNew.getSyProfitMarginPremiums(),
+                insFeeOrderNew.getJqExternalProportion(), insFeeOrderNew.getJqExternalPremiums());
         deptManagerFeeList.add(syDeptManagerFee);
 
         //非车
@@ -2699,7 +2703,8 @@ public class FeeRuleSchemeServiceImpl implements FeeRuleSchemeService {
                 insFeeOrderNew.getNoDeptProportionLevel3(), insFeeOrderNew.getNoDeptPremiumsLevel3(),
                 insFeeOrderNew.getNoDeptProportionLevel4(), insFeeOrderNew.getNoDeptPremiumsLevel4(),
                 insFeeOrderNew.getNoDeptProportionLevel5(), insFeeOrderNew.getNoDeptPremiumsLevel5(),
-                insFeeOrderNew.getNoProfitMarginPremiums());
+                insFeeOrderNew.getNoProfitMarginPremiums(),
+                insFeeOrderNew.getJqExternalProportion(), insFeeOrderNew.getJqExternalPremiums());
         deptManagerFeeList.add(noDeptManagerFee);
 
         //endregion
@@ -2714,7 +2719,7 @@ public class FeeRuleSchemeServiceImpl implements FeeRuleSchemeService {
         retailFeeLevel1.setNoRetailProportion(insFeeOrderNew.getNoRetailProportionLevel1());
         retailFeeLevel1.setNoRetailPremiums(insFeeOrderNew.getNoRetailPremiumsLevel1());
         retailFeeLevel1.setTotalRetailPremiums(insFeeOrderNew.getFirstDetailPremiums());
-        if(insFeeOrderNew.getFirstLevelUserId() != null) {
+        if (insFeeOrderNew.getFirstLevelUserId() != null) {
             SysUser byId = sysUserService.getById(insFeeOrderNew.getFirstLevelUserId());
             retailFeeLevel1.setUserName(byId.getName() + "(" + byId.getId() + ")");
         }
@@ -2729,7 +2734,7 @@ public class FeeRuleSchemeServiceImpl implements FeeRuleSchemeService {
         retailFeeLevel2.setNoRetailProportion(insFeeOrderNew.getNoRetailProportionLevel2());
         retailFeeLevel2.setNoRetailPremiums(insFeeOrderNew.getNoRetailPremiumsLevel2());
         retailFeeLevel2.setTotalRetailPremiums(insFeeOrderNew.getSecondDetailPremiums());
-        if(insFeeOrderNew.getTwoLevelUserId() != null) {
+        if (insFeeOrderNew.getTwoLevelUserId() != null) {
             SysUser byId = sysUserService.getById(insFeeOrderNew.getTwoLevelUserId());
             retailFeeLevel2.setUserName(byId.getName() + "(" + byId.getId() + ")");
         }
@@ -2744,9 +2749,9 @@ public class FeeRuleSchemeServiceImpl implements FeeRuleSchemeService {
         retailFeeLevel3.setNoRetailProportion(insFeeOrderNew.getNoRetailProportionLevel3());
         retailFeeLevel3.setNoRetailPremiums(insFeeOrderNew.getNoRetailPremiumsLevel3());
         retailFeeLevel3.setTotalRetailPremiums(insFeeOrderNew.getThirdDetailPremiums());
-        if(insFeeOrderNew.getThreeLevelUserId() != null){
+        if (insFeeOrderNew.getThreeLevelUserId() != null) {
             SysUser byId = sysUserService.getById(insFeeOrderNew.getThreeLevelUserId());
-            retailFeeLevel3.setUserName(byId.getName()+"("+byId.getId()+")");
+            retailFeeLevel3.setUserName(byId.getName() + "(" + byId.getId() + ")");
         }
         retailFeeList.add(retailFeeLevel3);
 
@@ -2757,28 +2762,31 @@ public class FeeRuleSchemeServiceImpl implements FeeRuleSchemeService {
         //交强
         FeeOrderNewVo.ExportFee jqExportFee = this.assignExportFee("交强险",
                 insFeeOrderNew.getJqPremium(), insFeeOrderNew.getJqCostsExportProportion(),
-                 insFeeOrderNew.getJqExportOtherCostsProportion(),
-                insFeeOrderNew.getJqExportSuperviseCostsPremiums(), insFeeOrderNew.getJqExportOtherCostsPremiums());
+                insFeeOrderNew.getJqExportOtherCostsProportion(),
+                insFeeOrderNew.getJqExportSuperviseCostsPremiums(), insFeeOrderNew.getJqExportOtherCostsPremiums()
+        );
         //exportFeeList.add(jqExportFee);
 
         //交强
         FeeOrderNewVo.ExportFee syExportFee = this.assignExportFee("商业险",
                 insFeeOrderNew.getSyPremium(), insFeeOrderNew.getSyCostsExportProportion(),
                 insFeeOrderNew.getSyExportOtherCostsProportion(),
-                insFeeOrderNew.getSyExportSuperviseCostsPremiums(), insFeeOrderNew.getSyExportOtherCostsPremiums());
+                insFeeOrderNew.getSyExportSuperviseCostsPremiums(), insFeeOrderNew.getSyExportOtherCostsPremiums()
+        );
         //exportFeeList.add(syExportFee);
 
 
         //交强
         FeeOrderNewVo.ExportFee noExportFee = this.assignExportFee("非车险",
                 insFeeOrderNew.getNoPremium(), insFeeOrderNew.getNoCostsExportProportion(),
-insFeeOrderNew.getNoExportOtherCostsProportion(),
+                insFeeOrderNew.getNoExportOtherCostsProportion(),
                 insFeeOrderNew.getNoExportSuperviseCostsPremiums(), insFeeOrderNew.getNoExportOtherCostsPremiums());
-       // exportFeeList.add(noExportFee);
+
+        // exportFeeList.add(noExportFee);
         //add  by  hxl   添加出单员不能查看优惠的限制    2024-07-11
         String userId = new BaseController().getUserId();
         SysUserRole sysUserRole = sysUserRoleService.selectByUserId(userId);
-        if(sysUserRole!=null && sysUserRole.getRoleId()==19){
+        if (sysUserRole != null && sysUserRole.getRoleId() == 19) {
             jqExportFee.setTotalAmount(BigDecimal.ZERO);
             jqExportFee.setTotalProportion(BigDecimal.ZERO);
             syExportFee.setTotalAmount(BigDecimal.ZERO);
@@ -2806,17 +2814,17 @@ insFeeOrderNew.getNoExportOtherCostsProportion(),
      * @param otherCostsProportion     跟单比例
      */
     public FeeOrderNewVo.EntranceFee calcEntranceFee(BigDecimal premium, BigDecimal superviseCostsProportion,
-     BigDecimal otherCostsProportion, BigDecimal taxRate) {
+                                                     BigDecimal otherCostsProportion, BigDecimal taxRate) {
         FeeOrderNewVo.EntranceFee entranceFee = new FeeOrderNewVo.EntranceFee();
         entranceFee.setPremium(premium);
         premium = premium.divide(taxRate, 5, BigDecimal.ROUND_DOWN);
         //手续费
         entranceFee.setSuperviseCostsPremiums(premium.multiply(superviseCostsProportion.divide(new BigDecimal(100))).setScale(5,
-BigDecimal.ROUND_DOWN));
+                BigDecimal.ROUND_DOWN));
         entranceFee.setSuperviseCosts(superviseCostsProportion);
         //跟单费
         entranceFee.setOtherCostsPremiums(premium.multiply(otherCostsProportion.divide(new BigDecimal(100))).setScale(5,
-BigDecimal.ROUND_DOWN));
+                BigDecimal.ROUND_DOWN));
         entranceFee.setOtherCostsProportion(otherCostsProportion);
         //总费用比例
         BigDecimal totalCostsProportion = superviseCostsProportion.add(otherCostsProportion);
@@ -2842,11 +2850,11 @@ BigDecimal.ROUND_DOWN));
         FeeOrderNewVo.DeptManagerFee deptManagerFee = new FeeOrderNewVo.DeptManagerFee();
         //一级管理费
         deptManagerFee.setDeptPremiumsLevelOne(premium.multiply(level1Proportion.divide(new BigDecimal(100))).setScale(2,
-         BigDecimal.ROUND_DOWN));
+                BigDecimal.ROUND_DOWN));
         deptManagerFee.setDeptProportionLevelOne(level1Proportion);
         //二级管理费
         deptManagerFee.setDeptPremiumsLevelTwo(premium.multiply(level2Proportion.divide(new BigDecimal(100))).setScale(2,
-        BigDecimal.ROUND_DOWN));
+                BigDecimal.ROUND_DOWN));
         deptManagerFee.setDeptProportionLevelTwo(level2Proportion);
         //三级管理费
         deptManagerFee.setDeptPremiumsLevelThree(premium.multiply(level3Proportion.divide(new BigDecimal(100))).setScale(2,
@@ -2875,14 +2883,20 @@ BigDecimal.ROUND_DOWN));
      * @return
      */
     public FeeOrderNewVo.ExportFee calcExportFee(BigDecimal premium, BigDecimal superviseCostsProportion,
-     BigDecimal entranceTotalProportion,
-                                                 BigDecimal deptTotalProportion, BigDecimal retailTotalProportion, BigDecimal taxRate) {
+                                                 BigDecimal entranceTotalProportion,
+                                                 BigDecimal deptTotalProportion, BigDecimal retailTotalProportion, BigDecimal taxRate, BigDecimal enterProportion) {
         FeeOrderNewVo.ExportFee exportFee = new FeeOrderNewVo.ExportFee();
         exportFee.setPremium(premium);
         //去税后的入口比例
         BigDecimal noTaxEntranceTotalProportion = entranceTotalProportion.divide(taxRate, 2, RoundingMode.DOWN);
         //出口的总比例
-        BigDecimal exportTotalProportion = noTaxEntranceTotalProportion.subtract(deptTotalProportion).subtract(retailTotalProportion);
+        BigDecimal exportTotalProportion = noTaxEntranceTotalProportion.subtract(deptTotalProportion).subtract(retailTotalProportion).subtract(enterProportion);
+
+        // 外部
+        exportFee.setExternalProportion(enterProportion);
+        exportFee.setExternalPremiums(premium.multiply(enterProportion.divide(new BigDecimal(100))).setScale(2,
+                BigDecimal.ROUND_DOWN));
+
         if (exportTotalProportion.compareTo(BigDecimal.ZERO) < 0 && premium.compareTo(BigDecimal.ZERO) == 0) {
             //出口比例为负数了
             exportTotalProportion = new BigDecimal(0);
@@ -2908,32 +2922,32 @@ BigDecimal.ROUND_DOWN));
     }
 
     @Override
-    public FeeOrderNewVo.RetailFee calcRetail(BigDecimal jqPremiums,BigDecimal jqProportion, BigDecimal syPremiums,BigDecimal syProportion, BigDecimal noPremiums,
-                                 BigDecimal noProportion, BigDecimal jqRetailProportion, BigDecimal syRetailProportion, BigDecimal noRetailProportion) {
+    public FeeOrderNewVo.RetailFee calcRetail(BigDecimal jqPremiums, BigDecimal jqProportion, BigDecimal syPremiums, BigDecimal syProportion, BigDecimal noPremiums,
+                                              BigDecimal noProportion, BigDecimal jqRetailProportion, BigDecimal syRetailProportion, BigDecimal noRetailProportion) {
         BigDecimal jqRetail = new BigDecimal(0);
         BigDecimal syRetail = new BigDecimal(0);
         BigDecimal noRetail = new BigDecimal(0);
         FeeOrderNewVo.RetailFee retailFee = new FeeOrderNewVo.RetailFee();
         //计算交强险分销
-        if(jqProportion.compareTo(new BigDecimal(0)) > 0) {
+        if (jqProportion.compareTo(new BigDecimal(0)) > 0) {
             jqRetail = jqPremiums.multiply(jqRetailProportion.divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
             retailFee.setJqRetailPremiums(jqRetail);
             retailFee.setJqRetailProportion(jqRetailProportion);
         }
         //计算商业险分销
-        if(syProportion.compareTo(new BigDecimal(0)) > 0) {
+        if (syProportion.compareTo(new BigDecimal(0)) > 0) {
             syRetail = syPremiums.multiply(syRetailProportion.divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
             retailFee.setSyRetailPremiums(syRetail);
             retailFee.setSyRetailProportion(syRetailProportion);
         }
         //计算非车险分销
-        if(noProportion.compareTo(new BigDecimal(0)) > 0) {
+        if (noProportion.compareTo(new BigDecimal(0)) > 0) {
             noRetail = noPremiums.multiply(noRetailProportion.divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
             retailFee.setNoRetailPremiums(noRetail);
             retailFee.setNoRetailProportion(noRetailProportion);
         }
         //总分销
-        BigDecimal totalRetail = jqRetail.add(syRetail).add(noRetail).setScale(2,BigDecimal.ROUND_DOWN);
+        BigDecimal totalRetail = jqRetail.add(syRetail).add(noRetail).setScale(2, BigDecimal.ROUND_DOWN);
         retailFee.setTotalRetailPremiums(totalRetail);
         return retailFee;
     }
@@ -2995,9 +3009,9 @@ BigDecimal.ROUND_DOWN));
      * @return
      */
     public FeeOrderNewVo.EntranceFee assignEntranceFee(String title, BigDecimal premium, BigDecimal superviseCostsProportion,
-     BigDecimal otherCostsProportion,
+                                                       BigDecimal otherCostsProportion,
                                                        BigDecimal costsProportion, BigDecimal superviseCostsPremiums,
-                                                        BigDecimal otherCostsPremiums,
+                                                       BigDecimal otherCostsPremiums,
                                                        BigDecimal costsPremiums) {
         FeeOrderNewVo.EntranceFee entranceFee = new FeeOrderNewVo.EntranceFee();
         entranceFee.setInsuranceType(title);
@@ -3039,7 +3053,8 @@ BigDecimal.ROUND_DOWN));
                                                       BigDecimal level3Proportion, BigDecimal level3Premium,
                                                       BigDecimal level4Proportion, BigDecimal level4Premium,
                                                       BigDecimal level5Proportion, BigDecimal level5Premium,
-                                                      BigDecimal profitMarginPremiums) {
+                                                      BigDecimal profitMarginPremiums,
+                                                      BigDecimal externalProportion, BigDecimal externalPremiums) {
         FeeOrderNewVo.DeptManagerFee deptManagerFee = new FeeOrderNewVo.DeptManagerFee();
         deptManagerFee.setInsuranceType(title);
         deptManagerFee.setDeptProportionLevelOne(level1Proportion);
@@ -3053,6 +3068,8 @@ BigDecimal.ROUND_DOWN));
         deptManagerFee.setDeptProportionLevelFive(level5Proportion);
         deptManagerFee.setDeptPremiumsLevelFive(level5Premium);
         deptManagerFee.setProfitMarginPremiums(profitMarginPremiums);
+        deptManagerFee.setExternalProportion(externalProportion);
+        deptManagerFee.setExternalPremiums(externalPremiums);
         return deptManagerFee;
     }
 
@@ -3068,8 +3085,9 @@ BigDecimal.ROUND_DOWN));
      * @return
      */
     public FeeOrderNewVo.ExportFee assignExportFee(String title, BigDecimal premium, BigDecimal superviseCostsProportion,
-     BigDecimal otherCostsProportion,
-                                                   BigDecimal superviseCostsPremiums, BigDecimal otherCostsPremiums) {
+                                                   BigDecimal otherCostsProportion,
+                                                   BigDecimal superviseCostsPremiums, BigDecimal otherCostsPremiums
+    ) {
         FeeOrderNewVo.ExportFee exportFee = new FeeOrderNewVo.ExportFee();
         exportFee.setInsuranceType(title);
         //保费
@@ -3086,6 +3104,7 @@ BigDecimal.ROUND_DOWN));
         exportFee.setOtherCostsPremiums(otherCostsPremiums);
         //总费用
         exportFee.setTotalAmount(superviseCostsPremiums.add(otherCostsPremiums));
+
         return exportFee;
     }
 
@@ -3101,17 +3120,18 @@ BigDecimal.ROUND_DOWN));
      */
     @Override
     public boolean calculateProportion(FeeOrderNewVo.EntranceFee entranceFee, FeeOrderNewVo.DeptManagerFee deptManagerFee,
-     FeeOrderNewVo.ExportFee exportFee, BigDecimal retailRadio, BigDecimal taxRadio, BigDecimal premiums) {
+                                       FeeOrderNewVo.ExportFee exportFee, BigDecimal retailRadio, BigDecimal taxRadio, BigDecimal premiums) {
         if (entranceFee.getTotalAmount().compareTo(BigDecimal.ZERO) == 0)
             return true;
         //去税入口比例
         BigDecimal noTaxEntranceTotalProportion = entranceFee.getTotalProportion().divide(taxRadio, 2, BigDecimal.ROUND_DOWN);
-        if (noTaxEntranceTotalProportion.subtract(exportFee.getTotalProportion()).subtract(deptManagerFee.getDeptProportionLevelOne())
-                .subtract(deptManagerFee.getDeptProportionLevelTwo()).subtract(deptManagerFee.getDeptProportionLevelThree())
-                .subtract(deptManagerFee.getDeptProportionLevelFoure()).subtract(deptManagerFee.getDeptProportionLevelFive())
-                .subtract(retailRadio).compareTo(BigDecimal.ZERO) == 0) {
-            return true;
-        }
-        return false;
+        return noTaxEntranceTotalProportion.subtract(exportFee.getTotalProportion())
+                .subtract(exportFee.getExternalProportion())
+                .subtract(deptManagerFee.getDeptProportionLevelOne())
+                .subtract(deptManagerFee.getDeptProportionLevelTwo())
+                .subtract(deptManagerFee.getDeptProportionLevelThree())
+                .subtract(deptManagerFee.getDeptProportionLevelFoure())
+                .subtract(deptManagerFee.getDeptProportionLevelFive())
+                .subtract(retailRadio).compareTo(BigDecimal.ZERO) == 0;
     }
 }

+ 125 - 94
src/main/java/com/ydtech/modules/fee/service/impl/FeeRuleSchemeServiceNewImpl.java

@@ -10,6 +10,7 @@ import com.ydtech.modules.esm.model.EsmRetail;
 import com.ydtech.modules.esm.model.EsmUserReferrer;
 import com.ydtech.modules.esm.service.EsmRetailService;
 import com.ydtech.modules.esm.service.EsmUserReferrerService;
+import com.ydtech.modules.fee.constants.CostAllocation;
 import com.ydtech.modules.fee.dto.po.InsFeeOrderConfig;
 import com.ydtech.modules.fee.dto.vo.ReCalcuLateProportion;
 import com.ydtech.modules.fee.dto.vo.RetailProportion;
@@ -156,26 +157,27 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
     }
 
     //BigDecimal取两位
-    private BigDecimal twoPeople(BigDecimal number){
+    private BigDecimal twoPeople(BigDecimal number) {
         return number.setScale(2, BigDecimal.ROUND_DOWN);
     }
 
     /**
      * 重新计算分销和机构比例
-     * @param sumCostsProportion       总入口费用比例
-     * @param deptProportion        机构管理总比例
-     * @param retailProportion      默认分销总比例
-     * @param retailLevel           分销级别
-     * @return  如果不够减则 返回新的分销比例
+     *
+     * @param sumCostsProportion 总入口费用比例
+     * @param deptProportion     机构管理总比例
+     * @param retailProportion   默认分销总比例
+     * @param retailLevel        分销级别
+     * @return 如果不够减则 返回新的分销比例
      */
     public ReCalcuLateProportion recalculateProportion(BigDecimal sumCostsProportion,
-                                                        BigDecimal deptProportion,
-                                                        BigDecimal retailProportion,
-                                                        BigDecimal taxRadio,
-                                                        Integer retailLevel,
-                                                        PtlAgreementProductCostsExport ptlAgreementProductCostsExport,
-                                                        RetailProportion originalRetailProportion,
-                                                        String type){
+                                                       BigDecimal deptProportion,
+                                                       BigDecimal retailProportion,
+                                                       BigDecimal taxRadio,
+                                                       Integer retailLevel,
+                                                       PtlAgreementProductCostsExport ptlAgreementProductCostsExport,
+                                                       RetailProportion originalRetailProportion,
+                                                       String type) {
         ReCalcuLateProportion reCalcuLateProportion = new ReCalcuLateProportion();
         BigDecimal costsProportion = sumCostsProportion.divide(taxRadio, 2, BigDecimal.ROUND_DOWN);
         List<InsFeeOrderConfig> list = insFeeOrderConfigService.list();
@@ -186,7 +188,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
 
         //分销比例均分
         BigDecimal jqAverageRetail = new BigDecimal(0);
-        if(retailLevel != 0) {
+        if (retailLevel != 0) {
             jqAverageRetail = twoPeople(twoPeople(costsProportion.multiply(retailSettingProportion)).divide(new BigDecimal(retailLevel), 2, RoundingMode.DOWN));
         }
         //机构配置的比例
@@ -195,16 +197,15 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
         //机构比例均分
         BigDecimal jqAverageDept = twoPeople(twoPeople(costsProportion.multiply(deptSettingProportion)).divide(new BigDecimal(5)));
 
-
         //如果不够减的话
-        if(deptProportion.add(retailProportion).compareTo(costsProportion) > 0){
-            if(retailLevel >= 3){
+        if (deptProportion.add(retailProportion).compareTo(costsProportion) > 0) {
+            if (retailLevel >= 3) {
                 reCalcuLateProportion.setRetail_level_3_proportion(jqAverageRetail);
             }
-            if(retailLevel >= 2){
+            if (retailLevel >= 2) {
                 reCalcuLateProportion.setRetail_level_2_proportion(jqAverageRetail);
             }
-            if(retailLevel >= 1){
+            if (retailLevel >= 1) {
                 reCalcuLateProportion.setRetail_level_1_proportion(jqAverageRetail);
             }
             reCalcuLateProportion.setDept_level_1_proportion(jqAverageDept);
@@ -212,8 +213,8 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
             reCalcuLateProportion.setDept_level_3_proportion(jqAverageDept);
             reCalcuLateProportion.setDept_level_4_proportion(jqAverageDept);
             reCalcuLateProportion.setDept_level_5_proportion(jqAverageDept);
-        }else{
-            if(type.equals("jq")) {
+        } else {
+            if (type.equals("jq")) {
                 reCalcuLateProportion.setDept_level_1_proportion(ptlAgreementProductCostsExport.getJqExportRadioLevel1());
                 reCalcuLateProportion.setDept_level_2_proportion(ptlAgreementProductCostsExport.getJqExportRadioLevel2());
                 reCalcuLateProportion.setDept_level_3_proportion(ptlAgreementProductCostsExport.getJqExportRadioLevel3());
@@ -223,8 +224,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                 reCalcuLateProportion.setRetail_level_1_proportion(originalRetailProportion.getJqRetailLevel1Proportion());
                 reCalcuLateProportion.setRetail_level_2_proportion(originalRetailProportion.getJqRetailLevel2Proportion());
                 reCalcuLateProportion.setRetail_level_3_proportion(originalRetailProportion.getJqRetailLevel3Proportion());
-            }else if(type.equals("sy"))
-            {
+            } else if (type.equals("sy")) {
                 reCalcuLateProportion.setDept_level_1_proportion(ptlAgreementProductCostsExport.getSyExportRadioLevel1());
                 reCalcuLateProportion.setDept_level_2_proportion(ptlAgreementProductCostsExport.getSyExportRadioLevel2());
                 reCalcuLateProportion.setDept_level_3_proportion(ptlAgreementProductCostsExport.getSyExportRadioLevel3());
@@ -233,7 +233,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                 reCalcuLateProportion.setRetail_level_1_proportion(originalRetailProportion.getSyRetailLevel1Proportion());
                 reCalcuLateProportion.setRetail_level_2_proportion(originalRetailProportion.getSyRetailLevel2Proportion());
                 reCalcuLateProportion.setRetail_level_3_proportion(originalRetailProportion.getSyRetailLevel3Proportion());
-            }else if(type.equals("no")){
+            } else if (type.equals("no")) {
                 reCalcuLateProportion.setDept_level_1_proportion(ptlAgreementProductCostsExport.getNoCarExportRadioLevel1());
                 reCalcuLateProportion.setDept_level_2_proportion(ptlAgreementProductCostsExport.getNoCarExportRadioLevel2());
                 reCalcuLateProportion.setDept_level_3_proportion(ptlAgreementProductCostsExport.getNoCarExportRadioLevel3());
@@ -279,7 +279,6 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
         insFeeOrderNew.setAgreementId(insAreaCompany.getAgreementId());
 
 
-
         //存储部门id与用户id
         InsOrders order = insOrdersService.getById(insAreaCompany.getOrderno());
         InsFeeOrderNew insFeeOrderNewByCompanyId = insFeeOrderNewService.getInsFeeOrderNewByCompanyId(insAreaCompany.getId());
@@ -347,11 +346,10 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
 
         //默认分销比例设置
         RetailProportion retailProportion = new RetailProportion();
-        if(!Objects.isNull(esmRetailList) && !esmRetailList.isEmpty())
-        {
+        if (!Objects.isNull(esmRetailList) && !esmRetailList.isEmpty()) {
             retailLevel = Integer.parseInt(esmRetailList.get(0).getRetailtype());
             //赋值默认的分销比例
-            retailProportion.setProportion(esmRetailList.get(0).getDisrate1(),esmRetailList.get(0).getDisrate2(),esmRetailList.get(0).getDisrate3());
+            retailProportion.setProportion(esmRetailList.get(0).getDisrate1(), esmRetailList.get(0).getDisrate2(), esmRetailList.get(0).getDisrate3());
         }
 
 
@@ -389,19 +387,23 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                 .add(retailProportion.getNoRetailLevel2Proportion())
                 .add(retailProportion.getNoRetailLevel3Proportion());
 
+        // 外部订单比例
+        BigDecimal enterProportion = insFeeOrderConfigService.getEnterProportion(insAreaCompany.getEntryStatus());
+
         //重新计算比例  入口是否超出支付的比例
         ReCalcuLateProportion jqReCalcuLateProportion = recalculateProportion(
-                new BigDecimal(ptlAgreementProductCostsNew.getJqCostsProportion()),
+                new BigDecimal(ptlAgreementProductCostsNew.getJqCostsProportion()).subtract(enterProportion),
                 jqDeptProportion,
                 jqRetailProportion,
                 taxRadio,
                 retailLevel,
                 ptlAgreementProductCostsExport,
                 retailProportion,
-                "jq");
+                "jq"
+        );
 
         ReCalcuLateProportion syReCalcuLateProportion = recalculateProportion(
-                new BigDecimal(ptlAgreementProductCostsNew.getSyCostsProportion()),
+                new BigDecimal(ptlAgreementProductCostsNew.getSyCostsProportion()).subtract(enterProportion),
                 syDeptProportion,
                 syRetailProportion,
                 taxRadio,
@@ -411,7 +413,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                 "sy");
 
         ReCalcuLateProportion noReCalcuLateProportion = recalculateProportion(
-                new BigDecimal(ptlAgreementProductCostsNew.getNoCostsProportion()),
+                new BigDecimal(ptlAgreementProductCostsNew.getNoCostsProportion()).subtract(enterProportion),
                 noDeptProportion,
                 noRetailProportion,
                 taxRadio,
@@ -420,7 +422,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                 retailProportion,
                 "no");
 
-        retailProportion.setProportion(jqReCalcuLateProportion,syReCalcuLateProportion,noReCalcuLateProportion);
+        retailProportion.setProportion(jqReCalcuLateProportion, syReCalcuLateProportion, noReCalcuLateProportion);
 //        ptlAgreementProductCostsExportService.updateById(ptlAgreementProductCostsExport);
 
 
@@ -464,7 +466,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                     if (parents != null && parents.size() > 2) {
                         insFeeOrderNew.setThreeLevelUserId(parents.get(2).getId());
                     }
-                }else{
+                } else {
                     insFeeOrderNew.setThirdDetailProportion(new BigDecimal(0));
                 }
                 if (Integer.parseInt(esmRetail.getRetailtype()) >= 2) {
@@ -484,7 +486,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                     if (parents != null && parents.size() > 1) {
                         insFeeOrderNew.setTwoLevelUserId(parents.get(1).getId());
                     }
-                }else{
+                } else {
                     insFeeOrderNew.setSecondDetailProportion(new BigDecimal(0));
                 }
                 if (Integer.parseInt(esmRetail.getRetailtype()) >= 1) {
@@ -505,32 +507,32 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                         insFeeOrderNew.setFirstLevelUserId(parents.get(0).getId());
                     }
 
-                }else{
+                } else {
                     insFeeOrderNew.setFirstDetailProportion(new BigDecimal(0));
                 }
-            }else{
+            } else {
                 insFeeOrderNew.setFirstDetailPremiums(new BigDecimal(0));
                 insFeeOrderNew.setSecondDetailPremiums(new BigDecimal(0));
                 insFeeOrderNew.setThirdDetailPremiums(new BigDecimal(0));
             }
-        }else{
+        } else {
             insFeeOrderNew.setFirstDetailProportion(new BigDecimal(0));
             insFeeOrderNew.setSecondDetailProportion(new BigDecimal(0));
             insFeeOrderNew.setThirdDetailProportion(new BigDecimal(0));
         }
         jqRetailRadio = jqRetailRadio.add(retailFeeLevel1.getJqRetailProportion())
-                        .add(retailFeeLevel2.getJqRetailProportion())
-                                .add(retailFeeLevel3.getJqRetailProportion());
+                .add(retailFeeLevel2.getJqRetailProportion())
+                .add(retailFeeLevel3.getJqRetailProportion());
 
         syRetailRadio = syRetailRadio.add(retailFeeLevel1.getSyRetailProportion())
-                        .add(retailFeeLevel2.getSyRetailProportion())
-                                .add(retailFeeLevel3.getSyRetailProportion());
+                .add(retailFeeLevel2.getSyRetailProportion())
+                .add(retailFeeLevel3.getSyRetailProportion());
 
         noRetailRadio = noRetailRadio.add(retailFeeLevel1.getNoRetailProportion())
-                        .add(retailFeeLevel2.getNoRetailProportion())
-                                .add(retailFeeLevel3.getNoRetailProportion());
+                .add(retailFeeLevel2.getNoRetailProportion())
+                .add(retailFeeLevel3.getNoRetailProportion());
 
-        insFeeOrderNew.assignRetail(retailFeeLevel1,retailFeeLevel2,retailFeeLevel3);
+        insFeeOrderNew.assignRetail(retailFeeLevel1, retailFeeLevel2, retailFeeLevel3);
 
         //endregion
 
@@ -582,7 +584,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                 noReCalcuLateProportion.getDept_level_4_proportion(),
                 noReCalcuLateProportion.getDept_level_5_proportion());
 
-        insFeeOrderNew.assignDept(jqDeptManagerFee,syDeptManagerFee,noDeptManagerFee);
+        insFeeOrderNew.assignDept(jqDeptManagerFee, syDeptManagerFee, noDeptManagerFee);
 
         //endregion
 
@@ -595,7 +597,9 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                 insFeeOrderNew.getJqCostsProportion(),
                 jqDeptRadio,
                 jqRetailRadio,
-                taxRadio);
+                taxRadio,
+                enterProportion
+        );
 
         //商业出口手续费比例
         FeeOrderNewVo.ExportFee syExportFee = feeRuleSchemeService.calcExportFee(
@@ -604,7 +608,10 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                 insFeeOrderNew.getSyCostsProportion(),
                 syDeptRadio,
                 syRetailRadio,
-                taxRadio);
+                taxRadio,
+                enterProportion
+
+        );
 
         //非车出口手续费比例
         FeeOrderNewVo.ExportFee noExportFee = feeRuleSchemeService.calcExportFee(
@@ -613,7 +620,9 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                 insFeeOrderNew.getNoCostsProportion(),
                 noDeptRadio,
                 noRetailRadio,
-                taxRadio);
+                taxRadio,
+                enterProportion
+        );
 
         //出口手续费用
         insFeeOrderNew.setJqExportSuperviseCostsPremiums(twoPeople(jqExportFee.getSuperviseCostsPremiums()));
@@ -625,6 +634,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
         insFeeOrderNew.setSyExportOtherCostsProportion(twoPeople(syExportFee.getOtherCostsProportion()));
         insFeeOrderNew.setNoExportOtherCostsProportion(twoPeople(noExportFee.getOtherCostsProportion()));
 
+
         //出口其他费用
         insFeeOrderNew.setJqExportOtherCostsPremiums(twoPeople(jqExportFee.getOtherCostsPremiums()));
         insFeeOrderNew.setSyExportOtherCostsPremiums(twoPeople(syExportFee.getOtherCostsPremiums()));
@@ -635,6 +645,15 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
         insFeeOrderNew.setSyCostsExportProportion(twoPeople(syExportFee.getSuperviseCosts()));
         insFeeOrderNew.setNoCostsExportProportion(twoPeople(noExportFee.getSuperviseCosts()));
 
+        insFeeOrderNew.setJqExternalProportion(jqExportFee.getExternalProportion());
+        insFeeOrderNew.setJqExportOtherCostsPremiums(jqExportFee.getExternalPremiums());
+
+        insFeeOrderNew.setSyExternalProportion(syExportFee.getExternalProportion());
+        insFeeOrderNew.setSyExportOtherCostsPremiums(syExportFee.getExternalPremiums());
+
+        insFeeOrderNew.setNoExternalProportion(noExportFee.getExternalProportion());
+        insFeeOrderNew.setNoExportOtherCostsPremiums(noExportFee.getExternalPremiums());
+
         //endregion
 
         //region 计算利润差值
@@ -642,19 +661,19 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
 
         //分销交强费用
         //分开算  1  2 3 级
-        BigDecimal jqFirst = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getJqRetailProportionLevel1().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
-        BigDecimal jqSecond = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getJqRetailProportionLevel2().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
-        BigDecimal jqThird = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getJqRetailProportionLevel3().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+        BigDecimal jqFirst = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getJqRetailProportionLevel1().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
+        BigDecimal jqSecond = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getJqRetailProportionLevel2().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
+        BigDecimal jqThird = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getJqRetailProportionLevel3().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
         BigDecimal jqFenXiao = jqFirst.add(jqSecond).add(jqThird);
         //分销商业费用
-        BigDecimal syFirst = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSyRetailProportionLevel1().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
-        BigDecimal sySecond = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSyRetailProportionLevel2().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
-        BigDecimal syThird = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSyRetailProportionLevel3().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+        BigDecimal syFirst = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSyRetailProportionLevel1().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
+        BigDecimal sySecond = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSyRetailProportionLevel2().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
+        BigDecimal syThird = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSyRetailProportionLevel3().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
         BigDecimal syFenXiao = syFirst.add(sySecond).add(syThird);
         //分销非车费用
-        BigDecimal noFirst = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getNoRetailProportionLevel1().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
-        BigDecimal noSecond = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getNoRetailProportionLevel2().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
-        BigDecimal noThird = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getNoRetailProportionLevel3().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+        BigDecimal noFirst = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getNoRetailProportionLevel1().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
+        BigDecimal noSecond = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getNoRetailProportionLevel2().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
+        BigDecimal noThird = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getNoRetailProportionLevel3().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
         BigDecimal noFenXiao = noFirst.add(noSecond).add(noThird);
 
 
@@ -688,13 +707,13 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
 
         //region 比例逆推是否等于0
 
-        if(!feeRuleSchemeService.calculateProportion(jqEntranceFee,jqDeptManagerFee,jqExportFee,jqRetailRadio,taxRadio,insFeeOrderNew.getJqPremium()))
+        if (!feeRuleSchemeService.calculateProportion(jqEntranceFee, jqDeptManagerFee, jqExportFee, jqRetailRadio, taxRadio, insFeeOrderNew.getJqPremium()))
             throw new SystemException("交强比例异常");
 
-        if(!feeRuleSchemeService.calculateProportion(syEntranceFee,syDeptManagerFee,syExportFee,syRetailRadio,taxRadio,insFeeOrderNew.getSyPremium()))
+        if (!feeRuleSchemeService.calculateProportion(syEntranceFee, syDeptManagerFee, syExportFee, syRetailRadio, taxRadio, insFeeOrderNew.getSyPremium()))
             throw new SystemException("商业比例异常");
 
-        if(!feeRuleSchemeService.calculateProportion(noEntranceFee,noDeptManagerFee,noExportFee,noRetailRadio,taxRadio,insFeeOrderNew.getNoPremium()))
+        if (!feeRuleSchemeService.calculateProportion(noEntranceFee, noDeptManagerFee, noExportFee, noRetailRadio, taxRadio, insFeeOrderNew.getNoPremium()))
             throw new SystemException("非车比例异常");
 
         //endregion
@@ -705,6 +724,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
 
     /**
      * 计算费用测试方法 没有数据库保存操作 只带入值进行计算核对
+     *
      * @param costsId
      * @param insAreaCompany
      */
@@ -1028,6 +1048,9 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
     @Override
     public void calcCostsExternal(PtlAgreementProductCostsNew ptlAgreementProductCostsNew, InsAreaCompany insAreaCompany) {
         //获取协议信息
+        // 外部订单比例
+        BigDecimal enterProportion = insFeeOrderConfigService.getEnterProportion(insAreaCompany.getEntryStatus());
+
         PtlAgreement ptlAgreement = ptlAgreementService.getById(insAreaCompany.getAgreementId());
         InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
         SysUser sysUser = sysUserService.findByUserId(insOrders.getUserid());
@@ -1112,11 +1135,10 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
 
         //默认分销比例设置
         RetailProportion retailProportion = new RetailProportion();
-        if(!Objects.isNull(esmRetailList) && !esmRetailList.isEmpty())
-        {
+        if (!Objects.isNull(esmRetailList) && !esmRetailList.isEmpty()) {
             retailLevel = Integer.parseInt(esmRetailList.get(0).getRetailtype());
             //赋值默认的分销比例
-            retailProportion.setProportion(esmRetailList.get(0).getDisrate1(),esmRetailList.get(0).getDisrate2(),esmRetailList.get(0).getDisrate3());
+            retailProportion.setProportion(esmRetailList.get(0).getDisrate1(), esmRetailList.get(0).getDisrate2(), esmRetailList.get(0).getDisrate3());
         }
 
 
@@ -1156,7 +1178,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
 
         //重新计算比例  入口是否超出支付的比例
         ReCalcuLateProportion jqReCalcuLateProportion = recalculateProportion(
-                new BigDecimal(ptlAgreementProductCostsNew.getJqCostsProportion()),
+                new BigDecimal(ptlAgreementProductCostsNew.getJqCostsProportion()).subtract(enterProportion),
                 jqDeptProportion,
                 jqRetailProportion,
                 taxRadio,
@@ -1166,7 +1188,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                 "jq");
 
         ReCalcuLateProportion syReCalcuLateProportion = recalculateProportion(
-                new BigDecimal(ptlAgreementProductCostsNew.getSyCostsProportion()),
+                new BigDecimal(ptlAgreementProductCostsNew.getSyCostsProportion()).subtract(enterProportion),
                 syDeptProportion,
                 syRetailProportion,
                 taxRadio,
@@ -1176,7 +1198,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                 "sy");
 
         ReCalcuLateProportion noReCalcuLateProportion = recalculateProportion(
-                new BigDecimal(ptlAgreementProductCostsNew.getNoCostsProportion()),
+                new BigDecimal(ptlAgreementProductCostsNew.getNoCostsProportion()).subtract(enterProportion),
                 noDeptProportion,
                 noRetailProportion,
                 taxRadio,
@@ -1185,7 +1207,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                 retailProportion,
                 "no");
 
-        retailProportion.setProportion(jqReCalcuLateProportion,syReCalcuLateProportion,noReCalcuLateProportion);
+        retailProportion.setProportion(jqReCalcuLateProportion, syReCalcuLateProportion, noReCalcuLateProportion);
 //        ptlAgreementProductCostsExportService.updateById(ptlAgreementProductCostsExport);
 
 
@@ -1232,7 +1254,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                     if (parents != null && parents.size() > 2) {
                         insFeeOrderNew.setThreeLevelUserId(parents.get(2).getId());
                     }
-                }else{
+                } else {
                     insFeeOrderNew.setThirdDetailProportion(new BigDecimal(0));
                 }
                 if (Integer.parseInt(esmRetail.getRetailtype()) >= 2) {
@@ -1251,7 +1273,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                     if (parents != null && parents.size() > 1) {
                         insFeeOrderNew.setTwoLevelUserId(parents.get(1).getId());
                     }
-                }else{
+                } else {
                     insFeeOrderNew.setSecondDetailProportion(new BigDecimal(0));
                 }
                 if (Integer.parseInt(esmRetail.getRetailtype()) >= 1) {
@@ -1270,20 +1292,20 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
                     if (parents != null && parents.size() > 0) {
                         insFeeOrderNew.setFirstLevelUserId(parents.get(0).getId());
                     }
-                }else{
+                } else {
                     insFeeOrderNew.setFirstDetailProportion(new BigDecimal(0));
                 }
-            }else{
+            } else {
                 insFeeOrderNew.setFirstDetailPremiums(new BigDecimal(0));
                 insFeeOrderNew.setSecondDetailPremiums(new BigDecimal(0));
                 insFeeOrderNew.setThirdDetailPremiums(new BigDecimal(0));
             }
-        }else{
+        } else {
             insFeeOrderNew.setFirstDetailProportion(new BigDecimal(0));
             insFeeOrderNew.setSecondDetailProportion(new BigDecimal(0));
             insFeeOrderNew.setThirdDetailProportion(new BigDecimal(0));
         }
-        insFeeOrderNew.assignRetail(retailFeeLevel1,retailFeeLevel2,retailFeeLevel3);
+        insFeeOrderNew.assignRetail(retailFeeLevel1, retailFeeLevel2, retailFeeLevel3);
 
         //endregion
 
@@ -1347,15 +1369,15 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
 
         //交强出口手续费比例
         FeeOrderNewVo.ExportFee jqExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getJqPremium(), new BigDecimal(ptlAgreementProductCostsNew.getJqCostsExportProportion()),
-                insFeeOrderNew.getJqCostsProportion(), jqDeptRadio, retailRadio, taxRadio);
+                insFeeOrderNew.getJqCostsProportion(), jqDeptRadio, retailRadio, taxRadio, enterProportion);
 
         //商业出口手续费比例
         FeeOrderNewVo.ExportFee syExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getSyPremium(), new BigDecimal(ptlAgreementProductCostsNew.getSyCostsExportProportion()),
-                insFeeOrderNew.getSyCostsProportion(), syDeptRadio, retailRadio, taxRadio);
+                insFeeOrderNew.getSyCostsProportion(), syDeptRadio, retailRadio, taxRadio, enterProportion);
 
         //非车出口手续费比例
         FeeOrderNewVo.ExportFee noExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getNoPremium(), new BigDecimal(ptlAgreementProductCostsNew.getNoCostsExportProportion()),
-                insFeeOrderNew.getNoCostsProportion(), noDeptRadio, retailRadio, taxRadio);
+                insFeeOrderNew.getNoCostsProportion(), noDeptRadio, retailRadio, taxRadio, enterProportion);
 
         //出口手续费用
         insFeeOrderNew.setJqExportSuperviseCostsPremiums(twoPeople(jqExportFee.getSuperviseCostsPremiums()));
@@ -1377,6 +1399,16 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
         insFeeOrderNew.setSyCostsExportProportion(twoPeople(syExportFee.getSuperviseCosts()));
         insFeeOrderNew.setNoCostsExportProportion(twoPeople(noExportFee.getSuperviseCosts()));
 
+
+        insFeeOrderNew.setJqExternalProportion(jqExportFee.getExternalProportion());
+        insFeeOrderNew.setJqExportOtherCostsPremiums(jqExportFee.getExternalPremiums());
+
+        insFeeOrderNew.setSyExternalProportion(syExportFee.getExternalProportion());
+        insFeeOrderNew.setSyExportOtherCostsPremiums(syExportFee.getExternalPremiums());
+
+        insFeeOrderNew.setNoExternalProportion(noExportFee.getExternalProportion());
+        insFeeOrderNew.setNoExportOtherCostsPremiums(noExportFee.getExternalPremiums());
+
         //endregion
 
         //region 计算利润差值
@@ -1384,19 +1416,19 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
 
         //分销交强费用
         //分开算  1  2 3 级
-        BigDecimal jqFirst = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getFirstDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
-        BigDecimal jqSecond = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
-        BigDecimal jqThird = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+        BigDecimal jqFirst = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getFirstDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
+        BigDecimal jqSecond = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
+        BigDecimal jqThird = insFeeOrderNew.getJqPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
         BigDecimal jqFenXiao = jqFirst.add(jqSecond).add(jqThird);
         //分销商业费用
-        BigDecimal syFirst = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getFirstDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
-        BigDecimal sySecond = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
-        BigDecimal syThird = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+        BigDecimal syFirst = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getFirstDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
+        BigDecimal sySecond = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
+        BigDecimal syThird = insFeeOrderNew.getSyPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
         BigDecimal syFenXiao = syFirst.add(sySecond).add(syThird);
         //分销非车费用
-        BigDecimal noFirst = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getFirstDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
-        BigDecimal noSecond = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
-        BigDecimal noThird = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal(100))).setScale(2,BigDecimal.ROUND_DOWN);
+        BigDecimal noFirst = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getFirstDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
+        BigDecimal noSecond = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getSecondDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
+        BigDecimal noThird = insFeeOrderNew.getNoPremium().multiply(insFeeOrderNew.getThirdDetailProportion().divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
         BigDecimal noFenXiao = noFirst.add(noSecond).add(noThird);
 
 
@@ -1430,13 +1462,13 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
 
         //region 比例逆推是否等于0
 
-        if(!feeRuleSchemeService.calculateProportion(jqEntranceFee,jqDeptManagerFee,jqExportFee,retailRadio,taxRadio,insFeeOrderNew.getJqPremium()))
+        if (!feeRuleSchemeService.calculateProportion(jqEntranceFee, jqDeptManagerFee, jqExportFee, retailRadio, taxRadio, insFeeOrderNew.getJqPremium()))
             throw new SystemException("交强比例异常");
 
-        if(!feeRuleSchemeService.calculateProportion(syEntranceFee,syDeptManagerFee,syExportFee,retailRadio,taxRadio,insFeeOrderNew.getSyPremium()))
+        if (!feeRuleSchemeService.calculateProportion(syEntranceFee, syDeptManagerFee, syExportFee, retailRadio, taxRadio, insFeeOrderNew.getSyPremium()))
             throw new SystemException("商业比例异常");
 
-        if(!feeRuleSchemeService.calculateProportion(noEntranceFee,noDeptManagerFee,noExportFee,retailRadio,taxRadio,insFeeOrderNew.getNoPremium()))
+        if (!feeRuleSchemeService.calculateProportion(noEntranceFee, noDeptManagerFee, noExportFee, retailRadio, taxRadio, insFeeOrderNew.getNoPremium()))
             throw new SystemException("非车比例异常");
 
         //endregion
@@ -1765,9 +1797,8 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
      */
     private boolean checkBoxEqual(PtlAgreementProductCostsAttrLink ptlAgreementProductCostsAttrLink, String value) {
         String[] split = ptlAgreementProductCostsAttrLink.getMin().split(",");
-        for( String sp : split)
-        {
-            if(sp.equals(value)){
+        for (String sp : split) {
+            if (sp.equals(value)) {
                 return true;
             }
         }
@@ -1867,13 +1898,13 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
         //将值进行分割
         String[] split = ptlAgreementUndwrtRulesAttrLink.getMin().split(",");
         AtomicBoolean returnBool = new AtomicBoolean(true);
-        if(ptlAgreementUndwrtRulesAttrLink.getAttrCode().equals("NatureOfUse")) {
+        if (ptlAgreementUndwrtRulesAttrLink.getAttrCode().equals("NatureOfUse")) {
             Arrays.stream(split).forEach(x -> {
                 if (!x.equals("") && value.equals(x)) {
                     returnBool.set(false);
                 }
             });
-        }else{
+        } else {
             Arrays.stream(split).forEach(x -> {
                 if (!x.equals("") && value.contains(x)) {
                     returnBool.set(false);

+ 5 - 1
src/main/java/com/ydtech/modules/fee/service/impl/InsFeeOrderConfigServiceImpl.java

@@ -23,7 +23,11 @@ public class InsFeeOrderConfigServiceImpl extends ServiceImpl<InsFeeOrderConfigM
         implements InsFeeOrderConfigService {
 
     @Override
-    public BigDecimal getEnterProportion() {
+    public BigDecimal getEnterProportion(Integer entryStatus) {
+        if (entryStatus != 2) {
+            return new BigDecimal(0);
+        }
+
         CostAllocation costAllocation = CostAllocation.CA_03;
         InsFeeOrderConfig insFeeOrderConfig = lambdaQuery().eq(InsFeeOrderConfig::getKeyword, costAllocation).one();
 

+ 6 - 2
src/main/java/com/ydtech/modules/order/aop/aspect/QuoteVerificationAspect.java

@@ -169,7 +169,7 @@ public class QuoteVerificationAspect {
                  **/
                 //添加外部订单的限制  add by hxl  2024-07-12
                 List<InsAreaCompany> insAreaList = insAreaCompanyService.getBaseMapper().selectList(new LambdaQueryWrapper<InsAreaCompany>().eq(InsAreaCompany::getOrderno, orderno));
-                if(insAreaList!=null  && insAreaList.size()>0 ){
+                if(insAreaList!=null  && !insAreaList.isEmpty()){
                     for(InsAreaCompany subOrder : insAreaList){
                         PtlAgreement ptlAgreement = ptlAgreementService.getById(subOrder.getAgreementId());
                         if(ptlAgreement!=null && ptlAgreement.getIsExternal()!=null && ptlAgreement.getIsExternal()==1){
@@ -200,7 +200,11 @@ public class QuoteVerificationAspect {
                 boolean isExclude = true;
                 //排除的部门信息
                 List<TaxSourceExcludeDto> excludeDepts =
-                        taxSourceExcludeService.list(new LambdaQueryWrapper<TaxSourceExcludeDto>().eq(TaxSourceExcludeDto::getExcludeInfo, deptId).eq(TaxSourceExcludeDto::getInsCompanyId, companyId).eq(TaxSourceExcludeDto::getType, TaxSourceStatusConstants.EXCLUDE_TYPE_DEPT));
+                        taxSourceExcludeService.list(new LambdaQueryWrapper<TaxSourceExcludeDto>()
+                                .eq(TaxSourceExcludeDto::getExcludeInfo, deptId)
+                                .eq(TaxSourceExcludeDto::getInsCompanyId, companyId)
+                                .eq(TaxSourceExcludeDto::getType, TaxSourceStatusConstants.EXCLUDE_TYPE_DEPT));
+
                 //部门排除
                 String finalDeptId = deptId;
                 if (excludeDepts.stream().anyMatch(taxSourceDto -> taxSourceDto.getExcludeInfo().equals(finalDeptId))) {

+ 6 - 0
src/main/java/com/ydtech/modules/order/entity/InsAreaCompany.java

@@ -491,6 +491,12 @@ public class InsAreaCompany implements Serializable {
     @TableField(exist = false)
     private String orderExternalStatus;
 
+    /**
+     * 录入状态 1 车险录入 2 待客录单 3 外部订单
+     */
+    @TableField(value = "entry_status")
+    private Integer entryStatus;
+
 
     public InsAreaCompany(QuoteRespVo quoteRespVo, PtlAgreementAttribution ptlAgreementAttribution) {
         this.id = IdGenerate.nextId();

+ 15 - 0
src/main/java/com/ydtech/modules/order/entity/vo/FeeOrderNewVo.java

@@ -1,6 +1,7 @@
 package com.ydtech.modules.order.entity.vo;
 
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -58,6 +59,7 @@ public class FeeOrderNewVo implements Serializable {
         @ApiModelProperty("出口手续费比例")
         private BigDecimal exportSuperviseCosts;
 
+
     }
 
     /**
@@ -82,6 +84,12 @@ public class FeeOrderNewVo implements Serializable {
         private BigDecimal otherCostsProportion;
         @ApiModelProperty("跟单费")
         private BigDecimal otherCostsPremiums;
+        @ApiModelProperty("外部比例")
+        private BigDecimal externalProportion;
+        @ApiModelProperty("外部金额")
+        private BigDecimal externalPremiums;
+
+
     }
 
     @ApiModel(description = "部门管理费用")
@@ -111,6 +119,13 @@ public class FeeOrderNewVo implements Serializable {
         private BigDecimal deptPremiumsLevelFive;
         @ApiModelProperty("利润差值")
         private BigDecimal profitMarginPremiums;
+
+        @ApiModelProperty("外部比例")
+        private BigDecimal externalProportion;
+        @ApiModelProperty("外部金额")
+        private BigDecimal externalPremiums;
+
+
     }
 
     @ApiModel(description = "分销费用")

+ 1 - 0
src/main/java/com/ydtech/modules/order/service/impl/InsOrdersServiceImpl.java

@@ -314,6 +314,7 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
         if (daikeFlag) {//当时代客录单业务时,才需要赋值该字段
             insOrders.setOperatorid(userId);//赋值代客录单操作人为登录人
         }
+        // 录入订单状态
         insOrders.setUpEntryStatus(daikeFlag);
 
         if (isCdy) {//赋值出单员  操作人为登录人

+ 1 - 1
src/main/java/com/ydtech/modules/order/service/impl/YongchengOrderApiServiceImpl.java

@@ -1242,6 +1242,7 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
         boolean jqFalg = jqPremium > 0;
         //保存订单信息
         InsAreaCompany insAreaCompany = new InsAreaCompany();
+        insAreaCompany.setEntryStatus(insOrder.getEntryStatus());
         insAreaCompany.setOrderno(insOrder.getOrderno());
         insAreaCompany.setApiType(PtlApiType.PTL_API_1.getCode());
         insAreaCompany.setReptxt(JSON.parseObject(JSON.toJSONString(responseData)));
@@ -1250,7 +1251,6 @@ public class YongchengOrderApiServiceImpl implements YongchengOrderApiService {
         insAreaCompany.setTaxamount(BigDecimal.valueOf(jqFalg ? quoteRespVo.getTaxAmount() : 0));
         insAreaCompany.setSumpremium(BigDecimal.valueOf(quoteRespVo.getSumPermium()));
         insAreaCompany.setOrderstatus(InsOrderStatusEnum.QUOTE_ING.getCode());
-
         insAreaCompany.setJypremium(BigDecimal.valueOf(quoteRespVo.getJyPremium()));
         insAreaCompany.setCreatetime(LocalDateTime.now());
         insAreaCompany.setInsOrderNo(insOrderNo);

+ 24 - 0
src/main/java/com/ydtech/modules/protocols/entity/po/InsFeeOrderNew.java

@@ -543,6 +543,30 @@ public class InsFeeOrderNew {
     private BigDecimal noProfitMarginPremiums;
 
 
+    @ApiModelProperty(value = "交强外部比例")
+    @TableField(value = "jq_external_proportion")
+    private BigDecimal jqExternalProportion;
+
+    @ApiModelProperty(value = "商业外部比例")
+    @TableField(value = "sy_external_proportion")
+    private BigDecimal syExternalProportion;
+
+    @ApiModelProperty(value = "非车外部比例")
+    @TableField(value = "no_external_proportion")
+    private BigDecimal noExternalProportion;
+
+    @ApiModelProperty(value = "交强外部金额")
+    @TableField(value = "jq_external_premiums")
+    private BigDecimal jqExternalPremiums;
+
+    @ApiModelProperty(value = "商业外部金额")
+    @TableField(value = "sy_external_premiums")
+    private BigDecimal syExternalPremiums;
+
+    @ApiModelProperty(value = "非车外部金额")
+    @TableField(value = "no_external_premiums")
+    private BigDecimal noExternalPremiums;
+
     @ApiModelProperty(value = "签单日期")
     @TableField(exist = false)
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")

+ 30 - 6
src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementProductCostsNewServiceImpl.java

@@ -19,6 +19,8 @@ import com.ydtech.modules.fee.dto.vo.RetailStoreFee;
 import com.ydtech.modules.fee.service.CostsCalcService;
 import com.ydtech.modules.fee.service.FeeRuleSchemeNewService;
 import com.ydtech.modules.fee.service.FeeRuleSchemeService;
+import com.ydtech.modules.fee.service.InsFeeOrderConfigService;
+import com.ydtech.modules.fee.service.impl.InsFeeOrderConfigServiceImpl;
 import com.ydtech.modules.fnc.entity.InsFeeAuditHistory;
 import com.ydtech.modules.fnc.service.InsFeeAuditHistoryService;
 import com.ydtech.modules.fnc.service.InsFeeAuditService;
@@ -98,6 +100,7 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
 
     @Autowired
     private InsFeeAuditHistoryService insFeeAuditHistoryService;
+    private InsFeeOrderConfigServiceImpl insFeeOrderConfigServiceImpl;
 
 
     @Override
@@ -1126,6 +1129,9 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
     @Autowired
     EsmRetailService esmRetailService;
 
+    @Autowired
+    private InsFeeOrderConfigService insFeeOrderConfigService;
+
 
     @Transactional
     @Override
@@ -1158,6 +1164,9 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
         String feeId = feeOrderNewRecordVo.getFeeId();
         InsFeeOrderNew insFeeOrderNew = insFeeOrderNewService.getById(feeId);
         InsAreaCompany insAreaCompany = insAreaCompanyService.getById(insFeeOrderNew.getInsOrderNo());
+        // 外部订单比例
+        BigDecimal enterProportion = insFeeOrderConfigService.getEnterProportion(insAreaCompany.getEntryStatus());
+
         InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
         SysUser sysUser = sysUserService.findByUserId(insOrders.getUserid());
 
@@ -1284,7 +1293,7 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
 
         //重新计算比例  入口是否超出支付的比例
         ReCalcuLateProportion jqReCalcuLateProportion = feeRuleSchemeNewService.recalculateProportion(
-                feeOrderNewVo.getEntranceFee().get(0).getTotalProportion(),
+                feeOrderNewVo.getEntranceFee().get(0).getTotalProportion().subtract(enterProportion),
                 jqDeptProportion,
                 jqRetailProportion,
                 taxRadio,
@@ -1294,7 +1303,7 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
                 "jq");
 
         ReCalcuLateProportion syReCalcuLateProportion = feeRuleSchemeNewService.recalculateProportion(
-                feeOrderNewVo.getEntranceFee().get(1).getTotalProportion(),
+                feeOrderNewVo.getEntranceFee().get(1).getTotalProportion().subtract(enterProportion),
                 syDeptProportion,
                 syRetailProportion,
                 taxRadio,
@@ -1304,7 +1313,7 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
                 "sy");
 
         ReCalcuLateProportion noReCalcuLateProportion = feeRuleSchemeNewService.recalculateProportion(
-                feeOrderNewVo.getEntranceFee().get(2).getTotalProportion(),
+                feeOrderNewVo.getEntranceFee().get(2).getTotalProportion().subtract(enterProportion),
                 noDeptProportion,
                 noRetailProportion,
                 taxRadio,
@@ -1508,7 +1517,9 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
                 feeOrderNewVo.getEntranceFee().get(0).getTotalProportion(),
                 jqDeptRadio,
                 jqRetailRadio,
-                taxRadio);
+                taxRadio,
+                enterProportion
+        );
 
         jqExportFee.setInsuranceType("交强险");
         exportFeeList.add(jqExportFee);
@@ -1521,7 +1532,9 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
                 feeOrderNewVo.getEntranceFee().get(1).getTotalProportion(),
                 syDeptRadio,
                 syRetailRadio,
-                taxRadio);
+                taxRadio,
+                enterProportion
+        );
 
         syExportFee.setInsuranceType("商业险");
         exportFeeList.add(syExportFee);
@@ -1534,13 +1547,23 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
                 feeOrderNewVo.getEntranceFee().get(2).getTotalProportion(),
                 noDeptRadio,
                 noRetailRadio,
-                taxRadio);
+                taxRadio,
+                enterProportion
+        );
 
         noExportFee.setInsuranceType("非车险");
         exportFeeList.add(noExportFee);
 
         //endregion
 
+        insFeeOrderNew.setJqExternalProportion(jqExportFee.getExternalProportion());
+        insFeeOrderNew.setJqExportOtherCostsPremiums(jqExportFee.getExternalPremiums());
+
+        insFeeOrderNew.setSyExternalProportion(syExportFee.getExternalProportion());
+        insFeeOrderNew.setSyExportOtherCostsPremiums(syExportFee.getExternalPremiums());
+
+        insFeeOrderNew.setNoExternalProportion(noExportFee.getExternalProportion());
+        insFeeOrderNew.setNoExportOtherCostsPremiums(noExportFee.getExternalPremiums());
 
         FeeOrderNewVo resultFeeOrderNewVo = new FeeOrderNewVo();
         resultFeeOrderNewVo.setEntranceFee(entranceFeeList);
@@ -1644,6 +1667,7 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
         insFeeOrderNew.setNoRetailProportionLevel3(retailFeeLevel3.getNoRetailProportion());
         insFeeOrderNew.setNoRetailPremiumsLevel3(retailFeeLevel3.getNoRetailPremiums());
 
+
         insFeeOrderNew.setFirstDetailPremiums(
                 retailFeeLevel1.getJqRetailPremiums()
                         .add(retailFeeLevel1.getSyRetailPremiums())