|
|
@@ -166,7 +166,8 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
|
|
|
//获取协议信息
|
|
|
PtlAgreement ptlAgreement = ptlAgreementService.getById(insAreaCompany.getAgreementId());
|
|
|
BigDecimal taxRadio = new BigDecimal("1.00");
|
|
|
- if (ptlAgreement.getWithTax().equals("否")) {
|
|
|
+ //如果是外部订单则 不含税
|
|
|
+ if (ptlAgreement.getWithTax().equals("否") && ptlAgreement.getIsExternal() == 0) {
|
|
|
taxRadio = new BigDecimal("1.06");
|
|
|
}
|
|
|
//税比例 固定1.06
|
|
|
@@ -459,6 +460,303 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
|
|
|
insFeeOrderNewService.saveOrUpdate(insFeeOrderNew);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void calcCostsExternal(PtlAgreementProductCostsNew ptlAgreementProductCostsNew, InsAreaCompany insAreaCompany) {
|
|
|
+ //获取协议信息
|
|
|
+ PtlAgreement ptlAgreement = ptlAgreementService.getById(insAreaCompany.getAgreementId());
|
|
|
+ BigDecimal taxRadio = new BigDecimal("1.00");
|
|
|
+ //如果是外部订单则 不含税
|
|
|
+ if (ptlAgreement.getWithTax().equals("否") && ptlAgreement.getIsExternal() == 0) {
|
|
|
+ taxRadio = new BigDecimal("1.06");
|
|
|
+ }
|
|
|
+ //税比例 固定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 计算分销费用
|
|
|
+ InsOrders insOrders = insOrdersService.getById(insAreaCompany.getOrderno());
|
|
|
+ SysUser sysUser = sysUserService.findByUserId(insOrders.getUserid());
|
|
|
+
|
|
|
+ //获取分销比例
|
|
|
+ List<EsmRetail> esmRetailList = esmRetailService.selectList(" where t.deptid=? and t.status = '1' ",
|
|
|
+ new Object[]{sysUser.getDeptId()});
|
|
|
+
|
|
|
+ //分销总比例
|
|
|
+ BigDecimal retailRadio = new BigDecimal("0");
|
|
|
+ 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) {
|
|
|
+ BigDecimal sumPremium = insFeeOrderNew.getJqPremium().add(insFeeOrderNew.getSyPremium()).add(insFeeOrderNew.getNoPremium());
|
|
|
+ if (Integer.parseInt(esmRetail.getRetailtype()) >= 3) {
|
|
|
+ insFeeOrderNew.setThirdDetailProportion(new BigDecimal(esmRetail.getDisrate3()));
|
|
|
+ retailRadio = retailRadio.add(insFeeOrderNew.getThirdDetailProportion()).setScale(2, BigDecimal.ROUND_DOWN);
|
|
|
+ BigDecimal thirdDetailPremiums = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(), insFeeOrderNew.getSyPremium(), insFeeOrderNew.getNoPremium(), insFeeOrderNew.getThirdDetailProportion());
|
|
|
+ insFeeOrderNew.setThirdDetailPremiums(thirdDetailPremiums);
|
|
|
+ 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(new BigDecimal(esmRetail.getDisrate2()));
|
|
|
+ retailRadio = retailRadio.add(insFeeOrderNew.getSecondDetailProportion()).setScale(2, BigDecimal.ROUND_DOWN);
|
|
|
+ BigDecimal secondDetailPremiums = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(), insFeeOrderNew.getSyPremium(), insFeeOrderNew.getNoPremium(), insFeeOrderNew.getSecondDetailProportion());
|
|
|
+ insFeeOrderNew.setSecondDetailPremiums(secondDetailPremiums);
|
|
|
+ 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(new BigDecimal(esmRetail.getDisrate1()));
|
|
|
+ retailRadio = retailRadio.add(insFeeOrderNew.getFirstDetailProportion()).setScale(2, BigDecimal.ROUND_DOWN);
|
|
|
+ BigDecimal firstDetailPremiums = feeRuleSchemeService.calcRetail(insFeeOrderNew.getJqPremium(), insFeeOrderNew.getSyPremium(), insFeeOrderNew.getNoPremium(), insFeeOrderNew.getFirstDetailProportion());
|
|
|
+ insFeeOrderNew.setFirstDetailPremiums(firstDetailPremiums);
|
|
|
+ if (parents != null && parents.size() > 0) {
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 设置机构管理费
|
|
|
+
|
|
|
+ //交强机构管理费
|
|
|
+ BigDecimal jqDeptRadio =
|
|
|
+ ptlAgreementProductCostsExport.getJqExportRadioLevel1().add(ptlAgreementProductCostsExport.getJqExportRadioLevel2()).add(ptlAgreementProductCostsExport.getJqExportRadioLevel3()).add(ptlAgreementProductCostsExport.getJqExportRadioLevel4()).add(ptlAgreementProductCostsExport.getJqExportRadioLevel5());
|
|
|
+ FeeOrderNewVo.DeptManagerFee jqDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getJqPremium(),
|
|
|
+ ptlAgreementProductCostsExport.getJqExportRadioLevel1(), ptlAgreementProductCostsExport.getJqExportRadioLevel2(),
|
|
|
+ ptlAgreementProductCostsExport.getJqExportRadioLevel3(), ptlAgreementProductCostsExport.getJqExportRadioLevel4(),
|
|
|
+ ptlAgreementProductCostsExport.getJqExportRadioLevel5());
|
|
|
+ insFeeOrderNew.setJqDeptProportionLevel1(jqDeptManagerFee.getDeptProportionLevelOne());
|
|
|
+ insFeeOrderNew.setJqDeptPremiumsLevel1(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelOne()));
|
|
|
+ insFeeOrderNew.setJqDeptProportionLevel2(jqDeptManagerFee.getDeptProportionLevelTwo());
|
|
|
+ insFeeOrderNew.setJqDeptPremiumsLevel2(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelTwo()));
|
|
|
+ insFeeOrderNew.setJqDeptProportionLevel3(jqDeptManagerFee.getDeptProportionLevelThree());
|
|
|
+ insFeeOrderNew.setJqDeptPremiumsLevel3(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelThree()));
|
|
|
+ insFeeOrderNew.setJqDeptProportionLevel4(jqDeptManagerFee.getDeptProportionLevelFoure());
|
|
|
+ insFeeOrderNew.setJqDeptPremiumsLevel4(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelFoure()));
|
|
|
+ insFeeOrderNew.setJqDeptProportionLevel5(jqDeptManagerFee.getDeptProportionLevelFive());
|
|
|
+ insFeeOrderNew.setJqDeptPremiumsLevel5(twoPeople(jqDeptManagerFee.getDeptPremiumsLevelFive()));
|
|
|
+
|
|
|
+ BigDecimal syDeptRadio =
|
|
|
+ ptlAgreementProductCostsExport.getSyExportRadioLevel1().add(ptlAgreementProductCostsExport.getSyExportRadioLevel2()).add(ptlAgreementProductCostsExport.getSyExportRadioLevel3()).add(ptlAgreementProductCostsExport.getSyExportRadioLevel4()).add(ptlAgreementProductCostsExport.getSyExportRadioLevel5());
|
|
|
+ FeeOrderNewVo.DeptManagerFee syDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getSyPremium(),
|
|
|
+ ptlAgreementProductCostsExport.getSyExportRadioLevel1(), ptlAgreementProductCostsExport.getSyExportRadioLevel2(),
|
|
|
+ ptlAgreementProductCostsExport.getSyExportRadioLevel3(), ptlAgreementProductCostsExport.getSyExportRadioLevel4(),
|
|
|
+ ptlAgreementProductCostsExport.getSyExportRadioLevel5());
|
|
|
+ insFeeOrderNew.setSyDeptProportionLevel1(syDeptManagerFee.getDeptProportionLevelOne());
|
|
|
+ insFeeOrderNew.setSyDeptPremiumsLevel1(twoPeople(syDeptManagerFee.getDeptPremiumsLevelOne()));
|
|
|
+ insFeeOrderNew.setSyDeptProportionLevel2(syDeptManagerFee.getDeptProportionLevelTwo());
|
|
|
+ insFeeOrderNew.setSyDeptPremiumsLevel2(twoPeople(syDeptManagerFee.getDeptPremiumsLevelTwo()));
|
|
|
+ insFeeOrderNew.setSyDeptProportionLevel3(syDeptManagerFee.getDeptProportionLevelThree());
|
|
|
+ insFeeOrderNew.setSyDeptPremiumsLevel3(twoPeople(syDeptManagerFee.getDeptPremiumsLevelThree()));
|
|
|
+ insFeeOrderNew.setSyDeptProportionLevel4(syDeptManagerFee.getDeptProportionLevelFoure());
|
|
|
+ insFeeOrderNew.setSyDeptPremiumsLevel4(twoPeople(syDeptManagerFee.getDeptPremiumsLevelFoure()));
|
|
|
+ insFeeOrderNew.setSyDeptProportionLevel5(syDeptManagerFee.getDeptProportionLevelFive());
|
|
|
+ insFeeOrderNew.setSyDeptPremiumsLevel5(twoPeople(syDeptManagerFee.getDeptPremiumsLevelFive()));
|
|
|
+
|
|
|
+ BigDecimal noDeptRadio =
|
|
|
+ ptlAgreementProductCostsExport.getNoCarExportRadioLevel1().add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel2()).add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel3()).add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel4()).add(ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
|
|
|
+ FeeOrderNewVo.DeptManagerFee noDeptManagerFee = feeRuleSchemeService.calcDeptManagerFee(insFeeOrderNew.getNoPremium(),
|
|
|
+ ptlAgreementProductCostsExport.getNoCarExportRadioLevel1(), ptlAgreementProductCostsExport.getNoCarExportRadioLevel2(),
|
|
|
+ ptlAgreementProductCostsExport.getNoCarExportRadioLevel3(), ptlAgreementProductCostsExport.getNoCarExportRadioLevel4(),
|
|
|
+ ptlAgreementProductCostsExport.getNoCarExportRadioLevel5());
|
|
|
+ insFeeOrderNew.setNoDeptProportionLevel1(noDeptManagerFee.getDeptProportionLevelOne());
|
|
|
+ insFeeOrderNew.setNoDeptPremiumsLevel1(twoPeople(noDeptManagerFee.getDeptPremiumsLevelOne()));
|
|
|
+ insFeeOrderNew.setNoDeptProportionLevel2(noDeptManagerFee.getDeptProportionLevelTwo());
|
|
|
+ insFeeOrderNew.setNoDeptPremiumsLevel2(twoPeople(noDeptManagerFee.getDeptPremiumsLevelTwo()));
|
|
|
+ insFeeOrderNew.setNoDeptProportionLevel3(noDeptManagerFee.getDeptProportionLevelThree());
|
|
|
+ insFeeOrderNew.setNoDeptPremiumsLevel3(twoPeople(noDeptManagerFee.getDeptPremiumsLevelThree()));
|
|
|
+ insFeeOrderNew.setNoDeptProportionLevel4(noDeptManagerFee.getDeptProportionLevelFoure());
|
|
|
+ insFeeOrderNew.setNoDeptPremiumsLevel4(twoPeople(noDeptManagerFee.getDeptPremiumsLevelFoure()));
|
|
|
+ insFeeOrderNew.setNoDeptProportionLevel5(noDeptManagerFee.getDeptProportionLevelFive());
|
|
|
+ insFeeOrderNew.setNoDeptPremiumsLevel5(twoPeople(noDeptManagerFee.getDeptPremiumsLevelFive()));
|
|
|
+
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //region 出口费用
|
|
|
+
|
|
|
+ //交强出口手续费比例
|
|
|
+ FeeOrderNewVo.ExportFee jqExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getJqPremium(), new BigDecimal(ptlAgreementProductCostsNew.getJqCostsExportProportion()),
|
|
|
+ insFeeOrderNew.getJqCostsProportion(), jqDeptRadio, retailRadio, taxRadio);
|
|
|
+
|
|
|
+ //商业出口手续费比例
|
|
|
+ FeeOrderNewVo.ExportFee syExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getSyPremium(), new BigDecimal(ptlAgreementProductCostsNew.getSyCostsExportProportion()),
|
|
|
+ insFeeOrderNew.getSyCostsProportion(), syDeptRadio, retailRadio, taxRadio);
|
|
|
+
|
|
|
+ //非车出口手续费比例
|
|
|
+ FeeOrderNewVo.ExportFee noExportFee = feeRuleSchemeService.calcExportFee(insFeeOrderNew.getNoPremium(), new BigDecimal(ptlAgreementProductCostsNew.getNoCostsExportProportion()),
|
|
|
+ insFeeOrderNew.getNoCostsProportion(), noDeptRadio, retailRadio, taxRadio);
|
|
|
+
|
|
|
+ //出口手续费用
|
|
|
+ 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()));
|
|
|
+
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ //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 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 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 noFenXiao = noFirst.add(noSecond).add(noThird);
|
|
|
+
|
|
|
+
|
|
|
+ BigDecimal jqDifference = jqEntranceFee.getTotalAmount().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.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.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,retailRadio,taxRadio,insFeeOrderNew.getJqPremium()))
|
|
|
+ throw new SystemException("交强比例异常");
|
|
|
+
|
|
|
+ if(!feeRuleSchemeService.calculateProportion(syEntranceFee,syDeptManagerFee,syExportFee,retailRadio,taxRadio,insFeeOrderNew.getSyPremium()))
|
|
|
+ throw new SystemException("商业比例异常");
|
|
|
+
|
|
|
+ if(!feeRuleSchemeService.calculateProportion(noEntranceFee,noDeptManagerFee,noExportFee,retailRadio,taxRadio,insFeeOrderNew.getNoPremium()))
|
|
|
+ throw new SystemException("非车比例异常");
|
|
|
+
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ insFeeOrderNewService.saveOrUpdate(insFeeOrderNew);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 判断是否包含非车险
|
|
|
@@ -493,45 +791,6 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
|
|
|
List<RuleAttrMappingVo> ruleAttrMappingVoList = RuleAttrMappingVo.getRuleAttrMappingVoList(insAreaCompany, insOrders,
|
|
|
undwrtRulesAttrList, carJudgeRule);
|
|
|
|
|
|
-// List<AgreementProductCosts> filterAgreementProductCosts = new ArrayList<>();
|
|
|
-
|
|
|
-// boolean isNoCar = false;
|
|
|
-// //查找是否有强制非车因子
|
|
|
-// for(int i=0;i<agreementProductCosts.size();i++) {
|
|
|
-// PtlAgreementProductCostsAttrLink ptlAgreementProductCostsAttrLink =
|
|
|
-// agreementProductCosts.get(i).getCostsAttrLinks().stream().filter(x -> x.getAttrCode().equals("IsNonMotorInsurance")
|
|
|
-// ).findFirst().orElse(null);
|
|
|
-//
|
|
|
-// if(!Objects.isNull(ptlAgreementProductCostsAttrLink)){
|
|
|
-// if(ptlAgreementProductCostsAttrLink.getMin().equals("1")){
|
|
|
-// //只走强制非车的费用因子
|
|
|
-// AgreementProductCosts productCosts = agreementProductCosts.get(i);
|
|
|
-// filterAgreementProductCosts.add(productCosts);
|
|
|
-// isNoCar = true;
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if(filterAgreementProductCosts.isEmpty()){
|
|
|
-// filterAgreementProductCosts = agreementProductCosts;
|
|
|
-// }
|
|
|
- //是否强制走非车
|
|
|
-// if(isNoCar) {
|
|
|
-// for(int i=0;i<filterAgreementProductCosts.size();i++) {
|
|
|
-// if (judgementsIsNoCar(filterAgreementProductCosts.get(i).getCostsAttrLinks(), undwrtRulesAttrList,
|
|
|
-// ruleAttrMappingVoList)) {
|
|
|
-// return filterAgreementProductCosts.get(i).getId();
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }else{
|
|
|
-// for (int i = 0; i < filterAgreementProductCosts.size(); i++) {
|
|
|
-// //判断是否匹配
|
|
|
-// if (judgements(filterAgreementProductCosts.get(i).getCostsAttrLinks(), undwrtRulesAttrList, ruleAttrMappingVoList)) {
|
|
|
-// //返回 费用id 如果需要匹配非车的情况 将返回值返回list 后赛选
|
|
|
-// return filterAgreementProductCosts.get(i).getId();
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
for (int i = 0; i < agreementProductCosts.size(); i++) {
|
|
|
//判断是否匹配
|
|
|
log.debug("费用因子匹配开始:" + agreementProductCosts.get(i).getId());
|
|
|
@@ -909,20 +1168,11 @@ public class FeeRuleSchemeServiceNewImpl implements FeeRuleSchemeNewService {
|
|
|
//将值进行分割
|
|
|
String[] split = ptlAgreementProductCostsAttrLink.getMin().split(",");
|
|
|
AtomicBoolean returnBool = new AtomicBoolean(false);
|
|
|
- if(ptlAgreementProductCostsAttrLink.getAttrCode().equals("NatureOfUse")){
|
|
|
- Arrays.stream(split).forEach(x -> {
|
|
|
- if (value.equals(x)) {
|
|
|
- returnBool.set(true);
|
|
|
- }
|
|
|
- });
|
|
|
- }else{
|
|
|
- Arrays.stream(split).forEach(x -> {
|
|
|
- if (value.contains(x)) {
|
|
|
- returnBool.set(true);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
+ Arrays.stream(split).forEach(x -> {
|
|
|
+ if (value.equals(x)) {
|
|
|
+ returnBool.set(true);
|
|
|
+ }
|
|
|
+ });
|
|
|
return returnBool.get();
|
|
|
}
|
|
|
|