Ver Fonte

费用调整修改

785834757 há 2 anos atrás
pai
commit
5b772403f1

+ 15 - 0
src/main/java/com/ydtech/modules/fee/dao/InsFeeOrderConfigMapper.java

@@ -0,0 +1,15 @@
+package com.ydtech.modules.fee.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ydtech.modules.fee.dto.po.InsFeeOrderConfig;
+import com.ydtech.modules.order.entity.BatchOrder;
+
+/**
+ * @author Administrator
+ * @description 针对表【InsFeeOrderConfig(费用配置)】的数据库操作Mapper
+ * @createDate 2024-6-5 16:19:14
+ * @Entity generator.domain.InsAccidentalDriving
+ */
+public interface InsFeeOrderConfigMapper extends BaseMapper<InsFeeOrderConfig> {
+
+}

+ 63 - 0
src/main/java/com/ydtech/modules/fee/dto/po/InsFeeOrderConfig.java

@@ -0,0 +1,63 @@
+package com.ydtech.modules.fee.dto.po;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ydtech.constants.enums.dict.InsOrderStatusEnum;
+import com.ydtech.modules.ins.model.vo.QuoteRespVo;
+import com.ydtech.modules.order.entity.InsAreaCompanyAccidentalDriving;
+import com.ydtech.modules.protocol.entity.po.PtlAgreementAttribution;
+import com.ydtech.utils.StringUtils;
+import com.ydtech.utils.idgen.IdGenerate;
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+/**
+ * 费用差值配置
+ *
+ * @TableName ins_fee_order_config
+ */
+@TableName(value = "ins_fee_order_config", autoResultMap = true)
+@Data
+@ApiModel(value = "费用差值")
+@NoArgsConstructor
+@AllArgsConstructor
+public class InsFeeOrderConfig implements Serializable {
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = -6827009009645748788L;
+    /**
+     * 主键
+     */
+    @TableId(value = "id")
+    private String id;
+    /**
+     * 订单号
+     */
+    @TableField(value = "name")
+    private String name;
+    /**
+     * 协议id
+     */
+    @TableField(value = "keyword")
+    private String keyword;
+    /**
+     * 请求类型
+     */
+    @TableField(value = "val")
+    private BigDecimal val;
+
+}
+

+ 46 - 0
src/main/java/com/ydtech/modules/fee/dto/vo/ReCalcuLateProportion.java

@@ -0,0 +1,46 @@
+package com.ydtech.modules.fee.dto.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class ReCalcuLateProportion {
+
+    @ApiModelProperty("一级管理费比例")
+    private BigDecimal dept_level_1_proportion;
+
+    @ApiModelProperty("二级管理费")
+    private BigDecimal dept_level_2_proportion;
+
+    @ApiModelProperty("三级管理费")
+    private BigDecimal dept_level_3_proportion;
+
+    @ApiModelProperty("四级管理费")
+    private BigDecimal dept_level_4_proportion;
+
+    @ApiModelProperty("五级管理费")
+    private BigDecimal dept_level_5_proportion;
+
+    @ApiModelProperty("一级分销费")
+    private BigDecimal retail_level_1_proportion;
+
+    @ApiModelProperty("二级分销费")
+    private BigDecimal retail_level_2_proportion;
+
+    @ApiModelProperty("三级分销费")
+    private BigDecimal retail_level_3_proportion;
+
+    public ReCalcuLateProportion() {
+        this.dept_level_1_proportion = new BigDecimal(0);
+        this.dept_level_2_proportion = new BigDecimal(0);
+        this.dept_level_3_proportion = new BigDecimal(0);
+        this.dept_level_4_proportion = new BigDecimal(0);
+        this.dept_level_5_proportion = new BigDecimal(0);
+        this.retail_level_1_proportion = new BigDecimal(0);
+        this.retail_level_2_proportion = new BigDecimal(0);
+        this.retail_level_3_proportion = new BigDecimal(0);
+    }
+
+}

+ 73 - 0
src/main/java/com/ydtech/modules/fee/dto/vo/RetailProportion.java

@@ -0,0 +1,73 @@
+package com.ydtech.modules.fee.dto.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class RetailProportion {
+    @ApiModelProperty("交强一级分销比例")
+    private BigDecimal jqRetailLevel1Proportion;
+
+    @ApiModelProperty("交强二级分销比例")
+    private BigDecimal jqRetailLevel2Proportion;
+
+    @ApiModelProperty("交强三级分销比例")
+    private BigDecimal jqRetailLevel3Proportion;
+
+    @ApiModelProperty("商业一级分销比例")
+    private BigDecimal syRetailLevel1Proportion;
+
+    @ApiModelProperty("商业二级分销比例")
+    private BigDecimal syRetailLevel2Proportion;
+
+    @ApiModelProperty("商业三级分销比例")
+    private BigDecimal syRetailLevel3Proportion;
+
+    @ApiModelProperty("非车一级分销比例")
+    private BigDecimal noRetailLevel1Proportion;
+
+    @ApiModelProperty("非车二级分销比例")
+    private BigDecimal noRetailLevel2Proportion;
+
+    @ApiModelProperty("非车三级分销比例")
+    private BigDecimal noRetailLevel3Proportion;
+
+    public RetailProportion(){
+        this.jqRetailLevel1Proportion = new BigDecimal(0);
+        this.jqRetailLevel2Proportion = new BigDecimal(0);
+        this.jqRetailLevel3Proportion = new BigDecimal(0);
+        this.syRetailLevel1Proportion = new BigDecimal(0);
+        this.syRetailLevel2Proportion = new BigDecimal(0);
+        this.syRetailLevel3Proportion = new BigDecimal(0);
+        this.noRetailLevel1Proportion = new BigDecimal(0);
+        this.noRetailLevel2Proportion = new BigDecimal(0);
+        this.noRetailLevel3Proportion = new BigDecimal(0);
+    }
+
+    public void setProportion(double disrate1,double disrate2,double disrate3){
+        this.jqRetailLevel1Proportion = new BigDecimal(disrate1);
+        this.jqRetailLevel2Proportion = new BigDecimal(disrate2);
+        this.jqRetailLevel3Proportion = new BigDecimal(disrate3);
+        this.syRetailLevel1Proportion = new BigDecimal(disrate1);
+        this.syRetailLevel2Proportion = new BigDecimal(disrate2);
+        this.syRetailLevel3Proportion = new BigDecimal(disrate3);
+        this.noRetailLevel1Proportion = new BigDecimal(disrate1);
+        this.noRetailLevel2Proportion = new BigDecimal(disrate2);
+        this.noRetailLevel3Proportion = new BigDecimal(disrate3);
+    }
+
+    public void setProportion(ReCalcuLateProportion jqReCalcuLateProportion,ReCalcuLateProportion syReCalcuLateProportion,ReCalcuLateProportion noReCalcuLateProportion){
+        this.jqRetailLevel1Proportion = jqReCalcuLateProportion.getRetail_level_1_proportion();
+        this.jqRetailLevel2Proportion = jqReCalcuLateProportion.getRetail_level_2_proportion();
+        this.jqRetailLevel3Proportion = jqReCalcuLateProportion.getRetail_level_3_proportion();
+        this.syRetailLevel1Proportion = syReCalcuLateProportion.getRetail_level_1_proportion();
+        this.syRetailLevel2Proportion = syReCalcuLateProportion.getRetail_level_2_proportion();
+        this.syRetailLevel3Proportion = syReCalcuLateProportion.getRetail_level_3_proportion();
+        this.noRetailLevel1Proportion = noReCalcuLateProportion.getRetail_level_1_proportion();
+        this.noRetailLevel2Proportion = noReCalcuLateProportion.getRetail_level_2_proportion();
+        this.noRetailLevel3Proportion = noReCalcuLateProportion.getRetail_level_3_proportion();
+    }
+}

+ 24 - 0
src/main/java/com/ydtech/modules/fee/service/FeeRuleSchemeNewService.java

@@ -1,14 +1,18 @@
 package com.ydtech.modules.fee.service;
 
 
