|
|
@@ -315,7 +315,7 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
|
|
|
/**
|
|
|
* 单个险种费用计算
|
|
|
*/
|
|
|
- private static void calcInsuranceType(InsFeeOrders o, BigDecimal premium, PtlAgreementCostTypeVo ct, BigDecimal commissionRatio, BigDecimal followRatio, BigDecimal taxFactor, String type) {
|
|
|
+ private static void calcInsuranceType(InsFeeOrders o, BigDecimal premium, PtlAgreementCostTypeVo ct, BigDecimal commissionRatio, BigDecimal followRatio, BigDecimal taxFactor,BigDecimal KeepPointRatio, String type) {
|
|
|
if (ct == null || premium == null) {
|
|
|
if ("jq".equals(type)) {
|
|
|
o.setJqReceivablePremium(BigDecimal.ZERO);
|
|
|
@@ -340,8 +340,6 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
|
|
|
BigDecimal receivable = taxable.multiply(commissionRatio.add(followRatio)).setScale(5, RoundingMode.HALF_EVEN);
|
|
|
receivable = receivable.setScale(5, RoundingMode.HALF_EVEN); // 与旧代码保持一致:二次setScale
|
|
|
BigDecimal follow = receivable.subtract(commission);
|
|
|
- BigDecimal keepRate = BigDecimalUtil.subtract(BigDecimalUtil.add(BigDecimalUtil.divide(inlet, taxFactor), addThrow), export).setScale(5, RoundingMode.HALF_EVEN);
|
|
|
- BigDecimal keepAmt = BigDecimalUtil.subtract(BigDecimalUtil.add(receivable, addAmt), payable).setScale(5, RoundingMode.HALF_EVEN);
|
|
|
|
|
|
switch (type) {
|
|
|
case "jq":
|
|
|
@@ -350,8 +348,8 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
|
|
|
o.setJqCommissionPremium(commission);
|
|
|
o.setJqFollowPremium(follow);
|
|
|
o.setJqAdditionalPremium(addAmt);
|
|
|
- o.setJqKeepPointRatio(keepRate);
|
|
|
- o.setJqKeepPointPremium(keepAmt);
|
|
|
+ o.setJqKeepPointRatio(KeepPointRatio);
|
|
|
+ o.setJqKeepPointPremium(premium.multiply(KeepPointRatio).setScale(5, RoundingMode.HALF_EVEN).divide(new BigDecimal(100), 5, RoundingMode.HALF_EVEN));
|
|
|
break;
|
|
|
case "sy":
|
|
|
o.setSyReceivablePremium(receivable);
|
|
|
@@ -359,8 +357,8 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
|
|
|
o.setSyCommissionPremium(commission);
|
|
|
o.setSyFollowPremium(follow);
|
|
|
o.setSyAdditionalPremium(addAmt);
|
|
|
- o.setSyKeepPointRatio(keepRate);
|
|
|
- o.setSyKeepPointPremium(keepAmt);
|
|
|
+ o.setSyKeepPointRatio(KeepPointRatio);
|
|
|
+ o.setSyKeepPointPremium(premium.multiply(KeepPointRatio).setScale(5, RoundingMode.HALF_EVEN).divide(new BigDecimal(100), 5, RoundingMode.HALF_EVEN));
|
|
|
break;
|
|
|
case "jy":
|
|
|
o.setJyReceivablePremium(receivable);
|
|
|
@@ -368,8 +366,8 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
|
|
|
o.setJyCommissionPremium(commission);
|
|
|
o.setJyFollowPremium(follow);
|
|
|
o.setJyAdditionalPremium(addAmt);
|
|
|
- o.setJyKeepPointRatio(keepRate);
|
|
|
- o.setJyKeepPointPremium(keepAmt);
|
|
|
+ o.setJyKeepPointRatio(KeepPointRatio);
|
|
|
+ o.setJyKeepPointPremium(premium.multiply(KeepPointRatio).setScale(5, RoundingMode.HALF_EVEN).divide(new BigDecimal(100), 5, RoundingMode.HALF_EVEN));
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
@@ -2126,9 +2124,9 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
|
|
|
BigDecimal syExport = this.calExportByIsRecordByLeader(request.isIsrecordByLeader(), nvl(request.getSyExport()));
|
|
|
BigDecimal jyExport = this.calExportByIsRecordByLeader(request.isIsrecordByLeader(), nvl(request.getJyExport()));
|
|
|
|
|
|
- BigDecimal jqEKP = nvl(request.getJqExportKeepPointRatio());
|
|
|
- BigDecimal syEKP = nvl(request.getSyExportKeepPointRatio());
|
|
|
- BigDecimal jyEKP = nvl(request.getJyExportKeepPointRatio());
|
|
|
+ BigDecimal jqEKP = nvl(request.getJqKeepPointRatio());
|
|
|
+ BigDecimal syEKP = nvl(request.getSyKeepPointRatio());
|
|
|
+ BigDecimal jyEKP = nvl(request.getJyKeepPointRatio());
|
|
|
|
|
|
// 1. 查询协议(同时获取入口手续费比例 + 税率因子,一次查询)
|
|
|
PtlAgreement ptlAgreement = orgClient.getByAgreementId(agreementId);
|
|
|
@@ -2186,9 +2184,9 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
|
|
|
feeOrders.setJyFollowRatio(jyFollow);
|
|
|
|
|
|
// 6. 各险种费用计算(应收/应付/手续费/跟单费/加投费/留点)
|
|
|
- calcInsuranceType(feeOrders, jqPremium, jqCostType, jqRatio, jqFollow, taxFactor, "jq");
|
|
|
- calcInsuranceType(feeOrders, syPremium, syCostType, syRatio, syFollow, taxFactor, "sy");
|
|
|
- calcInsuranceType(feeOrders, jyPremium, jyCostType, jyRatio, jyFollow, taxFactor, "jy");
|
|
|
+ calcInsuranceType(feeOrders, jqPremium, jqCostType, jqRatio, jqFollow, taxFactor,request.getJqKeepPointRatio(), "jq");
|
|
|
+ calcInsuranceType(feeOrders, syPremium, syCostType, syRatio, syFollow, taxFactor,request.getSyKeepPointRatio(),"sy");
|
|
|
+ calcInsuranceType(feeOrders, jyPremium, jyCostType, jyRatio, jyFollow, taxFactor,request.getJyKeepPointRatio(), "jy");
|
|
|
|
|
|
// 7. 计算分销费用(返回分销精度差值)—— 须在 saveRatio 之前,因为 export 需要减分销比例
|
|
|
BigDecimal distributionDiff = calcDistributionFee(sumPremium, feeOrders, request.getMobile());
|
|
|
@@ -2207,11 +2205,11 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
|
|
|
feeOrders.setJqAdditionalRatio(div100(jqAddThrow));
|
|
|
feeOrders.setSyAdditionalRatio(div100(syAddThrow));
|
|
|
feeOrders.setJyAdditionalRatio(div100(jyAddThrow));
|
|
|
- feeOrders.setJqKeepPointRatio(nvl(feeOrders.getJqKeepPointRatio()));
|
|
|
- feeOrders.setSyKeepPointRatio(nvl(feeOrders.getSyKeepPointRatio()));
|
|
|
- feeOrders.setJyKeepPointRatio(nvl(feeOrders.getJyKeepPointRatio()));
|
|
|
+ feeOrders.setJqKeepPointRatio(div100(nvl(feeOrders.getJqKeepPointRatio())));
|
|
|
+ feeOrders.setSyKeepPointRatio(div100(nvl(feeOrders.getSyKeepPointRatio())));
|
|
|
+ feeOrders.setJyKeepPointRatio(div100(nvl(feeOrders.getJyKeepPointRatio())));
|
|
|
|
|
|
- // 出口比例 = 入口比例 +加投比例 - 分销比例 -出口留点比例
|
|
|
+ // 出口比例 = 入口比例 +加投比例 - 分销比例 -留点比例
|
|
|
BigDecimal firstDist = nvl(feeOrders.getFirstDistributionRatio());
|
|
|
BigDecimal secondDist = nvl(feeOrders.getSecondDistributionRatio());
|
|
|
BigDecimal thirdDist = nvl(feeOrders.getThirdDistributionRatio());
|
|
|
@@ -2219,9 +2217,9 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
|
|
|
feeOrders.setSyExportRatio(syInlet.compareTo(BigDecimal.ZERO) > 0 ? div100(syInlet).add(div100(request.getSyAddThrow())).subtract(div100(firstDist)).subtract(div100(secondDist)).subtract(div100(thirdDist)).subtract(div100(syEKP)) : BigDecimal.ZERO);
|
|
|
feeOrders.setJyExportRatio(jyInlet.compareTo(BigDecimal.ZERO) > 0 ? div100(jyInlet).add(div100(request.getJyAddThrow())).subtract(div100(firstDist)).subtract(div100(secondDist)).subtract(div100(thirdDist)).subtract(div100(jyEKP)) : BigDecimal.ZERO);
|
|
|
|
|
|
- feeOrders.setJqExportKeepPointRatio(div100(jqEKP));
|
|
|
- feeOrders.setSyExportKeepPointRatio(div100(syEKP));
|
|
|
- feeOrders.setJyExportKeepPointRatio(div100(jyEKP));
|
|
|
+ feeOrders.setJqExportKeepPointRatio(div100(request.getJqExportKeepPointRatio()!=null? request.getJqExportKeepPointRatio() : new BigDecimal(0)));
|
|
|
+ feeOrders.setSyExportKeepPointRatio(div100(request.getSyExportKeepPointRatio()!=null? request.getSyExportKeepPointRatio() : new BigDecimal(0)));
|
|
|
+ feeOrders.setJyExportKeepPointRatio(div100(request.getJyExportKeepPointRatio()!=null? request.getJyExportKeepPointRatio() : new BigDecimal(0)));
|
|
|
|
|
|
// 7.2 保费为0 → 出口相关字段归零(对齐旧 saveRatio)
|
|
|
if (jqPremium.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
@@ -2260,13 +2258,13 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
|
|
|
BigDecimal jyEOrigin = feeOrders.getJyExportRatio().multiply(jyPremium);
|
|
|
BigDecimal jyE = jyEOrigin.setScale(2, RoundingMode.DOWN);
|
|
|
feeOrders.setJyExportPremium(jyE);
|
|
|
-
|
|
|
- BigDecimal jqK = feeOrders.getJqExportKeepPointRatio().multiply(jqPremium);
|
|
|
- feeOrders.setJqExportKeepPointPremium(jqK);
|
|
|
- BigDecimal syK = feeOrders.getSyExportKeepPointRatio().multiply(syPremium);
|
|
|
- feeOrders.setSyExportKeepPointPremium(syK);
|
|
|
- BigDecimal jyK = feeOrders.getJyExportKeepPointRatio().multiply(jyPremium);
|
|
|
- feeOrders.setJyExportKeepPointPremium(jyK);
|
|
|
+ // 出口留点费用
|
|
|
+ BigDecimal jqEK = feeOrders.getJqExportKeepPointRatio().multiply(jqPremium);
|
|
|
+ feeOrders.setJqExportKeepPointPremium(jqEK);
|
|
|
+ BigDecimal syEK = feeOrders.getSyExportKeepPointRatio().multiply(syPremium);
|
|
|
+ feeOrders.setSyExportKeepPointPremium(syEK);
|
|
|
+ BigDecimal jyEK = feeOrders.getJyExportKeepPointRatio().multiply(jyPremium);
|
|
|
+ feeOrders.setJyExportKeepPointPremium(jyEK);
|
|
|
|
|
|
// 截断差值 = 出口精度损失 + 分销差值
|
|
|
List<BigDecimal> diffs = new ArrayList<>();
|
|
|
@@ -2276,9 +2274,9 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
|
|
|
diffs.add(distributionDiff);
|
|
|
feeOrders.setTotalExportDiffAmount(BigDecimalUtil.add(diffs));
|
|
|
|
|
|
- feeOrders.setAvailableAmount(jqE.add(syE).add(jyE).subtract(jqK).subtract(syK).subtract(jyK).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ feeOrders.setAvailableAmount(jqE.add(syE).add(jyE).subtract(jyEK).subtract(syEK).subtract(jyEK).setScale(2, RoundingMode.HALF_UP));
|
|
|
feeOrders.setTotalExportPremium(jqE.add(syE).add(jyE));
|
|
|
- feeOrders.setTotalExportKeepPointPremium(jqK.add(syK).add(jyK));
|
|
|
+ feeOrders.setTotalExportKeepPointPremium(jyEK.add(syEK).add(jyEK));
|
|
|
|
|
|
// 10. 构建比例VO
|
|
|
PtlAgreementCostRatioVo costRatio = new PtlAgreementCostRatioVo(feeOrders);
|