|
|
@@ -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());
|
|
|
@@ -110,7 +112,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;
|
|
|
@@ -122,6 +127,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服务是否启动");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 最开始的过滤 过滤 能源 车辆类型
|
|
|
@@ -223,7 +245,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());
|
|
|
@@ -338,7 +361,7 @@ public class QuoteVerificationAspect {
|
|
|
BigDecimal distributionDiff = calculateDistributionFee(insOrdersCosts,insFeeOrders, insOrders);
|
|
|
|
|
|
// 8. 计算总应收、总应付、保存费用比例 入库
|
|
|
- saveRatio(insFeeOrders, agreementInfoVo, jqCostType, syCostType, jyCostType);
|
|
|
+ saveRatio(insFeeOrders, agreementInfoVo, jqCostType, syCostType, jyCostType, isrecordByLeader);
|
|
|
calculateTotalPremium(insFeeOrders, distributionDiff);
|
|
|
|
|
|
|
|
|
@@ -551,8 +574,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());
|
|
|
@@ -607,19 +633,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)
|