+import com.ydtech.modules.fee.dto.vo.ReCalcuLateProportion;
+import com.ydtech.modules.fee.dto.vo.RetailProportion;
 import com.ydtech.modules.ins.model.vo.QuoteRespVo;
 import com.ydtech.modules.order.entity.InsAreaCompany;
 import com.ydtech.modules.order.entity.InsOrders;
 import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
 import com.ydtech.modules.order.entity.vo.QueryOrderFeeResultVo;
 import com.ydtech.modules.order.entity.vo.QueryOrderFeeVo;
+import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsExport;
 import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsNew;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -58,6 +62,26 @@ public interface FeeRuleSchemeNewService {
      */
     void verificationRuleFactor(InsAreaCompany insAreaCompany, InsOrders insOrders);
 
+    /**
+     * 重新计算费用
+     * @param costsProportion
+     * @param deptProportion
+     * @param retailProportion
+     * @param retailLevel
+     * @param ptlAgreementProductCostsExport
+     * @param originalRetailProportion
+     * @param type
+     * @return
+     */
+    public ReCalcuLateProportion recalculateProportion(BigDecimal costsProportion,
+                                                       BigDecimal deptProportion,
+                                                       BigDecimal retailProportion,
+                                                       BigDecimal taxRadio,
+                                                       Integer retailLevel,
+                                                       PtlAgreementProductCostsExport ptlAgreementProductCostsExport,
+                                                       RetailProportion originalRetailProportion,
+                                                       String type);
+
 
     /**
      * 计算费用因子

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

@@ -2,10 +2,7 @@ package com.ydtech.modules.fee.service;
 
 
 import com.ydtech.modules.ins.model.vo.QuoteRespVo;
-import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
-import com.ydtech.modules.order.entity.vo.FeeOrderNewVo;
-import com.ydtech.modules.order.entity.vo.QueryOrderFeeResultVo;
-import com.ydtech.modules.order.entity.vo.QueryOrderFeeVo;
+import com.ydtech.modules.order.entity.vo.*;
 import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
 import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsNew;
 
@@ -86,9 +83,10 @@ public interface FeeRuleSchemeService {
      * @param syProportion
      * @param noPremiums
      * @param noProportion
-     * @param proportion
+     * @param jqRetailProportion
      */
-    public BigDecimal calcRetail(BigDecimal jqPremiums,BigDecimal jqProportion, BigDecimal syPremiums,BigDecimal syProportion, BigDecimal noPremiums,BigDecimal noProportion, BigDecimal proportion);
+    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);
@@ -119,4 +117,6 @@ public interface FeeRuleSchemeService {
      * @return
      */
     boolean calculateProportion(FeeOrderNewVo.EntranceFee entranceFee,FeeOrderNewVo.DeptManagerFee deptManagerFee,FeeOrderNewVo.ExportFee exportFee,BigDecimal retailRadio,BigDecimal taxRadio,BigDecimal premiums);
+
+    List<DistributionLevelVo> converDistrbutionData(InsFeeOrderNew insFeeOrderNew);
 }

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

@@ -0,0 +1,14 @@
+package com.ydtech.modules.fee.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ydtech.modules.fee.dto.po.InsFeeOrderConfig;
+import com.ydtech.modules.order.entity.vo.dajia.InsAccidentalDrivingDajia;
+
+/**
+ * @author
+ * @description 针对表【InsFeeOrderConfig()】的数据库操作Service
+ * @createDate 2023-03-09 14:45:58
+ */
+public interface InsFeeOrderConfigService extends IService<InsFeeOrderConfig> {
+
+}

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

@@ -1,5 +1,6 @@
 package com.ydtech.modules.fee.service.impl;
 
+import com.beust.ah.A;
 import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.model.SysUser;
 import com.ydtech.modules.admin.model.SysUserRole;
@@ -2640,6 +2641,7 @@ public class FeeRuleSchemeServiceImpl implements FeeRuleSchemeService {
         List<FeeOrderNewVo.EntranceFee> entranceFeeList = new ArrayList<>();
         List<FeeOrderNewVo.ExportFee> exportFeeList = new ArrayList<>();
         List<FeeOrderNewVo.DeptManagerFee> deptManagerFeeList = new ArrayList<>();
+        List<FeeOrderNewVo.RetailFee> retailFeeList = new ArrayList<>();
 
         //region 入口费用
         //交强
@@ -2702,6 +2704,54 @@ public class FeeRuleSchemeServiceImpl implements FeeRuleSchemeService {
 
         //endregion
 
+        //region 分销
+        FeeOrderNewVo.RetailFee retailFeeLevel1 = new FeeOrderNewVo.RetailFee();
+        retailFeeLevel1.setInsuranceType("一级分销");
+        retailFeeLevel1.setJqRetailProportion(insFeeOrderNew.getJqRetailProportionLevel1());
+        retailFeeLevel1.setJqRetailPremiums(insFeeOrderNew.getJqRetailPremiumsLevel1());
+        retailFeeLevel1.setSyRetailProportion(insFeeOrderNew.getSyRetailProportionLevel1());
+        retailFeeLevel1.setSyRetailPremiums(insFeeOrderNew.getSyRetailPremiumsLevel1());
+        retailFeeLevel1.setNoRetailProportion(insFeeOrderNew.getNoRetailProportionLevel1());
+        retailFeeLevel1.setNoRetailPremiums(insFeeOrderNew.getNoRetailPremiumsLevel1());
+        retailFeeLevel1.setTotalRetailPremiums(insFeeOrderNew.getFirstDetailPremiums());
+        if(insFeeOrderNew.getFirstLevelUserId() != null) {
+            SysUser byId = sysUserService.getById(insFeeOrderNew.getFirstLevelUserId());
+            retailFeeLevel1.setUserName(byId.getName() + "(" + byId.getId() + ")");
+        }
+        retailFeeList.add(retailFeeLevel1);
+
+        FeeOrderNewVo.RetailFee retailFeeLevel2 = new FeeOrderNewVo.RetailFee();
+        retailFeeLevel2.setInsuranceType("二级分销");
+        retailFeeLevel2.setJqRetailProportion(insFeeOrderNew.getJqRetailProportionLevel2());
+        retailFeeLevel2.setJqRetailPremiums(insFeeOrderNew.getJqRetailPremiumsLevel2());
+        retailFeeLevel2.setSyRetailProportion(insFeeOrderNew.getSyRetailProportionLevel2());
+        retailFeeLevel2.setSyRetailPremiums(insFeeOrderNew.getSyRetailPremiumsLevel2());
+        retailFeeLevel2.setNoRetailProportion(insFeeOrderNew.getNoRetailProportionLevel2());
+        retailFeeLevel2.setNoRetailPremiums(insFeeOrderNew.getNoRetailPremiumsLevel2());
+        retailFeeLevel2.setTotalRetailPremiums(insFeeOrderNew.getSecondDetailPremiums());
+        if(insFeeOrderNew.getTwoLevelUserId() != null) {
+            SysUser byId = sysUserService.getById(insFeeOrderNew.getTwoLevelUserId());
+            retailFeeLevel2.setUserName(byId.getName() + "(" + byId.getId() + ")");
+        }
+        retailFeeList.add(retailFeeLevel2);
+
+        FeeOrderNewVo.RetailFee retailFeeLevel3 = new FeeOrderNewVo.RetailFee();
+        retailFeeLevel3.setInsuranceType("三级分销");
+        retailFeeLevel3.setJqRetailProportion(insFeeOrderNew.getJqRetailProportionLevel3());
+        retailFeeLevel3.setJqRetailPremiums(insFeeOrderNew.getJqRetailPremiumsLevel3());
+        retailFeeLevel3.setSyRetailProportion(insFeeOrderNew.getSyRetailProportionLevel3());
+        retailFeeLevel3.setSyRetailPremiums(insFeeOrderNew.getSyRetailPremiumsLevel3());
+        retailFeeLevel3.setNoRetailProportion(insFeeOrderNew.getNoRetailProportionLevel3());
+        retailFeeLevel3.setNoRetailPremiums(insFeeOrderNew.getNoRetailPremiumsLevel3());
+        retailFeeLevel3.setTotalRetailPremiums(insFeeOrderNew.getThirdDetailPremiums());
+        if(insFeeOrderNew.getThreeLevelUserId() != null){
+            SysUser byId = sysUserService.getById(insFeeOrderNew.getThreeLevelUserId());
+            retailFeeLevel3.setUserName(byId.getName()+"("+byId.getId()+")");
+        }
+        retailFeeList.add(retailFeeLevel3);
+
+        //endregion
+
 
         //region 出口费用
         //交强
@@ -2744,6 +2794,7 @@ insFeeOrderNew.getNoExportOtherCostsProportion(),
         feeOrderNewVo.setEntranceFee(entranceFeeList);
         feeOrderNewVo.setExportFee(exportFeeList);
         feeOrderNewVo.setDeptManagerFee(deptManagerFeeList);
+        feeOrderNewVo.setRetailFee(retailFeeList);
         return feeOrderNewVo;
     }
 
@@ -2848,36 +2899,43 @@ BigDecimal.ROUND_DOWN));
             exportFee.setSuperviseCosts(superviseCostsProportion);
         }
         exportFee.setSuperviseCostsPremiums(premium.multiply(exportFee.getSuperviseCosts().divide(new BigDecimal(100))).setScale(2,
-BigDecimal.ROUND_DOWN));
-        exportFee.setOtherCostsPremiums(premium.multiply(exportFee.getOtherCostsProportion().divide(new BigDecimal(100))).setScale(2,
                 BigDecimal.ROUND_DOWN));
