Explorar el Código

Merge branch 'master' into wrq_dev

wangrq hace 2 meses
padre
commit
1c26e2a6ff
Se han modificado 26 ficheros con 511 adiciones y 363 borrados
  1. 5 0
      commons/src/main/java/com/jzg/commons/entity/finance/po/InsPlyIncome.java
  2. 19 0
      commons/src/main/java/com/jzg/commons/entity/finance/vo/FollowCompanyFeeVO.java
  3. 5 0
      commons/src/main/java/com/jzg/commons/entity/finance/vo/InvoiceRecordResult.java
  4. 63 0
      commons/src/main/java/com/jzg/commons/entity/orders/vo/FeeAuditVo.java
  5. 12 0
      commons/src/main/java/com/jzg/commons/entity/po/InsFeeOrders.java
  6. 58 22
      commons/src/main/java/com/jzg/commons/entity/vo/PtlAgreementCostRatioVo.java
  7. 19 0
      commons/src/main/java/com/jzg/commons/util/BigDecimalUtil.java
  8. 0 191
      commons/src/main/java/com/jzg/commons/util/UserContextUtil.java
  9. 8 1
      platform/src/main/java/com/jzg/service/impl/PtlAgreementAttributionImpl.java
  10. 2 2
      tenant/insurance/quotation-ansheng/src/main/java/com/jzg/quotation/ansheng/crawler/service/impl/AnShengCrawlerRequestImpl.java
  11. 1 1
      tenant/insurance/quotation-guoren/src/main/java/com/jzg/quotation/guoren/crawler/build/GuoRenCrawlerQuoteResultsVoBuild.java
  12. 2 0
      tenant/insurance/quotation-hengbang/src/main/java/com/jzg/quotation/hengbang/crawler/service/Impl/HengBangCrawlerRequestImpl.java
  13. 1 1
      tenant/insurance/quotation-huanong/src/main/java/com/jzg/quotation/huanong/crawler/build/HuaNongCrawlerQuoteResultsVoBuild.java
  14. 7 4
      tenant/insurance/quotation-huatai/src/main/java/com/jzg/quotation/huatai/crawler/build/HuaTaiCrawlerQuoteResultsVoBuild.java
  15. 18 11
      tenant/insurance/quotation-huatai/src/main/java/com/jzg/quotation/huatai/crawler/entity/Request/HtCrawlerOrderStateRequest.java
  16. 21 15
      tenant/insurance/quotation-huatai/src/main/java/com/jzg/quotation/huatai/crawler/service/Impl/HuaTaiCrawlerRequestImpl.java
  17. 6 6
      tenant/insurance/quotation-renbaonew/src/main/java/com/jzg/quotation/renbaonew/crawler/service/impl/RenBaoNewCrawlerRequestBuilder.java
  18. 24 11
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsFeeOrdersServiceImpl.java
  19. 61 10
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsOrdersServiceImpl.java
  20. 4 1
      tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementServiceImpl.java
  21. 1 1
      tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlSchemeServiceImpl.java
  22. 136 35
      tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java
  23. 5 4
      tenant/organization/src/main/resources/mapper/InsFeeFollowOrderMapper.xml
  24. 20 14
      tenant/organization/src/main/resources/mapper/PtlAgreementMapper.xml
  25. 12 32
      tenant/organization/src/main/resources/mapper/ReceivableMapper.xml
  26. 1 1
      tenant/organization/src/main/resources/mapper/SysUserJzgInfoBankCardMapper.xml

+ 5 - 0
commons/src/main/java/com/jzg/commons/entity/finance/po/InsPlyIncome.java

@@ -10,6 +10,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 import java.io.Serial;
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 
 @EqualsAndHashCode(callSuper = true)
@@ -341,5 +342,9 @@ public class InsPlyIncome extends BaseModel {
     @ExcelIgnore
     private String jyTotalProportion;
 
+    @TableField(exist = false)
+    @Schema(description = "非车应收金额")
+    private BigDecimal jyTotalPremiums;
+
 
 }

+ 19 - 0
commons/src/main/java/com/jzg/commons/entity/finance/vo/FollowCompanyFeeVO.java

