Просмотр исходного кода

报价 车险报价的时候代客录单的时候,出口比例扣减1%。原先的功能没有实现

lipf 2 месяцев назад
Родитель
Сommit
f6ba6f2aec

+ 10 - 0
tenant/insurance/quotation-commons/src/main/java/com/jzg/quotation/commons/client/OrgClient.java

@@ -245,4 +245,14 @@ public interface OrgClient {
      */
     @PostMapping("/api/v1/organization/queryJzgInfoId2UserId")
     public HttpResult<Map<String,String>> queryJzgInfoId2UserId(@RequestBody List<String> jzgInfoTids);
+
+    /**
+     * 根据用户登录名查询sysUser对象
+     *
+     * @param userName 用户登录名,默认为手机号
+     * @author lipf
+     * @date 2026/7/10 15:04
+     */
+    @GetMapping("/userInfo/querySysUserByUserName")
+    public HttpResult<SysUser> querySysUserByUserName(@RequestParam("userName") String userName);
 }

+ 38 - 7
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/aop/aspect/QuoteVerificationAspect.java

@@ -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)

+ 12 - 0
tenant/organization/src/main/java/com/jzg/organization/controller/UserController.java

@@ -351,5 +351,17 @@ public class UserController extends BaseController {
         return HttpResult.ok(sysUser);
     }
 
+    /**
+     * 根据用户登录名查询sysUser对象
+     *
+     * @param userName 用户登录名,默认为手机号
+     * @author lipf
+     * @date 2026/7/10 15:04
+     */
+    @GetMapping("/querySysUserByUserName")
+    public HttpResult<SysUser> querySysUserByUserName(@RequestParam("userName") String userName){
+        return HttpResult.ok(sysUserService.querySysUserByUserName(userName));
+    }
+
 
 }

+ 9 - 0
tenant/organization/src/main/java/com/jzg/organization/service/SysUserService.java

@@ -294,4 +294,13 @@ public interface SysUserService extends IService<SysUser> {
      * @date 2026/6/30 11:27
      */
     SysUser querySysUserByUserId(String userId);
+
+    /**
+     * 根据用户登录名查询sysUser对象
+     *
+     * @param userName 用户登录名,默认为手机号
+     * @author lipf
+     * @date 2026/7/10 15:04
+     */
+    SysUser querySysUserByUserName(String userName);
 }

+ 12 - 0
tenant/organization/src/main/java/com/jzg/organization/service/impl/SysUserServiceImpl.java

@@ -1652,6 +1652,18 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         }
     }
 
+    /**
+     * 根据用户登录名查询sysUser对象
+     *
+     * @param userName 用户登录名,默认为手机号
+     * @author lipf
+     * @date 2026/7/10 15:04
+     */
+    @Override
+    public SysUser querySysUserByUserName(String userName) {
+        return baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
+                .eq(SysUser::getUsername,userName));
+    }
 
 }