-        exportFee.setTotalAmount(premium.multiply(exportFee.getTotalProportion().divide(new BigDecimal(100))).setScale(2,
+        exportFee.setOtherCostsPremiums(premium.multiply(exportFee.getOtherCostsProportion().divide(new BigDecimal(100))).setScale(2,
                 BigDecimal.ROUND_DOWN));
+        exportFee.setTotalAmount(exportFee.getSuperviseCostsPremiums().add(exportFee.getOtherCostsPremiums()));
 
         return exportFee;
     }
 
     @Override
-    public BigDecimal calcRetail(BigDecimal jqPremiums,BigDecimal jqProportion, BigDecimal syPremiums,BigDecimal syProportion, BigDecimal noPremiums,
-                                 BigDecimal noProportion, BigDecimal proportion) {
+    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) {
-            jqRetail = jqPremiums.multiply(proportion.divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
+            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) {
-            syRetail = syPremiums.multiply(proportion.divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
+            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) {
-            noRetail = noPremiums.multiply(proportion.divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_DOWN);
+            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);
-        return totalRetail;
+        retailFee.setTotalRetailPremiums(totalRetail);
+        return retailFee;
     }
 
     public List<DistributionLevelVo> converDistrbutionData(InsFeeOrderNew insFeeOrderNew) {

Diff do ficheiro suprimidas por serem muito extensas
+ 728 - 410
src/main/java/com/ydtech/modules/fee/service/impl/FeeRuleSchemeServiceNewImpl.java


+ 25 - 0
src/main/java/com/ydtech/modules/fee/service/impl/InsFeeOrderConfigServiceImpl.java

@@ -0,0 +1,25 @@
+package com.ydtech.modules.fee.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.modules.fee.dao.InsFeeOrderConfigMapper;
+import com.ydtech.modules.fee.dto.po.InsFeeOrderConfig;
+import com.ydtech.modules.fee.service.InsFeeOrderConfigService;
+import com.ydtech.modules.order.dao.InsAccidentalDrivingDaJiaMapper;
+import com.ydtech.modules.order.entity.vo.dajia.InsAccidentalDrivingDajia;
+import com.ydtech.modules.order.service.InsAccidentalDrivingDaJiaService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Administrator
+ * @description 针对表【InsFeeOrderConfig()】的数据库操作Service实现
+ * @createDate 2023-03-09 14:45:58
+ */
+@Service
+public class InsFeeOrderConfigServiceImpl extends ServiceImpl<InsFeeOrderConfigMapper, InsFeeOrderConfig>
+        implements InsFeeOrderConfigService {
+
+}
+
+
+
+

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

@@ -30,6 +30,9 @@ public class FeeOrderNewVo implements Serializable {
     @ApiModelProperty("部门管理费用")
     private List<FeeOrderNewVo.DeptManagerFee> deptManagerFee;
 
+    @ApiModelProperty("分销费用")
+    private List<RetailFee> retailFee;
+
     /**
      * 入口费用
      */
@@ -109,4 +112,45 @@ public class FeeOrderNewVo implements Serializable {
         @ApiModelProperty("利润差值")
         private BigDecimal profitMarginPremiums;
     }
+
+    @ApiModel(description = "分销费用")
+    @Data
+    public static class RetailFee{
+        @ApiModelProperty("险种")
+        private String insuranceType;
+
+        @ApiModelProperty("姓名")
+        private String userName;
+
+        @ApiModelProperty("交强分销比例")
+        private BigDecimal jqRetailProportion;
+
+        @ApiModelProperty("交强分销费用")
+        private BigDecimal jqRetailPremiums;
+
+        @ApiModelProperty("商业分销比例")
+        private BigDecimal syRetailProportion;
+
+        @ApiModelProperty("商业分销费用")
+        private BigDecimal syRetailPremiums;
+
+        @ApiModelProperty("非车分销比例")
+        private BigDecimal noRetailProportion;
+
+        @ApiModelProperty("非车分销费用")
+        private BigDecimal noRetailPremiums;
+
+        @ApiModelProperty("总分销金额")
+        private BigDecimal totalRetailPremiums;
+
+        public RetailFee(){
+            jqRetailProportion = new BigDecimal(0);
+            jqRetailPremiums = new BigDecimal(0);
+            syRetailProportion = new BigDecimal(0);
+            syRetailPremiums = new BigDecimal(0);
+            noRetailProportion = new BigDecimal(0);
+            noRetailPremiums = new BigDecimal(0);
+            totalRetailPremiums = new BigDecimal(0);
+        }
+    }
 }

+ 3 - 0
src/main/java/com/ydtech/modules/order/service/impl/InsAreaCompanyServiceImpl.java

@@ -667,10 +667,13 @@ public class InsAreaCompanyServiceImpl extends ServiceImpl<InsAreaCompanyMapper,
 
         costsNews.get(0).setJqCarCostsProportion(quoteVo.getJqSuperviseCostsProportion().toString());
         costsNews.get(0).setJqCarOtherCostsProportion(quoteVo.getJqOtherCostsProportion().toString());
+        costsNews.get(0).setJqCostsProportion(quoteVo.getJqSuperviseCostsProportion().add(quoteVo.getJqOtherCostsProportion()).toString());
         costsNews.get(0).setSyCarCostsProportion(quoteVo.getSySuperviseCostsProportion().toString());
         costsNews.get(0).setSyCarOtherCostsProportion(quoteVo.getSyOtherCostsProportion().toString());
+        costsNews.get(0).setSyCostsProportion(quoteVo.getSySuperviseCostsProportion().add(quoteVo.getSyOtherCostsProportion()).toString());
         costsNews.get(0).setNoCarCostsProportion(quoteVo.getNoSuperviseCostsProportion().toString());
         costsNews.get(0).setNoCarOtherCostsProportion(quoteVo.getNoOtherCostsProportion().toString());
+        costsNews.get(0).setNoCostsProportion(quoteVo.getNoSuperviseCostsProportion().add(quoteVo.getNoOtherCostsProportion()).toString());
 
         //计算费用
         feeRuleSchemeNewService.calcCostsExternal(costsNews.get(0),insAreaCompany);

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

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ydtech.modules.order.entity.vo.FeeOrderNewVo;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.Data;
@@ -356,6 +357,133 @@ public class InsFeeOrderNew {
     @TableField(exist = false)
     private String threeLevelUserInfo;
 
+    /**
+     * 一级交强分销比例
+     */
+    @ApiModelProperty(value = "一级交强分销比例")
+    @TableField(value = "jq_retail_proportion_level_1")
+    private BigDecimal jqRetailProportionLevel1;
+
+    /**
+     * 一级交强分销费
+     */
+    @ApiModelProperty(value = "一级交强分销费")
+    @TableField(value = "jq_retail_premiums_level_1")
+    private BigDecimal jqRetailPremiumsLevel1;
+
+    /**
+     * 一级商业分销比例
+     */
+    @ApiModelProperty(value = "一级商业分销比例")
+    @TableField(value = "sy_retail_proportion_level_1")
+    private BigDecimal syRetailProportionLevel1;
+
+    /**
+     * 一级商业分销费
+     */
+    @ApiModelProperty(value = "一级商业分销费")
+    @TableField(value = "sy_retail_premiums_level_1")
+    private BigDecimal syRetailPremiumsLevel1;
+
+    /**
+     * 一级非车分销比例
+     */
+    @ApiModelProperty(value = "一级非车分销比例")
+    @TableField(value = "no_retail_proportion_level_1")
+    private BigDecimal noRetailProportionLevel1;
+
+    /**
+     * 一级非车分销费
+     */
+    @ApiModelProperty(value = "一级非车分销费")
+    @TableField(value = "no_retail_premiums_level_1")
+    private BigDecimal noRetailPremiumsLevel1;
+
+    /**
+     * 二级交强分销比例
+     */
+    @ApiModelProperty(value = "二级交强分销比例")
+    @TableField(value = "jq_retail_proportion_level_2")
+    private BigDecimal jqRetailProportionLevel2;
+
+    /**
+     * 二级交强分销费
+     */
+    @ApiModelProperty(value = "二级交强分销费")
+    @TableField(value = "jq_retail_premiums_level_2")
+    private BigDecimal jqRetailPremiumsLevel2;
+
+    /**
+     * 二级商业分销比例
+     */
+    @ApiModelProperty(value = "二级商业分销比例")
+    @TableField(value = "sy_retail_proportion_level_2")
+    private BigDecimal syRetailProportionLevel2;
+
+    /**
+     * 二级商业分销费
+     */
+    @ApiModelProperty(value = "二级商业分销费")
+    @TableField(value = "sy_retail_premiums_level_2")
+    private BigDecimal syRetailPremiumsLevel2;
+
+    /**
+     * 二级非车分销比例
+     */
+    @ApiModelProperty(value = "二级非车分销比例")
+    @TableField(value = "no_retail_proportion_level_2")
+    private BigDecimal noRetailProportionLevel2;
+
+    /**
+     * 二级非车分销费
+     */
+    @ApiModelProperty(value = "二级非车分销费")
+    @TableField(value = "no_retail_premiums_level_2")
+    private BigDecimal noRetailPremiumsLevel2;
+
+    /**
+     * 三级交强分销比例
+     */
+    @ApiModelProperty(value = "三级交强分销比例")
+    @TableField(value = "jq_retail_proportion_level_3")
+    private BigDecimal jqRetailProportionLevel3;
+
+    /**
+     * 三级交强分销费
+     */
+    @ApiModelProperty(value = "三级交强分销费")
+    @TableField(value = "jq_retail_premiums_level_3")
+    private BigDecimal jqRetailPremiumsLevel3;
+
+    /**
+     * 三级商业分销比例
+     */
+    @ApiModelProperty(value = "三级商业分销比例")
+    @TableField(value = "sy_retail_proportion_level_3")
+    private BigDecimal syRetailProportionLevel3;
+
+    /**
+     * 三级商业分销费
+     */
+    @ApiModelProperty(value = "三级商业分销费")
+    @TableField(value = "sy_retail_premiums_level_3")
+    private BigDecimal syRetailPremiumsLevel3;
+
+    /**
+     * 三级非车分销比例
+     */
+    @ApiModelProperty(value = "三级非车分销比例")
+    @TableField(value = "no_retail_proportion_level_3")
+    private BigDecimal noRetailProportionLevel3;
+
+    /**
+     * 三级非车分销费
+     */
+    @ApiModelProperty(value = "三级非车分销费")
+    @TableField(value = "no_retail_premiums_level_3")
+    private BigDecimal noRetailPremiumsLevel3;
+
+
     @ApiModelProperty(value = "分销等级")
     @TableField(value = "distribution_status")
     private String distributionStatus;
@@ -457,4 +585,71 @@ public class InsFeeOrderNew {
         this.setDeptId(deptId);
         this.setUserId(userId);
     }
+
+    /**
+     * 赋值分销
+     */
+    public void assignRetail(FeeOrderNewVo.RetailFee retailFeeLevel1,FeeOrderNewVo.RetailFee retailFeeLevel2,FeeOrderNewVo.RetailFee retailFeeLevel3){
+        this.setJqRetailProportionLevel1(retailFeeLevel1.getJqRetailProportion());
+        this.setJqRetailProportionLevel2(retailFeeLevel2.getJqRetailProportion());
+        this.setJqRetailProportionLevel3(retailFeeLevel3.getJqRetailProportion());
+        this.setJqRetailPremiumsLevel1(retailFeeLevel1.getJqRetailPremiums());
+        this.setJqRetailPremiumsLevel2(retailFeeLevel2.getJqRetailPremiums());
+        this.setJqRetailPremiumsLevel3(retailFeeLevel3.getJqRetailPremiums());
+
+        this.setSyRetailProportionLevel1(retailFeeLevel1.getSyRetailProportion());
+        this.setSyRetailProportionLevel2(retailFeeLevel2.getSyRetailProportion());
+        this.setSyRetailProportionLevel3(retailFeeLevel3.getSyRetailProportion());
+        this.setSyRetailPremiumsLevel1(retailFeeLevel1.getSyRetailPremiums());
+        this.setSyRetailPremiumsLevel2(retailFeeLevel2.getSyRetailPremiums());
+        this.setSyRetailPremiumsLevel3(retailFeeLevel3.getSyRetailPremiums());
+
+        this.setNoRetailProportionLevel1(retailFeeLevel1.getNoRetailProportion());
+        this.setNoRetailProportionLevel2(retailFeeLevel2.getNoRetailProportion());
+        this.setNoRetailProportionLevel3(retailFeeLevel3.getNoRetailProportion());
+        this.setNoRetailPremiumsLevel1(retailFeeLevel1.getNoRetailPremiums());
+        this.setNoRetailPremiumsLevel2(retailFeeLevel2.getNoRetailPremiums());
+        this.setNoRetailPremiumsLevel3(retailFeeLevel3.getNoRetailPremiums());
+    }
+
+
+    private BigDecimal twoPeople(BigDecimal number){
+        return number.setScale(2, BigDecimal.ROUND_DOWN);
+    }
+
+    /**
+     * 赋值机构管理信息
+     */
+    public void assignDept(FeeOrderNewVo.DeptManagerFee jqDeptManagerFee,FeeOrderNewVo.DeptManagerFee syDeptManagerFee, FeeOrderNewVo.DeptManagerFee noDeptManagerFee){
+        this.setJqDeptProportionLevel1(jqDeptManagerFee.getDeptProportionLevelOne());
+        this.setJqDeptPremiumsLevel1(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelOne()));
+        this.setJqDeptProportionLevel2(jqDeptManagerFee.getDeptProportionLevelTwo());
+        this.setJqDeptPremiumsLevel2(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelTwo()));
+        this.setJqDeptProportionLevel3(jqDeptManagerFee.getDeptProportionLevelThree());
+        this.setJqDeptPremiumsLevel3(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelThree()));
+        this.setJqDeptProportionLevel4(jqDeptManagerFee.getDeptProportionLevelFoure());
+        this.setJqDeptPremiumsLevel4(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelFoure()));
+        this.setJqDeptProportionLevel5(jqDeptManagerFee.getDeptProportionLevelFive());
+        this.setJqDeptPremiumsLevel5(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelFive()));
+        this.setSyDeptProportionLevel1(syDeptManagerFee.getDeptProportionLevelOne());
+        this.setSyDeptPremiumsLevel1(twoPeople(syDeptManagerFee.getDeptPremiumsLevelOne()));
+        this.setSyDeptProportionLevel2(syDeptManagerFee.getDeptProportionLevelTwo());
+        this.setSyDeptPremiumsLevel2(twoPeople(syDeptManagerFee.getDeptPremiumsLevelTwo()));
+        this.setSyDeptProportionLevel3(syDeptManagerFee.getDeptProportionLevelThree());
+        this.setSyDeptPremiumsLevel3(twoPeople(syDeptManagerFee.getDeptPremiumsLevelThree()));
+        this.setSyDeptProportionLevel4(syDeptManagerFee.getDeptProportionLevelFoure());
+        this.setSyDeptPremiumsLevel4(twoPeople(syDeptManagerFee.getDeptPremiumsLevelFoure()));
+        this.setSyDeptProportionLevel5(syDeptManagerFee.getDeptProportionLevelFive());
+        this.setSyDeptPremiumsLevel5(twoPeople(syDeptManagerFee.getDeptPremiumsLevelFive()));
+        this.setNoDeptProportionLevel1(noDeptManagerFee.getDeptProportionLevelOne());
+        this.setNoDeptPremiumsLevel1(twoPeople(noDeptManagerFee.getDeptPremiumsLevelOne()));
+        this.setNoDeptProportionLevel2(noDeptManagerFee.getDeptProportionLevelTwo());
+        this.setNoDeptPremiumsLevel2(twoPeople(noDeptManagerFee.getDeptPremiumsLevelTwo()));
+        this.setNoDeptProportionLevel3(noDeptManagerFee.getDeptProportionLevelThree());
+        this.setNoDeptPremiumsLevel3(twoPeople(noDeptManagerFee.getDeptPremiumsLevelThree()));
+        this.setNoDeptProportionLevel4(noDeptManagerFee.getDeptProportionLevelFoure());
+        this.setNoDeptPremiumsLevel4(twoPeople(noDeptManagerFee.getDeptPremiumsLevelFoure()));
+        this.setNoDeptProportionLevel5(noDeptManagerFee.getDeptProportionLevelFive());
+        this.setNoDeptPremiumsLevel5(twoPeople(noDeptManagerFee.getDeptPremiumsLevelFive()));
+    }
 }

