|
|
@@ -1,6 +1,7 @@
|
|
|
package com.jzg.quotation.summary.aop.aspect;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.jzg.commons.constants.quote.enums.quote.EnergyTypeCode;
|
|
|
@@ -12,10 +13,10 @@ import com.jzg.commons.entity.agreement.dispatch.vo.PtlAgreementDispatchVo;
|
|
|
import com.jzg.commons.entity.dto.CostAgreementParam;
|
|
|
import com.jzg.commons.entity.orders.po.*;
|
|
|
import com.jzg.commons.entity.po.*;
|
|
|
-import com.jzg.commons.entity.quote.vo.KindInfoVo;
|
|
|
import com.jzg.commons.entity.quote.vo.QuoteVo;
|
|
|
import com.jzg.commons.entity.quote.vo.aggregated.QuoteResultsVo;
|
|
|
import com.jzg.commons.entity.vo.*;
|
|
|
+import com.jzg.commons.exception.ServiceException;
|
|
|
import com.jzg.commons.util.BigDecimalUtil;
|
|
|
import com.jzg.commons.util.StringUtils;
|
|
|
import com.jzg.quotation.commons.client.OrgClient;
|
|
|
@@ -74,6 +75,7 @@ public class QuoteVerificationAspect {
|
|
|
|
|
|
@AfterReturning(pointcut = "@annotation(com.jzg.quotation.summary.aop.QuoteVerification)", returning = "result")
|
|
|
public void doAfter(HttpResult<QuoteResultsVo> result) {
|
|
|
+ String loginUserId = baseController.getUserId();
|
|
|
if (result.getCode() == 200) {
|
|
|
StringBuilder logs = new StringBuilder();
|
|
|
InsOrders insOrders = insOrdersService.getById(result.getData().getOrdersNo());
|
|
|
@@ -132,7 +134,10 @@ public class QuoteVerificationAspect {
|
|
|
insOrdersCarUserInfos, kindList, insOrdersCosts, insOrdersAccidentalDriving, insOrders);
|
|
|
if (costId != null) {
|
|
|
// 根据匹配到的协议、费用 开始计算入口费用
|
|
|
- InsFeeOrders insFeeOrders = calcCosts(agreementInfoVo,costId, insOrders,insOrdersCosts);
|
|
|
+ boolean isrecordByLeader = false;
|
|
|
+ String reqlQuoteUserId = this.queryReqlQuoteUserIdByUserName(insOrders.getRealQuoteUserId());
|
|
|
+ isrecordByLeader = !Objects.equals(loginUserId, reqlQuoteUserId);
|
|
|
+ InsFeeOrders insFeeOrders = calcCosts(agreementInfoVo,costId, insOrders,insOrdersCosts,isrecordByLeader);
|
|
|
log.info("费用因子校验通过,子订单id:" + insOrders.getId() + ",费用id:" + costId);
|
|
|
result.getData().setFeeOrders(insFeeOrders);
|
|
|
return;
|
|
|
@@ -144,6 +149,23 @@ public class QuoteVerificationAspect {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据用户的登录名查询用户的useId
|
|
|
+ *
|
|
|
+ * @author lipf
|
|
|
+ * @date 2026/7/10 14:58
|
|
|
+ */
|
|
|
+ private String queryReqlQuoteUserIdByUserName(String userName) {
|
|
|
+ if(StrUtil.isEmpty(userName)){
|
|
|
+ return StrUtil.EMPTY;
|
|
|
+ }
|
|
|
+ HttpResult<SysUser> sysUserHttpResult = orgClient.querySysUserByUserName(userName);
|
|
|
+ if(sysUserHttpResult.isSuccess()){
|
|
|
+ return sysUserHttpResult.getData().getId();
|
|
|
+ }
|
|
|
+ throw new ServiceException("调用异常,请查看orgnization服务是否启动");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 最开始的过滤 过滤 能源 车辆类型
|
|
|
@@ -245,7 +267,8 @@ public class QuoteVerificationAspect {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public InsFeeOrders calcCosts(AgreementInfoVo agreementInfoVo, String costId, InsOrders insOrders, InsOrdersCosts insOrdersCosts) {
|
|
|
+
|
|
|
+ public InsFeeOrders calcCosts(AgreementInfoVo agreementInfoVo, String costId, InsOrders insOrders, InsOrdersCosts insOrdersCosts,boolean isrecordByLeader) {
|
|
|
InsFeeOrders insFeeOrders = new InsFeeOrders();
|
|
|
insFeeOrders.setOrderNo(insOrders.getId());
|
|
|
insFeeOrders.setAgreementId(insOrders.getAgreementId());
|
|
|
@@ -340,27 +363,27 @@ public class QuoteVerificationAspect {
|
|
|
insFeeOrders,
|
|
|
InsFeeOrders::setJqReceivablePremium, InsFeeOrders::setJqPayablePremium,
|
|
|
InsFeeOrders::setJqCommissionPremium, InsFeeOrders::setJqFollowPremium, InsFeeOrders::setJqAdditionalPremium,
|
|
|
- InsFeeOrders::setJqKeepPointRatio,InsFeeOrders::setJqKeepPointPremium);
|
|
|
+ InsFeeOrders::setJqKeepPointRatio,InsFeeOrders::setJqKeepPointPremium, isrecordByLeader);
|
|
|
|
|
|
processInsuranceType(
|
|
|
insOrdersCosts.getSyPremium(), syCostType, syEntranceFeeRatio, syFollowRatio, taxFactor,
|
|
|
insFeeOrders,
|
|
|
InsFeeOrders::setSyReceivablePremium, InsFeeOrders::setSyPayablePremium,
|
|
|
InsFeeOrders::setSyCommissionPremium, InsFeeOrders::setSyFollowPremium, InsFeeOrders::setSyAdditionalPremium,
|
|
|
- InsFeeOrders::setSyKeepPointRatio,InsFeeOrders::setSyKeepPointPremium);
|
|
|
+ InsFeeOrders::setSyKeepPointRatio,InsFeeOrders::setSyKeepPointPremium, isrecordByLeader);
|
|
|
|
|
|
processInsuranceType(
|
|
|
insOrdersCosts.getJyPremium(), jyCostType, jyEntranceFeeRatio, jyFollowRatio, taxFactor,
|
|
|
insFeeOrders,
|
|
|
InsFeeOrders::setJyReceivablePremium, InsFeeOrders::setJyPayablePremium,
|
|
|
InsFeeOrders::setJyCommissionPremium, InsFeeOrders::setJyFollowPremium, InsFeeOrders::setJyAdditionalPremium,
|
|
|
- InsFeeOrders::setJyKeepPointRatio,InsFeeOrders::setJyKeepPointPremium);
|
|
|
+ InsFeeOrders::setJyKeepPointRatio,InsFeeOrders::setJyKeepPointPremium, isrecordByLeader);
|
|
|
|
|
|
// 7. 计算分销费用 返回分销的差值
|
|
|
BigDecimal distributionDiff = calculateDistributionFee(insOrdersCosts,insFeeOrders, insOrders);
|
|
|
|
|
|
// 8. 计算总应收、总应付、保存费用比例 入库
|
|
|
- saveRatio(insFeeOrders, agreementInfoVo, jqCostType, syCostType, jyCostType);
|
|
|
+ saveRatio(insFeeOrders, agreementInfoVo, jqCostType, syCostType, jyCostType, isrecordByLeader);
|
|
|
calculateTotalPremium(insFeeOrders, distributionDiff);
|
|
|
|
|
|
|
|
|
@@ -406,19 +429,20 @@ public class QuoteVerificationAspect {
|
|
|
/**
|
|
|
* 处理单个险种的费用计算(核心复用方法)
|
|
|
*
|
|
|
- * @param premium 险种保费
|
|
|
- * @param costType 险种费用类型配置
|
|
|
- * @param commissionRatio 手续费比例
|
|
|
- * @param followRatio 跟单费比例
|
|
|
- * @param taxFactor 税率因子(平台协议为1,私有协议为1/1.06)
|
|
|
- * @param insFeeOrders 费用订单对象
|
|
|
- * @param setReceivable 应收金额setter
|
|
|
- * @param setPayable 应付金额setter
|
|
|
- * @param setCommission 手续费setter
|
|
|
- * @param setFollow 跟单费setter
|
|
|
- * @param setAdditional 加投费setter
|
|
|
- * @param keepPointRate 留点比例
|
|
|
+ * @param premium 险种保费
|
|
|
+ * @param costType 险种费用类型配置
|
|
|
+ * @param commissionRatio 手续费比例
|
|
|
+ * @param followRatio 跟单费比例
|
|
|
+ * @param taxFactor 税率因子(平台协议为1,私有协议为1/1.06)
|
|
|
+ * @param insFeeOrders 费用订单对象
|
|
|
+ * @param setReceivable 应收金额setter
|
|
|
+ * @param setPayable 应付金额setter
|
|
|
+ * @param setCommission 手续费setter
|
|
|
+ * @param setFollow 跟单费setter
|
|
|
+ * @param setAdditional 加投费setter
|
|
|
+ * @param keepPointRate 留点比例
|
|
|
* @param keepPointPremium 留点费用
|
|
|
+ * @param isrecordByLeader 是否是代课录单
|
|
|
*/
|
|
|
private void processInsuranceType(
|
|
|
BigDecimal premium,
|
|
|
@@ -433,7 +457,8 @@ public class QuoteVerificationAspect {
|
|
|
BiConsumer<InsFeeOrders, BigDecimal> setFollow,
|
|
|
BiConsumer<InsFeeOrders, BigDecimal> setAdditional,
|
|
|
BiConsumer<InsFeeOrders, BigDecimal> keepPointRate,
|
|
|
- BiConsumer<InsFeeOrders, BigDecimal> keepPointPremium) {
|
|
|
+ BiConsumer<InsFeeOrders, BigDecimal> keepPointPremium,
|
|
|
+ boolean isrecordByLeader) {
|
|
|
// 若险种配置为空,默认应收应付为0
|
|
|
if (costType == null) {
|
|
|
setReceivable.accept(insFeeOrders, BigDecimal.ZERO);
|
|
|
@@ -449,6 +474,11 @@ public class QuoteVerificationAspect {
|
|
|
BigDecimal addThrowPercent = convertPercent(costType.getAddThrow());
|
|
|
BigDecimal exportPercent = convertPercent(costType.getExport());
|
|
|
|
|
|
+ if(isrecordByLeader){
|
|
|
+ // 如果是代客录单,出口比例减去一个百分比,也就是 0.01 2026年7月11日09:30:09
|
|
|
+ exportPercent = BigDecimalUtil.subtract(exportPercent, new BigDecimal("0.01"));
|
|
|
+ }
|
|
|
+
|
|
|
// 去税保费金额
|
|
|
BigDecimal taxablePremium = premium.divide(taxFactor,5,RoundingMode.HALF_EVEN);
|
|
|
|
|
|
@@ -573,8 +603,11 @@ public class QuoteVerificationAspect {
|
|
|
}
|
|
|
/**
|
|
|
* 保存比例
|
|
|
+ * @param isrecordByLeader 是否代客录单,如果是代客入单,出口比例减一个百分比
|
|
|
*/
|
|
|
- private void saveRatio(InsFeeOrders insFeeOrders, AgreementInfoVo agreementInfoVo,PtlAgreementCostTypeVo jqCostType,PtlAgreementCostTypeVo syCostType,PtlAgreementCostTypeVo jyCostType) {
|
|
|
+ private void saveRatio(InsFeeOrders insFeeOrders, AgreementInfoVo agreementInfoVo,
|
|
|
+ PtlAgreementCostTypeVo jqCostType, PtlAgreementCostTypeVo syCostType,
|
|
|
+ PtlAgreementCostTypeVo jyCostType, boolean isrecordByLeader) {
|
|
|
// 手续费比例
|
|
|
insFeeOrders.setJqCommissionRatio(agreementInfoVo.getAgreement().getJqEntranceFeeRatio());
|
|
|
insFeeOrders.setSyCommissionRatio(agreementInfoVo.getAgreement().getSyEntranceFeeRatio());
|
|
|
@@ -629,19 +662,24 @@ public class QuoteVerificationAspect {
|
|
|
? convertPercent(jqCostType.getExport()).subtract(convertPercent(firstDistributionRatio))
|
|
|
.subtract(convertPercent(secondDistributionRatio)).subtract(convertPercent(thirdDistributionRatio))
|
|
|
: BigDecimal.ZERO));
|
|
|
-
|
|
|
insFeeOrders.setSyExportRatio(syCostType == null ? BigDecimal.ZERO :
|
|
|
(syCostType.getExport() != null && syCostType.getExport().compareTo(BigDecimal.ZERO) > 0
|
|
|
? convertPercent(syCostType.getExport()).subtract(convertPercent(firstDistributionRatio))
|
|
|
.subtract(convertPercent(secondDistributionRatio)).subtract(convertPercent(thirdDistributionRatio))
|
|
|
: BigDecimal.ZERO));
|
|
|
-
|
|
|
insFeeOrders.setJyExportRatio(jyCostType == null ? BigDecimal.ZERO :
|
|
|
(jyCostType.getExport() != null && jyCostType.getExport().compareTo(BigDecimal.ZERO) > 0
|
|
|
? convertPercent(jyCostType.getExport()).subtract(convertPercent(firstDistributionRatio))
|
|
|
.subtract(convertPercent(secondDistributionRatio)).subtract(convertPercent(thirdDistributionRatio))
|
|
|
: BigDecimal.ZERO));
|
|
|
|
|
|
+ if(isrecordByLeader){
|
|
|
+ // 如果是代客录单, 交强,商业,驾意的出口比例减1%, 也就是0.01 add by lipf 2026年7月10日15:40:47
|
|
|
+ insFeeOrders.setJqExportRatio(BigDecimalUtil.subtract(insFeeOrders.getJqExportRatio(), new BigDecimal("0.01")));
|
|
|
+ insFeeOrders.setSyExportRatio(BigDecimalUtil.subtract(insFeeOrders.getSyExportRatio(), new BigDecimal("0.01")));
|
|
|
+ insFeeOrders.setJyExportRatio(BigDecimalUtil.subtract(insFeeOrders.getJyExportRatio(), new BigDecimal("0.01")));
|
|
|
+ }
|
|
|
+
|
|
|
// 出口留点比例
|
|
|
insFeeOrders.setJqExportKeepPointRatio(jqCostType != null
|
|
|
? convertPercent(jqCostType.getExportKeepPointRatio() != null ? jqCostType.getExportKeepPointRatio() : BigDecimal.ZERO)
|