Qchen пре 11 месеци
родитељ
комит
2d2db2ad3d
25 измењених фајлова са 859 додато и 352 уклоњено
  1. 3 0
      commons/src/main/java/com/jzg/commons/core/base/PageRequest.java
  2. 7 1
      commons/src/main/java/com/jzg/commons/entity/finance/dto/CompanySuperviseSettlementReportDto.java
  3. 6 0
      commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportOtherSettlementExcelDto.java
  4. 12 0
      commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportSuperviseSettlementDetailExcelDto.java
  5. 6 0
      commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportSuperviseSettlementExcelDto.java
  6. 46 0
      commons/src/main/java/com/jzg/commons/entity/finance/dto/ReceiverSettlementReportDto.java
  7. 6 0
      commons/src/main/java/com/jzg/commons/entity/finance/vo/ReceivableQueryVo.java
  8. 5 1
      commons/src/main/java/com/jzg/commons/entity/finance/vo/SettlementQueryVo.java
  9. 8 1
      commons/src/main/java/com/jzg/commons/entity/finance/vo/SettlementReportQueryVo.java
  10. 26 3
      commons/src/main/java/com/jzg/commons/entity/po/InsFeeOrders.java
  11. 6 0
      commons/src/main/java/com/jzg/commons/entity/vo/IsDeleteVo.java
  12. 1 7
      gateway/src/main/resources/application-dev.yml
  13. 32 5
      tenant/insurance/quotation-commons/src/main/java/com/jzg/quotation/commons/client/OrgClient.java
  14. 101 195
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/aop/aspect/QuoteVerificationAspect.java
  15. 40 0
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/controller/InsFeeOrderController.java
  16. 5 0
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/mapper/InsFeeOrdersMapper.java
  17. 6 0
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/InsFeeOrdersService.java
  18. 10 0
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsFeeOrdersServiceImpl.java
  19. 29 0
      tenant/insurance/quotation-summary/src/main/resources/mapper/InsFeeOrdersMapper.xml
  20. 22 0
      tenant/organization/src/main/java/com/jzg/organization/client/QuoteClient.java
  21. 75 21
      tenant/organization/src/main/java/com/jzg/organization/controller/ReceivableController.java
  22. 16 7
      tenant/organization/src/main/java/com/jzg/organization/mapper/ReceivableMapper.java
  23. 35 12
      tenant/organization/src/main/java/com/jzg/organization/service/ReceivableService.java
  24. 155 43
      tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java
  25. 201 56
      tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

+ 3 - 0
commons/src/main/java/com/jzg/commons/core/base/PageRequest.java

@@ -1,5 +1,6 @@
 package com.jzg.commons.core.base;
 
+import com.alibaba.excel.annotation.ExcelIgnore;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.Data;
 