+ 392 - 67
src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementProductCostsNewServiceImpl.java

@@ -7,11 +7,18 @@ import com.ydtech.exception.SystemException;
 import com.ydtech.modules.admin.model.SysUser;
 import com.ydtech.modules.admin.service.SysUserService;
 import com.ydtech.modules.base.controller.BaseController;
+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.fee.dto.vo.ReCalcuLateProportion;
+import com.ydtech.modules.fee.dto.vo.RetailProportion;
 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.order.entity.InsAreaCompany;
 import com.ydtech.modules.order.entity.InsOrders;
+import com.ydtech.modules.order.entity.vo.DistributionLevelVo;
 import com.ydtech.modules.order.entity.vo.FeeOrderNewRecordVo;
 import com.ydtech.modules.order.entity.vo.FeeOrderNewVo;
 import com.ydtech.modules.order.service.InsAreaCompanyService;
@@ -1096,10 +1103,20 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
     @Autowired
     FeeRuleSchemeService feeRuleSchemeService;
 
+    @Autowired
+    FeeRuleSchemeNewService feeRuleSchemeNewService;
+
+    @Autowired
+    EsmRetailService esmRetailService;
+
+
     @Transactional
     @Override
     public FeeOrderNewVo costsAdjust(FeeOrderNewRecordVo feeOrderNewRecordVo) {
         FeeOrderNewVo feeOrderNewVo = feeOrderNewRecordVo.getFeeOrderNewVoNew();
+
+        //region 费用校验
+
         //验证费用是否匹配
         if (feeOrderNewVo.getEntranceFee().get(0).getSuperviseCosts().add(feeOrderNewVo.getEntranceFee().get(0).getOtherCostsProportion())
                 .compareTo(feeOrderNewVo.getEntranceFee().get(0).getTotalProportion()) != 0) {
@@ -1118,9 +1135,14 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
         if(!modifyCostsHistory(feeOrderNewRecordVo)){
             throw new SystemException("调整费用失败");
         }
+
+        //endregion
+
         String feeId = feeOrderNewRecordVo.getFeeId();
         InsFeeOrderNew insFeeOrderNew = insFeeOrderNewService.getById(feeId);
-
+        InsAreaCompany insAreaCompany = insAreaCompanyService.getById(insFeeOrderNew.getInsOrderNo());
+        InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
+        SysUser sysUser = sysUserService.findByUserId(insOrders.getUserid());
 
 
         //查询协议是否包含税
@@ -1130,127 +1152,387 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
             taxRadio = new BigDecimal("1.06");
         }
 
-        //分销费用信息 使用比例
-        InsAreaCompany insAreaCompany = insAreaCompanyService.getById(insFeeOrderNew.getInsOrderNo());
-        InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
-        SysUser sysUser = sysUserService.findByUserId(insOrders.getUserid());
-        RetailStoreFee retailStoreFee = costsCalcService.getRetailStoreFee(sysUser.getId(),
-                insFeeOrderNew.getJqPremium().add(insFeeOrderNew.getSyPremium()).add(insFeeOrderNew.getNoPremium()));
 
 
         List<FeeOrderNewVo.EntranceFee> entranceFeeList = new ArrayList<>();
         List<FeeOrderNewVo.DeptManagerFee> deptManagerFeeList = new ArrayList<>();
         List<FeeOrderNewVo.ExportFee> exportFeeList = new ArrayList<>();
+        List<FeeOrderNewVo.RetailFee> retailFeeList = new ArrayList<>();
 
         //region 入口费用
         //交强入口费用
-        FeeOrderNewVo.EntranceFee jqEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getJqPremium(),
+        FeeOrderNewVo.EntranceFee jqEntranceFee = feeRuleSchemeService.calcEntranceFee(
+                insFeeOrderNew.getJqPremium(),
                 feeOrderNewVo.getEntranceFee().get(0).getSuperviseCosts(),
-                feeOrderNewVo.getEntranceFee().get(0).getOtherCostsProportion(), taxRadio);
+                feeOrderNewVo.getEntranceFee().get(0).getOtherCostsProportion(),
+                taxRadio);
+
         jqEntranceFee.setInsuranceType("交强险");
         entranceFeeList.add(jqEntranceFee);
 
         //商业入口费用
         FeeOrderNewVo.EntranceFee syEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getSyPremium(),
                 feeOrderNewVo.getEntranceFee().get(1).getSuperviseCosts(),