@@ -15,6 +15,10 @@ public class FollowCompanyFeeVO {
 
     private String companyId;
 
+    private String year;
+
+    private String month;
+
     @Schema(description = "对接人")
     private String contactPerson;
 
@@ -47,4 +51,19 @@ public class FollowCompanyFeeVO {
     /** 累计应收  totalReceivable */
     private BigDecimal totalReceivable;
 
+    /**
+     * 开票记录id
+     */
+    private String invoiceId;
+
+    /**
+     * 结算记录id
+     */
+    private String settlementId;
+
+    /**
+     * 跟单id
+     */
+    private String followId;
+
 }

+ 5 - 0
commons/src/main/java/com/jzg/commons/entity/finance/vo/InvoiceRecordResult.java

@@ -148,4 +148,9 @@ public class InvoiceRecordResult extends PageRequest {
      * 分支公司名称
      */
     private String partnerCompanyName;
+
+    /**
+     * 回款差额
+     */
+    private BigDecimal settlementPaymentDifference;
 }

+ 63 - 0
commons/src/main/java/com/jzg/commons/entity/orders/vo/FeeAuditVo.java

@@ -2,6 +2,7 @@ package com.jzg.commons.entity.orders.vo;
 
 import com.alibaba.excel.annotation.ExcelIgnore;
 import com.alibaba.excel.annotation.ExcelProperty;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.jzg.commons.core.base.BaseModel;
 import io.swagger.v3.oas.annotations.media.Schema;
@@ -352,4 +353,66 @@ public class FeeAuditVo extends BaseModel {
     @ExcelProperty("权益相关:可用金额<可用金额=出口费用➖出口人留点费用>")
     @Schema(description = "权益相关:可用金额<可用金额=出口费用➖出口人留点费用>")
     private BigDecimal availableAmount;
+
+
+    @Schema(description = "一级分销费")
+    @ExcelProperty("一级分销费")
+    @TableField(exist = false)
+    private BigDecimal firstDistributionFee;
+
+//    @Schema(description = "一级分销员id")
+//    @ExcelProperty("订单号")
+//    @TableField(exist = false)
+//    private String firstDistributorId;
+//
+//    @Schema(description = "一级分销员")
+//    @ExcelProperty("订单号")
+//    @TableField(exist = false)
+//    private String firstDistributorName;
+
+    @Schema(description = "一级分销比例")
+    @ExcelProperty("一级分销比例")
+    @TableField(exist = false)
+    private BigDecimal firstDistributionRatio;
+
+    @Schema(description = "二级分销费")
+    @ExcelProperty("二级分销费")
+    @TableField(exist = false)
+    private BigDecimal secondDistributionFee;
+
+//    @Schema(description = "二级分销员id")
+//    @ExcelProperty("二级分销员id")
+//    @ExcelIgnore
+//    @TableField(exist = false)
+//    private String secondDistributorId;
+//
+//    @Schema(description = "二级分销员")
+//    @ExcelProperty("二级分销员")
+//    @TableField(exist = false)
+//    private String secondDistributorName;
+
+    @Schema(description = "二级分销比例")
+    @ExcelProperty("二级分销比例")
+    @TableField(exist = false)
+    private BigDecimal secondDistributionRatio;
+
+    @Schema(description = "三级分销费")
+    @ExcelProperty("三级分销费")
+    @TableField(exist = false)
+    private BigDecimal thirdDistributionFee;
+
+//    @Schema(description = "三级分销员id")
+//    @ExcelIgnore
+//    @TableField(exist = false)
+//    private String thirdDistributorId;
+//
+//    @Schema(description = "三级分销员")
+//    @ExcelProperty("三级分销员")
+//    @TableField(exist = false)
+//    private String thirdDistributorName;
+
+    @Schema(description = "三级分销比例")
+    @ExcelProperty("三级分销比例")
+    @TableField(exist = false)
+    private BigDecimal thirdDistributionRatio;
 }

+ 12 - 0
commons/src/main/java/com/jzg/commons/entity/po/InsFeeOrders.java

@@ -165,12 +165,24 @@ public class InsFeeOrders {
     @Schema(description = "交强出口比例")
     private BigDecimal jqExportRatio;
 
+    @TableField(exist = false)
+    @Schema(description = "交强出口比例(含分销比例)")
+    private BigDecimal jqExportRatioContainDistribution;
+
     @Schema(description = "商业险出口比例")
     private BigDecimal syExportRatio;
 
+    @TableField(exist = false)
+    @Schema(description = "商业险出口比例(含分销比例)")
+    private BigDecimal syExportRatioContainDistribution;
+
     @Schema(description = "驾意险出口比例")
     private BigDecimal jyExportRatio;
 
+    @TableField(exist = false)
+    @Schema(description = "驾意险出口比例(含分销比例)")
+    private BigDecimal jyExportRatioContainDistribution;
+
     @Schema(description = "交强出口费用")
     private BigDecimal jqExportPremium;
 

+ 58 - 22
commons/src/main/java/com/jzg/commons/entity/vo/PtlAgreementCostRatioVo.java

@@ -132,32 +132,68 @@ public class PtlAgreementCostRatioVo {
         this.orderNo = insFeeOrders.getOrderNo();
 
         // 交强险比例
-        this.jqCommissionRatio = insFeeOrders.getJqCommissionRatio() != null ? insFeeOrders.getJqCommissionRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-        this.jqInletRatio = insFeeOrders.getJqInletRatio() != null ? insFeeOrders.getJqInletRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-        this.jqFollowRatio = insFeeOrders.getJqFollowRatio() != null ? insFeeOrders.getJqFollowRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-        this.jqAdditionalRatio = insFeeOrders.getJqAdditionalRatio() != null ? insFeeOrders.getJqAdditionalRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-        this.jqKeepPointRatio = insFeeOrders.getJqKeepPointRatio() != null ? insFeeOrders.getJqKeepPointRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-        this.jqExportRatio = insFeeOrders.getJqExportRatio() != null ? insFeeOrders.getJqExportRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-        this.jqExportKeepPointRatio = insFeeOrders.getJqExportKeepPointRatio() != null ? insFeeOrders.getJqExportKeepPointRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+        if(insFeeOrders.getJqPremium().compareTo(BigDecimal.ZERO) == 0){
+            this.jqCommissionRatio = BigDecimal.ZERO;
+            this.jqInletRatio = BigDecimal.ZERO;
+            this.jqFollowRatio =  BigDecimal.ZERO;
+            this.jqAdditionalRatio = BigDecimal.ZERO;
+            this.jqKeepPointRatio = BigDecimal.ZERO;
+            this.jqExportRatio = BigDecimal.ZERO;
+            this.jqExportKeepPointRatio = BigDecimal.ZERO;
+
+        }else{
+            this.jqCommissionRatio = insFeeOrders.getJqCommissionRatio() != null ? insFeeOrders.getJqCommissionRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+            this.jqInletRatio = insFeeOrders.getJqInletRatio() != null ? insFeeOrders.getJqInletRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+            this.jqFollowRatio = insFeeOrders.getJqFollowRatio() != null ? insFeeOrders.getJqFollowRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+            this.jqAdditionalRatio = insFeeOrders.getJqAdditionalRatio() != null ? insFeeOrders.getJqAdditionalRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+            this.jqKeepPointRatio = insFeeOrders.getJqKeepPointRatio() != null ? insFeeOrders.getJqKeepPointRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+            this.jqExportRatio = insFeeOrders.getJqExportRatio() != null ? insFeeOrders.getJqExportRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+            this.jqExportKeepPointRatio = insFeeOrders.getJqExportKeepPointRatio() != null ? insFeeOrders.getJqExportKeepPointRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+        }
+
 
         // 商业险比例
-        this.syCommissionRatio = insFeeOrders.getSyCommissionRatio() != null ? insFeeOrders.getSyCommissionRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-        this.syInletRatio = insFeeOrders.getSyInletRatio() != null ? insFeeOrders.getSyInletRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-        this.syFollowRatio = insFeeOrders.getSyFollowRatio() != null ? insFeeOrders.getSyFollowRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-        this.syAdditionalRatio = insFeeOrders.getSyAdditionalRatio() != null ? insFeeOrders.getSyAdditionalRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-        this.syKeepPointRatio = insFeeOrders.getSyKeepPointRatio() != null ? insFeeOrders.getSyKeepPointRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-        this.syExportRatio = insFeeOrders.getSyExportRatio() != null ? insFeeOrders.getSyExportRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-        this.syExportKeepPointRatio = insFeeOrders.getSyExportKeepPointRatio() != null ? insFeeOrders.getSyExportKeepPointRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+        if(insFeeOrders.getSyPremium().compareTo(BigDecimal.ZERO) == 0){
+            this.syCommissionRatio = BigDecimal.ZERO;
+            this.syInletRatio = BigDecimal.ZERO;
+            this.syFollowRatio = BigDecimal.ZERO;
+            this.syAdditionalRatio = BigDecimal.ZERO;
+            this.syKeepPointRatio = BigDecimal.ZERO;
+            this.syExportRatio =  BigDecimal.ZERO;
+            this.syExportKeepPointRatio = BigDecimal.ZERO;
+
+        }else{
+            this.syCommissionRatio = insFeeOrders.getSyCommissionRatio() != null ? insFeeOrders.getSyCommissionRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+            this.syInletRatio = insFeeOrders.getSyInletRatio() != null ? insFeeOrders.getSyInletRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+            this.syFollowRatio = insFeeOrders.getSyFollowRatio() != null ? insFeeOrders.getSyFollowRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+            this.syAdditionalRatio = insFeeOrders.getSyAdditionalRatio() != null ? insFeeOrders.getSyAdditionalRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+            this.syKeepPointRatio = insFeeOrders.getSyKeepPointRatio() != null ? insFeeOrders.getSyKeepPointRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+            this.syExportRatio = insFeeOrders.getSyExportRatio() != null ? insFeeOrders.getSyExportRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+            this.syExportKeepPointRatio = insFeeOrders.getSyExportKeepPointRatio() != null ? insFeeOrders.getSyExportKeepPointRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+
+        }
 
         // 驾意险比例
-        this.jyCommissionRatio = insFeeOrders.getJyCommissionRatio() != null ? insFeeOrders.getJyCommissionRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-        this.jyInletRatio = insFeeOrders.getJyInletRatio() != null ? insFeeOrders.getJyInletRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-        this.jyFollowRatio = insFeeOrders.getJyFollowRatio() != null ? insFeeOrders.getJyFollowRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-        this.jyAdditionalRatio = insFeeOrders.getJyAdditionalRatio() != null ? insFeeOrders.getJyAdditionalRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-        this.jyKeepPointRatio = insFeeOrders.getJyKeepPointRatio() != null ? insFeeOrders.getJyKeepPointRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-        this.jyExportRatio = insFeeOrders.getJyExportRatio() != null ? insFeeOrders.getJyExportRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-        this.jyExportKeepPointRatio = insFeeOrders.getJyExportKeepPointRatio() != null ? insFeeOrders.getJyExportKeepPointRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
-    }
+        if(insFeeOrders.getJyPremium().compareTo(BigDecimal.ZERO) == 0){
+            this.jyCommissionRatio = BigDecimal.ZERO;
+            this.jyInletRatio =  BigDecimal.ZERO;
+            this.jyFollowRatio = BigDecimal.ZERO;
+            this.jyAdditionalRatio = BigDecimal.ZERO;
+            this.jyKeepPointRatio =BigDecimal.ZERO;
+            this.jyExportRatio = BigDecimal.ZERO;
+            this.jyExportKeepPointRatio = BigDecimal.ZERO;
+
+        }else{
+            this.jyCommissionRatio = insFeeOrders.getJyCommissionRatio() != null ? insFeeOrders.getJyCommissionRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+            this.jyInletRatio = insFeeOrders.getJyInletRatio() != null ? insFeeOrders.getJyInletRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+            this.jyFollowRatio = insFeeOrders.getJyFollowRatio() != null ? insFeeOrders.getJyFollowRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+            this.jyAdditionalRatio = insFeeOrders.getJyAdditionalRatio() != null ? insFeeOrders.getJyAdditionalRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+            this.jyKeepPointRatio = insFeeOrders.getJyKeepPointRatio() != null ? insFeeOrders.getJyKeepPointRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+            this.jyExportRatio = insFeeOrders.getJyExportRatio() != null ? insFeeOrders.getJyExportRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+            this.jyExportKeepPointRatio = insFeeOrders.getJyExportKeepPointRatio() != null ? insFeeOrders.getJyExportKeepPointRatio().multiply(new BigDecimal("100")) : BigDecimal.ZERO;
+
+        }
+       }
 
 
 

+ 19 - 0
commons/src/main/java/com/jzg/commons/util/BigDecimalUtil.java

@@ -36,6 +36,25 @@ public class BigDecimalUtil {
         return val.negate();
     }
 
+    /**
+     *
+     * @author lipf
+     * @date 2026/7/1 14:58
+     */
+    public static BigDecimal add(BigDecimal ... v1s){
+        if (v1s == null || v1s.length == 0) {
+            return BigDecimal.ZERO;
+        }
+        BigDecimal sum = BigDecimal.ZERO;
+        for (BigDecimal v1 : v1s) {
+            if(v1 == null){
+                v1 = BigDecimal.ZERO;
+            }
+            sum = BigDecimalUtil.add(sum,v1);
+        }
+        return sum;
+    }
+
     /**
      * 提供精确的加法运算
      * @param v1 被加数

+ 0 - 191
commons/src/main/java/com/jzg/commons/util/UserContextUtil.java

@@ -1,191 +0,0 @@
-package com.jzg.commons.util;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import jakarta.servlet.http.HttpServletRequest;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * 用户上下文工具类 —— 从网关透传的请求头中读取用户信息
- * <p>
- * 网关层 {@code AuthGlobalFilter} 在 Token 校验通过后,
- * 会将用户信息注入到以下请求头中,下游微服务可直接读取,无需重复查询 Redis:
- * <ul>
- *   <li>{@code X-User-Id} —— 用户ID</li>
- *   <li>{@code X-Username} —— 用户名/手机号</li>
- *   <li>{@code X-User-Name} —— 姓名</li>
- *   <li>{@code X-System-Code} —— 登录系统编码</li>
- *   <li>{@code X-Dept-Id} —— 部门ID</li>
- *   <li>{@code X-Work-Number} —— 工号</li>
- *   <li>{@code X-Province} —— 省份</li>
- *   <li>{@code X-Auths} —— 权限列表(JSON数组)</li>
- *   <li>{@code X-Data-Scope} —— 数据权限(JSON对象)</li>
- *   <li>{@code X-Head-Sculpture} —— 头像URL</li>
- * </ul>
- * </p>
- *
- * @author lipf
- * @date 2026/6/16
- */
-public class UserContextUtil {
-
-    private UserContextUtil() {
-        // 工具类,禁止实例化
-    }
-
-    /**
-     * 获取当前 HTTP 请求(可能为 null,非 Web 上下文时)
-     */
-    private static HttpServletRequest getRequest() {
-        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
-        if (attributes == null) {
-            return null;
-        }
-        return attributes.getRequest();
-    }
-
-    /**
-     * 从请求头获取用户ID
-     *
-     * @return 用户ID,未获取到时返回空字符串
-     */
-    public static String getUserId() {
-        HttpServletRequest request = getRequest();
-        if (request == null) return "";
-        return headerOrEmpty(request, "X-User-Id");
-    }
-
-    /**
-     * 从请求头获取用户名
-     *
-     * @return 用户名,未获取到时返回空字符串
-     */
-    public static String getUsername() {
-        HttpServletRequest request = getRequest();
-        if (request == null) return "";
-        return headerOrEmpty(request, "X-Username");
-    }
-
-    /**
-     * 从请求头获取姓名
-     *
-     * @return 姓名,未获取到时返回空字符串
-     */
-    public static String getUserName() {
-        HttpServletRequest request = getRequest();
-        if (request == null) return "";
-        return headerOrEmpty(request, "X-User-Name");
-    }
-
-    /**
-     * 从请求头获取系统编码
-     *
-     * @return 系统编码,未获取到时返回空字符串
-     */
-    public static String getSystemCode() {
-        HttpServletRequest request = getRequest();
-        if (request == null) return "";
-        return headerOrEmpty(request, "X-System-Code");
-    }
-
-    /**
-     * 从请求头获取部门ID
-     *
-     * @return 部门ID,未获取到时返回空字符串
-     */
-    public static String getDeptId() {
-        HttpServletRequest request = getRequest();
-        if (request == null) return "";
-        return headerOrEmpty(request, "X-Dept-Id");
-    }
-
-    /**
-     * 从请求头获取工号
-     *
-     * @return 工号,未获取到时返回空字符串
-     */
-    public static String getWorkNumber() {
-        HttpServletRequest request = getRequest();
-        if (request == null) return "";
-        return headerOrEmpty(request, "X-Work-Number");
-    }
-
-    /**
-     * 从请求头获取省份
-     *
-     * @return 省份,未获取到时返回空字符串
-     */
-    public static String getProvince() {
-        HttpServletRequest request = getRequest();
-        if (request == null) return "";
-        return headerOrEmpty(request, "X-Province");
-    }
-
-    /**
-     * 从请求头获取头像URL
-     *
-     * @return 头像URL,未获取到时返回空字符串
-     */
-    public static String getHeadSculpture() {
-        HttpServletRequest request = getRequest();
-        if (request == null) return "";
-        return headerOrEmpty(request, "X-Head-Sculpture");
-    }
-
-    /**
-     * 从请求头获取用户权限列表
-     *
-     * @return 权限标识列表,未获取到时返回空列表
-     */
-    public static List<String> getPerms() {
-        HttpServletRequest request = getRequest();
-        if (request == null) return new ArrayList<>();
-
-        String authsJson = headerOrEmpty(request, "X-Auths");
-        if (authsJson.isEmpty()) return new ArrayList<>();
-
-        List<String> perms = new ArrayList<>();
-        try {
-            JSONArray auths = JSONArray.parseArray(authsJson);
-            for (int i = 0; i < auths.size(); i++) {
-                JSONObject auth = auths.getJSONObject(i);
-                String perm = auth.getString("perms");
-                if (perm != null) {
-                    perms.add(perm);
-                }
-            }
-        } catch (Exception e) {
-            // 解析失败,返回空列表
-        }
-        return perms;
-    }
-
-    /**
-     * 从请求头获取数据权限
-     *
-     * @return 数据权限 JSON 字符串,未获取到时返回 "{}"
-     */
-    public static String getDataScope() {
-        HttpServletRequest request = getRequest();
-        if (request == null) return "{}";
-        return headerOrEmpty(request, "X-Data-Scope");
-    }
-
-    /**
-     * 判断用户信息是否来自网关透传(即请求头中是否存在 X-User-Id)
-     *
-     * @return true 表示本次请求已经过网关鉴权
-     */
-    public static boolean isFromGateway() {
-        return !getUserId().isEmpty();
-    }
-
-    private static String headerOrEmpty(HttpServletRequest request, String name) {
-        String value = request.getHeader(name);
-        return value != null ? value : "";
-    }
-}

+ 8 - 1
platform/src/main/java/com/jzg/service/impl/PtlAgreementAttributionImpl.java

@@ -80,7 +80,14 @@ public class PtlAgreementAttributionImpl extends ServiceImpl<PtlAgreementAttribu
 
     @Override
     public Page<PtlAgreementAttribution> getAgreementAttributionList(Page page, PtlAgreementAttributionQueryVo ptlAgreementAttributionQueryVo) {
-        return baseMapper.getAgreementAttributionList(page,ptlAgreementAttributionQueryVo);
+        Page<PtlAgreementAttribution> agreementAttributionList = baseMapper.getAgreementAttributionList(page, ptlAgreementAttributionQueryVo);
+        agreementAttributionList.getRecords().forEach(item->{
+            // 将用户名密码设置为空
+            if(Objects.isNull(item.getUsername())){
+                item.setUsername("");
+            }
+        });
+        return agreementAttributionList;
     }
 
     @Override

+ 2 - 2
tenant/insurance/quotation-ansheng/src/main/java/com/jzg/quotation/ansheng/crawler/service/impl/AnShengCrawlerRequestImpl.java

@@ -250,8 +250,8 @@ public class AnShengCrawlerRequestImpl implements AnShengCrawlerRequest {
         paymentLinkResultsVo = loopAcquisitionPaymentLink(paymentLinkVo);
         // 支付链接为空直接失败返回
         if (StringUtils.isEmpty(paymentLinkResultsVo.getPaymentLink())) {
-            underwritingResultsVo.setUnderwritingResult(applyApplicationResponse.getMessage());
-            underwritingResultsVo.setUnderwritingStatus(InsOrderStatusEnum.AUDIT_FAIL);
+            underwritingResultsVo.setUnderwritingResult("核保失败,转人工");
+            underwritingResultsVo.setUnderwritingStatus(InsOrderStatusEnum.STAFF_PROCESS);
             return underwritingResultsVo;
         }
         // 正常赋值逻辑

+ 1 - 1
tenant/insurance/quotation-guoren/src/main/java/com/jzg/quotation/guoren/crawler/build/GuoRenCrawlerQuoteResultsVoBuild.java

@@ -57,7 +57,7 @@ public final class GuoRenCrawlerQuoteResultsVoBuild {
         quoteResultsVo.getCosts().setBiPremium(biPremium); // 注意这里CI和BI保费相同
         quoteResultsVo.getCosts().setNiPremium(bcPremium);
         quoteResultsVo.getCosts().setVvTax(vvTax);
-        String sumPremium = String.valueOf(Integer.parseInt(biPremium) + Double.parseDouble(ciPremium) + Integer.parseInt(bcPremium) + Double.parseDouble(vvTax));
+        String sumPremium = String.valueOf(Double.parseDouble(biPremium) + Double.parseDouble(ciPremium) + Double.parseDouble(bcPremium) + Double.parseDouble(vvTax));
         quoteResultsVo.getCosts().setSumPremium(sumPremium);
         quoteResultsVo.setQuoteStatusEnum(InsOrderStatusEnum.WAIT_AUDIT);
 

+ 2 - 0
tenant/insurance/quotation-hengbang/src/main/java/com/jzg/quotation/hengbang/crawler/service/Impl/HengBangCrawlerRequestImpl.java

@@ -189,6 +189,8 @@ public class HengBangCrawlerRequestImpl implements HengBangCrawlerRequest {
         if (errorMsg.contains("该车是转保车,请输入对应的转保验证码")) {
             String responseBody = resJsonObj.getString("responseBody");
             HbCrawlerRecordResponse recordResponse = JSONObject.parseObject(responseBody, HbCrawlerRecordResponse.class);
+            recordResponse.getCheckcodeJq().replace("0","o");
+            recordResponse.getCheckcodeSy().replace("0","o");
             calculationRequest.setTransferVehicle(recordResponse);
 
             resJson = hbCrawlerRequestComponent.getCalculationResult(calculationRequest, headers);

+ 1 - 1
tenant/insurance/quotation-huanong/src/main/java/com/jzg/quotation/huanong/crawler/build/HuaNongCrawlerQuoteResultsVoBuild.java

@@ -121,7 +121,7 @@ public final class HuaNongCrawlerQuoteResultsVoBuild {
 
         JSONArray scoreJson = new JSONArray();
         scoreJson.add(new JSONObject()
-                .fluentPut("scoreName", "总评分")
+                .fluentPut("scoreName", "交商合计分")
                 .fluentPut("scoreKey", "mark")
                 .fluentPut("score", ultimateScoreBiCi));
         scoreJson.add(new JSONObject()

+ 7 - 4
tenant/insurance/quotation-huatai/src/main/java/com/jzg/quotation/huatai/crawler/build/HuaTaiCrawlerQuoteResultsVoBuild.java

@@ -2,6 +2,7 @@ package com.jzg.quotation.huatai.crawler.build;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.jzg.commons.constants.ProductsType;
 import com.jzg.commons.constants.dict.InsOrderStatusEnum;
 import com.jzg.commons.entity.quote.vo.KindInfoVo;
 import com.jzg.commons.entity.quote.vo.RiskInfoVo;
@@ -9,6 +10,7 @@ import com.jzg.commons.entity.quote.vo.aggregated.QuoteResultsVo;
 import com.jzg.commons.entity.quote.vo.QuoteVo;
 import com.jzg.commons.entity.quote.vo.base.OrderBase;
 import com.jzg.commons.util.StringUtils;
+import com.jzg.quotation.commons.constant.enums.quote.RenewalEnum;
 import com.jzg.quotation.huatai.api.constant.enums.ContractEnum;
 import com.jzg.quotation.huatai.crawler.entity.Response.HtCrawlerQuoteResponse;
 
@@ -53,10 +55,11 @@ public class HuaTaiCrawlerQuoteResultsVoBuild {
                 .fluentPut("score",quoteResponseData.getApplicationdto().getBicategory()));
         quoteResultsVo.getScoreVo().setScoreJson(scoreJson);
 
-        //续保标志0否1是 (跟python 一致)
-        quoteResultsVo.getScoreVo().setJqRenewal("转入".equals(quoteResponseData.getApplicationdto().getCustombusinesstype_ci()) ? "0" : "1");
-        quoteResultsVo.getScoreVo().setSyRenewal("转入".equals(quoteResponseData.getApplicationdto().getCustombusinesstype_bi()) ? "0" : "1");
-
+        //续保标志
+        quoteResultsVo.getScoreVo().setJqRenewal("转入".equals(quoteResponseData.getApplicationdto().getCustombusinesstype_ci()) ? String.valueOf(RenewalEnum.Transfer.getCode()) : quoteResponseData.getApplicationdto().getCustombusinesstype_ci());
+        if (!ProductsType.PT_0330.getCode().equals(quoteVo.getOrder().getProductId())) {
+            quoteResultsVo.getScoreVo().setSyRenewal("转入".equals(quoteResponseData.getApplicationdto().getCustombusinesstype_bi()) ? String.valueOf(RenewalEnum.Transfer.getCode()) : quoteResponseData.getApplicationdto().getCustombusinesstype_ci());
+        }
         quoteResultsVo.setQuoteStatusEnum(InsOrderStatusEnum.WAIT_AUDIT);
         return quoteResultsVo;
     }

+ 18 - 11
tenant/insurance/quotation-huatai/src/main/java/com/jzg/quotation/huatai/crawler/entity/Request/HtCrawlerOrderStateRequest.java

@@ -5,6 +5,7 @@ import lombok.Data;
 
 import java.io.Serial;
 import java.io.Serializable;
+import java.time.LocalDate;
 
 /**
  * @description: 华泰财险 查询订单状态 请求参数
@@ -20,9 +21,13 @@ public class HtCrawlerOrderStateRequest implements Serializable {
         this.quotationNo = quotationRelaNo;
         this.comcode = parameters.getComCode();
     }
-
+    private String telemarketnum = "";
     private String telemarketFlag = "0";
-    private String renewalTwoSwitch = "1";
+    private String renewalTwoSwitch = "";
+    private String insuredName = "";
+    private String certiCode = "";
+    private String flag = "";
+    private String status = "";
     /**
      * 报价单号
      */
@@ -30,20 +35,20 @@ public class HtCrawlerOrderStateRequest implements Serializable {
     /**
      * 车牌号
      */
-    private String licensePlateNo;
+    private String licensePlateNo = "";
     /**
      * 开始时间
      */
-    private String createDate1;
+    private String createDate1 = LocalDate.now().minusDays(30).toString();
     /**
      * 结束时间
      */
-    private String createDate2;
+    private String createDate2 = LocalDate.now().toString();
     private String comcode;
     /**
      * 出单系统:集成
      */
-    private String Single_system = "8";
+    private String Single_system = "10000";
     /**
      * 状态:有效
      */
@@ -56,10 +61,12 @@ public class HtCrawlerOrderStateRequest implements Serializable {
      * 业务类型:全部
      */
     private String businesstype = "0";
-    private String iFlag = "3";
-    private Integer VENUS_PAGE_NO_KEY = 1;
-    private Integer VENUS_PAGE_COUNT_KEY = 1;
-    private Integer VENUS_PAGE_SIZE_KEY = 15;
-    private Integer VENUS_PAGE_NO_KEY_INPUT = 1;
+    private String agentno_fdl = "";
+    private String agentno_dl = "";
+    private String iFlag = "2";
+    private String VENUS_PAGE_NO_KEY = "1";
+    private String VENUS_PAGE_COUNT_KEY = "476";
+    private String VENUS_PAGE_SIZE_KEY = "15";
+    private String VENUS_PAGE_NO_KEY_INPUT = "1";
 
 }

+ 21 - 15
tenant/insurance/quotation-huatai/src/main/java/com/jzg/quotation/huatai/crawler/service/Impl/HuaTaiCrawlerRequestImpl.java

@@ -233,7 +233,7 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
             pre = prepareQuote(attr, mmap, car, modelcodexh, cookie, quotationNo, xbResult);
         } catch (Exception e) {
             log.error("报价失败:保存车辆信息、过滤车型异常,{}",e.getMessage());
-            return quoteResultsVo;
+            throw new SystemException(e.getMessage());
         }
         // 报价
         CoreResult core = null;
@@ -241,7 +241,7 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
             core = executeQuote(quoteVo, quotationNo, dto, cookie, pre, gsInfo, attr);
         } catch (Exception e) {
             log.error("报价失败,{}",e.getMessage());
-            return quoteResultsVo;
+            throw new SystemException(e.getMessage());
         }
         if (!core.success()) return quoteResultsVo;
         // 保存订单到MongoDB
@@ -470,9 +470,9 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
                     // 累加计数,超过次数则抛出异常
                     if (retryCount.incrementAndGet() >= MAX_RETRY_TIMES) {
                         if(e.getMessage().contains("上传的行业车型编码不在平台车型范围内,请核实。")) {
-                            throw new SystemException("报价重试次数已达上限(" + MAX_RETRY_TIMES + "次),车型匹配失败。上传的行业车型编码不在平台车型范围内,请核实。", e.getMessage());
+                            throw new SystemException("上传的行业车型编码不在平台车型范围内,请核实。");
                         }else {
-                            throw new SystemException("报价重试次数已达上限(" + MAX_RETRY_TIMES + "次),车型匹配失败。" + e.getMessage());
+                            throw new SystemException(e.getMessage());
                         }
                     }
                     // 提取新的modelcodexh并重新执行预处理
@@ -480,7 +480,7 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
                     continue; // 继续下一次循环
                 }
                 // 非车型匹配异常,直接抛出
-                throw e;
+                throw new SystemException(e.getMessage());
             }
             // 无有效数据且未触发异常时,累加计数
             retryCount.incrementAndGet();
@@ -994,6 +994,7 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
         String body = post(BASE_URL + "/htcsp/DocumentPrintAction.do?cmd=electronicPolicyEndorseDownload",
                 buildDocumentHeaders(req.getCookie()), fd);
         HtCrawlerDownloadPolicyResponse res = JSONObject.parseObject(body, HtCrawlerDownloadPolicyResponse.class);
+        log.info("下载保单响应结果,{}", JSONObject.toJSONString(res));
         DownloadPolicyResultVo r = new DownloadPolicyResultVo();
         for (var ftp : res.getFtpdownloadJson()) {
             if (jq) { r.setJqUrl(ftp.getDownurl()); r.setJqFlagUrl(ftp.getBzdownurl()); }
@@ -1010,16 +1011,21 @@ public class HuaTaiCrawlerRequestImpl implements HuaTaiCrawlerRequest {
         HtCrawlerConfigureParameters params = ConfigureParametersConversion.conversionEntity(
                 HtCrawlerConfigureParameters.class, attr.getConfigInfo());
         HtCrawlerOrder order = orderService.findByOrdersNo(vo.getOrder().getOrdersNo());
-        String html = req.queryOrderStatus(new HtCrawlerOrderStateRequest(params, order.getQuotationRelaNo()), req.getHeaders());
-        Document doc = Jsoup.parse(html);
-        Elements tds = doc.select("table[id='table'] tbody tr td");
-        // TODO: 完善字段映射
-        tds.get(1).firstElementChild().text(); // 客户名称
-        tds.get(2).firstElementChild().text(); // 保险起保日期
-        tds.get(3).firstElementChild().text(); // 车牌号
-        tds.get(4).firstElementChild().text(); // 报价单创建日期
-        tds.get(7).firstElementChild().text(); // 订单状态
-        return null;
+        String orderStatus = req.queryOrderStatus(new HtCrawlerOrderStateRequest(params, order.getQuotationRelaNo()), req.getHeaders());
+        String regex = "<div style=\"display: inline-block;width:50px;text-align: center; \">(.*?)</div>";
+        Pattern pattern = Pattern.compile(regex);
+        Matcher matcher = pattern.matcher(orderStatus);
+        if (matcher.find()) orderStatus = matcher.group(1);
+        InsOrderStatusEnum orderStatusEnum = null;
+        if ("已通过核保已实收".equals(orderStatus)) {
+            orderStatusEnum = InsOrderStatusEnum.valueOf("QUOTE_ING");
+            orderStatus = orderStatusEnum.getCode();
+        }
+        OrderStatusResultVo orderStatusResultVo = new OrderStatusResultVo();
+        //将订单状态转换为枚举类型
+        orderStatusResultVo.setOrderStatus(orderStatusEnum);
+        orderStatusResultVo.setOrderStatusStr(orderStatus);
+        return orderStatusResultVo;
     }
 
     // ====================== Headers 统一构建 ======================

+ 6 - 6
tenant/insurance/quotation-renbaonew/src/main/java/com/jzg/quotation/renbaonew/crawler/service/impl/RenBaoNewCrawlerRequestBuilder.java

@@ -2568,19 +2568,19 @@ public class RenBaoNewCrawlerRequestBuilder {
                 }
             } else if ("TY1".equals(zgKindCode)) {
                 // 附加增值服务特约条款(道路救援服务)
-                if (serviceTimes != null) {
-                    kind.put("quantity", serviceTimes);
+                if (!amountStr.isEmpty()) {
+                    kind.put("quantity", amountStr);
                 }
             } else if ("TY2".equals(zgKindCode)) {
                 // 附加增值服务特约条款(车辆安全检测)
-                if (serviceTimes != null) {
-                    List<Map<String, Object>> safeCheckItemList = buildSafeCheckItemList(serviceTimes);
+                if (!amountStr.isEmpty()) {
+                    List<Map<String, Object>> safeCheckItemList = buildSafeCheckItemList(amountStr);
                     kind.put("safeCheckItemList", safeCheckItemList);
                 }
             } else if ("TY3".equals(zgKindCode) || "TY4".equals(zgKindCode)) {
                 // 附加增值服务特约条款(代为驾驶服务)
-                if (serviceTimes != null) {
-                    kind.put("quantity", serviceTimes);
+                if (!amountStr.isEmpty()) {
+                    kind.put("quantity", amountStr);
                 }
             }  else if ("MJ1".equals(zgKindCode) || "MJ2".equals(zgKindCode) ||
                     "MJ3".equals(zgKindCode) || "MJ4".equals(zgKindCode)){

+ 24 - 11
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsFeeOrdersServiceImpl.java

@@ -153,19 +153,19 @@ public class InsFeeOrdersServiceImpl extends ServiceImpl<InsFeeOrdersMapper, Ins
         // 1. 交强险
         calculatePremiumByRule(insFeeOrders, "jq", jqPremium,
                 insFeeOrders.getJqCommissionRatio(), insFeeOrders.getJqInletRatio(), insFeeOrders.getJqFollowRatio(),
-                insFeeOrders.getJqAdditionalRatio(), insFeeOrders.getJqKeepPointRatio(), insFeeOrders.getJqExportRatio(), insFeeOrders.getJqExportKeepPointRatio(),
+                insFeeOrders.getJqAdditionalRatio(), insFeeOrders.getJqKeepPointRatio(), insFeeOrders.getJqExportRatio(), insFeeOrders.getJqExportKeepPointRatio(),insFeeOrders.getJqExportRatioContainDistribution(),
                 withTax, taxRate, SCALE);
 
         // 2. 商业险
         calculatePremiumByRule(insFeeOrders, "sy", syPremium,
                 insFeeOrders.getSyCommissionRatio(), insFeeOrders.getSyInletRatio(), insFeeOrders.getSyFollowRatio(),
-                insFeeOrders.getSyAdditionalRatio(), insFeeOrders.getSyKeepPointRatio(), insFeeOrders.getSyExportRatio(), insFeeOrders.getSyExportKeepPointRatio(),
+                insFeeOrders.getSyAdditionalRatio(), insFeeOrders.getSyKeepPointRatio(), insFeeOrders.getSyExportRatio(), insFeeOrders.getSyExportKeepPointRatio(),insFeeOrders.getSyExportRatioContainDistribution(),
                 withTax, taxRate, SCALE);
 
         // 3. 驾乘险
         calculatePremiumByRule(insFeeOrders, "jy", jyPremium,
                 insFeeOrders.getJyCommissionRatio(), insFeeOrders.getJyInletRatio(), insFeeOrders.getJyFollowRatio(),
-                insFeeOrders.getJyAdditionalRatio(), insFeeOrders.getJyKeepPointRatio(), insFeeOrders.getJyExportRatio(), insFeeOrders.getJyExportKeepPointRatio(),
+                insFeeOrders.getJyAdditionalRatio(), insFeeOrders.getJyKeepPointRatio(), insFeeOrders.getJyExportRatio(), insFeeOrders.getJyExportKeepPointRatio(),insFeeOrders.getJyExportRatioContainDistribution(),
                 withTax, taxRate, SCALE);
 
         // 重新统计总应收、总应付
@@ -203,7 +203,7 @@ public class InsFeeOrdersServiceImpl extends ServiceImpl<InsFeeOrdersMapper, Ins
             InsFeeOrders insFeeOrders, String type,
             BigDecimal premium,
             BigDecimal commissionRatio, BigDecimal inletRatio, BigDecimal followRatio,
-            BigDecimal addThrowRatio, BigDecimal keepPointRatio, BigDecimal exportRatio, BigDecimal exportKeepPointRatio,
+            BigDecimal addThrowRatio, BigDecimal keepPointRatio, BigDecimal exportRatio, BigDecimal exportKeepPointRatio, BigDecimal exportRatioContainDistribution,
             Integer withTax, BigDecimal taxRate, int scale) {
 
         // 计算基数
@@ -224,12 +224,19 @@ public class InsFeeOrdersServiceImpl extends ServiceImpl<InsFeeOrdersMapper, Ins
         // 加投直接乘
         BigDecimal addThrow = premium.multiply(addThrowRatio).setScale(scale, RoundingMode.HALF_EVEN);
         // 出口直接乘
-        BigDecimal export = premium.multiply(exportRatio).setScale(scale, RoundingMode.HALF_EVEN);
-        BigDecimal exportKeepPoint = premium.multiply(exportKeepPointRatio).setScale(scale, RoundingMode.HALF_EVEN);
+        BigDecimal export = premium.multiply(exportRatio).setScale(scale, RoundingMode.DOWN);
+        BigDecimal exportKeepPoint = premium.multiply(exportKeepPointRatio).setScale(scale, RoundingMode.DOWN);
         // 留点比例直接乘, modify by lipf ,留点比例在infFeeOrder中计算得到。这里直接使用 2026年6月16日17:32:09, 为了保持金额一致,留点比例不适用百分比乘积,而是使用金额相减
         // BigDecimal keepPoint = premium.multiply(keepPointRatio).setScale(scale, RoundingMode.HALF_EVEN);
-        BigDecimal keepPoint = BigDecimalUtil.subtract(BigDecimalUtil.add(inlet,addThrow),export);
-        log.info("计算留点:inlet=[{}],addThrow=[{}].export=[{}]", inlet, addThrow, export);
+        //BigDecimal keepPoint = BigDecimalUtil.subtract(BigDecimalUtil.add(inlet,addThrow),export);
+        // modify by lipf 2026年7月1日10:07:18 计算留点的时候,将分销费用移除
+//        BigDecimal distributionFee = BigDecimalUtil.add(insFeeOrders.getFirstDistributionFee(), insFeeOrders.getSecondDistributionFee(), insFeeOrders.getThirdDistributionFee());
+//        log.info("分销总费用:distributionFee=【{}】",distributionFee);
+//        BigDecimal keepPoint = BigDecimalUtil.subtract(BigDecimalUtil.add(inlet,addThrow),BigDecimalUtil.add(export, distributionFee));
+//        log.info("留点费用:inlet=[{}],addThrow=[{}],export=[{}], distributionFee=[{}]mkeepPoint=[{}]", inlet, addThrow, export, distributionFee, keepPoint);
+        BigDecimal exportContainDistribute = premium.multiply(exportRatioContainDistribution).setScale(scale, RoundingMode.HALF_DOWN);
+        BigDecimal keepPoint = BigDecimalUtil.subtract(BigDecimalUtil.add(inlet,addThrow),exportContainDistribute);
+        log.info("计算留点:inlet=[{}],addThrow=[{}].exportContainDistribute=[{}]", inlet, addThrow, exportContainDistribute);
 
         // 赋值到实体(自动匹配 jq / sy / jy)
         if ("jq".equals(type)) {
@@ -432,9 +439,15 @@ public class InsFeeOrdersServiceImpl extends ServiceImpl<InsFeeOrdersMapper, Ins
         insFeeOrders.setSyExportRatio(syExportRatio);
         insFeeOrders.setJyExportRatio(jyExportRatio);
         // 需求:入口 + 加投 - 出口 = 留点
-        BigDecimal jqKeepPointRatio = (jqInletRatio.divide(taxFactor, 5, RoundingMode.HALF_EVEN)).add(jqAdditionalRatio).subtract(jqExportRatio);
-        BigDecimal syKeepPointRatio = (syInletRatio.divide(taxFactor, 5, RoundingMode.HALF_EVEN)).add(syAdditionalRatio).subtract(syExportRatio);
-        BigDecimal jyKeepPointRatio = (jyInletRatio.divide(taxFactor, 5, RoundingMode.HALF_EVEN)).add(jyAdditionalRatio).subtract(jyExportRatio);
+        BigDecimal distributionRatio = BigDecimalUtil.divide(BigDecimalUtil.add(insFeeOrders.getFirstDistributionRatio(), insFeeOrders.getSecondDistributionRatio(), insFeeOrders.getThirdDistributionRatio()),new BigDecimal(100));
+        insFeeOrders.setJqExportRatioContainDistribution(BigDecimalUtil.add(jqExportRatio,distributionRatio));
+        insFeeOrders.setSyExportRatioContainDistribution(BigDecimalUtil.add(syExportRatio,distributionRatio) );
+        insFeeOrders.setJyExportRatioContainDistribution(BigDecimalUtil.add(jyExportRatio,distributionRatio) );
+        BigDecimal jqKeepPointRatio = (jqInletRatio.divide(taxFactor, 5, RoundingMode.HALF_EVEN)).add(jqAdditionalRatio).subtract(BigDecimalUtil.add(jqExportRatio,distributionRatio));
+        log.info("计算留点比例。 distributionRatio=[{}],jqInletRatio=[{}],jqAdditionalRatio=[{}],jqExportRatio=[{}]", distributionRatio,jqInletRatio,jqAdditionalRatio,jqExportRatio);
+
+        BigDecimal syKeepPointRatio = (syInletRatio.divide(taxFactor, 5, RoundingMode.HALF_EVEN)).add(syAdditionalRatio).subtract(BigDecimalUtil.add(jqExportRatio,syExportRatio));
+        BigDecimal jyKeepPointRatio = (jyInletRatio.divide(taxFactor, 5, RoundingMode.HALF_EVEN)).add(jyAdditionalRatio).subtract(BigDecimalUtil.add(jqExportRatio,jyExportRatio));
         // 留点比例
         insFeeOrders.setJqKeepPointRatio(jqKeepPointRatio);
         insFeeOrders.setSyKeepPointRatio(syKeepPointRatio);

+ 61 - 10
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsOrdersServiceImpl.java

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

+ 4 - 1
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementServiceImpl.java

@@ -173,6 +173,9 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
             log.info("协议id不存在:id=[{}]",id);
             throw new SystemException("协议id不存在!id=" + id);
         }
+        if (Objects.isNull(agreementVo.getUsername())){
+            agreementVo.setUsername("");
+        }
         return agreementVo;
     }
 
@@ -228,7 +231,7 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
 
 
     @Override
-    @GlobalTransactional(rollbackFor = Exception.class)
+//    @GlobalTransactional(rollbackFor = Exception.class)
     public void agreementAdd(AgreementAddParam param) {
         PtlAgreement ptlAgreement = new PtlAgreement();
         BeanUtils.copyProperties(param,ptlAgreement);

+ 1 - 1
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlSchemeServiceImpl.java

@@ -588,7 +588,7 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
         //过滤 能源类型 使用性质 车辆种类
         List<PtlScheme> ptlSchemes = ptlSchemeMapper.selectList(new LambdaQueryWrapper<PtlScheme>().
                 eq(PtlScheme::getCompanyId, companyId).eq(PtlScheme::getEnergyType, energyType).
-                like(PtlScheme::getCarnature, carnature).like(PtlScheme::getVehicleType, vehicleType).
+                eq(PtlScheme::getCarnature, carnature).eq(PtlScheme::getVehicleType, vehicleType).
                 eq(PtlScheme::getProductId, productId).eq(PtlScheme::getIsDelete, 0));
         Map<String, PtlScheme> collectPtlSchemes = ptlSchemes.stream().collect(Collectors.toMap(PtlScheme::getId, Function.identity()));
         AssertionUtils.isFail(collectPtlSchemes.isEmpty(), "没有可报价的方案配置信息");

+ 136 - 35
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -729,19 +729,79 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
     public List<FollowCompanyFeeVO> followCompanySuperviseSettlementReport(SettlementReportQueryVo settlementReportQueryVo) {
         log.info("私有协议-跟单结算记录-结算报表: settlementReportQueryVo=[{}]", JSONUtil.toJsonStr(settlementReportQueryVo));
 
+        // 返回值
+        List<FollowCompanyFeeVO> resultList = CollUtil.newArrayList();
+
         List<FollowCompanyFeeVO> followCompanyFeeVos = insFeeFollowOrderMapper.selectFollowCompanySettlementReport(settlementReportQueryVo);
         // 查询所有保险公司,匹配保险公司的id和名称
         HttpResult<Map<String, EsmInsCompany>> mapHttpResult = esmInsCompanyClient.queryAllCompanyMap();
         Map<String, EsmInsCompany> data = mapHttpResult.getData();
-        if (CollUtil.isEmpty(data)){
-            return followCompanyFeeVos;
+        if (CollUtil.isEmpty(data) || CollUtil.isEmpty(followCompanyFeeVos)){
+            return resultList;
         }
-        for (FollowCompanyFeeVO followCompanyFeeVo : followCompanyFeeVos) {
-            followCompanyFeeVo.setCompanyName(null != data.get(followCompanyFeeVo.getPartnerCompanyId()) ? data.get(followCompanyFeeVo.getPartnerCompanyId()).getName() : "");
-            followCompanyFeeVo.setTotalUnSettlementAmount(followCompanyFeeVo.getTotalInvoiced().subtract(followCompanyFeeVo.getTotalSettlementAmount()));
-            followCompanyFeeVo.setTotalUnInvoiced(followCompanyFeeVo.getTotalReceivable().subtract(followCompanyFeeVo.getTotalInvoiced()));
+
+        // 根据分支公司分组
+        Map<String, List<FollowCompanyFeeVO>> followMap = followCompanyFeeVos.stream().collect(Collectors.groupingBy(follow -> follow.getPartnerCompanyId() + "_" + follow.getYear() + "_" + follow.getMonth()));
+        for (Map.Entry<String, List<FollowCompanyFeeVO>> entry : followMap.entrySet()) {
+            // key = 合作公司ID
+            String key = entry.getKey();
+
+            // 分组参数
+            String[] arr = key.split("_");
+            String partnerCompanyId = arr[0];
+            String year = arr[1];
+            String month = arr[2];
+
+
+            // value = 当前公司下所有VO集合
+            List<FollowCompanyFeeVO> voList = entry.getValue();
+
+            // 返回值
+            FollowCompanyFeeVO followCompanyFeeVO = new FollowCompanyFeeVO();
+            followCompanyFeeVO.setPartnerCompanyId(partnerCompanyId);
+
+            List<String> followIds = voList.stream().map(FollowCompanyFeeVO::getFollowId).toList();
+            List<String> invoiceIds = voList.stream().map(FollowCompanyFeeVO::getInvoiceId).toList();
+            List<String> settlementIds = voList.stream().map(FollowCompanyFeeVO::getSettlementId).toList();
+
+            // 根据所有followCompanyFeeVos的followId统计出已开票
+            LambdaQueryWrapper<InsFeeFollowOrder> insFeeFollowOrderLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            insFeeFollowOrderLambdaQueryWrapper.in(InsFeeFollowOrder::getId, followIds);
+            List<InsFeeFollowOrder> insFeeFollowOrders = insFeeFollowOrderMapper.selectList(insFeeFollowOrderLambdaQueryWrapper);
+            // 总金额
+            InsFeeFollowOrder feeFollowOrder = CollUtil.getFirst(insFeeFollowOrders);
+            // 取对账金额
+            BigDecimal receivablePremium = feeFollowOrder.getReconciliationAmount();
+            followCompanyFeeVO.setTotalReceivable(receivablePremium);
+
+            BigDecimal totalInvoiced = insFeeFollowOrders.stream().map(InsFeeFollowOrder::getInvoiced).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
+            // 已开票总金额
+            followCompanyFeeVO.setTotalInvoiced(totalInvoiced);
+
+            // 未结算金额
+            followCompanyFeeVO.setTotalUnInvoiced(receivablePremium.subtract(totalInvoiced));
+
+            // 统计结算金额
+            LambdaQueryWrapper<InsPlyIncomeInvoiceSettlement> insPlyIncomeInvoiceSettlementLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            insPlyIncomeInvoiceSettlementLambdaQueryWrapper.in(InsPlyIncomeInvoiceSettlement::getId, settlementIds);
+            List<InsPlyIncomeInvoiceSettlement> insPlyIncomeInvoiceSettlements = insPlyIncomeInvoiceSettlementMapper.selectList(insPlyIncomeInvoiceSettlementLambdaQueryWrapper);
+            BigDecimal totalSettlementAmount = insPlyIncomeInvoiceSettlements.stream().map(InsPlyIncomeInvoiceSettlement::getActualReceivedAmount).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
+            // 已结算总金额
+            followCompanyFeeVO.setTotalSettlementAmount(totalSettlementAmount);
+
+            // 未结算金额
+            followCompanyFeeVO.setTotalUnSettlementAmount(totalInvoiced.subtract(totalSettlementAmount));
+            followCompanyFeeVO.setCompanyName(null != data.get(partnerCompanyId) ? data.get(partnerCompanyId).getName() : "");
+
+            resultList.add(followCompanyFeeVO);
         }
-        return followCompanyFeeVos;
+
+//        for (FollowCompanyFeeVO followCompanyFeeVo : followCompanyFeeVos) {
+//            followCompanyFeeVo.setCompanyName(null != data.get(followCompanyFeeVo.getPartnerCompanyId()) ? data.get(followCompanyFeeVo.getPartnerCompanyId()).getName() : "");
+//            followCompanyFeeVo.setTotalUnSettlementAmount(followCompanyFeeVo.getTotalInvoiced().subtract(followCompanyFeeVo.getTotalSettlementAmount()));
+//            followCompanyFeeVo.setTotalUnInvoiced(followCompanyFeeVo.getTotalReceivable().subtract(followCompanyFeeVo.getTotalInvoiced()));
+//        }
+        return resultList;
     }
 
     /**
@@ -3289,7 +3349,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         // 设置应收
         updateIncome.setJqReceivablePremium(jqInletPremium.toString());
         updateIncome.setSyReceivablePremium(syInletPremium.toString());
-        updateIncome.setJyReceivablePremium(jyPremium.toString());
+        updateIncome.setJyReceivablePremium(jyInletPremium.toString());
 
         // 设置手续费比例
         updateIncome.setJqSuperviseCostsProportion(BigDecimalUtil.toString(ratioVo.getJqCommissionRatio()));
@@ -4042,6 +4102,10 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                         .map(InsPlyIncomeInvoiceSettlement::getActualReceivedAmount)
                         .filter(Objects::nonNull)
                         .reduce(BigDecimal.ZERO, BigDecimal::add);
+                BigDecimal settlementPaymentDifference = insPlyIncomeInvoiceSettlements.stream()
+                        .map(InsPlyIncomeInvoiceSettlement::getSettlementPaymentDifference)
+                        .filter(Objects::nonNull)
+                        .reduce(BigDecimal.ZERO, BigDecimal::add);
                 BigDecimal receivableSupervisePremium = action.getReceivableSupervisePremium()  != null ? action.getReceivableSupervisePremium(): BigDecimal.ZERO;
 //                BigDecimal overinflatedAmount = action.getOverinflatedAmount() != null? action.getOverinflatedAmount(): BigDecimal.ZERO;
                 // 待结算金额 = 开票金额 - 已收金额
@@ -4052,6 +4116,9 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 action.setRemainSettlementAmount(remainSettlementAmount);
                 action.setCompanyAllName(allCompanyHierarchyPaths.get(Objects.toString(action.getCompanyId(),"")));
                 action.setSettlementStatus(settlementStatusName);
+                // 回款差额
+                action.setSettlementPaymentDifference(settlementPaymentDifference);
+
                 if ("2".equals(invoiceRecordQueryVo.getInvoiceType())) {
                     LambdaQueryWrapper<InsFeeFollowOrder> insFeeFollowOrderLambdaQueryWrapper = new LambdaQueryWrapper<>();
                     insFeeFollowOrderLambdaQueryWrapper.eq(InsFeeFollowOrder::getYear, action.getYear());
@@ -4412,18 +4479,60 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         }else{
             exportSuperviseSettlementDetailExcelDtos = baseMapper.getSuperviseSettlementDetailExcelDtos(page, settlementQueryVo);
         }
-        exportSuperviseSettlementDetailExcelDtos.getRecords().forEach(dto -> {
-            if (dto.getInvoiceParty().equals("1")) {
-                dto.setInvoiceParty("我方开票");
-            } else if (dto.getInvoiceParty().equals("2")) {
-                dto.setInvoiceParty("保司开票");
-            }
-            if (dto.getStatus().equals("1")) {
-                dto.setStatus("已结算");
-            } else if (dto.getStatus().equals("0")) {
-                dto.setStatus("未结算");
+        if (CollUtil.isNotEmpty(exportSuperviseSettlementDetailExcelDtos.getRecords())){
+            Map<String, InsPlyIncomeInvoiceSettlement> settlementMap = new HashMap<>();
+            if (!(settlementQueryVo.getInvoiceTypes().contains("5") && settlementQueryVo.getInvoiceTypes().contains("6"))) {
+                // 根据invoiceId关联查询ins_ply_income_invoice_settlement表
+                LambdaQueryWrapper<InsPlyIncomeInvoiceSettlement> insPlyIncomeInvoiceSettlementLambdaQueryWrapper = new LambdaQueryWrapper<>();
+                insPlyIncomeInvoiceSettlementLambdaQueryWrapper.in(InsPlyIncomeInvoiceSettlement::getInvoiceId, exportSuperviseSettlementDetailExcelDtos.getRecords().stream().map(ExportSuperviseSettlementDetailExcelDto::getInvoiceId).toList());
+                insPlyIncomeInvoiceSettlementLambdaQueryWrapper.eq(InsPlyIncomeInvoiceSettlement::getIsDelete, 0);
+                if (StrUtil.isNotBlank(settlementQueryVo.getSettlementPerson())) {
+                    // 结算人
+                    insPlyIncomeInvoiceSettlementLambdaQueryWrapper.eq(InsPlyIncomeInvoiceSettlement::getCreateBy, settlementQueryVo.getSettlementPerson());
+                }
+                if (StrUtil.isNotBlank(settlementQueryVo.getSettlementTimeStart()) && StrUtil.isNotBlank(settlementQueryVo.getSettlementTimeEnd())) {
+                    // 结算时间
+                    insPlyIncomeInvoiceSettlementLambdaQueryWrapper.between(StrUtil.isNotBlank(settlementQueryVo.getSettlementTimeStart()) && StrUtil.isNotBlank(settlementQueryVo.getSettlementTimeEnd()),
+                            InsPlyIncomeInvoiceSettlement::getCreateTime, settlementQueryVo.getSettlementTimeStart(), settlementQueryVo.getSettlementTimeEnd());
+                }
+                List<InsPlyIncomeInvoiceSettlement> insPlyIncomeInvoiceSettlements = insPlyIncomeInvoiceSettlementMapper.selectList(insPlyIncomeInvoiceSettlementLambdaQueryWrapper);
+                // 如果结算记录不为空,且结算人、结算时间不为空,则根据结算记录的invoiceId过滤列表
+                if (CollUtil.isNotEmpty(insPlyIncomeInvoiceSettlements)) {
+                    if (StrUtil.isNotBlank(settlementQueryVo.getSettlementPerson()) || (StrUtil.isNotBlank(settlementQueryVo.getSettlementTimeStart()) && StrUtil.isNotBlank(settlementQueryVo.getSettlementTimeEnd()))) {
+                        List<String> invoiceList = insPlyIncomeInvoiceSettlements.stream().map(InsPlyIncomeInvoiceSettlement::getInvoiceId).toList();
+                        // filter:lambda 返回 true 的元素留下,false 的剔除
+                        exportSuperviseSettlementDetailExcelDtos.setRecords(exportSuperviseSettlementDetailExcelDtos.getRecords().stream().filter(detail -> invoiceList.contains(detail.getInvoiceId())).toList());
+                    }
+
+                    // 冲突时保留旧值(第一条)
+                    settlementMap = insPlyIncomeInvoiceSettlements.stream()
+                            .collect(Collectors.toMap(
+                                    InsPlyIncomeInvoiceSettlement::getInvoiceId,
+                                    Function.identity(),
+                                    (oldVal, newVal) -> oldVal
+                            ));
+                }
             }
-        });
+
+            final Map<String, InsPlyIncomeInvoiceSettlement> finalSettlementMap = settlementMap;
+            exportSuperviseSettlementDetailExcelDtos.getRecords().forEach(dto -> {
+                if (dto.getInvoiceParty().equals("1")) {
+                    dto.setInvoiceParty("我方开票");
+                } else if (dto.getInvoiceParty().equals("2")) {
+                    dto.setInvoiceParty("保司开票");
+                }
+                if (dto.getStatus().equals("1")) {
+                    dto.setStatus("已结算");
+                } else if (dto.getStatus().equals("0")) {
+                    dto.setStatus("未结算");
+                }
+                InsPlyIncomeInvoiceSettlement insPlyIncomeInvoiceSettlement = finalSettlementMap.get(dto.getInvoiceId());
+                if (null != insPlyIncomeInvoiceSettlement){
+                    dto.setSettlementPerson(insPlyIncomeInvoiceSettlement.getCreateBy());
+                    dto.setSettlementTime(insPlyIncomeInvoiceSettlement.getCreateTime());
+                }
+            });
+        }
         return exportSuperviseSettlementDetailExcelDtos;
     }
 
@@ -4643,22 +4752,14 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
     public void exportOtherSettlementExcel(Page page, SettlementQueryVo settlementQueryVo) throws IOException {
         verifyUploadPath();
         settlementQueryVo.setSystemCode(baseController.getSystemCode());
-        Page<ExportOtherSettlementExcelDto> exportOtherSettlementExcelDtos = baseMapper.getOtherSettlementExcelDtos(page, settlementQueryVo);
-        exportOtherSettlementExcelDtos.getRecords().forEach(dto -> {
-            if (dto.getInvoiceParty().equals("1")) {
-                dto.setInvoiceParty("我方开票");
-            } else if (dto.getInvoiceParty().equals("2")) {
-                dto.setInvoiceParty("保司开票");
-            }
-            switch (dto.getInvoiceType()) {
-                case "1" -> dto.setInvoiceType("手续费");
-                case "2" -> dto.setInvoiceType("跟单费");
-                case "3" -> dto.setInvoiceType("驾意险手续费");
-                case "4" -> dto.setInvoiceType("驾意险跟单费");
-            }
-        });
-        List<ExportOtherSettlementExcelDto> list = exportOtherSettlementExcelDtos.getRecords();
-        EasyExcelUtils.exportForWeb(ServletUtils.getResponse(), ExportOtherSettlementExcelDto.class, list, "车险跟单费结算记录");
+        log.info("查询平台结算记录:settlementQueryVo=[{}]", JSONUtil.toJsonStr(settlementQueryVo));
+        // 设置空条件
+        setNoneCondition(settlementQueryVo);
+        settlementQueryVo.setSystemCode(baseController.getSystemCode());
+        Page<ExportSuperviseSettlementExcelDto> exportSuperviseSettlementExcelDtos = baseMapper.followSettlementExcelDtos(page, settlementQueryVo);
+        // 补充、转换列表的数据
+        supplementaryListData(exportSuperviseSettlementExcelDtos);
+        EasyExcelUtils.exportForWeb(ServletUtils.getResponse(), ExportSuperviseSettlementExcelDto.class, exportSuperviseSettlementExcelDtos.getRecords(), "车险跟单费结算记录");
     }
 
     /**

+ 5 - 4
tenant/organization/src/main/resources/mapper/InsFeeFollowOrderMapper.xml

@@ -48,9 +48,11 @@
     <select id="selectFollowCompanySettlementReport" resultType="com.jzg.commons.entity.finance.vo.FollowCompanyFeeVO">
         SELECT
         ffo.partner_company_id AS partnerCompanyId,
-        SUM(COALESCE(ffo.invoiced, 0.00)) AS totalInvoiced,
-        SUM(COALESCE(sett.actual_received_amount, 0.00)) AS totalSettlementAmount,
-        MAX(COALESCE(ffo.reconciliation_amount, 0.00)) AS totalReceivable
+        ffo.id AS followId,
+        ffo.year,
+        ffo.month,
+        inv.id AS invoiceId,
+        sett.id AS settlementId
         FROM ins_fee_follow_order ffo
         -- 跟单订单关联发票中间表
         INNER JOIN ins_ply_follow_invoice_link link
@@ -84,7 +86,6 @@
                 AND sett.create_time BETWEEN #{query.settlementStartTime} AND #{query.settlementEndTime}
             </if>
         </where>
-        GROUP BY ffo.partner_company_id
     </select>
 
 

+ 20 - 14
tenant/organization/src/main/resources/mapper/PtlAgreementMapper.xml

@@ -62,6 +62,25 @@
         pa.api_type,pa.jq_entrance_fee_ratio,pa.sy_entrance_fee_ratio,pa.jy_entrance_fee_ratio
     </sql>
     <select id="queryPage" resultType="com.jzg.commons.entity.vo.AgreementVo">
+        WITH RECURSIVE t AS (
+        SELECT
+        id,
+        CAST(id AS CHAR) COLLATE utf8mb4_general_ci AS str_id
+        FROM
+        esm_ins_company
+        WHERE
+        id = #{param.companyId}
+        AND is_delete = 0
+        AND parent_id = 0 UNION ALL
+        SELECT
+        c.id,
+        CAST(c.id AS CHAR) COLLATE utf8mb4_general_ci AS str_id
+        FROM
+        esm_ins_company c
+        JOIN t ON c.parent_id = t.id
+        WHERE
+        c.is_delete = 0
+        )
         select <include refid="Base_Column_List"/>
         FROM ptl_agreement pa
         LEFT JOIN ptl_agreement_attribution paa on pa.attribution_id = paa.id AND paa.is_delete = 0
@@ -80,20 +99,7 @@
                 and pa.system_code = #{param.systemCode}
             </if>
             <if test="param.companyId != null and param.companyId != ''">
-                and pa.company_id in (
-                WITH RECURSIVE t AS (
-                SELECT id
-                FROM esm_ins_company
-                WHERE id = #{param.companyId}
-                AND parent_id = 0
-                AND is_delete = 0
-                UNION ALL
-                SELECT c.id
-                FROM esm_ins_company c
-                JOIN t ON c.parent_id = t.id
-                WHERE c.is_delete = 0
-                )
-                SELECT id FROM t)
+                AND pa.company_id IN (SELECT str_id FROM t)
             </if>
             <if test="param.companyIds != null and param.companyIds != ''">
                 and pa.company_id in

+ 12 - 32
tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

@@ -239,6 +239,7 @@
         ipi.jq_other_costs_premiums,
         ipi.sy_other_costs_premiums,
         ipi.jy_other_costs_premiums,
+        COALESCE(ipi.jy_supervise_costs_premiums, 0) + COALESCE(ipi.jy_other_costs_premiums,0) as jyTotalPremiums,
         io.product_name,
         iocui.name AS insuredPerson,
         ipi.jq_premium,
@@ -248,6 +249,7 @@
         ipi.jq_receivable_premium,
         ipi.sy_receivable_premium,
         ipi.jy_receivable_premium,
+
         ipi.jq_supervise_costs_proportion,
         ipi.sy_supervise_costs_proportion,
         ipi.jy_supervise_costs_proportion,
@@ -876,10 +878,9 @@
 
     <select id="getSuperviseSettlementDetailExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportSuperviseSettlementDetailExcelDto">
         select ipi.contact_person, ipi.contact_person_phone,
-        ipiis.id as settlementId,
-        ipiis.invoice_id as invoiceId,
         io.company_name as companyName,
         io.signing_time as signingTime,
+        ipii.id as invoiceId,
         ipii.status as status,
         ipi.license_no as licenseNo,
         io.product_name as productName,
@@ -896,29 +897,14 @@
         ipi.jy_premium as jyPremium,
         ipi.jy_supervise_costs_proportion as jySuperviseCostsProportion,
         ipi.jy_policy_no as jyPolicyNo,
-        ipi.tax_premium as taxPremium,
-        ipii.create_by as invoicePerson,
-        ipii.create_time as invoiceTime,
-        ipiis.create_by as settlementPerson,
-        ipiis.create_time as settlementTime
-        FROM
-        ins_ply_income_invoice ipii
-        LEFT JOIN ins_ply_income_invoice_settlement ipiis ON ipiis.invoice_id = ipii.id AND ipiis.is_delete = 0
-        LEFT JOIN ins_ply_income_invoice_link ipil ON ipil.invoice_id = ipiis.invoice_id AND ipil.is_delete = 0
-        LEFT JOIN ins_ply_income ipi ON ipi.id = ipil.income_id AND ipi.is_delete = 0
-        LEFT JOIN ins_orders io ON ipi.order_no = io.id AND io.is_delete = 0
+        ipi.tax_premium as taxPremium
+        FROM ins_ply_income_invoice ipii
+        LEFT JOIN ins_ply_income_invoice_link ipil ON ipii.id = ipil.invoice_id AND ipil.is_delete = 0
+        LEFT JOIN ins_ply_income ipi ON ipi.id = ipil.income_id  AND ipi.is_delete = 0
+        LEFT JOIN ins_orders io  ON ipi.order_no = io.id  AND io.is_delete = 0
         <where>
             ipii.is_delete = 0
             AND ipii.system_code = #{settlementQueryVo.systemCode}
-            <if test="settlementQueryVo.settlementId != null and settlementQueryVo.settlementId != ''">
-                AND ipiis.id = #{settlementQueryVo.settlementId}
-            </if>
-            <if test="settlementQueryVo.settlementIds != null and settlementQueryVo.settlementIds != ''">
-                AND ipiis.id IN
-                <foreach collection="settlementQueryVo.settlementIds" item="settlementId" open="(" separator="," close=")">
-                    #{settlementId}
-                </foreach>
-            </if>
             <if test="settlementQueryVo.invoiceTypes != null and settlementQueryVo.invoiceTypes != ''">
                 AND ipii.invoice_type IN
                 <foreach collection="settlementQueryVo.invoiceTypes" item="invoiceType" open="(" separator="," close=")">
@@ -926,7 +912,7 @@
                 </foreach>
             </if>
             <if test="settlementQueryVo.invoiceId != null and settlementQueryVo.invoiceId != ''">
-                AND ipiis.invoice_id = #{settlementQueryVo.invoiceId}
+                AND ipii.id = #{settlementQueryVo.invoiceId}
             </if>
             <if test="settlementQueryVo.companyId != null and settlementQueryVo.companyId != ''">
                 AND ipi.company_id = #{settlementQueryVo.companyId}
@@ -934,12 +920,6 @@
             <if test="settlementQueryVo.invoiceParty != null and settlementQueryVo.invoiceParty != ''">
                 AND ipii.invoice_party = #{settlementQueryVo.invoiceParty}
             </if>
-            <if test="settlementQueryVo.settlementPerson != null and settlementQueryVo.settlementPerson != ''">
-                AND ipiis.create_by = #{settlementQueryVo.settlementPerson}
-            </if>
-            <if test="settlementQueryVo.settlementTimeStart != null and settlementQueryVo.settlementTimeStart != ''">
-                AND ipiis.create_time between #{settlementQueryVo.signingTimeStart} and #{settlementQueryVo.signingTimeEnd}
-            </if>
             <if test="settlementQueryVo.agreementType != null and settlementQueryVo.agreementType != ''">
                 AND ipi.agreement_type = #{settlementQueryVo.agreementType}
             </if>
@@ -2100,15 +2080,15 @@
         LEFT JOIN ins_ply_income_invoice_settlement sett ON ipii.id = sett.invoice_id AND sett.is_delete = 0
         left join ins_orders io on ipi.order_no = io.id
         <where>
-            ipi.is_delete = 0
+            ipi.is_delete = 0  and ipi.agreement_type = 1
             <if test="query.companyId != null and query.companyId != ''">
                 AND ipi.company_id = #{query.companyId}
             </if>
             <if test="query.contactPersonPhone != null and query.contactPersonPhone != ''">
-                AND ipii.contact_person_phone LIKE CONCAT('%', #{query.contactPersonPhone}, '%')
+                AND io.docking_person_phone LIKE CONCAT('%', #{query.contactPersonPhone}, '%')
             </if>
             <if test="query.contactPerson != null and query.contactPerson != ''">
-                AND ipii.contact_person LIKE CONCAT('%', #{query.contactPerson}, '%')
+                AND io.docking_person LIKE CONCAT('%', #{query.contactPerson}, '%')
             </if>
             -- 跟单订单创建时间范围
             <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">

+ 1 - 1
tenant/organization/src/main/resources/mapper/SysUserJzgInfoBankCardMapper.xml

@@ -72,7 +72,7 @@
                 and sujibc.audit_status = #{sysUserJzgInfoBankCardVo.auditStatus}
             </if>
             <if test="sysUserJzgInfoBankCardVo.userId != null and sysUserJzgInfoBankCardVo.userId != ''">
-                and su.id = #{sysUserJzgInfoBankCardVo.userId}
+                and sujibc.user_info_id = #{sysUserJzgInfoBankCardVo.userId}
             </if>
         </where>
         order by