|
|
@@ -1713,6 +1713,11 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
|
|
|
*/
|
|
|
@Override
|
|
|
public HttpResult<InsFeeCalculateResponse> cvalculateFees(InsFeeCalculateRequest request) {
|
|
|
+
|
|
|
+ if(request.getMobile().isEmpty()){
|
|
|
+ return HttpResult.error("请选择业务员!");
|
|
|
+ }
|
|
|
+
|
|
|
String agreementId = request.getAgreementId();
|
|
|
// 保费 & 所有比例字段 null → 0
|
|
|
BigDecimal jqPremium = nvl(request.getJqPremium());
|
|
|
@@ -1754,6 +1759,23 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
|
|
|
syRatio = capRatio(syRatio, syCostType);
|
|
|
jyRatio = capRatio(jyRatio, jyCostType);
|
|
|
|
|
|
+ // 3.1 保费为0 → 入口手续费比例和入口比例归零
|
|
|
+ if (jqPremium.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ jqRatio = BigDecimal.ZERO;
|
|
|
+ jqInlet = BigDecimal.ZERO;
|
|
|
+ jqCostType.setInlet(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ if (syPremium.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ syRatio = BigDecimal.ZERO;
|
|
|
+ syInlet = BigDecimal.ZERO;
|
|
|
+ syCostType.setInlet(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ if (jyPremium.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ jyRatio = BigDecimal.ZERO;
|
|
|
+ jyInlet = BigDecimal.ZERO;
|
|
|
+ jyCostType.setInlet(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+
|
|
|
// 4. 跟单费比例 = 入口比例 - 手续费比例
|
|
|
BigDecimal jqFollow = calcFollowRatio(jqCostType, jqRatio);
|
|
|
BigDecimal syFollow = calcFollowRatio(syCostType, syRatio);
|
|
|
@@ -1775,11 +1797,14 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
|
|
|
calcInsuranceType(feeOrders, syPremium, syCostType, syRatio, syFollow, taxFactor, "sy");
|
|
|
calcInsuranceType(feeOrders, jyPremium, jyCostType, jyRatio, jyFollow, taxFactor, "jy");
|
|
|
|
|
|
- // 7. 保存各比例(小数)到 feeOrders
|
|
|
- // 保存各比例到 feeOrders
|
|
|
- feeOrders.setJqCommissionRatio(div100(ptlAgreement.getJqEntranceFeeRatio()));
|
|
|
- feeOrders.setSyCommissionRatio(div100(ptlAgreement.getSyEntranceFeeRatio()));
|
|
|
- feeOrders.setJyCommissionRatio(div100(ptlAgreement.getJyEntranceFeeRatio()));
|
|
|
+ // 7. 计算分销费用(返回分销精度差值)—— 须在 saveRatio 之前,因为 export 需要减分销比例
|
|
|
+ BigDecimal distributionDiff = calcDistributionFee(sumPremium, feeOrders, request.getMobile());
|
|
|
+
|
|
|
+ // 7.1 保存各比例到 feeOrders
|
|
|
+
|
|
|
+ feeOrders.setJqCommissionRatio(div100(jqRatio));
|
|
|
+ feeOrders.setSyCommissionRatio(div100(syRatio));
|
|
|
+ feeOrders.setJyCommissionRatio(div100(jyRatio));
|
|
|
feeOrders.setJqInletRatio(div100(jqInlet));
|
|
|
feeOrders.setSyInletRatio(div100(syInlet));
|
|
|
feeOrders.setJyInletRatio(div100(jyInlet));
|
|
|
@@ -1792,15 +1817,41 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
|
|
|
feeOrders.setJqKeepPointRatio(nvl(feeOrders.getJqKeepPointRatio()));
|
|
|
feeOrders.setSyKeepPointRatio(nvl(feeOrders.getSyKeepPointRatio()));
|
|
|
feeOrders.setJyKeepPointRatio(nvl(feeOrders.getJyKeepPointRatio()));
|
|
|
- feeOrders.setJqExportRatio(div100(jqExport));
|
|
|
- feeOrders.setSyExportRatio(div100(syExport));
|
|
|
- feeOrders.setJyExportRatio(div100(jyExport));
|
|
|
+
|
|
|
+ // —— 出口比例 = 出口比例 - 分销比例(对齐旧 saveRatio)
|
|
|
+ BigDecimal firstDist = nvl(feeOrders.getFirstDistributionRatio());
|
|
|
+ BigDecimal secondDist = nvl(feeOrders.getSecondDistributionRatio());
|
|
|
+ BigDecimal thirdDist = nvl(feeOrders.getThirdDistributionRatio());
|
|
|
+ feeOrders.setJqExportRatio(jqExport.compareTo(BigDecimal.ZERO) > 0
|
|
|
+ ? div100(jqExport).subtract(div100(firstDist)).subtract(div100(secondDist)).subtract(div100(thirdDist))
|
|
|
+ : BigDecimal.ZERO);
|
|
|
+ feeOrders.setSyExportRatio(syExport.compareTo(BigDecimal.ZERO) > 0
|
|
|
+ ? div100(syExport).subtract(div100(firstDist)).subtract(div100(secondDist)).subtract(div100(thirdDist))
|
|
|
+ : BigDecimal.ZERO);
|
|
|
+ feeOrders.setJyExportRatio(jyExport.compareTo(BigDecimal.ZERO) > 0
|
|
|
+ ? div100(jyExport).subtract(div100(firstDist)).subtract(div100(secondDist)).subtract(div100(thirdDist))
|
|
|
+ : BigDecimal.ZERO);
|
|
|
+
|
|
|
feeOrders.setJqExportKeepPointRatio(div100(jqEKP));
|
|
|
feeOrders.setSyExportKeepPointRatio(div100(syEKP));
|
|
|
feeOrders.setJyExportKeepPointRatio(div100(jyEKP));
|
|
|
|
|
|
- // 计算分销费用(返回分销精度差值)
|
|
|
- BigDecimal distributionDiff = calcDistributionFee(sumPremium, feeOrders,request.getMobile());
|
|
|
+ // 7.2 保费为0 → 出口相关字段归零(对齐旧 saveRatio)
|
|
|
+ if (jqPremium.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ feeOrders.setJqExportRatio(BigDecimal.ZERO); feeOrders.setJqExportPremium(BigDecimal.ZERO);
|
|
|
+ feeOrders.setJqExportKeepPointRatio(BigDecimal.ZERO); feeOrders.setJqExportKeepPointPremium(BigDecimal.ZERO);
|
|
|
+ feeOrders.setJqKeepPointRatio(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ if (syPremium.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ feeOrders.setSyExportRatio(BigDecimal.ZERO); feeOrders.setSyExportPremium(BigDecimal.ZERO);
|
|
|
+ feeOrders.setSyExportKeepPointRatio(BigDecimal.ZERO); feeOrders.setSyExportKeepPointPremium(BigDecimal.ZERO);
|
|
|
+ feeOrders.setSyKeepPointRatio(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ if (jyPremium.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ feeOrders.setJyExportRatio(BigDecimal.ZERO); feeOrders.setJyExportPremium(BigDecimal.ZERO);
|
|
|
+ feeOrders.setJyExportKeepPointRatio(BigDecimal.ZERO); feeOrders.setJyExportKeepPointPremium(BigDecimal.ZERO);
|
|
|
+ feeOrders.setJyKeepPointRatio(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
|
|
|
// 8. 总应收/总应付
|
|
|
feeOrders.setTotalReceivablePremium(feeOrders.getJqReceivablePremium()
|