-                feeOrderNewVo.getEntranceFee().get(1).getOtherCostsProportion(), taxRadio);
+                feeOrderNewVo.getEntranceFee().get(1).getOtherCostsProportion(),
+                taxRadio);
+
         syEntranceFee.setInsuranceType("商业险");
         entranceFeeList.add(syEntranceFee);
 
         //非车入口费用
         FeeOrderNewVo.EntranceFee noEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getNoPremium(),
                 feeOrderNewVo.getEntranceFee().get(2).getSuperviseCosts(),
-                feeOrderNewVo.getEntranceFee().get(2).getOtherCostsProportion(), taxRadio);
+                feeOrderNewVo.getEntranceFee().get(2).getOtherCostsProportion(),
+                taxRadio);
+
         noEntranceFee.setInsuranceType("非车险");
         entranceFeeList.add(noEntranceFee);
 
         //endregion
 
+        //region 重新计算管理费比例和分销比例
+
+        List<EsmRetail> esmRetailList = esmRetailService.selectList(" where t.deptid=? and t.status = '1' ",
+                new Object[]{sysUser.getDeptId()});
+
+        Integer retailLevel = 0;
+
+        PtlAgreementProductCostsExport ptlAgreementProductCostsExport = new PtlAgreementProductCostsExport();
+
+        //默认分销比例设置
+        RetailProportion retailProportion = new RetailProportion();
+        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());
+        }
+
+
+        //获取交强机构管理费总比例
+        BigDecimal jqDeptProportion =
+                     feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelOne()
+                .add(feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelTwo())
+                .add(feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelThree())
+                .add(feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelFoure())
+                .add(feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelFive());
+        //获取商业机构管理费总比例
+        BigDecimal syDeptProportion =
+                feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelOne()
+                        .add(feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelTwo())
+                        .add(feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelThree())
+                        .add(feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelFoure())
+                        .add(feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelFive());
+        //获取非车机构管理费总比例
+        BigDecimal noDeptProportion =
+                feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelOne()
+                        .add(feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelTwo())
+                        .add(feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelThree())
+                        .add(feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelFoure())
+                        .add(feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelFive());
+
+        ptlAgreementProductCostsExport.setJqExportRadioLevel1(feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelOne());
+        ptlAgreementProductCostsExport.setJqExportRadioLevel2(feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelTwo());
+        ptlAgreementProductCostsExport.setJqExportRadioLevel3(feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelThree());
+        ptlAgreementProductCostsExport.setJqExportRadioLevel4(feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelFoure());
+        ptlAgreementProductCostsExport.setJqExportRadioLevel5(feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelFive());
+
+        ptlAgreementProductCostsExport.setSyExportRadioLevel1(feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelOne());
+        ptlAgreementProductCostsExport.setSyExportRadioLevel2(feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelTwo());
+        ptlAgreementProductCostsExport.setSyExportRadioLevel3(feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelThree());
+        ptlAgreementProductCostsExport.setSyExportRadioLevel4(feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelFoure());
+        ptlAgreementProductCostsExport.setSyExportRadioLevel5(feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelFive());
+
+        ptlAgreementProductCostsExport.setNoCarExportRadioLevel1(feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelOne());
+        ptlAgreementProductCostsExport.setNoCarExportRadioLevel2(feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelTwo());
+        ptlAgreementProductCostsExport.setNoCarExportRadioLevel3(feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelThree());
+        ptlAgreementProductCostsExport.setNoCarExportRadioLevel4(feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelFoure());
+        ptlAgreementProductCostsExport.setNoCarExportRadioLevel5(feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelFive());
+
+
+        //获取交强分销总比例
+        BigDecimal jqRetailProportion = retailProportion.getJqRetailLevel1Proportion()
+                .add(retailProportion.getJqRetailLevel2Proportion())
+                .add(retailProportion.getJqRetailLevel3Proportion());
+
+        //获取商业分销总比例
+        BigDecimal syRetailProportion = retailProportion.getSyRetailLevel1Proportion()
+                .add(retailProportion.getSyRetailLevel2Proportion())
+                .add(retailProportion.getSyRetailLevel3Proportion());
+
+        //获取非车分销总比例
+        BigDecimal noRetailProportion = retailProportion.getNoRetailLevel1Proportion()
+                .add(retailProportion.getNoRetailLevel2Proportion())
+                .add(retailProportion.getNoRetailLevel3Proportion());
+
+        //重新计算比例  入口是否超出支付的比例
+        ReCalcuLateProportion jqReCalcuLateProportion = feeRuleSchemeNewService.recalculateProportion(
+                feeOrderNewVo.getEntranceFee().get(0).getTotalProportion(),
+                jqDeptProportion,
+                jqRetailProportion,
+                taxRadio,
+                retailLevel,
+                ptlAgreementProductCostsExport,
+                retailProportion,
+                "jq");
+
+        ReCalcuLateProportion syReCalcuLateProportion = feeRuleSchemeNewService.recalculateProportion(
+                feeOrderNewVo.getEntranceFee().get(1).getTotalProportion(),
+                syDeptProportion,
+                syRetailProportion,
+                taxRadio,
+                retailLevel,
+                ptlAgreementProductCostsExport,
+                retailProportion,
+                "sy");
+
+        ReCalcuLateProportion noReCalcuLateProportion = feeRuleSchemeNewService.recalculateProportion(
+                feeOrderNewVo.getEntranceFee().get(2).getTotalProportion(),
+                noDeptProportion,
+                noRetailProportion,
+                taxRadio,
+                retailLevel,
+                ptlAgreementProductCostsExport,
+                retailProportion,
+                "no");
+
+        retailProportion.setProportion(jqReCalcuLateProportion,syReCalcuLateProportion,noReCalcuLateProportion);
+//        ptlAgreementProductCostsExportService.updateById(ptlAgreementProductCostsExport);
+
+
+        //endregion
+
+        //region 计算分销费用
+
+        //获取分销比例
+
+        //分销总比例
+        BigDecimal jqRetailRadio = new BigDecimal("0");
+        BigDecimal syRetailRadio = new BigDecimal("0");
+        BigDecimal noRetailRadio = new BigDecimal("0");
+
+        FeeOrderNewVo.RetailFee retailFeeLevel3 = new FeeOrderNewVo.RetailFee();
+        FeeOrderNewVo.RetailFee retailFeeLevel2 = new FeeOrderNewVo.RetailFee();
+        FeeOrderNewVo.RetailFee retailFeeLevel1 = new FeeOrderNewVo.RetailFee();
+
+        if (esmRetailList != null && !esmRetailList.isEmpty()) {
+            EsmRetail esmRetail = esmRetailList.get(0);
+            //分销等级
+            insFeeOrderNew.setDistributionStatus(esmRetailList.get(0).getRetailtype());
+
+            if (esmRetail != null) {
+                if (Integer.parseInt(esmRetail.getRetailtype()) >= 3) {
+                    insFeeOrderNew.setThirdDetailProportion(retailProportion.getJqRetailLevel3Proportion());
+                    retailFeeLevel3 = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(),
+                            insFeeOrderNew.getJqCostsProportion(),
+                            insFeeOrderNew.getSyPremium(),
+                            insFeeOrderNew.getSyCostsProportion().add(insFeeOrderNew.getSyOtherCostsProportion()),
+                            insFeeOrderNew.getNoPremium(),
+                            insFeeOrderNew.getNoCostsProportion().add(insFeeOrderNew.getNoOtherCostsProportion()),
+                            retailProportion.getJqRetailLevel3Proportion(),
+                            retailProportion.getSyRetailLevel3Proportion(),
+                            retailProportion.getNoRetailLevel3Proportion());
+                    if(insFeeOrderNew.getFirstLevelUserId() != null){
+                        SysUser byId = sysUserService.getById(insFeeOrderNew.getThreeLevelUserId());
+                        retailFeeLevel3.setUserName(byId.getName()+"("+byId.getId()+")");
+                    }
+                    insFeeOrderNew.setThirdDetailPremiums(retailFeeLevel3.getTotalRetailPremiums());
+                }else{
+                    insFeeOrderNew.setThirdDetailProportion(new BigDecimal(0));
+                }
+                if (Integer.parseInt(esmRetail.getRetailtype()) >= 2) {
+                    insFeeOrderNew.setSecondDetailProportion(retailProportion.getJqRetailLevel2Proportion());
+                    retailFeeLevel2 = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(),
+                            insFeeOrderNew.getJqCostsProportion(),
+                            insFeeOrderNew.getSyPremium(),
+                            insFeeOrderNew.getSyCostsProportion(),
+                            insFeeOrderNew.getNoPremium(),
+                            insFeeOrderNew.getNoCostsProportion(),
+                            retailProportion.getJqRetailLevel2Proportion(),
+                            retailProportion.getSyRetailLevel2Proportion(),
+                            retailProportion.getNoRetailLevel2Proportion());
+
+                    insFeeOrderNew.setSecondDetailPremiums(retailFeeLevel2.getTotalRetailPremiums());
+                    if(insFeeOrderNew.getTwoLevelUserId() != null) {
+                        SysUser byId = sysUserService.getById(insFeeOrderNew.getTwoLevelUserId());
+                        retailFeeLevel2.setUserName(byId.getName() + "(" + byId.getId() + ")");
+                    }
+                }else{
+                    insFeeOrderNew.setSecondDetailProportion(new BigDecimal(0));
+                }
+                if (Integer.parseInt(esmRetail.getRetailtype()) >= 1) {
+                    insFeeOrderNew.setFirstDetailProportion(retailProportion.getJqRetailLevel1Proportion());
+                    retailFeeLevel1 = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(),
+                            insFeeOrderNew.getJqCostsProportion(),
+                            insFeeOrderNew.getSyPremium(),
+                            insFeeOrderNew.getSyCostsProportion(),
+                            insFeeOrderNew.getNoPremium(),
+                            insFeeOrderNew.getNoCostsProportion(),
+                            retailProportion.getJqRetailLevel1Proportion(),
+                            retailProportion.getSyRetailLevel1Proportion(),
+                            retailProportion.getNoRetailLevel1Proportion());
+
+                    insFeeOrderNew.setFirstDetailPremiums(retailFeeLevel1.getTotalRetailPremiums());
+                    if(insFeeOrderNew.getFirstLevelUserId() != null) {
+                        SysUser byId = sysUserService.getById(insFeeOrderNew.getFirstLevelUserId());
+                        retailFeeLevel1.setUserName(byId.getName() + "(" + byId.getId() + ")");
+                    }
+                }else{
+                    insFeeOrderNew.setFirstDetailProportion(new BigDecimal(0));
+                }
+            }else{
+                insFeeOrderNew.setFirstDetailPremiums(new BigDecimal(0));
+                insFeeOrderNew.setSecondDetailPremiums(new BigDecimal(0));
+                insFeeOrderNew.setThirdDetailPremiums(new BigDecimal(0));
+            }
+        }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());
+
+        syRetailRadio = syRetailRadio.add(retailFeeLevel1.getSyRetailProportion())
+                .add(retailFeeLevel2.getSyRetailProportion())
+                .add(retailFeeLevel3.getSyRetailProportion());
+
+        noRetailRadio = noRetailRadio.add(retailFeeLevel1.getNoRetailProportion())
+                .add(retailFeeLevel2.getNoRetailProportion())
+                .add(retailFeeLevel3.getNoRetailProportion());
+
+        retailFeeLevel1.setInsuranceType("一级分销");
+        retailFeeLevel2.setInsuranceType("二级分销");
+        retailFeeLevel3.setInsuranceType("三级分销");
+
+        retailFeeList.add(retailFeeLevel1);
+        retailFeeList.add(retailFeeLevel2);
+        retailFeeList.add(retailFeeLevel3);
+
+
+
+
+
+        insFeeOrderNew.assignRetail(retailFeeLevel1,retailFeeLevel2,retailFeeLevel3);
+
+        //endregion
+
+        //region 设置机构管理费
+
+        //交强机构管理费
+        BigDecimal jqDeptRadio =
+                jqReCalcuLateProportion.getDept_level_1_proportion()
+                        .add(jqReCalcuLateProportion.getDept_level_2_proportion())
+                        .add(jqReCalcuLateProportion.getDept_level_3_proportion())
+                        .add(jqReCalcuLateProportion.getDept_level_4_proportion())
+                        .add(jqReCalcuLateProportion.getDept_level_5_proportion());
+
+        FeeOrderNewVo.DeptManagerFee jqDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(
+                insFeeOrderNew.getJqPremium(),
+                jqReCalcuLateProportion.getDept_level_1_proportion(),
+                jqReCalcuLateProportion.getDept_level_2_proportion(),
+                jqReCalcuLateProportion.getDept_level_3_proportion(),
+                jqReCalcuLateProportion.getDept_level_4_proportion(),
+                jqReCalcuLateProportion.getDept_level_5_proportion());
 