@@ -9,10 +10,12 @@ public class PageRequest {
     /**
      * 当前页码
      */
+    @ExcelIgnore
     private int pages = 1;
     /**
      * 每页数量
      */
+    @ExcelIgnore
     private int size = 10;
 
 

+ 7 - 1
commons/src/main/java/com/jzg/commons/entity/finance/dto/CompanySuperviseSettlementReportDto.java

@@ -18,12 +18,18 @@ public class CompanySuperviseSettlementReportDto {
     @Schema(description = "保险公司")
     private String companyName;
 
-    @Schema(description = "累计应收")
+    @Schema(description = "累计应收手续费")
     private String totalReceivable;
 
+    @Schema(description = "累计应收跟单费")
+    private String totalFollowFee;
+
     @Schema(description = "应收手续费")
     private String superviseFee;
 
+    @Schema(description = "应收跟单费")
+    private String followFee;
+
     @Schema(description = "已开票金额")
     private String invoicedAmount;
 

+ 6 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportOtherSettlementExcelDto.java

@@ -54,4 +54,10 @@ public class ExportOtherSettlementExcelDto {
     @ExcelProperty(value = "开票记录编号")
     private String invoiceId;
 
+    @Schema(description = "附件id")
+    private String fileId;
+
+    @Schema(description = "附件url")
+    private String fileUrl;
+
 }

+ 12 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportSuperviseSettlementDetailExcelDto.java

@@ -73,6 +73,18 @@ public class ExportSuperviseSettlementDetailExcelDto {
     @ExcelProperty(value = "商业手续费比例")
     private String sySuperviseCostsProportion;
 
+    @Schema(description = "非车保单号")
+    @ExcelProperty(value = "非车保单号")
+    private String jyPolicyNo;
+
+    @Schema(description = "非车保费")
+    @ExcelProperty(value = "非车保费")
+    private String jyPremium;
+
+    @Schema(description = "非车手续费比例")
+    @ExcelProperty(value = "非车手续费比例")
+    private String jySuperviseCostsProportion;
+
     @Schema(description = "车船税")
     @ExcelProperty(value = "车船税")
     private String taxPremium;

+ 6 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/ExportSuperviseSettlementExcelDto.java

@@ -54,4 +54,10 @@ public class ExportSuperviseSettlementExcelDto {
     @ExcelProperty(value = "开票记录编号")
     private String invoiceId;
 
+    @Schema(description = "附件id")
+    private String fileId;
+
+    @Schema(description = "附件url")
+    private String fileUrl;
+
 }

+ 46 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/ReceiverSettlementReportDto.java

@@ -0,0 +1,46 @@
+package com.jzg.commons.entity.finance.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * @author quchen
+ * @date 2025/9/16 10:32
+ */
+
+@Data
+public class ReceiverSettlementReportDto {
+    @Schema(description = "对接人")
+    private String receiver;
+
+    @Schema(description = "保险公司")
+    private String companyName;
+
+    @Schema(description = "应收总计")
+    private String totalReceivable;
+
+    @Schema(description = "应收手续费")
+    private String superviseFee;
+
+    @Schema(description = "应收跟单费")
+    private String followFee;
+
+    @Schema(description = "已结算手续费")
+    private String settledSuperviseFee;
+
+    @Schema(description = "已结算跟单费")
+    private String settledFollowFee;
+
+    @Schema(description = "已结算总计")
+    private String settledAmount;
+
+    @Schema(description = "未结算手续费")
+    private String unSettledSuperviseFee;
+
+    @Schema(description = "未结算跟单费")
+    private String unSettledFollowFee;
+
+
+    @Schema(description = "未结算总计")
+    private String unSettledAmount;
+}

+ 6 - 0
commons/src/main/java/com/jzg/commons/entity/finance/vo/ReceivableQueryVo.java

@@ -26,6 +26,12 @@ public class ReceivableQueryVo extends PageRequest {
     @Schema(description = "协议类型")
     private String agreementType;
 
+    @Schema(description = "id")
+    private String id;
+
+    @Schema(description = "ids")
+    private List<String> ids;
+
     @Schema(description = "查询类型")
     private String queryType;
 

+ 5 - 1
commons/src/main/java/com/jzg/commons/entity/finance/vo/SettlementQueryVo.java

@@ -1,5 +1,6 @@
 package com.jzg.commons.entity.finance.vo;
 
+import com.jzg.commons.core.base.PageRequest;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
@@ -12,7 +13,7 @@ import java.util.List;
 
 @Data
 @Schema(description = "结算记录查询Vo")
-public class SettlementQueryVo {
+public class SettlementQueryVo extends PageRequest {
 
     @Schema(description = "结算记录编号")
     private String settlementId;
@@ -43,4 +44,7 @@ public class SettlementQueryVo {
 
     @Schema(description = "开票类型集合")
     private List<String> invoiceTypes;
+
+    @Schema(description = "协议类型 1-平台协议 2-私有协议")
+    private String agreementType;
 }

+ 8 - 1
commons/src/main/java/com/jzg/commons/entity/finance/vo/SettlementReportQueryVo.java

@@ -1,5 +1,6 @@
 package com.jzg.commons.entity.finance.vo;
 
+import com.jzg.commons.core.base.PageRequest;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
@@ -11,7 +12,7 @@ import java.util.List;
  */
 
 @Data
-public class SettlementReportQueryVo {
+public class SettlementReportQueryVo extends PageRequest {
     @Schema(description = "保险公司id")
     private String companyId;
 
@@ -29,4 +30,10 @@ public class SettlementReportQueryVo {
 
     @Schema(description = "上级公司id")
     private String parentId;
+
+    @Schema(description = "协议类型")
+    private String agreementType;
+
+    @Schema(description = "对接人")
+    private String receiver;
 }

+ 26 - 3
commons/src/main/java/com/jzg/commons/entity/po/InsFeeOrders.java

@@ -1,14 +1,13 @@
 package com.jzg.commons.entity.po;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.jzg.commons.entity.vo.PtlAgreementCostTypeVo;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
 import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.List;
+import java.time.LocalDateTime;
 
 /**
  * @author quchen
@@ -154,4 +153,28 @@ public class InsFeeOrders {
 
     @Schema(description = "驾意险出口比例")
     private BigDecimal jyExportRatio;
+
+    @Schema(description = "一级分销费")
+    private BigDecimal firstDistributionFee;
+
+    @Schema(description = "一级分销员id")
+    private String firstDistributorId;
+
+    @Schema(description = "二级分销费")
+    private BigDecimal secondDistributionFee;
+
+    @Schema(description = "二级分销员id")
+    private String secondDistributorId;
+
+    @Schema(description = "三级分销费")
+    private BigDecimal thirdDistributionFee;
+
+    @Schema(description = "三级分销员id")
+    private String thirdDistributorId;
+
+    @Schema(description = "签单时间")
+    @TableField(exist = false)
+    private LocalDateTime signingTime;
+
+
 }

+ 6 - 0
commons/src/main/java/com/jzg/commons/entity/vo/IsDeleteVo.java

@@ -15,4 +15,10 @@ import java.util.List;
 public class IsDeleteVo {
     @Schema(description = "id集合")
     private List<String> ids;
+
+    @Schema(description = "分销处理类型 1不处理 分销关系保留 2 解除绑定关系 3 转移分销关系")
+    private String type;
+
+    @Schema(description = "转移手机号")
+    private String mobile;
 }

+ 1 - 7
gateway/src/main/resources/application-dev.yml

@@ -33,14 +33,8 @@ spring:
         - id: tenant_route
           uri: http://localhost:8084/
           predicates:
-            - Path=/tenant/**,/dept/**,/area/**,/dict/**,/userInfo/**,/sysOrganization/**,/activity/**,/message/**,/messageNotice/**,/poster/**,/agreement/**,/pltAgreement/**,/agreementRules/**,/plt/areaLicense/**,/scheme/**,/schemeRules/**,/schemeRulesAttrLink/**,/schemeRulesAttr/**,/schemeRulesDictLable/**,/schemeRulesUndwrt/**,/schemeRulesUndwrtAttrLink/**,/schemeRulesUndwrtAttr/**,/schemeRulesUndwrtDictLable/**,/schemeRulesUndwrtRules/**,/schemeRulesUndwrtRulesAttrLink/**,/schemeRules,/ptlAgreementCost/**,/ptlAgreementCost/**,/ptlAgreementCostExternal/**,/operatorTrajectory/**,/messageTemplate/**,/message/**,/appUser/**,/userBankCard/**,/accountCard/**,/account/**,/amountAuditing/**,/userAccount/**
+            - Path=/tenant/**,/dept/**,/area/**,/dict/**,/userInfo/**,/sysOrganization/**,/activity/**,/message/**,/messageNotice/**,/poster/**,/agreement/**,/pltAgreement/**,/agreementRules/**,/plt/areaLicense/**,/scheme/**,/schemeRules/**,/schemeRulesAttrLink/**,/schemeRulesAttr/**,/schemeRulesDictLable/**,/schemeRulesUndwrt/**,/schemeRulesUndwrtAttrLink/**,/schemeRulesUndwrtAttr/**,/schemeRulesUndwrtDictLable/**,/schemeRulesUndwrtRules/**,/schemeRulesUndwrtRulesAttrLink/**,/schemeRules,/ptlAgreementCost/**,/ptlAgreementCost/**,/ptlAgreementCostExternal/**,/operatorTrajectory/**,/messageTemplate/**,/message/**,/appUser/**,/userBankCard/**,/accountCard/**,/account/**,/amountAuditing/**,/userAccount/**,/receivable/**,/sysDistributionSetting/**
 
-            - Path=/tenant/**,/dept/**,/area/**,/dict/**,/userInfo/**,/sysOrganization/**,/activity/**,/message/**,/messageNotice/**,
-             /poster/**,/agreement/**,/pltAgreement/**,/agreementRules/**,/plt/areaLicense/**,/scheme/**,/schemeRules/**,/schemeRulesAttrLink/**,
-             /schemeRulesAttr/**,/schemeRulesDictLable/**,/schemeRulesUndwrt/**,/schemeRulesUndwrtAttrLink/**,/schemeRulesUndwrtAttr/**,
-             /schemeRulesUndwrtDictLable/**,/schemeRulesUndwrtRules/**,/schemeRulesUndwrtRulesAttrLink/**,/schemeRules,/ptlAgreementCost/**,
-             /ptlAgreementCost/**,/ptlAgreementCostExternal/**,/operatorTrajectory/**,/messageTemplate/**,/message/**,/appUser/**,/userBankCard/**,
-             /receivable/**
         - id: summary_route
           uri: http://localhost:9898/
           predicates:

+ 32 - 5
tenant/insurance/quotation-commons/src/main/java/com/jzg/quotation/commons/client/OrgClient.java

@@ -4,11 +4,7 @@ import com.jzg.commons.core.page.HttpResult;
 import com.jzg.commons.entity.dto.CostAgreementParam;
 import com.jzg.commons.entity.dto.MessageAddParam;
 import com.jzg.commons.entity.enums.MessageCodeEnum;
-import com.jzg.commons.entity.po.PtlAgreement;
-import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttr;
-import com.jzg.commons.entity.po.SysMessageTemplate;
-import com.jzg.commons.entity.po.SysUserAccount;
-import com.jzg.commons.entity.quote.vo.orders.InsOrdersVo;
+import com.jzg.commons.entity.po.*;
 import com.jzg.commons.entity.vo.*;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.*;
@@ -91,4 +87,35 @@ public interface OrgClient {
      */
     @PostMapping(value = "/userAccount/saveOrUpdate")
     public HttpResult saveOrUpdate(@RequestBody SysUserAccount userAccount, @RequestHeader("Authorization") String authToken);
+
+    /**
+     * 获取租户分销设置
+     */
+    @PostMapping(value = "/sysDistributionSetting/getSettingBySystemCode")
+    public HttpResult<SysDistributionSetting> getSettingBySystemCode();
+
+    /**
+     * 获取机构
+     */
+    @GetMapping(value = "/dept/deptGet")
+    public HttpResult<SysDeptVo> deptGet(String id);
+
+    /**
+     * 获取租户用户
+     */
+    @GetMapping(value = "userInfo/getUserInfoByMobile")
+    public HttpResult<SysUserJzgInfo> getUserInfoByMobile(String mobile);
+
+    /**
+     * 获取上级推荐人
+     */
+    @GetMapping(value = "esmUserReferrer/getReferrer")
+    public HttpResult<EsmUserReferrer> getReferrer(String id);
+
+
+    /**
+     * 获取租户用户
+     */
+    @GetMapping(value = "userInfo/getUserInfo")
+    public HttpResult<SysUserJzgInfo> getUserInfo(String id);
 }

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

@@ -11,10 +11,7 @@ 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.aggregated.QuoteResultsVo;
-import com.jzg.commons.entity.vo.AgreementInfoVo;
-import com.jzg.commons.entity.vo.CostsListVo;
-import com.jzg.commons.entity.vo.PtlAgreementCostTypeVo;
-import com.jzg.commons.entity.vo.RuleAttrMappingVo;
+import com.jzg.commons.entity.vo.*;
 import com.jzg.quotation.commons.client.OrgClient;
 import com.jzg.quotation.summary.service.*;
 import lombok.RequiredArgsConstructor;
@@ -722,6 +719,8 @@ public class QuoteVerificationAspect {
         // 7. 计算总应收、总应付、保存费用比例 入库
         saveRatio(insFeeOrders, agreementInfoVo, jqCostType, syCostType, jyCostType);
         calculateTotalPremium(insFeeOrders);
+        // 8. 计算分销费用
+        calculateDistributionFee(insOrdersCosts,insFeeOrders, insOrders);
         insFeeOrdersService.save(insFeeOrders);
     }
 
@@ -861,197 +860,104 @@ public class QuoteVerificationAspect {
         insFeeOrders.setJyExportRatio(convertPercent(jyCostType.getExport()));
     }
 
+    /**
+     * 计算分销费
+     */
+    private void calculateDistributionFee(InsOrdersCosts insOrdersCosts, InsFeeOrders insFeeOrders,InsOrders insOrders){
+        // 总保费
+        BigDecimal totalPremium = insOrdersCosts.getSumPremium();
+        // 获取当前租户信息
+        HttpResult<SysUserJzgInfo> sysUserJzgInfoResult = orgClient.getUserInfoByMobile(insOrders.getRealQuoteUserId());
+        SysUserJzgInfo currentUser = sysUserJzgInfoResult.getData();
+        // 获取租户分销设置
+        HttpResult<SysDistributionSetting> setting = orgClient.getSettingBySystemCode();
+        SysDistributionSetting sysDistributionSetting = setting.getData();
+        if (sysDistributionSetting != null) {
+            // 判断业务员所属机构是否被排除
+            // 1.获取业务员所属机构
+            String deptId = baseController.getUserDeptId();
+            HttpResult<SysDeptVo> sysDept = orgClient.deptGet(deptId);
+            if (sysDept.getData() != null && sysDept.getData().getIsDistribution().equals("1")) {
+                // 获取租户分销设置为几级分销
+                String level = sysDistributionSetting.getDistributionMode();
+                switch (level) {
+                    case "1":
+                        calculateLevel1Distribution(insFeeOrders, totalPremium, currentUser.getUserId(), sysDistributionSetting);
+                        break;
+                    case "2":
+                        String firstDistributorId = calculateLevel1Distribution(insFeeOrders, totalPremium, currentUser.getUserId(), sysDistributionSetting);
+                        if (firstDistributorId != null) {
+                            calculateLevel2Distribution(insFeeOrders, totalPremium, firstDistributorId, sysDistributionSetting);
+                        }
+                        break;
+                    case "3":
+                        String level1Id = calculateLevel1Distribution(insFeeOrders, totalPremium, currentUser.getUserId(), sysDistributionSetting);
+                        if (level1Id != null) {
+                            String level2Id = calculateLevel2Distribution(insFeeOrders, totalPremium, level1Id, sysDistributionSetting);
+                            if (level2Id != null) {
+                                calculateLevel3Distribution(insFeeOrders, totalPremium, level2Id, sysDistributionSetting);
+                            }
+                        }
+                        break;
+                }
+            }
+        }
+    }
 
+    /**
+     * 计算一级分销费
+     * @return 一级分销员ID,若不存在则返回null
+     */
+    private String calculateLevel1Distribution(InsFeeOrders insFeeOrders, BigDecimal totalPremium,
+                                               String userId, SysDistributionSetting setting) {
+        HttpResult<EsmUserReferrer> referrerResult = orgClient.getReferrer(userId);
+        if (referrerResult.getData() != null) {
+            EsmUserReferrer referrer = referrerResult.getData();
+            HttpResult<SysUserJzgInfo> referrerInfoResult = orgClient.getUserInfo(referrer.getReferrerId());
+            if (referrerInfoResult.getData() != null && "1".equals(referrerInfoResult.getData().getIsDistribution())) {
+                String distributorId = referrer.getReferrerId();
+                insFeeOrders.setFirstDistributorId(distributorId);
+                insFeeOrders.setFirstDistributionFee(totalPremium.multiply(setting.getCommissionRatioLevel1()));
+                return distributorId;
+            }
+        }
+        return null;
+    }
 
-    //    // 获取协议录入的 手续费比例 保留百分比
-//    BigDecimal jqEntranceFeeRatio = agreementInfoVo.getAgreement().getJqEntranceFeeRatio().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//    BigDecimal syEntranceFeeRatio = agreementInfoVo.getAgreement().getSyEntranceFeeRatio().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//    BigDecimal jyEntranceFeeRatio = agreementInfoVo.getAgreement().getJyEntranceFeeRatio().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//    // 开始计算费用
-//    // 通过费用id查询入口出口比例
-//    List<PtlAgreementCostTypeVo> costTypeList = orgClient.queryByCostId(costId);
-//    PtlAgreementCostTypeVo jqCostType = costTypeList.stream().filter(c -> "交强险".equals(c.getCostType())).findFirst().orElse(null);
-//    PtlAgreementCostTypeVo syCostType = costTypeList.stream().filter(c -> "商业险".equals(c.getCostType())).findFirst().orElse(null);
-//    PtlAgreementCostTypeVo jyCostType = costTypeList.stream().filter(c -> "驾意险".equals(c.getCostType())).findFirst().orElse(null);
-//    // 计算跟单费比例 入口比例 - 手续费比例 = 跟单比例 (保留百分比)
-//    BigDecimal jqFollowRatio = (jqCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN).subtract(jqEntranceFeeRatio));
-//    BigDecimal syFollowRatio = (syCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN).subtract(syEntranceFeeRatio));
-//    BigDecimal jyFollowRatio = (jyCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN).subtract(jyEntranceFeeRatio));
-//    // 当协议是平台协议时
-//        if (agreementType.equals("1")) {
-//        // 初始化交强应收 应付金额
-//        BigDecimal jqReceivablePremium = BigDecimal.ZERO;
-//        BigDecimal jqPayablePremium = BigDecimal.ZERO;
-//        // 交强险保费 * 入口手续费比例 + 交强险保费 * 跟单费比例 + 交强险保费 * 加投比例 = 交强应收(不含车船税);
-//        // 交强险保费 * 出口比例 = 交强应付;
-//        if (jqCostType != null) {
-//            // 转换百分比
-//            BigDecimal inletPercent = jqCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal addThrowPercent = jqCostType.getAddThrow().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal exportPercent = jqCostType.getExport().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            // 交强应收
-//            jqReceivablePremium = insOrdersCosts.getJqPremium().multiply(inletPercent)
-//                    .add(insOrdersCosts.getJqPremium().multiply(addThrowPercent))
-//                    .add(insOrdersCosts.getJqPremium().multiply(jqFollowRatio)).setScale(5, RoundingMode.HALF_EVEN);
-//            // 交强应付
-//            jqPayablePremium = insOrdersCosts.getJqPremium().multiply(exportPercent.setScale(2, RoundingMode.DOWN));
-//            // 交强手续费费用
-//            insFeeOrders.setJqCommissionPremium(insOrdersCosts.getJqPremium().multiply(jqEntranceFeeRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 交强跟单费费用
-//            insFeeOrders.setJqFollowPremium(insOrdersCosts.getJqPremium().multiply(jqFollowRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 交强加投费费用
-//            insFeeOrders.setJqAdditionalPremium(insOrdersCosts.getJqPremium().multiply(addThrowPercent).setScale(5, RoundingMode.HALF_EVEN));
-//        }
-//        insFeeOrders.setJqReceivablePremium(jqReceivablePremium);
-//        insFeeOrders.setJqPayablePremium(jqPayablePremium);
-//
-//        // 初始化商业应收 应付金额
-//        BigDecimal syReceivablePremium = BigDecimal.ZERO;
-//        BigDecimal syPayablePremium = BigDecimal.ZERO;
-//        // 商业险保费 * 入口手续费比例 + 商业险保费 * 跟单费比例 + 商业险保费 * 加投比例 = 商业应收
-//        // 商业险保费 * 出口比例 = 商业应付;
-//        if (syCostType != null) {
-//            // 转换百分比
-//            BigDecimal inletPercent = syCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal addThrowPercent = syCostType.getAddThrow().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal exportPercent = syCostType.getExport().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            // 商业应收
-//            syReceivablePremium = insOrdersCosts.getSyPremium().multiply(inletPercent)
-//                    .add(insOrdersCosts.getSyPremium().multiply(addThrowPercent))
-//                    .add(insOrdersCosts.getSyPremium().multiply(syFollowRatio)).setScale(5, RoundingMode.HALF_EVEN);
-//            // 商业应付
-//            syPayablePremium = insOrdersCosts.getSyPremium().multiply(exportPercent.setScale(2, RoundingMode.DOWN));
-//            // 商业手续费费用
-//            insFeeOrders.setSyCommissionPremium(insOrdersCosts.getSyPremium().multiply(syEntranceFeeRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 商业跟单费费用
-//            insFeeOrders.setSyFollowPremium(insOrdersCosts.getSyPremium().multiply(syFollowRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 商业加投费费用
-//            insFeeOrders.setSyAdditionalPremium(insOrdersCosts.getSyPremium().multiply(addThrowPercent).setScale(5, RoundingMode.HALF_EVEN));
-//        }
-//        insFeeOrders.setSyReceivablePremium(syReceivablePremium);
-//        insFeeOrders.setSyPayablePremium(syPayablePremium);
-//
-//        // 初始化驾意应收 应付金额
-//        BigDecimal jyReceivablePremium = BigDecimal.ZERO;
-//        BigDecimal jyPayablePremium = BigDecimal.ZERO;
-//        // 驾意险保费 * 入口手续费比例 + 驾意险保费 * 跟单费比例 + 驾意险保费 * 加投比例 = 商业应收
-//        // 驾意险保费 * 出口比例 = 驾意险应付;
-//        if (jyCostType != null) {
-//            // 转换百分比
-//            BigDecimal inletPercent = jyCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal addThrowPercent = jyCostType.getAddThrow().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal exportPercent = jyCostType.getExport().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            // 驾意应收
-//            jyReceivablePremium = insOrdersCosts.getJyPremium().multiply(inletPercent)
-//                    .add(insOrdersCosts.getJyPremium().multiply(addThrowPercent))
-//                    .add(insOrdersCosts.getJyPremium().multiply(jyFollowRatio)).setScale(5, RoundingMode.HALF_EVEN);
-//            // 驾意应付
-//            jyPayablePremium = insOrdersCosts.getJyPremium().multiply(exportPercent.setScale(2, RoundingMode.DOWN));
-//            // 驾意手续费费用
-//            insFeeOrders.setJyCommissionPremium(insOrdersCosts.getJyPremium().multiply(jyEntranceFeeRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 驾意跟单费费用
-//            insFeeOrders.setJyFollowPremium(insOrdersCosts.getJyPremium().multiply(jyFollowRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 驾意加投费费用
-//            insFeeOrders.setJyAdditionalPremium(insOrdersCosts.getJyPremium().multiply(addThrowPercent).setScale(5, RoundingMode.HALF_EVEN));
-//        }
-//        insFeeOrders.setJyReceivablePremium(jyReceivablePremium);
-//        insFeeOrders.setJyPayablePremium(jyPayablePremium);
-//        // 应收总金额
-//        BigDecimal totalReceivablePremium = jqReceivablePremium.add(syReceivablePremium).add(jyReceivablePremium).setScale(5, RoundingMode.HALF_EVEN);
-//        insFeeOrders.setTotalReceivablePremium(totalReceivablePremium);
-//        // 应付总金额
-//        BigDecimal totalPayablePremium = jqPayablePremium.add(syPayablePremium).add(jyPayablePremium).setScale(2, RoundingMode.DOWN);
-//        insFeeOrders.setTotalPayablePremium(totalPayablePremium);
-//        insFeeOrdersService.save(insFeeOrders);
-//    }
-//    // 当协议类型是私有协议时
-//        if (!agreementType.equals("1")) {
-//        // 固定税收 1.06
-//        BigDecimal fixedTax = new BigDecimal("1.06");
-//        // 初始化交强应收 应付金额
-//        BigDecimal jqReceivablePremium = BigDecimal.ZERO;
-//        BigDecimal jqPayablePremium = BigDecimal.ZERO;
-//        // 交强险保费 * 入口手续费比例 + 交强险保费 * 跟单费比例 + 交强险保费 * 加投比例 = 交强应收(不含车船税);
-//        // 交强险保费 * 出口比例 = 交强应付;
-//        if (jqCostType != null) {
-//            // 转换百分比
-//            BigDecimal inletPercent = jqCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal addThrowPercent = jqCostType.getAddThrow().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal exportPercent = jqCostType.getExport().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            // 交强应收
-//            jqReceivablePremium = (insOrdersCosts.getJqPremium().divide(fixedTax)).multiply(inletPercent)
-//                    .add((insOrdersCosts.getJqPremium().divide(fixedTax)).multiply(addThrowPercent))
-//                    .add((insOrdersCosts.getJqPremium().divide(fixedTax)).multiply(jqFollowRatio)).setScale(5, RoundingMode.HALF_EVEN);
-//            // 交强应付
-//            jqPayablePremium = insOrdersCosts.getJqPremium().multiply(exportPercent.setScale(2, RoundingMode.DOWN));
-//            // 交强手续费费用
-//            insFeeOrders.setJqCommissionPremium(insOrdersCosts.getJqPremium().multiply(jqEntranceFeeRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 交强跟单费费用
-//            insFeeOrders.setJqFollowPremium(insOrdersCosts.getJqPremium().multiply(jqFollowRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 交强加投费费用
-//            insFeeOrders.setJqAdditionalPremium(insOrdersCosts.getJqPremium().multiply(addThrowPercent).setScale(5, RoundingMode.HALF_EVEN));
-//        }
-//        insFeeOrders.setJqReceivablePremium(jqReceivablePremium);
-//        insFeeOrders.setJqPayablePremium(jqPayablePremium);
-//
-//        // 初始化商业应收 应付金额
-//        BigDecimal syReceivablePremium = BigDecimal.ZERO;
-//        BigDecimal syPayablePremium = BigDecimal.ZERO;
-//        // 商业险保费 * 入口手续费比例 + 商业险保费 * 跟单费比例 + 商业险保费 * 加投比例 = 商业应收
-//        // 商业险保费 * 出口比例 = 商业应付;
-//        if (syCostType != null) {
-//            // 转换百分比
-//            BigDecimal inletPercent = syCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal addThrowPercent = syCostType.getAddThrow().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal exportPercent = syCostType.getExport().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            // 商业应收
-//            syReceivablePremium = (insOrdersCosts.getSyPremium().divide(fixedTax)).multiply(inletPercent)
-//                    .add((insOrdersCosts.getSyPremium().divide(fixedTax)).multiply(addThrowPercent))
-//                    .add((insOrdersCosts.getSyPremium().divide(fixedTax)).multiply(syFollowRatio)).setScale(5, RoundingMode.HALF_EVEN);
-//            // 商业应付
-//            syPayablePremium = insOrdersCosts.getSyPremium().multiply(exportPercent.setScale(2, RoundingMode.DOWN));
-//            // 商业手续费费用
-//            insFeeOrders.setSyCommissionPremium(insOrdersCosts.getSyPremium().multiply(syEntranceFeeRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 商业跟单费费用
-//            insFeeOrders.setSyFollowPremium(insOrdersCosts.getSyPremium().multiply(syFollowRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 商业加投费费用
-//            insFeeOrders.setSyAdditionalPremium(insOrdersCosts.getSyPremium().multiply(addThrowPercent).setScale(5, RoundingMode.HALF_EVEN));
-//        }
-//        insFeeOrders.setSyReceivablePremium(syReceivablePremium);
-//        insFeeOrders.setSyPayablePremium(syPayablePremium);
-//
-//        // 初始化驾意应收 应付金额
-//        BigDecimal jyReceivablePremium = BigDecimal.ZERO;
-//        BigDecimal jyPayablePremium = BigDecimal.ZERO;
-//        // 驾意险保费 * 入口手续费比例 + 驾意险保费 * 跟单费比例 + 驾意险保费 * 加投比例 = 商业应收
-//        // 驾意险保费 * 出口比例 = 驾意险应付;
-//        if (jyCostType != null) {
-//            // 转换百分比
-//            BigDecimal inletPercent = jyCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal addThrowPercent = jyCostType.getAddThrow().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal exportPercent = jyCostType.getExport().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            // 驾意应收
-//            jyReceivablePremium = (insOrdersCosts.getJyPremium().divide(fixedTax)).multiply(inletPercent)
-//                    .add((insOrdersCosts.getJyPremium().divide(fixedTax)).multiply(addThrowPercent))
-//                    .add((insOrdersCosts.getJyPremium().divide(fixedTax)).multiply(jyFollowRatio)).setScale(5, RoundingMode.HALF_EVEN);
-//            // 驾意应付
-//            jyPayablePremium = insOrdersCosts.getJyPremium().multiply(exportPercent.setScale(2, RoundingMode.DOWN));
-//            // 驾意手续费费用
-//            insFeeOrders.setJyCommissionPremium(insOrdersCosts.getJyPremium().multiply(jyEntranceFeeRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 驾意跟单费费用
-//            insFeeOrders.setJyFollowPremium(insOrdersCosts.getJyPremium().multiply(jyFollowRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 驾意加投费费用
-//            insFeeOrders.setJyAdditionalPremium(insOrdersCosts.getJyPremium().multiply(addThrowPercent).setScale(5, RoundingMode.HALF_EVEN));
-//        }
-//        insFeeOrders.setJyReceivablePremium(jyReceivablePremium);
-//        insFeeOrders.setJyPayablePremium(jyPayablePremium);
-//        // 应收总金额
-//        BigDecimal totalReceivablePremium = jqReceivablePremium.add(syReceivablePremium).add(jyReceivablePremium).setScale(5, RoundingMode.HALF_EVEN);
-//        insFeeOrders.setTotalReceivablePremium(totalReceivablePremium);
-//        // 应付总金额
-//        BigDecimal totalPayablePremium = jqPayablePremium.add(syPayablePremium).add(jyPayablePremium).setScale(2, RoundingMode.DOWN);
-//        insFeeOrders.setTotalPayablePremium(totalPayablePremium);
-//        insFeeOrdersService.save(insFeeOrders);
-//
-//    }
+    /**
+     * 计算二级分销费
+     * @return 二级分销员ID,若不存在则返回null
+     */
+    private String calculateLevel2Distribution(InsFeeOrders insFeeOrders, BigDecimal totalPremium,
+                                               String upperDistributorId, SysDistributionSetting setting) {
+        HttpResult<EsmUserReferrer> referrerResult = orgClient.getReferrer(upperDistributorId);
+        if (referrerResult.getData() != null) {
+            EsmUserReferrer referrer = referrerResult.getData();
+            HttpResult<SysUserJzgInfo> referrerInfoResult = orgClient.getUserInfo(referrer.getReferrerId());
+            if (referrerInfoResult.getData() != null && "1".equals(referrerInfoResult.getData().getIsDistribution())) {
+                String distributorId = referrer.getReferrerId();
+                insFeeOrders.setSecondDistributorId(distributorId);
+                insFeeOrders.setSecondDistributionFee(totalPremium.multiply(setting.getCommissionRatioLevel2()));
+                return distributorId;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 计算三级分销费
+     */
+    private void calculateLevel3Distribution(InsFeeOrders insFeeOrders, BigDecimal totalPremium,
+                                             String upperDistributorId, SysDistributionSetting setting) {
+        HttpResult<EsmUserReferrer> referrerResult = orgClient.getReferrer(upperDistributorId);
+        if (referrerResult.getData() != null) {
+            EsmUserReferrer referrer = referrerResult.getData();
+            HttpResult<SysUserJzgInfo> referrerInfoResult = orgClient.getUserInfo(referrer.getReferrerId());
+            if (referrerInfoResult.getData() != null
+                    && "1".equals(referrerInfoResult.getData().getIsDistribution())) {
+                insFeeOrders.setThirdDistributorId(referrer.getReferrerId());
+                insFeeOrders.setThirdDistributionFee(totalPremium.multiply(setting.getCommissionRatioLevel3()));
+            }
+        }
+    }
 }

+ 40 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/controller/InsFeeOrderController.java

@@ -0,0 +1,40 @@
+package com.jzg.quotation.summary.controller;
+
+import com.jzg.commons.entity.po.InsFeeOrders;
+import com.jzg.quotation.summary.service.InsFeeOrdersService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * @author quchen
+ * @date 2025/8/18 9:26
+ */
+
+@RestController
+@Tag(name="订单费用接口")
+@RequestMapping("/insFeeOrder")
+public class InsFeeOrderController {
+    @Autowired
+    private InsFeeOrdersService insFeeOrdersService;
+
+    /**
+     * 订单列表分页
+     * @return
+     */
+    @GetMapping("/getInsFeeOrdersList")
+    @Operation(summary = "订单费用列表通过分销员id查询")
+    public List<InsFeeOrders> getInsFeeOrdersList(String userId){
+        return insFeeOrdersService.getInsFeeOrdersList(userId);
+    }
+
+    @GetMapping("/getInsFeeOrderAudit")
+    @Operation(summary = "订单费用审核列表通过分销员id查询")
+    public List<InsFeeOrders> getInsFeeOrderAudit(String userId){
+        return insFeeOrdersService.getInsFeeOrderAudit(userId);
+    }
+
+}

+ 5 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/mapper/InsFeeOrdersMapper.java

@@ -4,6 +4,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.jzg.commons.entity.po.InsFeeOrders;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 @Mapper
 public interface InsFeeOrdersMapper extends BaseMapper<InsFeeOrders> {
+    List<InsFeeOrders> getInsFeeOrdersList(String userId);
+
+    List<InsFeeOrders> getInsFeeOrderAudit(String userId);
 }

+ 6 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/InsFeeOrdersService.java

@@ -4,8 +4,14 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.jzg.commons.entity.po.InsFeeOrders;
 import com.jzg.commons.entity.vo.PtlAgreementCostRatioVo;
 
+import java.util.List;
+
 public interface InsFeeOrdersService extends IService<InsFeeOrders> {
     InsFeeOrders calcCosts(PtlAgreementCostRatioVo ptlAgreementCostRatioVo) throws ReflectiveOperationException;
 
+    List<InsFeeOrders> getInsFeeOrdersList(String userId);
+
+    List<InsFeeOrders> getInsFeeOrderAudit(String userId);
+
 
 }

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

@@ -231,4 +231,14 @@ public class InsFeeOrdersServiceImpl extends ServiceImpl<InsFeeOrdersMapper, Ins
         insFeeOrders.setSyExportRatio(covertPercent(ptlAgreementCostRatioVo.getSyExportRatio()));
         insFeeOrders.setJyExportRatio(covertPercent(ptlAgreementCostRatioVo.getJyExportRatio()));
     }
+
+    @Override
+    public List<InsFeeOrders> getInsFeeOrdersList(String userId) {
+        return insFeeOrdersMapper.getInsFeeOrdersList(userId);
+    }
+
+    @Override
+    public List<InsFeeOrders> getInsFeeOrderAudit(String userId) {
+        return insFeeOrdersMapper.getInsFeeOrderAudit(userId);
+    }
 }

+ 29 - 0
tenant/insurance/quotation-summary/src/main/resources/mapper/InsFeeOrdersMapper.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jzg.quotation.summary.mapper.InsFeeOrdersMapper">
+
+    <select id="getInsFeeOrdersList" resultType="com.jzg.commons.entity.po.InsFeeOrders">
+        select ifo.*,
+               io.signing_time as signingTime
+        from ins_fee_orders ifo
+                 left join ins_orders io on io.id = ifo.order_no
+        where
+            (ifo.first_distributor_id = #{userId}
+            or ifo.second_distributor_id = #{userId}
+            or ifo.third_distributor_id = #{userId})
+    </select>
+
+    <select id="getInsFeeOrderAudit" resultType="com.jzg.commons.entity.po.InsFeeOrders">
+        select ifo.*,
+               io.signing_time as signingTime
+        from ins_fee_orders ifo
+                 left join ins_fee_audit ifa on ifa.order_no = ifo.order_no
+        where
+            (ifo.first_distributor_id = #{userId}
+                or ifo.second_distributor_id = #{userId}
+                or ifo.third_distributor_id = #{userId})
+            and ifa.status = 0
+    </select>
+</mapper>

+ 22 - 0
tenant/organization/src/main/java/com/jzg/organization/client/QuoteClient.java

@@ -0,0 +1,22 @@
+package com.jzg.organization.client;
+
+import com.jzg.commons.core.page.HttpResult;
+import com.jzg.commons.entity.po.InsFeeOrders;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@FeignClient(name="jzg-insurance",url = "http://192.168.0.106:9898/")
+public interface QuoteClient {
+    @GetMapping(value = "/insFeeOrder/getInsFeeOrdersList")
+    public List<InsFeeOrders> getInsFeeOrdersList(@RequestParam("userId") String userId);
+
+    @GetMapping(value = "/insFeeOrder/getInsFeeOrderAudit")
+    public List<InsFeeOrders> getInsFeeOrderAudit(@RequestParam("userId") String userId);
+
+
+
+
+
+}

+ 75 - 21
tenant/organization/src/main/java/com/jzg/organization/controller/ReceivableController.java

@@ -1,5 +1,6 @@
 package com.jzg.organization.controller;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jzg.commons.constants.dict.InsOrderStatusEnum;
 import com.jzg.commons.core.page.HttpResult;
 import com.jzg.commons.entity.finance.po.InsPlyIncome;
@@ -209,70 +210,123 @@ public class ReceivableController {
 //    }
     @PostMapping("exportSuperviseExcel")
     @Operation(summary = "导出应收手续费excel文件(车险)")
-    public HttpResult exportSuperviseExcel(@RequestBody ReceivableQueryVo receivableQueryVo) throws IOException {
-        return HttpResult.ok(receivableService.exportSuperviseExcel(receivableQueryVo));
+    public void exportSuperviseExcel(@RequestBody ReceivableQueryVo receivableQueryVo) throws IOException {
+        receivableQueryVo.setQueryType("1");
+        receivableService.exportSuperviseExcel(receivableQueryVo);
     }
 
     @PostMapping("exportSuperviseJyExcel")
     @Operation(summary = "导出应收手续费excel文件(非车险)")
-    public HttpResult exportSuperviseJyExcel(@RequestBody ReceivableQueryVo receivableQueryVo) throws IOException {
-        return HttpResult.ok(receivableService.exportSuperviseJyExcel(receivableQueryVo));
+    public void exportSuperviseJyExcel(@RequestBody ReceivableQueryVo receivableQueryVo) throws IOException {
+        receivableQueryVo.setQueryType("3");
+        receivableService.exportSuperviseJyExcel(receivableQueryVo);
     }
 
+    @PostMapping("superviseSettlementExcel")
+    @Operation(summary = "应收手续费结算记录")
+    public HttpResult superviseSettlementExcel(@RequestBody SettlementQueryVo settlementQueryVo) {
+        Page page = settlementQueryVo.getPage();
+        return HttpResult.ok(receivableService.superviseSettlementExcel(page,settlementQueryVo));
+    }
+
+
     @PostMapping("exportSuperviseSettlementExcel")
     @Operation(summary = "导出应收手续费结算记录excel文件")
-    public HttpResult exportSuperviseSettlementExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
-        return HttpResult.ok(receivableService.exportSuperviseSettlementExcel(settlementQueryVo));
+    public void exportSuperviseSettlementExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
+        Page page = new Page<>(1,1000000);
+        receivableService.exportSuperviseSettlementExcel(page,settlementQueryVo);
+    }
+
+    @PostMapping("superviseSettlementDetailExcel")
+    @Operation(summary = "应收手续费结算明细")
+    public HttpResult superviseSettlementDetailExcel(@RequestBody SettlementQueryVo settlementQueryVo) {
+        Page page = settlementQueryVo.getPage();
+        return HttpResult.ok(receivableService.superviseSettlementDetailExcel(page,settlementQueryVo));
     }
 
     @PostMapping("exportSuperviseSettlementDetailExcel")
     @Operation(summary = "导出应收手续费结算明细excel文件")
-    public HttpResult exportSuperviseSettlementDetailExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
-        return HttpResult.ok(receivableService.exportSuperviseSettlementDetailExcel(settlementQueryVo));
+    public void exportSuperviseSettlementDetailExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
+        Page page = new Page<>(1,1000000);
+        receivableService.exportSuperviseSettlementDetailExcel(page,settlementQueryVo);
     }
 
     @PostMapping("exportSuperviseSettlementDetailJyExcel")
     @Operation(summary = "导出应收手续费结算(非车)明细excel文件")
-    public HttpResult exportSuperviseSettlementDetailJyExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
-        return HttpResult.ok(receivableService.exportSuperviseSettlementDetailJyExcel(settlementQueryVo));
+    public void exportSuperviseSettlementDetailJyExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
+        Page page = new Page<>(1,1000000);
+        receivableService.exportSuperviseSettlementDetailJyExcel(page,settlementQueryVo);
     }
 
     @PostMapping("exportOtherExcel")
     @Operation(summary = "导出应收跟单费(车险)excel文件")
-    public HttpResult exportOtherExcel(@RequestBody ReceivableQueryVo receivableQueryVo) throws IOException {
-        return HttpResult.ok(receivableService.exportOtherExcel(receivableQueryVo));
+    public void exportOtherExcel(@RequestBody ReceivableQueryVo receivableQueryVo) throws IOException {
+        receivableQueryVo.setQueryType("2");
+        receivableService.exportOtherExcel(receivableQueryVo);
     }
 
     @PostMapping("exportOtherJyExcel")
     @Operation(summary = "导出应收跟单费(非车险)excel文件")
-    public HttpResult exportOtherJyExcel(@RequestBody ReceivableQueryVo receivableQueryVo) throws IOException {
-        return HttpResult.ok(receivableService.exportOtherJyExcel(receivableQueryVo));
+    public void exportOtherJyExcel(@RequestBody ReceivableQueryVo receivableQueryVo) throws IOException {
+        receivableQueryVo.setQueryType("4");
+        receivableService.exportOtherJyExcel(receivableQueryVo);
+    }
+
+    @PostMapping("otherSettlement")
+    @Operation(summary = "应收跟单费结算记录")
+    public HttpResult exportOtherSettlementDetail(@RequestBody SettlementQueryVo settlementQueryVo) {
+        Page page = settlementQueryVo.getPage();
+        return HttpResult.ok(receivableService.exportOtherSettlement(page,settlementQueryVo));
     }
 
     @PostMapping("exportOtherSettlementExcel")
     @Operation(summary = "导出应收跟单费结算记录excel文件")
-    public HttpResult exportOtherSettlementExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
-        return HttpResult.ok(receivableService.exportOtherSettlementExcel(settlementQueryVo));
+    public void exportOtherSettlementExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
+        Page page = new Page<>(1,1000000);
+        receivableService.exportOtherSettlementExcel(page,settlementQueryVo);
+    }
+
+    @PostMapping("otherSettlementDetail")
+    @Operation(summary = "应收跟单费结算明细")
+    public HttpResult otherSettlementDetail(@RequestBody SettlementQueryVo settlementQueryVo) {
+        Page page = settlementQueryVo.getPage();
+        return HttpResult.ok(receivableService.otherSettlementDetail(page,settlementQueryVo));
     }
 
     @PostMapping("exportOtherSettlementDetailExcel")
     @Operation(summary = "导出应收跟单费结算明细excel文件 (车险)")
-    public HttpResult exportOtherSettlementDetailExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
-        return HttpResult.ok(receivableService.exportOtherSettlementDetailExcel(settlementQueryVo));
+    public void exportOtherSettlementDetailExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
+        Page page = new Page<>(1,1000000);
+        receivableService.exportOtherSettlementDetailExcel(page,settlementQueryVo);
     }
 
     @PostMapping("exportOtherSettlementDetailJyExcel")
     @Operation(summary = "导出应收跟单费结算明细excel文件 (非车险)")
-    public HttpResult exportOtherSettlementDetailJyExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
-        return HttpResult.ok(receivableService.exportOtherSettlementDetailJyExcel(settlementQueryVo));
+    public void exportOtherSettlementDetailJyExcel(@RequestBody SettlementQueryVo settlementQueryVo) throws IOException {
+        Page page = new Page<>(1,1000000);
+        receivableService.exportOtherSettlementDetailJyExcel(page,settlementQueryVo);
     }
 
     @PostMapping("companySuperviseSettlementReport")
-    @Operation(summary = "保险公司手续费结算报表")
+    @Operation(summary = "保险公司结算报表")
     public HttpResult companySuperviseSettlementReport(@RequestBody SettlementReportQueryVo settlementReportQueryVo) {
         return HttpResult.ok(receivableService.companySuperviseSettlementReport(settlementReportQueryVo));
     }
 
+    @PostMapping("receiverSettlementReport")
+    @Operation(summary = "对接人结算报表")
+    public HttpResult receiverSettlementReport(@RequestBody SettlementReportQueryVo settlementReportQueryVo) {
+        Page page = settlementReportQueryVo.getPage();
+        return HttpResult.ok(receivableService.receiverSettlementReport(page,settlementReportQueryVo));
+    }
+
+    @PostMapping("exportReceiverSettlementReportExcel")
+    @Operation(summary = "导出对接人结算报表excel文件")
+    public void exportReceiverSettlementReportExcel(@RequestBody SettlementReportQueryVo settlementReportQueryVo) {
+        Page page = new Page<>(1,1000000);
+        receivableService.exportReceiverSettlementReportExcel(page,settlementReportQueryVo);
+    }
+
 
 
     @PostMapping("/getInvoiceRecordDetail")

+ 16 - 7
tenant/organization/src/main/java/com/jzg/organization/mapper/ReceivableMapper.java

@@ -1,6 +1,7 @@
 package com.jzg.organization.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jzg.commons.entity.finance.dto.*;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jzg.commons.entity.finance.po.InsPlyIncome;
@@ -59,21 +60,21 @@ public interface ReceivableMapper extends BaseMapper<InsPlyIncome> {
      * @param settlementQueryVo
      * @return
      */
-    List<ExportSuperviseSettlementExcelDto> getSuperviseSettlementExcelDtos(@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
+    Page<ExportSuperviseSettlementExcelDto> superviseSettlementExcelDtos(Page page,@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
 
     /**
      * 获取应收结算记录明细列表
      * @param settlementQueryVo
      * @return
      */
-    List<ExportSuperviseSettlementDetailExcelDto> getSuperviseSettlementDetailExcelDtos(@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
+    Page<ExportSuperviseSettlementDetailExcelDto> getSuperviseSettlementDetailExcelDtos(Page page,@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
 
     /**
      * 获取应收结算记录明细列表(非车)
      * @param settlementQueryVo
      * @return
      */
-    List<ExportSuperviseSettlementDetailJyExcelDto> getSuperviseSettlementDetailJyExcelDtos(@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
+    Page<ExportSuperviseSettlementDetailJyExcelDto> getSuperviseSettlementDetailJyExcelDtos(Page page,@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
 
     /**
      * 获取车险跟单费数据
@@ -94,14 +95,14 @@ public interface ReceivableMapper extends BaseMapper<InsPlyIncome> {
      * @param settlementQueryVo
      * @return
      */
-    List<ExportOtherSettlementExcelDto> getOtherSettlementExcelDtos(@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
+    Page<ExportOtherSettlementExcelDto> getOtherSettlementExcelDtos(Page page,@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
 
     /**
      * 获取车险跟单费结算明细数据
      * @param settlementQueryVo
      * @return
      */
-    List<ExportOtherSettlementDetailExcelDto> getOtherSettlementDetailExcelDtos(@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
+    Page<ExportOtherSettlementDetailExcelDto> getOtherSettlementDetailExcelDtos(Page page,@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
 
 
     /**
@@ -109,7 +110,7 @@ public interface ReceivableMapper extends BaseMapper<InsPlyIncome> {
      * @param settlementQueryVo
      * @return
      */
-    List<ExportOtherSettlementDetailJyExcelDto> getOtherSettlementDetailJyExcelDtos(@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
+    Page<ExportOtherSettlementDetailJyExcelDto> getOtherSettlementDetailJyExcelDtos(Page page,@Param("settlementQueryVo") SettlementQueryVo settlementQueryVo);
 
     /**
      * 获取保险公司手续费结算报表
@@ -126,11 +127,19 @@ public interface ReceivableMapper extends BaseMapper<InsPlyIncome> {
     /**
      * 根据父公司ID获取子公司
      */
-    List<CompanySuperviseSettlementReportDto> selectChildrenByParentId(@Param("parentId") String parentId, @Param("invoiceTypes") List<String> invoiceTypes);
+    List<CompanySuperviseSettlementReportDto> selectChildrenByParentId(@Param("parentId") String parentId, @Param("settlementReportQueryVo") SettlementReportQueryVo settlementReportQueryVo);
 
     List<InvoiceAmountDto> getSuperviseAmount();
     Integer invoicingCheck(@Param("invoicingVo") InvoicingVo invoicingVo);
 
+    /**
+     * 对接人结算报表
+     * @param page
+     * @param settlementReportQueryVo
+     * @return
+     */
+    Page<ReceiverSettlementReportDto> getReceiverSettlementReport(Page page,@Param("settlementReportQueryVo") SettlementReportQueryVo settlementReportQueryVo);
+
     /**
      * 获取应收的总金额
      */

+ 35 - 12
tenant/organization/src/main/java/com/jzg/organization/service/ReceivableService.java

@@ -2,7 +2,7 @@ package com.jzg.organization.service;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.jzg.commons.entity.finance.dto.CompanySuperviseSettlementReportDto;
+import com.jzg.commons.entity.finance.dto.*;
 import com.jzg.commons.entity.finance.po.InsPlyIncome;
 import com.jzg.commons.entity.finance.po.InsPlyIncomeInvoiceSettlement;
 import com.jzg.commons.entity.finance.vo.*;
@@ -173,54 +173,77 @@ public interface ReceivableService extends IService<InsPlyIncome> {
     /**
      * 导出应收手续费excel(车险)
      */
-    String exportSuperviseExcel(ReceivableQueryVo receivableQueryVo) throws IOException;
+    void exportSuperviseExcel(ReceivableQueryVo receivableQueryVo) throws IOException;
 
     /**
      * 导出应收手续费excel(非车险)
      */
-    String exportSuperviseJyExcel(ReceivableQueryVo receivableQueryVo) throws IOException;
+    void exportSuperviseJyExcel(ReceivableQueryVo receivableQueryVo) throws IOException;
 
+    /**
+     * 应收手续费结算记录
+     * @param settlementQueryVo
+     * @return
+     */
+    Page<ExportSuperviseSettlementExcelDto> superviseSettlementExcel(Page page, SettlementQueryVo settlementQueryVo);
 
     /**
      * 导出应收手续费结算记录excel
      */
-    String exportSuperviseSettlementExcel(SettlementQueryVo settlementQueryVo) throws IOException;
+    void exportSuperviseSettlementExcel(Page page,SettlementQueryVo settlementQueryVo) throws IOException;
 
+    /**
+     * 应收手续费结算明细
+     */
+    Page<ExportSuperviseSettlementDetailExcelDto> superviseSettlementDetailExcel(Page page, SettlementQueryVo settlementQueryVo);
     /**
      * 导出应收手续费结算明细excel(车险)
      */
-    String exportSuperviseSettlementDetailExcel(SettlementQueryVo settlementQueryVo) throws IOException;
+    void exportSuperviseSettlementDetailExcel(Page page,SettlementQueryVo settlementQueryVo) throws IOException;
 
     /**
      * 导出应收手续费结算明细excel(非车险)
      */
-    String exportSuperviseSettlementDetailJyExcel(SettlementQueryVo settlementQueryVo) throws IOException;
+    void exportSuperviseSettlementDetailJyExcel(Page page,SettlementQueryVo settlementQueryVo) throws IOException;
 
     /**
      * 导出应收跟单费excel文件(车险)
      */
-    String exportOtherExcel(ReceivableQueryVo receivableQueryVo) throws IOException;
+    void exportOtherExcel(ReceivableQueryVo receivableQueryVo) throws IOException;
 
     /**
      * 导出应收跟单费excel文件(非车险)
      */
-    String exportOtherJyExcel(ReceivableQueryVo receivableQueryVo) throws IOException;
+    void exportOtherJyExcel(ReceivableQueryVo receivableQueryVo) throws IOException;
+
+    /**
+     * 应收跟单费结算记录
+     */
+    Page<ExportOtherSettlementExcelDto> exportOtherSettlement(Page page, SettlementQueryVo settlementQueryVo);
 
     /**
      * 导出应收跟单费结算记录excel文件
      */
-    String exportOtherSettlementExcel(SettlementQueryVo settlementQueryVo) throws IOException;
+    void exportOtherSettlementExcel(Page page, SettlementQueryVo settlementQueryVo) throws IOException;
 
     /**
-     * 导出应收跟单费结算明细excel文件 (车险)
+     * 应收跟单费结算明细
      */
-    String exportOtherSettlementDetailExcel(SettlementQueryVo settlementQueryVo) throws IOException;
+    Page<ExportOtherSettlementDetailExcelDto> otherSettlementDetail(Page page, SettlementQueryVo settlementQueryVo);
 
+    /**
+     * 导出应收跟单费结算明细excel文件 (车险)
+     */
+    void exportOtherSettlementDetailExcel(Page page,SettlementQueryVo settlementQueryVo) throws IOException;
 
     /**
      * 导出应收跟单费结算明细excel文件 (非车险)
      */
-    String exportOtherSettlementDetailJyExcel(SettlementQueryVo settlementQueryVo) throws IOException;
+    void exportOtherSettlementDetailJyExcel(Page page,SettlementQueryVo settlementQueryVo) throws IOException;
 
     List<CompanySuperviseSettlementReportDto> companySuperviseSettlementReport(SettlementReportQueryVo settlementReportQueryVo);
+
+    Page<ReceiverSettlementReportDto> receiverSettlementReport(Page page,SettlementReportQueryVo settlementReportQueryVo);
+
+    void exportReceiverSettlementReportExcel(Page page,SettlementReportQueryVo settlementReportQueryVo);
 }

+ 155 - 43
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jzg.commons.constants.dict.InsOrderStatusEnum;
 import com.jzg.commons.core.base.BaseController;
 import com.jzg.commons.core.page.HttpResult;
 import com.jzg.commons.entity.finance.dto.*;
@@ -13,8 +14,11 @@ import com.jzg.commons.entity.finance.po.*;
 import com.jzg.commons.entity.finance.vo.*;
 import com.jzg.commons.entity.po.EsmInsCompany;
 import com.jzg.commons.entity.po.PtlAgreement;
+import com.jzg.commons.entity.po.SysUploadFiles;
 import com.jzg.commons.util.AssertionUtils;
 import com.jzg.commons.util.EasyExcelUtils;
+import com.jzg.commons.util.MinioUtils;
+import com.jzg.commons.util.ServletUtils;
 import com.jzg.commons.util.idgen.IdGenerate;
 import com.jzg.organization.client.EsmInsCompanyClient;
 import com.jzg.organization.excel.listener.JyExcelListener;
@@ -76,9 +80,15 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
     @Autowired
     private PtlAgreementMapper ptlAgreementMapper;
 
+    @Autowired
+    private SysUploadFilesMapper sysUploadFilesMapper;
+
     @Value("${upload.file.path}")
     private String uploadPath;
 
+    @Value("${upload.file.url}")
+    private String uploadUrl;
+
     // 车辆险种手续费结算锁
     private static final String CAR_INVOICING_COMMISSION_LOCK = "CAR_INVOICING_COMMISSION_LOCK:";
     // 车辆险种跟单费结算锁
@@ -781,14 +791,13 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
      * @return
      */
     @Override
-    public String exportSuperviseExcel(ReceivableQueryVo receivableQueryVo) throws IOException {
-        verifyUploadPath();
+    public void exportSuperviseExcel(ReceivableQueryVo receivableQueryVo) {
         List<InsPlyIncome> receivableList = getReceivableList(receivableQueryVo);
         // 转换为DTO列表,只包含需要的字段
         List<ExportSuperviseExcelDto> dtoList = receivableList.stream()
                 .map(this::convertToDto)
                 .toList();
-        return EasyExcelUtils.downExcel(uploadPath, "车险手续费应收明细", ExportSuperviseExcelDto.class, dtoList);
+        EasyExcelUtils.exportForWeb(ServletUtils.getResponse(),ExportSuperviseExcelDto.class,dtoList, "车险手续费应收明细");
     }
 
     // 过滤不需要的字段
@@ -821,7 +830,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
     }
 
     @Override
-    public String exportSuperviseJyExcel(ReceivableQueryVo receivableQueryVo) throws IOException {
+    public void exportSuperviseJyExcel(ReceivableQueryVo receivableQueryVo) throws IOException {
         verifyUploadPath();
         List<ExportSuperviseJyExcelDto> exportSuperviseJyExcelDtos = baseMapper.getSuperviseJyExcelDtos(receivableQueryVo);
         exportSuperviseJyExcelDtos.forEach(dto -> {
@@ -831,9 +840,36 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 case "3" -> dto.setEntryStatus("补录订单");
             }
         });
-        return EasyExcelUtils.downExcel(uploadPath, "非车险手续费应收明细", ExportSuperviseJyExcelDto.class, exportSuperviseJyExcelDtos);
+       EasyExcelUtils.exportForWeb(ServletUtils.getResponse(),ExportSuperviseJyExcelDto.class,exportSuperviseJyExcelDtos, "车险手续费结算明细");
     }
 
+    /**
+     * 应收手续费结算记录
+     * @param settlementQueryVo
+     * @return
+     */
+    @Override
+    public Page<ExportSuperviseSettlementExcelDto> superviseSettlementExcel(Page page,SettlementQueryVo settlementQueryVo)  {
+        Page<ExportSuperviseSettlementExcelDto> exportSuperviseSettlementExcelDtos = baseMapper.superviseSettlementExcelDtos(page,settlementQueryVo);
+        exportSuperviseSettlementExcelDtos.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("驾意险跟单费");
+            }
+            SysUploadFiles file = sysUploadFilesMapper.selectById(dto.getFileId());
+            if (file != null) {
+                dto.setFileUrl(MinioUtils.getPresignedObjectUrl("jzg",file.getFileName()));
+            }
+        });
+        return exportSuperviseSettlementExcelDtos;
+    }
 
     /**
      * 导出应收手续费结算记录
@@ -841,10 +877,9 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
      * @return
      */
     @Override
-    public String exportSuperviseSettlementExcel(SettlementQueryVo settlementQueryVo) throws IOException {
-        verifyUploadPath();
-        List<ExportSuperviseSettlementExcelDto> exportSuperviseSettlementExcelDtos = baseMapper.getSuperviseSettlementExcelDtos(settlementQueryVo);
-        exportSuperviseSettlementExcelDtos.forEach(dto -> {
+    public void exportSuperviseSettlementExcel(Page page,SettlementQueryVo settlementQueryVo) {
+        Page<ExportSuperviseSettlementExcelDto> exportSuperviseSettlementExcelDtos = baseMapper.superviseSettlementExcelDtos(page,settlementQueryVo);
+        exportSuperviseSettlementExcelDtos.getRecords().forEach(dto -> {
             if (dto.getInvoiceParty().equals("1")) {
                 dto.setInvoiceParty("我方开票");
             } else if (dto.getInvoiceParty().equals("2")) {
@@ -857,7 +892,26 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 case "4" -> dto.setInvoiceType("驾意险跟单费");
             }
         });
-        return EasyExcelUtils.downExcel(uploadPath, "手续费结算记录", ExportSuperviseSettlementExcelDto.class, exportSuperviseSettlementExcelDtos);
+        List<ExportSuperviseSettlementExcelDto> list = exportSuperviseSettlementExcelDtos.getRecords();
+        EasyExcelUtils.exportForWeb(ServletUtils.getResponse(),ExportSuperviseSettlementExcelDto.class,list, "车险手续费结算明细");
+    }
+
+    @Override
+    public Page<ExportSuperviseSettlementDetailExcelDto> superviseSettlementDetailExcel(Page page, SettlementQueryVo settlementQueryVo) {
+        Page<ExportSuperviseSettlementDetailExcelDto> 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("未结算");
+            }
+        });
+        return exportSuperviseSettlementDetailExcelDtos;
     }
 
     /**
@@ -866,10 +920,10 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
      * @return
      */
     @Override
-    public String exportSuperviseSettlementDetailExcel(SettlementQueryVo settlementQueryVo) throws IOException {
+    public void exportSuperviseSettlementDetailExcel(Page page,SettlementQueryVo settlementQueryVo) throws IOException {
         verifyUploadPath();
-        List<ExportSuperviseSettlementDetailExcelDto> exportSuperviseSettlementDetailExcelDtos = baseMapper.getSuperviseSettlementDetailExcelDtos(settlementQueryVo);
-        exportSuperviseSettlementDetailExcelDtos.forEach(dto -> {
+        Page<ExportSuperviseSettlementDetailExcelDto> exportSuperviseSettlementDetailExcelDtos = baseMapper.getSuperviseSettlementDetailExcelDtos(page,settlementQueryVo);
+        exportSuperviseSettlementDetailExcelDtos.getRecords().forEach(dto -> {
             if (dto.getInvoiceParty().equals("1")) {
                 dto.setInvoiceParty("我方开票");
             } else if (dto.getInvoiceParty().equals("2")) {
@@ -881,7 +935,8 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 dto.setStatus("未结算");
             }
         });
-        return EasyExcelUtils.downExcel(uploadPath, "车险手续费结算明细", ExportSuperviseSettlementDetailExcelDto.class, exportSuperviseSettlementDetailExcelDtos);
+        List<ExportSuperviseSettlementDetailExcelDto> list = exportSuperviseSettlementDetailExcelDtos.getRecords();
+        EasyExcelUtils.exportForWeb(ServletUtils.getResponse(),ExportSuperviseSettlementDetailExcelDto.class,list, "车险手续费结算明细");
     }
 
     /**
@@ -890,10 +945,10 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
      * @return
      */
     @Override
-    public String exportSuperviseSettlementDetailJyExcel(SettlementQueryVo settlementQueryVo) throws IOException {
+    public void exportSuperviseSettlementDetailJyExcel(Page page,SettlementQueryVo settlementQueryVo) throws IOException {
         verifyUploadPath();
-        List<ExportSuperviseSettlementDetailJyExcelDto> exportSuperviseSettlementDetailJyExcelDtos = baseMapper.getSuperviseSettlementDetailJyExcelDtos(settlementQueryVo);
-        exportSuperviseSettlementDetailJyExcelDtos.forEach(dto -> {
+        Page<ExportSuperviseSettlementDetailJyExcelDto> exportSuperviseSettlementDetailJyExcelDtos = baseMapper.getSuperviseSettlementDetailJyExcelDtos(page,settlementQueryVo);
+        exportSuperviseSettlementDetailJyExcelDtos.getRecords().forEach(dto -> {
             if (dto.getInvoiceParty().equals("1")) {
                 dto.setInvoiceParty("我方开票");
             } else if (dto.getInvoiceParty().equals("2")) {
@@ -905,14 +960,15 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 dto.setStatus("未结算");
             }
         });
-        return EasyExcelUtils.downExcel(uploadPath, "非车险手续费结算明细", ExportSuperviseSettlementDetailJyExcelDto.class, exportSuperviseSettlementDetailJyExcelDtos);
+        List<ExportSuperviseSettlementDetailJyExcelDto> list = exportSuperviseSettlementDetailJyExcelDtos.getRecords();
+        EasyExcelUtils.exportForWeb(ServletUtils.getResponse(),ExportSuperviseSettlementDetailJyExcelDto.class,list, "车险手续费结算明细(非车)");
     }
 
     /**
      * 导出车险跟单费数据(车险)
      */
     @Override
-    public String exportOtherExcel(ReceivableQueryVo receivableQueryVo) throws IOException {
+    public void exportOtherExcel(ReceivableQueryVo receivableQueryVo) throws IOException {
         verifyUploadPath();
         List<ExportOtherExcelDto> exportOtherExcelDtos = baseMapper.getOtherExcelDtos(receivableQueryVo);
         exportOtherExcelDtos.forEach(dto -> {
@@ -922,14 +978,14 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 case "3" -> dto.setEntryStatus("补录订单");
             }
         });
-        return EasyExcelUtils.downExcel(uploadPath, "车险跟单费应收明细", ExportOtherExcelDto.class, exportOtherExcelDtos);
+        EasyExcelUtils.exportForWeb(ServletUtils.getResponse(),ExportOtherExcelDto.class,exportOtherExcelDtos, "车险跟单费应收");
     }
 
     /**
      * 导出车险跟单费数据(非车险)
      */
     @Override
-    public String exportOtherJyExcel(ReceivableQueryVo receivableQueryVo) throws IOException {
+    public void exportOtherJyExcel(ReceivableQueryVo receivableQueryVo) throws IOException {
         verifyUploadPath();
         List<ExportOtherJyExcelDto> exportOtherJyExcelDtos = baseMapper.getOtherJyExcelDtos(receivableQueryVo);
         exportOtherJyExcelDtos.forEach(dto -> {
@@ -939,17 +995,40 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 case "3" -> dto.setEntryStatus("补录订单");
             }
         });
-        return EasyExcelUtils.downExcel(uploadPath, "非车险跟单费应收明细", ExportOtherJyExcelDto.class, exportOtherJyExcelDtos);
+        EasyExcelUtils.exportForWeb(ServletUtils.getResponse(),ExportOtherJyExcelDto.class,exportOtherJyExcelDtos, "车险跟单费应收(非车险)");
+    }
+
+    @Override
+    public Page<ExportOtherSettlementExcelDto> exportOtherSettlement(Page page,SettlementQueryVo settlementQueryVo) {
+        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("驾意险跟单费");
+            }
+            SysUploadFiles file = sysUploadFilesMapper.selectById(dto.getFileId());
+            if (file != null) {
+                dto.setFileUrl(MinioUtils.getPresignedObjectUrl("jzg",file.getFileName()));
+            }
+        });
+        return exportOtherSettlementExcelDtos;
     }
 
     /**
      * 导出车险跟单费结算记录
      */
     @Override
-    public String exportOtherSettlementExcel(SettlementQueryVo settlementQueryVo) throws IOException {
+    public void exportOtherSettlementExcel(Page page,SettlementQueryVo settlementQueryVo) throws IOException {
         verifyUploadPath();
-        List<ExportOtherSettlementExcelDto> exportOtherSettlementExcelDtos = baseMapper.getOtherSettlementExcelDtos(settlementQueryVo);
-        exportOtherSettlementExcelDtos.forEach(dto -> {
+        Page<ExportOtherSettlementExcelDto> exportOtherSettlementExcelDtos = baseMapper.getOtherSettlementExcelDtos(page,settlementQueryVo);
+        exportOtherSettlementExcelDtos.getRecords().forEach(dto -> {
             if (dto.getInvoiceParty().equals("1")) {
                 dto.setInvoiceParty("我方开票");
             } else if (dto.getInvoiceParty().equals("2")) {
@@ -962,17 +1041,36 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 case "4" -> dto.setInvoiceType("驾意险跟单费");
             }
         });
-        return EasyExcelUtils.downExcel(uploadPath, "非车险跟单费应收明细", ExportSuperviseSettlementExcelDto.class, exportOtherSettlementExcelDtos);
+        List<ExportOtherSettlementExcelDto> list = exportOtherSettlementExcelDtos.getRecords();
+        EasyExcelUtils.exportForWeb(ServletUtils.getResponse(),ExportOtherSettlementExcelDto.class, list, "车险跟单费结算记录");
+    }
+
+    @Override
+    public Page<ExportOtherSettlementDetailExcelDto> otherSettlementDetail(Page page,SettlementQueryVo settlementQueryVo) {
+        Page<ExportOtherSettlementDetailExcelDto> otherSettlementDetail = baseMapper.getOtherSettlementDetailExcelDtos(page,settlementQueryVo);
+        otherSettlementDetail.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("未结算");
+            }
+        });
+        return otherSettlementDetail;
     }
 
     /**
      * 导出应收跟单费结算记录明细(车险)
      */
     @Override
-    public String exportOtherSettlementDetailExcel(SettlementQueryVo settlementQueryVo) throws IOException {
+    public void exportOtherSettlementDetailExcel(Page page,SettlementQueryVo settlementQueryVo) throws IOException {
         verifyUploadPath();
-        List<ExportOtherSettlementDetailExcelDto> exportOtherSettlementDetailExcelDtos = baseMapper.getOtherSettlementDetailExcelDtos(settlementQueryVo);
-        exportOtherSettlementDetailExcelDtos.forEach(dto -> {
+        Page<ExportOtherSettlementDetailExcelDto> exportOtherSettlementDetailExcelDtos = baseMapper.getOtherSettlementDetailExcelDtos(page,settlementQueryVo);
+        exportOtherSettlementDetailExcelDtos.getRecords().forEach(dto -> {
             if (dto.getInvoiceParty().equals("1")) {
                 dto.setInvoiceParty("我方开票");
             } else if (dto.getInvoiceParty().equals("2")) {
@@ -984,7 +1082,8 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 dto.setStatus("未结算");
             }
         });
-        return EasyExcelUtils.downExcel(uploadPath, "车险跟单费结算明细", ExportOtherSettlementDetailExcelDto.class, exportOtherSettlementDetailExcelDtos);
+        List<ExportOtherSettlementDetailExcelDto> list = exportOtherSettlementDetailExcelDtos.getRecords();
+        EasyExcelUtils.exportForWeb(ServletUtils.getResponse(),ExportOtherSettlementDetailExcelDto.class, list, "车险应收跟单费结算记录明细");
     }
 
     /**
@@ -994,10 +1093,10 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
      * @throws IOException
      */
     @Override
-    public String exportOtherSettlementDetailJyExcel(SettlementQueryVo settlementQueryVo) throws IOException {
+    public void exportOtherSettlementDetailJyExcel(Page page, SettlementQueryVo settlementQueryVo) throws IOException {
         verifyUploadPath();
-        List<ExportOtherSettlementDetailJyExcelDto> exportOtherSettlementDetailJyExcelDtos = baseMapper.getOtherSettlementDetailJyExcelDtos(settlementQueryVo);
-        exportOtherSettlementDetailJyExcelDtos.forEach(dto -> {
+        Page<ExportOtherSettlementDetailJyExcelDto> exportOtherSettlementDetailJyExcelDtos = baseMapper.getOtherSettlementDetailJyExcelDtos(page,settlementQueryVo);
+        exportOtherSettlementDetailJyExcelDtos.getRecords().forEach(dto -> {
             if (dto.getInvoiceParty().equals("1")) {
                 dto.setInvoiceParty("我方开票");
             } else if (dto.getInvoiceParty().equals("2")) {
@@ -1009,16 +1108,17 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 dto.setStatus("未结算");
             }
         });
-        return EasyExcelUtils.downExcel(uploadPath, "非车险跟单费结算明细", ExportOtherSettlementDetailJyExcelDto.class, exportOtherSettlementDetailJyExcelDtos);
+        List<ExportOtherSettlementDetailJyExcelDto> list = exportOtherSettlementDetailJyExcelDtos.getRecords();
+        EasyExcelUtils.exportForWeb(ServletUtils.getResponse(),  ExportOtherSettlementDetailJyExcelDto.class, list,"非车险跟单费结算明细");
     }
 
     @Override
     public List<CompanySuperviseSettlementReportDto> companySuperviseSettlementReport(SettlementReportQueryVo settlementReportQueryVo) {
-        // 构建查手续费类型的数组
-        List<String> invoiceTypes = new ArrayList<>();
-        invoiceTypes.add("1");
-        invoiceTypes.add("3");
-        settlementReportQueryVo.setInvoiceTypes(invoiceTypes);
+//        // 构建查手续费类型的数组
+//        List<String> invoiceTypes = new ArrayList<>();
+//        invoiceTypes.add("1");
+//        invoiceTypes.add("3");
+//        settlementReportQueryVo.setInvoiceTypes(invoiceTypes);
         // 手续费应开票金额
         List<InvoiceAmountDto> commissionInvoicingAmount = baseMapper.getSuperviseAmount();
         Map<String, BigDecimal> invoicingAmountMap = commissionInvoicingAmount.stream()
@@ -1031,26 +1131,26 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         List<CompanySuperviseSettlementReportDto> companySuperviseSettlementReportDtos = baseMapper.selectRootCompanies(settlementReportQueryVo);
         for (CompanySuperviseSettlementReportDto companySuperviseSettlementReportDto : companySuperviseSettlementReportDtos) {
             // 递归设置子公司数据
-            setChildren(companySuperviseSettlementReportDto);
+            setChildren(companySuperviseSettlementReportDto,settlementReportQueryVo);
             updateUnInvoicedAmount(companySuperviseSettlementReportDto, invoicingAmountMap);
         }
 
         return companySuperviseSettlementReportDtos;
     }
 
-    private void setChildren(CompanySuperviseSettlementReportDto companySuperviseSettlementReportDto) {
+    private void setChildren(CompanySuperviseSettlementReportDto companySuperviseSettlementReportDto,SettlementReportQueryVo settlementReportQueryVo) {
         // 构建查手续费类型的数组
         List<String> invoiceTypes = new ArrayList<>();
         invoiceTypes.add("1");
         invoiceTypes.add("3");
         // 获取子公司数据
-        List<CompanySuperviseSettlementReportDto> children = baseMapper.selectChildrenByParentId(companySuperviseSettlementReportDto.getCompanyId(),invoiceTypes);
+        List<CompanySuperviseSettlementReportDto> children = baseMapper.selectChildrenByParentId(companySuperviseSettlementReportDto.getCompanyId(),settlementReportQueryVo);
         // 如果子公司存在,递归设置每个子公司的children
         if (children != null && !children.isEmpty()) {
             companySuperviseSettlementReportDto.setChildren(children);
             // 递归调用,设置每个子公司的children
             for (CompanySuperviseSettlementReportDto child : children) {
-                setChildren(child);
+                setChildren(child,settlementReportQueryVo);
 
                 // 将子公司的数据加到父公司
                 companySuperviseSettlementReportDto.setTotalReceivable(
@@ -1102,5 +1202,17 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         BigDecimal value2 = new BigDecimal(amount2 != null ? amount2 : "0");
         return value1.add(value2).toString();
     }
+
+    @Override
+    public Page<ReceiverSettlementReportDto> receiverSettlementReport(Page page,SettlementReportQueryVo settlementReportQueryVo) {
+        return baseMapper.getReceiverSettlementReport(page,settlementReportQueryVo);
+    }
+
+    @Override
+    public void exportReceiverSettlementReportExcel(Page page, SettlementReportQueryVo settlementReportQueryVo) {
+        Page<ReceiverSettlementReportDto> receiverSettlementReport = baseMapper.getReceiverSettlementReport(page,settlementReportQueryVo);
+        List<ReceiverSettlementReportDto> receiverSettlementReportDtos = receiverSettlementReport.getRecords();
+        EasyExcelUtils.exportForWeb(ServletUtils.getResponse(), ReceiverSettlementReportDto.class, receiverSettlementReportDtos, "对接人结算报表");
+    }
 }
 

+ 201 - 56
tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

@@ -205,6 +205,12 @@
         WHERE
             1=1
           AND NOT EXISTS ( SELECT 1 FROM ins_ply_income_invoice_link ipil WHERE ipil.income_id = ipi.id )
+        <if test = "receivableQueryVo.ids != null and receivableQueryVo.ids.size > 0">
+            AND ipi.id in
+            <foreach collection="receivableQueryVo.ids" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
         <if test="receivableQueryVo.queryType != null and receivableQueryVo.queryType == 1">
             AND ipi.supervise_settlement = 0
         </if>
@@ -296,6 +302,9 @@
         <if test="receivableQueryVo.signingTimeStart != null and receivableQueryVo.signingTimeStart != ''">
             AND ipi.signing_time between #{receivableQueryVo.signingTimeStart} and  #{receivableQueryVo.signingTimeEnd}
         </if>
+        <if test="receivableQueryVo.agreementType != null and receivableQueryVo.agreementType != ''">
+            AND ipi.agreement_type = #{receivableQueryVo.agreementType}
+        </if>
     </select>
 
     <select id="getSuperviseJyExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportSuperviseJyExcelDto">
@@ -308,7 +317,7 @@
         io.entry_status as entryStatus,
         ipi.license_no as licenseNo,
         (ipi.jq_receivable_premium + ipi.sy_receivable_premium + ipi.jy_receivable_premium) as receivableAmount,
-        ipi.product_name as productName,
+        io.product_name as productName,
         iocui.name AS insuredPerson,
         ipi.jy_premium as jqPremium,
         ipi.jy_supervise_costs_proportion as jqSuperviseCostsProportion,
@@ -362,27 +371,33 @@
         <if test="receivableQueryVo.signingTimeStart != null and receivableQueryVo.signingTimeStart != ''">
             AND ipi.signing_time between #{receivableQueryVo.signingTimeStart} and  #{receivableQueryVo.signingTimeEnd}
         </if>
+        <if test="receivableQueryVo.agreementType != null and receivableQueryVo.agreementType != ''">
+            AND ipi.agreement_type = #{receivableQueryVo.agreementType}
+        </if>
     </select>
 
-    <select id="getSuperviseSettlementExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportSuperviseSettlementExcelDto">
+    <select id="superviseSettlementExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportSuperviseSettlementExcelDto">
         select
-            ipiis.id as settlementId,
-            ipiis.invoice_id as invoiceId,
-            ipi.company_name as companyName,
-            ipii.invoice_type as invoiceType,
-            ipii.invoice_party as invoiceParty,
-            ipii.tax_point as taxPoint,
-            ipiis.actual_received_amount as actualReceivedAmount,
-            ipiis.receive_payment_date as receivePaymentDate,
-            ipiis.create_by as createBy,
-            ipiis.create_time as createTime
+        ipiis.id as settlementId,
+        ipiis.invoice_id as invoiceId,
+        io.company_name as companyName,
+        ipii.invoice_type as invoiceType,
+        ipii.invoice_party as invoiceParty,
+        ipii.tax_point as taxPoint,
+        ipiis.actual_received_amount as actualReceivedAmount,
+        ipiis.receive_payment_date as receivePaymentDate,
+        ipiis.create_by as createBy,
+        ipiis.create_time as createTime,
+        ipiisf.file_id as fileId
         FROM
-            ins_ply_income_invoice_settlement ipiis
+        ins_ply_income_invoice_settlement ipiis
+        LEFT JOIN ins_ply_income_invoice_settlement_file ipiisf ON ipiisf.settlement_id = ipiis.id
         LEFT JOIN ins_ply_income_invoice ipii ON ipii.id = ipiis.invoice_id
         LEFT JOIN ins_ply_income_invoice_link ipil ON ipil.invoice_id = ipiis.invoice_id
         LEFT JOIN ins_ply_income ipi ON ipi.id = ipil.income_id
+        LEFT JOIN ins_orders io ON ipi.order_no = io.id
         WHERE
-            1=1
+        1=1
         <if test="settlementQueryVo.settlementIds != null and settlementQueryVo.settlementIds != ''">
             AND ipiis.id IN
             <foreach collection="settlementQueryVo.settlementIds" item="settlementId" open="(" separator="," close=")">
@@ -390,13 +405,49 @@
             </foreach>
         </if>
         <if test="settlementQueryVo.invoiceTypes != null and settlementQueryVo.invoiceTypes != ''">
-            AND ipi.invoice_type IN
+            AND ipii.invoice_type IN
             <foreach collection="settlementQueryVo.invoiceTypes" item="invoiceType" open="(" separator="," close=")">
                 #{invoiceType}
             </foreach>
         </if>
+        <if test="settlementQueryVo.agreementType != null and settlementQueryVo.agreementType != ''">
+            AND ipii.agreement_type = #{agreementType}
+        </if>
     </select>
 
+<!--    <select id="getSuperviseSettlementExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportSuperviseSettlementExcelDto">-->
+<!--        select-->
+<!--            ipiis.id as settlementId,-->
+<!--            ipiis.invoice_id as invoiceId,-->
+<!--            ipi.company_name as companyName,-->
+<!--            ipii.invoice_type as invoiceType,-->
+<!--            ipii.invoice_party as invoiceParty,-->
+<!--            ipii.tax_point as taxPoint,-->
+<!--            ipiis.actual_received_amount as actualReceivedAmount,-->
+<!--            ipiis.receive_payment_date as receivePaymentDate,-->
+<!--            ipiis.create_by as createBy,-->
+<!--            ipiis.create_time as createTime-->
+<!--        FROM-->
+<!--            ins_ply_income_invoice_settlement ipiis-->
+<!--        LEFT JOIN ins_ply_income_invoice ipii ON ipii.id = ipiis.invoice_id-->
+<!--        LEFT JOIN ins_ply_income_invoice_link ipil ON ipil.invoice_id = ipiis.invoice_id-->
+<!--        LEFT JOIN ins_ply_income ipi ON ipi.id = ipil.income_id-->
+<!--        WHERE-->
+<!--            1=1-->
+<!--        <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 ipi.invoice_type IN-->
+<!--            <foreach collection="settlementQueryVo.invoiceTypes" item="invoiceType" open="(" separator="," close=")">-->
+<!--                #{invoiceType}-->
+<!--            </foreach>-->
+<!--        </if>-->
+<!--    </select>-->
+
     <select id="getSuperviseSettlementDetailExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportSuperviseSettlementDetailExcelDto">
         select
         ipiis.id as settlementId, -- 结算记录编号
@@ -416,6 +467,9 @@
         ipi.sy_premium as syPremium, -- 商业保费
         ipi.sy_supervise_costs_proportion as sySuperviseCostsProportion, -- 商业手续费比例
         ipi.sy_policy_no as syPolicyNo, -- 商业保单号
+        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, -- 开票时间
@@ -436,7 +490,7 @@
             </foreach>
         </if>
         <if test="settlementQueryVo.invoiceTypes != null and settlementQueryVo.invoiceTypes != ''">
-            AND ipi.invoice_type IN
+            AND ipii.invoice_type IN
             <foreach collection="settlementQueryVo.invoiceTypes" item="invoiceType" open="(" separator="," close=")">
                 #{invoiceType}
             </foreach>
@@ -456,6 +510,9 @@
         <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 ipii.agreement_type = #{settlementQueryVo.agreementType}
+        </if>
     </select>
 
     <select id="getSuperviseSettlementDetailJyExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportSuperviseSettlementDetailJyExcelDto">
@@ -494,7 +551,7 @@
             </foreach>
         </if>
         <if test="settlementQueryVo.invoiceTypes != null and settlementQueryVo.invoiceTypes != ''">
-            AND ipi.invoice_type IN
+            AND ipii.invoice_type IN
             <foreach collection="settlementQueryVo.invoiceTypes" item="invoiceType" open="(" separator="," close=")">
                 #{invoiceType}
             </foreach>
@@ -514,6 +571,9 @@
         <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>
     </select>
 
     <select id="getOtherExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportOtherExcelDto">
@@ -526,7 +586,7 @@
             io.entry_status as entryStatus,
             ipi.license_no as licenseNo,
             (ipi.jq_other_costs_premiums + ipi.sy_other_costs_premiums + ipi.jy_other_costs_premiums) as receivableAmount,
-            ipi.product_name as productName,
+            io.product_name as productName,
             iocui.name AS insuredPerson,
             ipi.jq_premium as jqPremium,
             ipi.jq_other_costs_proportion as jqSuperviseCostsProportion,
@@ -540,12 +600,21 @@
             ipi.create_time as createTime,
             ipi.contact_person as contactPerson
         FROM ins_ply_income ipi
-        LEFT JOIN ins_order io ON ipi.order_no = io.order_no
+        LEFT JOIN ins_orders io ON ipi.order_no = io.id
         LEFT JOIN ins_orders_car_user_info iocui ON ipi.order_no = iocui.order_no and iocui.policy_person_type = '3'
         LEFT JOIN ins_orders_risk ior1 ON ipi.order_no = ior1.order_no and ior1.risk_code = '0507'
         LEFT JOIN ins_orders_risk ior2 ON ipi.order_no = ior2.order_no and ior2.risk_code = '0510'
         WHERE
             1=1
+        <if test="receivableQueryVo.queryType != null and receivableQueryVo.queryType == 1">
+            AND ipi.supervise_settlement = 0
+        </if>
+        <if test="receivableQueryVo.queryType!= null and receivableQueryVo.queryType == 2">
+            AND ipi.other_settlement = 1
+        </if>
+        <if test="receivableQueryVo.queryType!= null and (receivableQueryVo.queryType == 3 or receivableQueryVo.queryType == 4)">
+            AND ipi.jy_premium != 0
+        </if>
         <if test="receivableQueryVo.licenseNo != null and receivableQueryVo.licenseNo != ''">
             and ipi.licenseNo = #{receivableQueryVo.licenseNo}
         </if>
@@ -585,12 +654,21 @@
             ior2.start_date as syStartDate,
             ipi.create_time as createTime
         FROM ins_ply_income ipi
-        LEFT JOIN ins_order io ON ipi.order_no = io.order_no
+        LEFT JOIN ins_orders io ON ipi.order_no = io.order_no
         LEFT JOIN ins_orders_car_user_info iocui ON ipi.order_no = iocui.order_no and iocui.policy_person_type = '3'
         LEFT JOIN ins_orders_risk ior1 ON ipi.order_no = ior1.order_no and ior1.risk_code = '0507'
         LEFT JOIN ins_orders_risk ior2 ON ipi.order_no = ior2.order_no and ior2.risk_code = '0510'
         WHERE
         1=1
+        <if test="receivableQueryVo.queryType != null and receivableQueryVo.queryType == 1">
+            AND ipi.supervise_settlement = 0
+        </if>
+        <if test="receivableQueryVo.queryType!= null and receivableQueryVo.queryType == 2">
+            AND ipi.other_settlement = 1
+        </if>
+        <if test="receivableQueryVo.queryType!= null and (receivableQueryVo.queryType == 3 or receivableQueryVo.queryType == 4)">
+            AND ipi.jy_premium != 0
+        </if>
         <if test="receivableQueryVo.licenseNo != null and receivableQueryVo.licenseNo != ''">
             and ipi.licenseNo = #{receivableQueryVo.licenseNo}
         </if>
@@ -637,11 +715,14 @@
             </foreach>
         </if>
         <if test="settlementQueryVo.invoiceTypes != null and settlementQueryVo.invoiceTypes != ''">
-            AND ipi.invoice_type IN
+            AND ipii.invoice_type IN
             <foreach collection="settlementQueryVo.invoiceTypes" item="invoiceType" open="(" separator="," close=")">
                 #{invoiceType}
             </foreach>
         </if>
+        <if test="settlementQueryVo.agreementType != null and settlementQueryVo.agreementType != ''">
+            AND ipii.agreement_type = #{settlementQueryVo.agreementType}
+        </if>
     </select>
 
     <select id="getOtherSettlementDetailExcelDtos" resultType="com.jzg.commons.entity.finance.dto.ExportOtherSettlementDetailExcelDto">
@@ -683,7 +764,7 @@
             </foreach>
         </if>
         <if test="settlementQueryVo.invoiceTypes != null and settlementQueryVo.invoiceTypes != ''">
-            AND ipi.invoice_type IN
+            AND ipii.invoice_type IN
             <foreach collection="settlementQueryVo.invoiceTypes" item="invoiceType" open="(" separator="," close=")">
                 #{invoiceType}
             </foreach>
@@ -701,7 +782,10 @@
             AND ipiis.create_by = #{settlementQueryVo.settlementPerson}
         </if>
         <if test="settlementQueryVo.settlementTimeStart != null and settlementQueryVo.settlementTimeStart != ''">
-            AND ipiis.create_time between #{receivableQueryVo.signingTimeStart} and #{receivableQueryVo.signingTimeEnd}
+            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>
     </select>
 
@@ -741,7 +825,7 @@
             </foreach>
         </if>
         <if test="settlementQueryVo.invoiceTypes != null and settlementQueryVo.invoiceTypes != ''">
-            AND ipi.invoice_type IN
+            AND ipii.invoice_type IN
             <foreach collection="settlementQueryVo.invoiceTypes" item="invoiceType" open="(" separator="," close=")">
                 #{invoiceType}
             </foreach>
@@ -761,6 +845,9 @@
         <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>
     </select>
 
     <select id="getReceivableCompany" resultType="com.jzg.commons.entity.po.EsmInsCompany">
@@ -850,7 +937,9 @@
         <result column="company_id" property="companyId"/>
         <result column="company_name" property="companyName"/>
         <result column="total_receivable" property="totalReceivable"/>
+        <result column="total_follow_fee" property="totalFollowFee"/>
         <result column="supervise_fee" property="superviseFee"/>
+        <result column="follow_fee" property="followFee"/>
         <result column="invoiced_amount" property="invoicedAmount"/>
         <result column="settled_amount" property="settledAmount"/>
         <result column="un_invoiced_amount" property="unInvoicedAmount"/>
@@ -864,14 +953,14 @@
             eic.name as company_name,
             COALESCE(SUM(ipi.jq_receivable_premium + ipi.sy_receivable_premium + ipi.jy_receivable_premium), 0) as total_receivable,
             COALESCE(SUM(ipi.jq_supervise_costs_premiums + ipi.sy_supervise_costs_premiums + ipi.jy_supervise_costs_premiums), 0) as supervise_fee,
---             COALESCE(SUM(fee_summary.total_commission), 0) as 佣金总和,
+            COALESCE(SUM(ipi.jq_other_costs_premiums + ipi.sy_other_costs_premiums + ipi.jy_other_costs_premiums), 0) as follow_fee,
             COALESCE(SUM(invoice_summary.total_invoice), 0) as invoiced_amount,
---             COALESCE(SUM(fee_summary.total_commission) - SUM(invoice_summary.total_invoice), 0) as un_invoiced_amount,
+            COALESCE(SUM(fee_summary.total_commission) - SUM(invoice_summary.total_invoice), 0) as un_invoiced_amount,
             COALESCE(SUM(invoice_summary.settled_invoice), 0) as settled_amount,
             COALESCE(SUM(invoice_summary.unsettled_invoice), 0) as un_settled_amount
         FROM
             esm_ins_company eic
-            LEFT JOIN ins_ply_income ipi ON eic.id = ipi.company_id
+            LEFT JOIN ins_ply_income ipi ON eic.id = ipi.company_id and ipi.agreement_type = #{settlementReportQueryVo.agreementType}
             LEFT JOIN (
             SELECT
             ipiil.income_id,
@@ -881,23 +970,29 @@
             FROM ins_ply_income_invoice_link ipiil
             LEFT JOIN ins_ply_income_invoice ipii
             ON ipii.id = ipiil.invoice_id
-            AND ipii.invoice_type IN
+            <where>
                 <if test="settlementReportQueryVo.invoiceTypes != null and settlementReportQueryVo.invoiceTypes.size() > 0">
-                <foreach item="item" collection="settlementReportQueryVo.invoiceTypes" separator="," open="(" close=")" index="">
-                    #{item}
-                </foreach>
+                    AND ipii.invoice_type IN
+                    <foreach item="item" collection="settlementReportQueryVo.invoiceTypes" separator="," open="(" close=")">
+                        #{item}
+                    </foreach>
+                </if>
+                <if test="settlementReportQueryVo.status != null and settlementReportQueryVo.status != ''">
+                    and ipii.status = #{settlementReportQueryVo.status}
                 </if>
+            </where>
             GROUP BY ipiil.income_id
             ) invoice_summary ON invoice_summary.income_id = ipi.id
---             LEFT JOIN (
---             SELECT
---             ifo.order_no,
---             SUM(DISTINCT (ifo.jq_commission_premium + ifo.sy_commission_premium + ifo.jy_commission_premium)) as total_commission
---             FROM ins_fee_orders ifo
---             GROUP BY ifo.order_no
---             ) fee_summary ON ipi.order_no = fee_summary.order_no
         WHERE
-            eic.parent_id = 0
+        eic.parent_id = 0
+            <if test="settlementReportQueryVo.companyId != null and settlementReportQueryVo.companyId != ''">
+                and eic.id = #{settlementReportQueryVo.companyId}
+            </if>
+            <if test="settlementReportQueryVo.startTime != null and settlementReportQueryVo.startTime != ''">
+                AND ipi.signing_time BETWEEN #{settlementReportQueryVo.startTime} AND #{settlementReportQueryVo.endTime}
+                AND (invoice_summary.invoiceTime BETWEEN #{settlementReportQueryVo.startTime} AND #{settlementReportQueryVo.endTime}
+                OR invoice_summary.invoiceTime IS NULL)
+            </if>
         GROUP BY
             eic.id,
             eic.name;
@@ -911,12 +1006,11 @@
             COALESCE(SUM(ipi.jq_receivable_premium + ipi.sy_receivable_premium + ipi.jy_receivable_premium), 0) as total_receivable,
             COALESCE(SUM(ipi.jq_supervise_costs_premiums + ipi.sy_supervise_costs_premiums + ipi.jy_supervise_costs_premiums), 0) as supervise_fee,
             COALESCE(SUM(invoice_summary.total_invoice), 0) as invoiced_amount,
---             COALESCE(SUM(fee_summary.total_commission) - SUM(invoice_summary.total_invoice), 0) as un_invoiced_amount,
             COALESCE(SUM(invoice_summary.settled_invoice), 0) as settled_amount,
             COALESCE(SUM(invoice_summary.unsettled_invoice), 0) as un_settled_amount
         FROM
             esm_ins_company eic
-                LEFT JOIN ins_ply_income ipi ON eic.id = ipi.company_id
+                LEFT JOIN ins_ply_income ipi ON eic.id = ipi.company_id and ipi.agreement_type = #{settlementReportQueryVo.agreementType}
                 LEFT JOIN (
                 SELECT
                     ipiil.income_id,
@@ -924,25 +1018,34 @@
                     SUM(CASE WHEN ipii.status = 1 THEN ipii.receivable_supervise_premium ELSE 0 END) as settled_invoice,
                     SUM(CASE WHEN ipii.status = 0 THEN ipii.receivable_supervise_premium ELSE 0 END) as unsettled_invoice
                 FROM ins_ply_income_invoice_link ipiil
-                         LEFT JOIN ins_ply_income_invoice ipii
-                                   ON ipii.id = ipiil.invoice_id
-                                       AND ipii.invoice_type IN
-                                        <if test="invoiceTypes != null and !invoiceTypes.isEmpty()">
-                                            <foreach item="item" collection="invoiceTypes" open="(" separator="," close=")">
-                                                #{item}
-                                            </foreach>
-                                        </if>
+                LEFT JOIN ins_ply_income_invoice ipii
+                ON ipii.id = ipiil.invoice_id
+                <where>
+                    <if test="settlementReportQueryVo.invoiceTypes != null and settlementReportQueryVo.invoiceTypes.size() > 0">
+                        AND ipii.invoice_type IN
+                        <foreach item="item" collection="settlementReportQueryVo.invoiceTypes" separator="," open="(" close=")">
+                            #{item}
+                        </foreach>
+                    </if>
+                    <if test="settlementReportQueryVo.status != null and settlementReportQueryVo.status != ''">
+                        and ipii.status = #{settlementReportQueryVo.status}
+                    </if>
+                </where>
                 GROUP BY ipiil.income_id
             ) invoice_summary ON invoice_summary.income_id = ipi.id
---                 LEFT JOIN (
---                 SELECT
---                     ifo.order_no,
---                     SUM(DISTINCT (ifo.jq_commission_premium + ifo.sy_commission_premium + ifo.jy_commission_premium)) as total_commission
---                 FROM ins_fee_orders ifo
---                 GROUP BY ifo.order_no
---             ) fee_summary ON ipi.order_no = fee_summary.order_no
         WHERE
             eic.parent_id = #{parentId}
+        <if test="settlementReportQueryVo.companyId != null and settlementReportQueryVo.companyId != ''">
+            and eic.id = #{settlementReportQueryVo.companyId}
+        </if>
+        <if test="settlementReportQueryVo.startTime != null and settlementReportQueryVo.startTime != ''">
+            AND ipi.signing_time BETWEEN #{settlementReportQueryVo.startTime} AND #{settlementReportQueryVo.endTime}
+            AND (invoice_summary.invoiceTime BETWEEN #{settlementReportQueryVo.startTime} AND #{settlementReportQueryVo.endTime}
+            OR invoice_summary.invoiceTime IS NULL)
+        </if>
+        <if test="settlementReportQueryVo.status != null and settlementReportQueryVo.status != ''">
+            AND ipi.status = #{settlementReportQueryVo.status}
+        </if>
         GROUP BY
             eic.id,
             eic.name;
@@ -966,4 +1069,46 @@
             eic.id;
     </select>
 
+    <select id="getReceiverSettlementReport" resultType="com.jzg.commons.entity.finance.dto.ReceiverSettlementReportDto">
+        SELECT
+            ipi.contact_person AS receiver,
+            ipi.company_name AS companyName,
+            -- 原有的应收费用合计
+            SUM(ipi.jq_supervise_costs_premiums + ipi.sy_supervise_costs_premiums + ipi.jy_supervise_costs_premiums) AS superviseFee,
+            SUM(ipi.jq_other_costs_premiums + ipi.sy_other_costs_premiums + ipi.jy_other_costs_premiums) AS followFee,
+            SUM(
+                        (ipi.jq_supervise_costs_premiums + ipi.sy_supervise_costs_premiums + ipi.jy_supervise_costs_premiums) +
+                        (ipi.jq_other_costs_premiums + ipi.sy_other_costs_premiums + ipi.jy_other_costs_premiums)
+                ) AS totalReceivable,
+            -- 已结算费用统计
+            SUM(CASE WHEN ipii.`status` = 1 AND ipii.invoice_type in (1,3) THEN ipii.receivable_supervise_premium ELSE 0 END) AS settledSuperviseFee,
+            SUM(CASE WHEN ipii.`status` = 1 AND ipii.invoice_type in (2,4) THEN ipii.receivable_supervise_premium ELSE 0 END) AS settledFollowFee,
+            SUM(CASE WHEN ipii.`status` = 1 AND ipii.invoice_type IN (1,2) THEN ipii.receivable_supervise_premium ELSE 0 END) AS settledAmount,
+            -- 未结算费用统计
+            SUM(CASE WHEN ipii.`status` = 0 AND ipii.invoice_type in (1,3) THEN ipii.receivable_supervise_premium ELSE 0 END) AS unSettledSuperviseFee,
+            SUM(CASE WHEN ipii.`status` = 0 AND ipii.invoice_type in (2,4) THEN ipii.receivable_supervise_premium ELSE 0 END) AS unSettledFollowFee,
+            SUM(CASE WHEN ipii.`status` = 0 AND ipii.invoice_type IN (1,2) THEN ipii.receivable_supervise_premium ELSE 0 END) AS unSettledAmount
+        FROM
+            ins_ply_income ipi
+                LEFT JOIN ins_ply_income_invoice_link ipil
+                          ON ipi.id = ipil.income_id
+                LEFT JOIN ins_ply_income_invoice ipii
+                          ON ipil.invoice_id = ipii.id
+        where ipi.agreement_type = '1'
+        <if test="settlementReportQueryVo.companyId != null and settlementReportQueryVo.companyId != ''">
+            and ipi.company_id = #{settlementReportQueryVo.companyId}
+        </if>
+        <if test="settlementReportQueryVo.receiver != null and settlementReportQueryVo.receiver != ''">
+            and ipi.contact_person = #{settlementReportQueryVo.receiver}
+        </if>
+        <if test="settlementReportQueryVo.startTime != null and settlementReportQueryVo.startTime != ''">
+            and ipi.signing_time BETWEEN #{settlementReportQueryVo.startTime} AND #{settlementReportQueryVo.endTime}
+            and (ipii.invoice_time BETWEEN #{settlementReportQueryVo.startTime} AND #{settlementReportQueryVo.endTime}
+            OR ipii.invoice_time IS NULL)
+        </if>
+        GROUP BY
+            ipi.contact_person,
+            ipi.company_name
+    </select>
+
 </mapper>