|
|
@@ -753,6 +753,7 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 计算费用测试方法 没有数据库保存操作 只带入值进行计算核对
|
|
|
*
|
|
|
@@ -1516,6 +1517,472 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
|
|
|
insFeeOrderNewService.saveOrUpdate(insFeeOrderNew);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void calcCostsExternalTelemarketing(PtlAgreementProductCostsNew ptlAgreementProductCostsNew, InsAreaCompany insAreaCompany) {
|
|
|
+ //获取协议信息
|
|
|
+ PtlAgreement ptlAgreement = ptlAgreementService.getById(insAreaCompany.getAgreementId());
|
|
|
+ InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
|
|
|
+ SysUser sysUser = sysUserService.findByUserId(insOrders.getUserid());
|
|
|
+
|
|
|
+ BigDecimal taxRadio = new BigDecimal("1.00");
|
|
|
+ //如果是外部订单则 不含税
|
|
|
+ if (ptlAgreement.getWithTax().equals("否") && ptlAgreement.getIsExternal() == 0) {
|
|
|
+ taxRadio = new BigDecimal("1.06");
|
|
|
+ }
|
|
|
+
|
|
|
+ //出口配置
|
|
|
+ PtlAgreementProductCostsExport ptlAgreementProductCostsExport =
|
|
|
+ ptlAgreementProductCostsExportService.getOne(new LambdaQueryWrapper<PtlAgreementProductCostsExport>().eq(PtlAgreementProductCostsExport::getCostsId, ptlAgreementProductCostsNew.getId()));
|
|
|
+ InsFeeOrderNew insFeeOrderNew = new InsFeeOrderNew();
|
|
|
+ insFeeOrderNew.setId(IdGenerate.nextId());
|
|
|
+ insFeeOrderNew.setCostsId(ptlAgreementProductCostsNew.getId());
|
|
|
+ insFeeOrderNew.setAgreementId(insAreaCompany.getAgreementId());
|
|
|
+
|
|
|
+ //存储部门id与用户id
|
|
|
+ InsOrders order = insOrdersService.getById(insAreaCompany.getOrderno());
|
|
|
+ InsFeeOrderNew insFeeOrderNewByCompanyId = insFeeOrderNewService.getInsFeeOrderNewByCompanyId(insAreaCompany.getId());
|
|
|
+ if (insFeeOrderNewByCompanyId != null) {
|
|
|
+ insFeeOrderNew.setId(insFeeOrderNewByCompanyId.getId());
|
|
|
+ }
|
|
|
+ insFeeOrderNew.setDeptId(order.getDeptid());
|
|
|
+ insFeeOrderNew.setUserId(order.getUserid());
|
|
|
+ insFeeOrderNew.setInsOrderNo(insAreaCompany.getId());
|
|
|
+ insFeeOrderNew.setJqPremium(insAreaCompany.getJqpremium());
|
|
|
+ insFeeOrderNew.setSyPremium(insAreaCompany.getSypremium());
|
|
|
+ insFeeOrderNew.setNoPremium(insAreaCompany.getJypremium());
|
|
|
+ //不含税
|
|
|
+ BigDecimal bigDecimal = new BigDecimal("1.06");
|
|
|
+ insFeeOrderNew.setJqNoTaxPremium(insAreaCompany.getJqpremium().divide(bigDecimal, 2));
|
|
|
+ insFeeOrderNew.setSyNoTaxPremium(insAreaCompany.getSypremium().divide(bigDecimal, 2));
|
|
|
+ insFeeOrderNew.setNoNoTaxPremium(insAreaCompany.getJypremium().divide(bigDecimal, 2));
|
|
|
+
|
|
|
+ //region 计算入口费用
|
|
|
+
|
|
|
+ //交强入口信息
|
|
|
+ FeeOrderNewVo.EntranceFee jqEntranceFee = feeRuleSchemeService.calcEntranceFee(
|
|
|
+ insFeeOrderNew.getJqPremium(),
|
|
|
+ new BigDecimal(ptlAgreementProductCostsNew.getJqCarCostsProportion()),
|
|
|
+ new BigDecimal(ptlAgreementProductCostsNew.getJqCarOtherCostsProportion()),
|
|
|
+ taxRadio);
|
|
|
+
|
|
|
+ insFeeOrderNew.setJqCostsProportion(jqEntranceFee.getTotalProportion());
|
|
|
+ insFeeOrderNew.setJqSuperviseCostsProportion(jqEntranceFee.getSuperviseCosts());
|
|
|
+ insFeeOrderNew.setJqSuperviseCostsPremiums(jqEntranceFee.getSuperviseCostsPremiums());
|
|
|
+ insFeeOrderNew.setJqOtherCostsProportion(jqEntranceFee.getOtherCostsProportion());
|
|
|
+ insFeeOrderNew.setJqOtherCostsPremiums(jqEntranceFee.getOtherCostsPremiums());
|
|
|
+ insFeeOrderNew.setJqCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums().add(insFeeOrderNew.getJqOtherCostsPremiums()));
|
|
|
+
|
|
|
+ //商业入口信息
|
|
|
+ FeeOrderNewVo.EntranceFee syEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getSyPremium(),
|
|
|
+ new BigDecimal(ptlAgreementProductCostsNew.getSyCarCostsProportion()),
|
|
|
+ new BigDecimal(ptlAgreementProductCostsNew.getSyCarOtherCostsProportion()), taxRadio);
|
|
|
+ insFeeOrderNew.setSyCostsProportion(syEntranceFee.getTotalProportion());
|
|
|
+ insFeeOrderNew.setSySuperviseCostsProportion(syEntranceFee.getSuperviseCosts());
|
|
|
+ insFeeOrderNew.setSySuperviseCostsPremiums(syEntranceFee.getSuperviseCostsPremiums());
|
|
|
+ insFeeOrderNew.setSyOtherCostsProportion(syEntranceFee.getOtherCostsProportion());
|
|
|
+ insFeeOrderNew.setSyOtherCostsPremiums(syEntranceFee.getOtherCostsPremiums());
|
|
|
+ insFeeOrderNew.setSyCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums().add(insFeeOrderNew.getSyOtherCostsPremiums()));
|
|
|
+
|
|
|
+ //非车入口信息
|
|
|
+ FeeOrderNewVo.EntranceFee noEntranceFee = feeRuleSchemeService.calcEntranceFee(insFeeOrderNew.getNoPremium(),
|
|
|
+ new BigDecimal(ptlAgreementProductCostsNew.getNoCarCostsProportion()),
|
|
|
+ new BigDecimal(ptlAgreementProductCostsNew.getNoCarOtherCostsProportion()), taxRadio);
|
|
|
+ insFeeOrderNew.setNoCostsProportion(noEntranceFee.getTotalProportion());
|
|
|
+ insFeeOrderNew.setNoSuperviseCostsProportion(noEntranceFee.getSuperviseCosts());
|
|
|
+ insFeeOrderNew.setNoSuperviseCostsPremiums(noEntranceFee.getSuperviseCostsPremiums());
|
|
|
+ insFeeOrderNew.setNoOtherCostsProportion(noEntranceFee.getOtherCostsProportion());
|
|
|
+ insFeeOrderNew.setNoOtherCostsPremiums(noEntranceFee.getOtherCostsPremiums());
|
|
|
+ insFeeOrderNew.setNoCostsPremiums(insFeeOrderNew.getNoSuperviseCostsPremiums().add(insFeeOrderNew.getNoOtherCostsPremiums()));
|
|
|
+ //endregion
|
|
|
+
|
|
|
+
|
|
|
+ //region 重新计算管理费比例和分销比例
|
|
|
+
|
|
|
+ List<EsmRetail> esmRetailList = esmRetailService.selectList(" where t.deptid=? and t.status = '1' ",
|
|
|
+ new Object[]{sysUser.getDeptId()});
|
|
|
+
|
|
|
+ Integer retailLevel = 0;
|
|
|
+
|
|
|
+ //默认分销比例设置
|
|
|
+ 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 = ptlAgreementProductCostsExport.getJqExportRadioLevel1()
|
|
|
+ .add(ptlAgreementProductCostsExport.getJqExportRadioLevel2())
|
|
|
+ .add(ptlAgreementProductCostsExport.getJqExportRadioLevel3())
|
|
|
+ .add(ptlAgreementProductCostsExport.getJqExportRadioLevel4())
|
|
|
+ .add(ptlAgreementProductCostsExport.getJqExportRadioLevel5());
|
|
|
+ //获取商业机构管理费总比例
|
|
|
+ BigDecimal syDeptProportion = ptlAgreementProductCostsExport.getSyExportRadioLevel1()
|
|
|
+ .add(ptlAgreementProductCostsExport.getSyExportRadioLevel2())
|
|
|
+ .add(ptlAgreementProductCostsExport.getSyExportRadioLevel3())
|
|
|
+ .add(ptlAgreementProductCostsExport.getSyExportRadioLevel4())
|
|
|
+ .add(ptlAgreementProductCostsExport.getSyExportRadioLevel5());
|
|
|
+ //获取非车机构管理费总比例
|
|
|
+ BigDecimal noDeptProportion = ptlAgreementProductCostsExport.getNoCarExportRadioLevel1()
|
|
|
+ .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel2())
|
|
|
+ .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel3())
|
|
|
+ .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel4())
|
|
|
+ .add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
|
|
|
+
|
|
|
+ //获取交强分销总比例
|
|
|
+ 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());
|
|
|
+
|
|
|
+ // 外部订单比例
|
|
|
+ BigDecimal enterProportion = sysSwitchConfigService.getEnterProportion(insOrders.getDeptid(), insOrders.getEntryStatus());
|
|
|
+
|
|
|
+ //重新计算比例 入口是否超出支付的比例
|
|
|
+ ReCalcuLateProportion jqReCalcuLateProportion = recalculateProportion(
|
|
|
+ new BigDecimal(ptlAgreementProductCostsNew.getJqCostsProportion()),
|
|
|
+ jqDeptProportion,
|
|
|
+ jqRetailProportion,
|
|
|
+ taxRadio,
|
|
|
+ retailLevel,
|
|
|
+ ptlAgreementProductCostsExport,
|
|
|
+ retailProportion,
|
|
|
+ "jq",
|
|
|
+ enterProportion
|
|
|
+ );
|
|
|
+
|
|
|
+ ReCalcuLateProportion syReCalcuLateProportion = recalculateProportion(
|
|
|
+ new BigDecimal(ptlAgreementProductCostsNew.getSyCostsProportion()),
|
|
|
+ syDeptProportion,
|
|
|
+ syRetailProportion,
|
|
|
+ taxRadio,
|
|
|
+ retailLevel,
|
|
|
+ ptlAgreementProductCostsExport,
|
|
|
+ retailProportion,
|
|
|
+ "sy",
|
|
|
+ enterProportion
|
|
|
+ );
|
|
|
+
|
|
|
+ ReCalcuLateProportion noReCalcuLateProportion = recalculateProportion(
|
|
|
+ new BigDecimal(ptlAgreementProductCostsNew.getNoCostsProportion()),
|
|
|
+ noDeptProportion,
|
|
|
+ noRetailProportion,
|
|
|
+ taxRadio,
|
|
|
+ retailLevel,
|
|
|
+ ptlAgreementProductCostsExport,
|
|
|
+ retailProportion,
|
|
|
+ "no",
|
|
|
+ enterProportion
|
|
|
+ );
|
|
|
+
|
|
|
+ retailProportion.setProportion(jqReCalcuLateProportion, syReCalcuLateProportion, noReCalcuLateProportion);
|
|
|
+ //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());
|
|
|
+ //用户分销人员id
|
|
|
+ List<EsmUserReferrer> parents = esmUserReferrerService.findParents(sysUser.getId());
|
|
|
+
|
|
|
+ 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());
|
|
|
+
|
|
|
+ insFeeOrderNew.setThirdDetailPremiums(retailFeeLevel3.getTotalRetailPremiums());
|
|
|
+ if (parents != null && parents.size() > 2) {
|
|
|
+ insFeeOrderNew.setThreeLevelUserId(parents.get(2).getId());
|
|
|
+ }
|
|
|
+ } 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 (parents != null && parents.size() > 1) {
|
|
|
+ insFeeOrderNew.setTwoLevelUserId(parents.get(1).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 (parents != null && !parents.isEmpty()) {
|
|
|
+ insFeeOrderNew.setFirstLevelUserId(parents.get(0).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());
|
|
|
+
|
|
|
+ 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());
|
|
|
+
|
|
|
+ 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());
|
|
|
+
|
|
|
+ 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());
|
|
|
+
|
|
|
+ insFeeOrderNew.assignDept(jqDeptManagerFee, syDeptManagerFee, noDeptManagerFee);
|
|
|
+
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 出口费用
|
|
|
+
|
|
|
+ //交强出口手续费比例
|
|
|
+ FeeOrderNewVo.ExportFee jqExportFee = feeRuleSchemeService.calcExportFee(
|
|
|
+ insFeeOrderNew.getJqPremium(),
|
|
|
+ new BigDecimal(ptlAgreementProductCostsNew.getJqCostsExportProportion()),
|
|
|
+ insFeeOrderNew.getJqCostsProportion(),
|
|
|
+ jqDeptRadio,
|
|
|
+ jqRetailRadio,
|
|
|
+ taxRadio,
|
|
|
+ jqReCalcuLateProportion.getProxyProportion()
|
|
|
+ );
|
|
|
+
|
|
|
+ //商业出口手续费比例
|
|
|
+ FeeOrderNewVo.ExportFee syExportFee = feeRuleSchemeService.calcExportFee(
|
|
|
+ insFeeOrderNew.getSyPremium(),
|
|
|
+ new BigDecimal(ptlAgreementProductCostsNew.getSyCostsExportProportion()),
|
|
|
+ insFeeOrderNew.getSyCostsProportion(),
|
|
|
+ syDeptRadio,
|
|
|
+ syRetailRadio,
|
|
|
+ taxRadio,
|
|
|
+ syReCalcuLateProportion.getProxyProportion()
|
|
|
+ );
|
|
|
+
|
|
|
+ //非车出口手续费比例
|
|
|
+ FeeOrderNewVo.ExportFee noExportFee = feeRuleSchemeService.calcExportFee(
|
|
|
+ insFeeOrderNew.getNoPremium(),
|
|
|
+ new BigDecimal(ptlAgreementProductCostsNew.getNoCostsExportProportion()),
|
|
|
+ insFeeOrderNew.getNoCostsProportion(),
|
|
|
+ noDeptRadio,
|
|
|
+ noRetailRadio,
|
|
|
+ taxRadio,
|
|
|
+ noReCalcuLateProportion.getProxyProportion()
|
|
|
+ );
|
|
|
+
|
|
|
+ //出口手续费用
|
|
|
+ insFeeOrderNew.setJqExportSuperviseCostsPremiums(twoPeople(jqExportFee.getSuperviseCostsPremiums()));
|
|
|
+ insFeeOrderNew.setSyExportSuperviseCostsPremiums(twoPeople(syExportFee.getSuperviseCostsPremiums()));
|
|
|
+ insFeeOrderNew.setNoExportSuperviseCostsPremiums(twoPeople(noExportFee.getSuperviseCostsPremiums()));
|
|
|
+
|
|
|
+ //出口其他费用比例
|
|
|
+ insFeeOrderNew.setJqExportOtherCostsProportion(twoPeople(jqExportFee.getOtherCostsProportion()));
|
|
|
+ insFeeOrderNew.setSyExportOtherCostsProportion(twoPeople(syExportFee.getOtherCostsProportion()));
|
|
|
+ insFeeOrderNew.setNoExportOtherCostsProportion(twoPeople(noExportFee.getOtherCostsProportion()));
|
|
|
+
|
|
|
+ //出口其他费用
|
|
|
+ insFeeOrderNew.setJqExportOtherCostsPremiums(twoPeople(jqExportFee.getOtherCostsPremiums()));
|
|
|
+ insFeeOrderNew.setSyExportOtherCostsPremiums(twoPeople(syExportFee.getOtherCostsPremiums()));
|
|
|
+ insFeeOrderNew.setNoExportOtherCostsPremiums(twoPeople(noExportFee.getOtherCostsPremiums()));
|
|
|
+
|
|
|
+ //设置出口手续费比例
|
|
|
+ insFeeOrderNew.setJqCostsExportProportion(twoPeople(jqExportFee.getSuperviseCosts()));
|
|
|
+ insFeeOrderNew.setSyCostsExportProportion(twoPeople(syExportFee.getSuperviseCosts()));
|
|
|
+ insFeeOrderNew.setNoCostsExportProportion(twoPeople(noExportFee.getSuperviseCosts()));
|
|
|
+
|
|
|
+ // 外部费用
|
|
|
+ insFeeOrderNew.setJqExternalProportion(jqExportFee.getExternalProportion());
|
|
|
+ insFeeOrderNew.setJqExternalPremiums(jqExportFee.getExternalPremiums());
|
|
|
+
|
|
|
+ insFeeOrderNew.setSyExternalProportion(syExportFee.getExternalProportion());
|
|
|
+ insFeeOrderNew.setSyExternalPremiums(syExportFee.getExternalPremiums());
|
|
|
+
|
|
|
+ insFeeOrderNew.setNoExternalProportion(noExportFee.getExternalProportion());
|
|
|
+ insFeeOrderNew.setNoExternalPremiums(noExportFee.getExternalPremiums());
|
|
|
+
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 计算利润差值
|
|
|
+ //入口 - 出口 - 机构管理费 1-5级 - 分销费 = 差值
|
|
|
+
|
|
|
+ //分销交强费用
|
|
|
+ //分开算 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 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 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 noFenXiao = noFirst.add(noSecond).add(noThird);
|
|
|
+
|
|
|
+ BigDecimal jqDifference = jqEntranceFee.getTotalAmount()
|
|
|
+ .subtract(jqExportFee.getExternalPremiums())
|
|
|
+ .subtract(
|
|
|
+ (jqExportFee.getSuperviseCostsPremiums().add(jqExportFee.getOtherCostsPremiums())))
|
|
|
+ .subtract(
|
|
|
+ (jqDeptManagerFee.getDeptPremiumsLevelOne().add(jqDeptManagerFee.getDeptPremiumsLevelTwo().add(jqDeptManagerFee.getDeptPremiumsLevelThree()).add(jqDeptManagerFee.getDeptPremiumsLevelFoure()).add(jqDeptManagerFee.getDeptPremiumsLevelFive())))
|
|
|
+ )
|
|
|
+ .subtract(jqFenXiao)
|
|
|
+ .setScale(5, BigDecimal.ROUND_HALF_DOWN);
|
|
|
+ insFeeOrderNew.setJqProfitMarginPremiums(jqDifference);
|
|
|
+
|
|
|
+ BigDecimal syDifference = syEntranceFee.getTotalAmount()
|
|
|
+ .subtract(syExportFee.getExternalPremiums())
|
|
|
+ .subtract(
|
|
|
+ (syExportFee.getSuperviseCostsPremiums().add(syExportFee.getOtherCostsPremiums())))
|
|
|
+ .subtract(
|
|
|
+ (syDeptManagerFee.getDeptPremiumsLevelOne().add(syDeptManagerFee.getDeptPremiumsLevelTwo().add(syDeptManagerFee.getDeptPremiumsLevelThree()).add(syDeptManagerFee.getDeptPremiumsLevelFoure()).add(syDeptManagerFee.getDeptPremiumsLevelFive())))
|
|
|
+ )
|
|
|
+ .subtract(syFenXiao)
|
|
|
+ .setScale(5, BigDecimal.ROUND_HALF_DOWN);
|
|
|
+ insFeeOrderNew.setSyProfitMarginPremiums(syDifference);
|
|
|
+
|
|
|
+ BigDecimal noDifference = noEntranceFee.getTotalAmount()
|
|
|
+ .subtract(noExportFee.getExternalPremiums())
|
|
|
+ .subtract(
|
|
|
+ (noExportFee.getSuperviseCostsPremiums().add(noExportFee.getOtherCostsPremiums())))
|
|
|
+ .subtract(
|
|
|
+ (noDeptManagerFee.getDeptPremiumsLevelOne().add(noDeptManagerFee.getDeptPremiumsLevelTwo().add(noDeptManagerFee.getDeptPremiumsLevelThree()).add(noDeptManagerFee.getDeptPremiumsLevelFoure()).add(noDeptManagerFee.getDeptPremiumsLevelFive())))
|
|
|
+ )
|
|
|
+ .subtract(noFenXiao)
|
|
|
+ .setScale(5, BigDecimal.ROUND_HALF_DOWN);
|
|
|
+ insFeeOrderNew.setNoProfitMarginPremiums(noDifference);
|
|
|
+
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 比例逆推是否等于0
|
|
|
+
|
|
|
+ if (!feeRuleSchemeService.calculateProportion(jqEntranceFee, jqDeptManagerFee, jqExportFee, jqRetailRadio, taxRadio, insFeeOrderNew.getJqPremium()))
|
|
|
+ throw new SystemException("交强比例异常");
|
|
|
+
|
|
|
+ if (!feeRuleSchemeService.calculateProportion(syEntranceFee, syDeptManagerFee, syExportFee, syRetailRadio, taxRadio, insFeeOrderNew.getSyPremium()))
|
|
|
+ throw new SystemException("商业比例异常");
|
|
|
+
|
|
|
+ if (!feeRuleSchemeService.calculateProportion(noEntranceFee, noDeptManagerFee, noExportFee, noRetailRadio, taxRadio, insFeeOrderNew.getNoPremium()))
|
|
|
+ throw new SystemException("非车比例异常");
|
|
|
+
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ insFeeOrderNewService.saveOrUpdate(insFeeOrderNew);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 判断是否包含非车险
|