-        //region 部门管理费用
-        //交强部门管理费用
-        FeeOrderNewVo.DeptManagerFee jqDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getJqPremium(),
-                feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelOne(),
-                feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelTwo(),
-                feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelThree(),
-                feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelFoure(),
-                feeOrderNewVo.getDeptManagerFee().get(0).getDeptProportionLevelFive());
         jqDeptManagerFee.setInsuranceType("交强险");
         deptManagerFeeList.add(jqDeptManagerFee);
 
-        //商业部门管理费用
-        FeeOrderNewVo.DeptManagerFee syDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getSyPremium(),
-                feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelOne(),
-                feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelTwo(),
-                feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelThree(),
-                feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelFoure(),
-                feeOrderNewVo.getDeptManagerFee().get(1).getDeptProportionLevelFive());
+        BigDecimal syDeptRadio =
+                syReCalcuLateProportion.getDept_level_1_proportion()
+                        .add(syReCalcuLateProportion.getDept_level_2_proportion())
+                        .add(syReCalcuLateProportion.getDept_level_3_proportion())
+                        .add(syReCalcuLateProportion.getDept_level_4_proportion())
+                        .add(syReCalcuLateProportion.getDept_level_5_proportion());
+
+        FeeOrderNewVo.DeptManagerFee syDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(
+                insFeeOrderNew.getSyPremium(),
+                syReCalcuLateProportion.getDept_level_1_proportion(),
+                syReCalcuLateProportion.getDept_level_2_proportion(),
+                syReCalcuLateProportion.getDept_level_3_proportion(),
+                syReCalcuLateProportion.getDept_level_4_proportion(),
+                syReCalcuLateProportion.getDept_level_5_proportion());
+
         syDeptManagerFee.setInsuranceType("商业险");
         deptManagerFeeList.add(syDeptManagerFee);
 
-        //非车部门管理费用
-        FeeOrderNewVo.DeptManagerFee noDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getNoPremium(),
-                feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelOne(),
-                feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelTwo(),
-                feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelThree(),
-                feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelFoure(),
-                feeOrderNewVo.getDeptManagerFee().get(2).getDeptProportionLevelFive());
+        BigDecimal noDeptRadio =
+                noReCalcuLateProportion.getDept_level_1_proportion()
+                        .add(noReCalcuLateProportion.getDept_level_2_proportion())
+                        .add(noReCalcuLateProportion.getDept_level_3_proportion())
+                        .add(noReCalcuLateProportion.getDept_level_4_proportion())
+                        .add(noReCalcuLateProportion.getDept_level_5_proportion());
+
+        FeeOrderNewVo.DeptManagerFee noDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(
+                insFeeOrderNew.getNoPremium(),
+                noReCalcuLateProportion.getDept_level_1_proportion(),
+                noReCalcuLateProportion.getDept_level_2_proportion(),
+                noReCalcuLateProportion.getDept_level_3_proportion(),
+                noReCalcuLateProportion.getDept_level_4_proportion(),
+                noReCalcuLateProportion.getDept_level_5_proportion());
+
         noDeptManagerFee.setInsuranceType("非车险");
         deptManagerFeeList.add(noDeptManagerFee);
 
+        insFeeOrderNew.assignDept(jqDeptManagerFee,syDeptManagerFee,noDeptManagerFee);
 
-        BigDecimal jqDeptManagerTotalProportion = jqDeptManagerFee.getDeptProportionLevelOne().add(jqDeptManagerFee.getDeptProportionLevelTwo())
-                .add(jqDeptManagerFee.getDeptProportionLevelThree()).add(jqDeptManagerFee.getDeptProportionLevelFoure())
-                .add(jqDeptManagerFee.getDeptProportionLevelFive());
-
-        BigDecimal syDeptManagerTotalProportion = syDeptManagerFee.getDeptProportionLevelOne().add(syDeptManagerFee.getDeptProportionLevelTwo())
-                .add(syDeptManagerFee.getDeptProportionLevelThree()).add(syDeptManagerFee.getDeptProportionLevelFoure())
-                .add(syDeptManagerFee.getDeptProportionLevelFive());
-
-        BigDecimal noDeptManagerTotalProportion = noDeptManagerFee.getDeptProportionLevelOne().add(noDeptManagerFee.getDeptProportionLevelTwo())
-                .add(noDeptManagerFee.getDeptProportionLevelThree()).add(noDeptManagerFee.getDeptProportionLevelFoure())
-                .add(noDeptManagerFee.getDeptProportionLevelFive());
 
         //endregion
 
-
         //region 出口费用
         //查费用里的手续费
         InsFeeOrderNew insFeeOrderNewServiceById = insFeeOrderNewService.getById(feeOrderNewRecordVo.getFeeId());
         PtlAgreementProductCostsNew costsNew = ptlAgreementProductCostsNewService.getById(insFeeOrderNewServiceById.getCostsId());
         //交强出口费用
-        FeeOrderNewVo.ExportFee jqExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getJqPremium(), new BigDecimal(costsNew.getJqCostsExportProportion()),
-                feeOrderNewVo.getEntranceFee().get(0).getTotalProportion(), jqDeptManagerTotalProportion, retailStoreFee.getRetailStoreRadio(), taxRadio);
+        FeeOrderNewVo.ExportFee jqExportFee = feeRuleSchemeService.calcExportFee(
+                insFeeOrderNew.getJqPremium(),
+                new BigDecimal(costsNew.getJqCostsExportProportion()),
+                feeOrderNewVo.getEntranceFee().get(0).getTotalProportion(),
+                jqDeptRadio,
+                jqRetailRadio,
+                taxRadio);
+
         jqExportFee.setInsuranceType("交强险");
         exportFeeList.add(jqExportFee);
 
 
         //商业出口费用
-        FeeOrderNewVo.ExportFee syExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getSyPremium(), new BigDecimal(costsNew.getSyCostsExportProportion()),
-                feeOrderNewVo.getEntranceFee().get(1).getTotalProportion(), syDeptManagerTotalProportion, retailStoreFee.getRetailStoreRadio(), taxRadio);
+        FeeOrderNewVo.ExportFee syExportFee = feeRuleSchemeService.calcExportFee(
+                insFeeOrderNew.getSyPremium(),
+                new BigDecimal(costsNew.getSyCostsExportProportion()),
+                feeOrderNewVo.getEntranceFee().get(1).getTotalProportion(),
+                syDeptRadio,
+                syRetailRadio,
+                taxRadio);
+
         syExportFee.setInsuranceType("商业险");
         exportFeeList.add(syExportFee);
 
 
         //非车出口费用
-        FeeOrderNewVo.ExportFee noExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getNoPremium(), new BigDecimal(costsNew.getNoCostsExportProportion()),
-                feeOrderNewVo.getEntranceFee().get(2).getTotalProportion(), noDeptManagerTotalProportion, retailStoreFee.getRetailStoreRadio(), taxRadio);
+        FeeOrderNewVo.ExportFee noExportFee = feeRuleSchemeService.calcExportFee(
+                insFeeOrderNew.getNoPremium(),
+                new BigDecimal(costsNew.getNoCostsExportProportion()),
+                feeOrderNewVo.getEntranceFee().get(2).getTotalProportion(),
+                noDeptRadio,
+                noRetailRadio,
+                taxRadio);
+
         noExportFee.setInsuranceType("非车险");
         exportFeeList.add(noExportFee);
 
         //endregion
 
 
-
-
-
         FeeOrderNewVo resultFeeOrderNewVo = new FeeOrderNewVo();
         resultFeeOrderNewVo.setEntranceFee(entranceFeeList);
         resultFeeOrderNewVo.setExportFee(exportFeeList);
-
+//        resultFeeOrderNewVo.setRetailFee(distributionLevelVoList);
 
 
         //ins_fee_order_new 保存新的费用
+        //入口
         insFeeOrderNew.setJqCostsProportion(entranceFeeList.get(0).getTotalProportion());
         insFeeOrderNew.setJqCostsPremiums(entranceFeeList.get(0).getTotalAmount());
         insFeeOrderNew.setJqSuperviseCostsProportion(entranceFeeList.get(0).getSuperviseCosts());
@@ -1323,24 +1605,64 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
         insFeeOrderNew.setNoExportOtherCostsProportion(exportFeeList.get(2).getOtherCostsProportion());
         insFeeOrderNew.setNoExportOtherCostsPremiums(exportFeeList.get(2).getOtherCostsPremiums());
 
-        //region 计算差值
-        //入口 - 出口 - 机构管理费 5级 - 分销费  = 差值
+        //分销费用
+        insFeeOrderNew.setJqRetailProportionLevel1(retailFeeLevel1.getJqRetailProportion());
+        insFeeOrderNew.setJqRetailPremiumsLevel1(retailFeeLevel1.getJqRetailPremiums());
+        insFeeOrderNew.setJqRetailProportionLevel2(retailFeeLevel2.getJqRetailProportion());
+        insFeeOrderNew.setJqRetailPremiumsLevel2(retailFeeLevel2.getJqRetailPremiums());
+        insFeeOrderNew.setJqRetailProportionLevel3(retailFeeLevel3.getJqRetailProportion());
+        insFeeOrderNew.setJqRetailPremiumsLevel3(retailFeeLevel3.getJqRetailPremiums());
+
+        insFeeOrderNew.setSyRetailProportionLevel1(retailFeeLevel1.getSyRetailProportion());
+        insFeeOrderNew.setSyRetailPremiumsLevel1(retailFeeLevel1.getSyRetailPremiums());
+        insFeeOrderNew.setSyRetailProportionLevel2(retailFeeLevel2.getSyRetailProportion());
+        insFeeOrderNew.setSyRetailPremiumsLevel2(retailFeeLevel2.getSyRetailPremiums());
+        insFeeOrderNew.setSyRetailProportionLevel3(retailFeeLevel3.getSyRetailProportion());
+        insFeeOrderNew.setSyRetailPremiumsLevel3(retailFeeLevel3.getSyRetailPremiums());
+
+        insFeeOrderNew.setNoRetailProportionLevel1(retailFeeLevel1.getNoRetailProportion());
+        insFeeOrderNew.setNoRetailPremiumsLevel1(retailFeeLevel1.getNoRetailPremiums());
+        insFeeOrderNew.setNoRetailProportionLevel2(retailFeeLevel2.getNoRetailProportion());
+        insFeeOrderNew.setNoRetailPremiumsLevel2(retailFeeLevel2.getNoRetailPremiums());
+        insFeeOrderNew.setNoRetailProportionLevel3(retailFeeLevel3.getNoRetailProportion());
+        insFeeOrderNew.setNoRetailPremiumsLevel3(retailFeeLevel3.getNoRetailPremiums());
+
+        insFeeOrderNew.setFirstDetailPremiums(
+                retailFeeLevel1.getJqRetailPremiums()
+                        .add(retailFeeLevel1.getSyRetailPremiums())
+                        .add(retailFeeLevel1.getNoRetailPremiums())
+        );
+
+        insFeeOrderNew.setSecondDetailPremiums(
+                retailFeeLevel2.getJqRetailPremiums()
+                        .add(retailFeeLevel2.getSyRetailPremiums())
+                        .add(retailFeeLevel2.getNoRetailPremiums())
+        );
+
+        insFeeOrderNew.setThirdDetailPremiums(
+                retailFeeLevel3.getJqRetailPremiums()
+                        .add(retailFeeLevel3.getSyRetailPremiums())
+                        .add(retailFeeLevel3.getNoRetailPremiums())
+        );
+
+        //region 计算利润差值
+        //入口 - 出口 - 机构管理费 1-5级 - 分销费  = 差值
 
         //分销交强费用
         //分开算  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.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.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.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.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.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);
 
 
@@ -1362,6 +1684,7 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
         insFeeOrderNew.setSyProfitMarginPremiums(syDifference);
         deptManagerFeeList.get(1).setProfitMarginPremiums(syDifference);
 
+
         BigDecimal noDifference = noEntranceFee.getTotalAmount().subtract(
                         (noExportFee.getSuperviseCostsPremiums().add(noExportFee.getOtherCostsPremiums())))
                 .subtract(
@@ -1371,15 +1694,17 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
 
         insFeeOrderNew.setNoProfitMarginPremiums(noDifference);
         deptManagerFeeList.get(2).setProfitMarginPremiums(noDifference);
+
         //endregion
         resultFeeOrderNewVo.setDeptManagerFee(deptManagerFeeList);
-
+        resultFeeOrderNewVo.setRetailFee(retailFeeList);
         //保存新的比例
         insFeeOrderNewService.updateById(insFeeOrderNew);
         return resultFeeOrderNewVo;
 
     }
 
+
     /**
      * 修改费用历史记录
      * @return

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff