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

Merge branch 'dev_jzg_lipf_v20260622'

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

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

@@ -310,4 +310,17 @@ public class InsPlyIncome extends BaseModel {
     @Schema(description = "地区归属")
     private String companyNameSimple;
 
+    @TableField(exist = false)
+    @Schema(description = "交强总比例")
+    private String jqTotalProportion;
+
+    @TableField(exist = false)
+    @Schema(description = "商业总比例")
+    private String syTotalProportion;
+
+    @TableField(exist = false)
+    @Schema(description = "非车总比例")
+    private String jyTotalProportion;
+
+
 }

+ 33 - 0
commons/src/main/java/com/jzg/commons/entity/finance/vo/BatchModifyVo.java

@@ -5,6 +5,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.LocalDateTime;
 import java.util.List;
 
@@ -56,4 +57,36 @@ public class BatchModifyVo {
     @Schema(description = "修改标识 1-手续费 2-跟单费 3-驾意险 4-所有都改")
     private String updateFlag;
 
+    /**
+     * 所有的比例都转换为百分比,除以100.
+     */
+    public void divide100() {
+
+        // 定义除数 100,保留两位小数即可,后续计算会根据业务需要自行处理精度
+        BigDecimal divisor = new BigDecimal("100");
+        // 交强手续费比例
+        if (this.jqSuperviseCostsProportion != null) {
+            this.jqSuperviseCostsProportion = this.jqSuperviseCostsProportion.divide(divisor,5, RoundingMode.HALF_EVEN);
+        }
+        // 商业手续费比例
+        if (this.sySuperviseCostsProportion != null) {
+            this.sySuperviseCostsProportion = this.sySuperviseCostsProportion.divide(divisor, 5,RoundingMode.HALF_EVEN);
+        }
+        // 驾意手续费比例
+        if (this.jySuperviseCostsProportion != null) {
+            this.jySuperviseCostsProportion = this.jySuperviseCostsProportion.divide(divisor, 5,RoundingMode.HALF_EVEN);
+        }
+        // 交强跟单费比例
+        if (this.jqOtherCostsProportion != null) {
+            this.jqOtherCostsProportion = this.jqOtherCostsProportion.divide(divisor, 5, RoundingMode.HALF_EVEN);
+        }
+        // 商业跟单费比例
+        if (this.syOtherCostsProportion != null) {
+            this.syOtherCostsProportion = this.syOtherCostsProportion.divide(divisor, 5, RoundingMode.HALF_EVEN);
+        }
+        // 驾意跟单费比例
+        if (this.jyOtherCostsProportion != null) {
+            this.jyOtherCostsProportion = this.jyOtherCostsProportion.divide(divisor, 5,RoundingMode.HALF_EVEN);
+        }
+    }
 }

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

@@ -0,0 +1,36 @@
+package com.jzg.commons.entity.finance.vo;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 保险公司结算费用实体
+ */
+@Data
+public class FollowCompanyFeeVO {
+
+    private String companyName;
+
+    private String companyId;
+
+    /** 分支保险公司ID partner_company_id */
+    private String partnerCompanyId;
+
+    /** 已开票总金额 SUM(invoiced) */
+    private BigDecimal totalInvoiced;
+
+    /** 未开票总金额 SUM(uninvoiced) */
+    private BigDecimal totalUnInvoiced;
+
+    /** 已结算总金额 SUM(实收金额 actual_received_amount) */
+    private BigDecimal totalSettlementAmount;
+
+    /** 未结算总金额  totalInvoiced - totalSettlementAmount */
+    private BigDecimal totalUnSettlementAmount;
+
+    /** 累计应收  totalReceivable */
+    private BigDecimal totalReceivable;
+
+}

+ 0 - 1
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/controller/InsFeeAuditController.java

@@ -23,7 +23,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
-import java.util.Objects;
 
 @Tag(name="订单审核接口")
 @RestController

+ 6 - 6
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsFeeAuditServiceImpl.java

@@ -823,12 +823,12 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
         String systemCode = baseController.getSystemCode();
         String userName = baseController.getUserName();
         log.info("保存调整后的费用:systemCode=[{}], userName=[{}],param=[{}]", systemCode, userName, JSONUtil.toJsonStr(param));
-        // add by lipf, 2026年6月22日10:15:51 已经审核通过的订单不能在让调整费用,否则会造成费用不一致。 会影响很多地方
-        String orderNo = param.getOrderNo();
-        HttpResult<String> validateRes = this.validateOrderCheck(orderNo);
-        if(validateRes.isFail()){
-            return validateRes;
-        }
+        // add by lipf, 2026年6月22日10:15:51 已经审核通过的订单不能在让调整费用,否则会造成费用不一致。 会影响很多地方. 实际业务场景存在审核通过后,调整费用的情况
+//        String orderNo = param.getOrderNo();
+//        HttpResult<String> validateRes = this.validateOrderCheck(orderNo);
+//        if(validateRes.isFail()){
+//            return validateRes;
+//        }
         try {
             feeOrdersService.calcCosts(param);
         } catch (ReflectiveOperationException e) {

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

@@ -1691,6 +1691,12 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
                 log.info("根据订单号[{}]没有找到车险订单信息和订单的费用信息",orderNo);
                 continue;
             }
+            // add by lipf, 进行费用的修改
+            if(this.rationIsNotNull(batchModifyVo)){
+                log.info("费用比例不为空,同步调整费用。batchModifyVo=[{}]", JSONUtil.toJsonStr(batchModifyVo));
+                PtlAgreementCostRatioVo param = this.calRatio(insFeeOrders,batchModifyVo);
+                insFeeAuditService.saveCostInfo(param);
+            }
             log.info("车险订单[{}]对应的订单明细是[{}]", orderNo, JSONUtil.toJsonStr(oldInsOrders));
             if(batchModifyVo.getSigningTime() != null){
                 baseMapper.update(null, new LambdaUpdateWrapper<InsOrders>()
@@ -1716,4 +1722,78 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
         log.info(msg);
         return HttpResult.ok(msg);
     }
+
+    /**
+     * 结合原有的费用比例,计算更新后的费用比例
+     *
+     * @param insFeeOrders 订单的费用信息
+     * @param batchModifyVo 批量修改的费用比例
+     *
+     * @author lipf
+     * @date 2026/6/23 16:35
+     */
+    private PtlAgreementCostRatioVo calRatio(InsFeeOrders insFeeOrders, BatchModifyVo batchModifyVo) {
+        log.info("batchModifyVo.转换百分比之前的数据=【{}】", JSONUtil.toJsonStr(batchModifyVo));
+
+        batchModifyVo.divide100();
+
+        PtlAgreementCostRatioVo vo = new PtlAgreementCostRatioVo();
+        vo.setOrderNo(insFeeOrders.getOrderNo());
+
+        // 加投费比例
+        vo.setJqAdditionalRatio(insFeeOrders.getJqAdditionalRatio());
+        vo.setSyAdditionalRatio(insFeeOrders.getSyAdditionalRatio());
+        vo.setJyAdditionalRatio(insFeeOrders.getJyAdditionalRatio());
+
+        // 手续费比例
+        vo.setJqCommissionRatio(batchModifyVo.getJqSuperviseCostsProportion() != null ? batchModifyVo.getJqSuperviseCostsProportion(): insFeeOrders.getJqCommissionRatio());
+        vo.setSyCommissionRatio(batchModifyVo.getSySuperviseCostsProportion() != null ? batchModifyVo.getSySuperviseCostsProportion(): insFeeOrders.getSyCommissionRatio());
+        vo.setJyCommissionRatio(batchModifyVo.getJySuperviseCostsProportion() != null ? batchModifyVo.getJySuperviseCostsProportion(): insFeeOrders.getJyCommissionRatio());
+
+        // 跟单费比例
+        vo.setJqFollowRatio(batchModifyVo.getJqOtherCostsProportion() != null ? batchModifyVo.getJqOtherCostsProportion(): insFeeOrders.getJqFollowRatio());
+        vo.setSyFollowRatio(batchModifyVo.getSyOtherCostsProportion() != null ? batchModifyVo.getSyOtherCostsProportion(): insFeeOrders.getSyFollowRatio());
+        vo.setJyFollowRatio(batchModifyVo.getJyOtherCostsProportion() != null ? batchModifyVo.getJyOtherCostsProportion(): insFeeOrders.getJyFollowRatio());
+
+        // 入口比例
+        vo.setJqInletRatio(BigDecimalUtil.add(vo.getJqCommissionRatio(), vo.getJqFollowRatio()));
+        vo.setSyInletRatio(BigDecimalUtil.add(vo.getSyCommissionRatio(), vo.getSyFollowRatio()));
+        vo.setJyInletRatio(BigDecimalUtil.add(vo.getJyCommissionRatio(), vo.getJyFollowRatio()));
+
+        // 出口比例
+        vo.setJqExportRatio(insFeeOrders.getJqExportRatio());
+        vo.setSyExportRatio(insFeeOrders.getSyExportRatio());
+        vo.setJyExportRatio(insFeeOrders.getJyExportRatio());
+
+        // 留点比例
+        vo.setJqKeepPointRatio(BigDecimalUtil.subtract(BigDecimalUtil.add(vo.getJqInletRatio(), vo.getJqAdditionalRatio()),vo.getJqExportRatio()));
+        vo.setSyKeepPointRatio(BigDecimalUtil.subtract(BigDecimalUtil.add(vo.getSyInletRatio(), vo.getSyAdditionalRatio()),vo.getSyExportRatio()));
+        vo.setJyKeepPointRatio(BigDecimalUtil.subtract(BigDecimalUtil.add(vo.getJyInletRatio(), vo.getJyAdditionalRatio()),vo.getJyExportRatio()));
+
+        // 出口留点比例
+        vo.setJqExportKeepPointRatio(insFeeOrders.getJqExportKeepPointRatio());
+        vo.setSyExportKeepPointRatio(insFeeOrders.getSyExportKeepPointRatio());
+        vo.setJyExportKeepPointRatio(insFeeOrders.getJyExportKeepPointRatio());
+        log.info("调整前的比例:fee=[{}]", JSONUtil.toJsonStr(insFeeOrders));
+        log.info("调整后的比例信息:vo=[{}]", JSONUtil.toJsonStr(vo));
+        return vo;
+    }
+
+    /**
+     * 存在是否不为空的费用比例
+     *      所有费用比例都为空,返回false, 有任意一个不为空,返回true
+     *
+     * @author lipf
+     * @date 2026/6/23 16:34
+     */
+    private boolean rationIsNotNull(BatchModifyVo vo) {
+        boolean hasSuperviseOrOtherCosts = vo.getJqSuperviseCostsProportion() != null
+                || vo.getSySuperviseCostsProportion() != null
+                || vo.getJySuperviseCostsProportion() != null
+                || vo.getJqOtherCostsProportion() != null
+                || vo.getSyOtherCostsProportion() != null
+                || vo.getJyOtherCostsProportion() != null;
+        log.info("hasSuperviseOrOtherCosts=[{}]",hasSuperviseOrOtherCosts);
+        return hasSuperviseOrOtherCosts;
+    }
 }

+ 19 - 1
tenant/organization/src/main/java/com/jzg/organization/controller/ReceivableController.java

@@ -508,6 +508,12 @@ public class ReceivableController {
         return HttpResult.ok(receivableService.deleteInvoiceById(id) ? "删除成功":"删除失败");
     }
 
+    @DeleteMapping("/deleteFollowInvoiceById/{id}")
+    @Operation(summary = "删除跟单开票记录")
+    public HttpResult<Boolean> deleteFollowInvoiceById(@PathVariable String id){
+        return HttpResult.ok(receivableService.deleteFollowInvoiceById(id) ? "删除成功":"删除失败");
+    }
+
     /**
      * 私有协议批量修改
      *      修改手续费比例(商业险手续费比例, 交强险手续费比例)
@@ -679,7 +685,7 @@ public class ReceivableController {
     }
 
     /**
-     * 私有协议-手续费,跟单费,平台协议三个页面的保险公司报表统计接口
+     * 私有协议-手续费,平台协议两个页面的保险公司报表统计接口
      *
      * @author lipf
      * @date 2026/5/28 11:15
@@ -690,6 +696,18 @@ public class ReceivableController {
         return receivableService.companySuperviseSettlementReport(settlementReportQueryVo);
     }
 
+    /**
+     * 跟单费保险公司报表统计接口
+     *
+     * @author jk
+     * @date 2026/5/28 11:15
+     */
+    @PostMapping("/followCompanySuperviseSettlementReport")
+    @Operation(summary = "保险公司结算报表")
+    public HttpResult<List<FollowCompanyFeeVO>> followCompanySuperviseSettlementReport(@RequestBody SettlementReportQueryVo settlementReportQueryVo) {
+        return HttpResult.ok(receivableService.followCompanySuperviseSettlementReport(settlementReportQueryVo));
+    }
+
     /**
      * 设置指定发票为结算完成状态
      *

+ 9 - 0
tenant/organization/src/main/java/com/jzg/organization/mapper/InsFeeFollowOrderMapper.java

@@ -2,7 +2,10 @@ package com.jzg.organization.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.jzg.commons.entity.finance.po.InsFeeFollowOrder;
+import com.jzg.commons.entity.finance.vo.FollowCompanyFeeVO;
+import com.jzg.commons.entity.finance.vo.SettlementReportQueryVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -11,4 +14,10 @@ import java.util.List;
  */
 @Mapper
 public interface InsFeeFollowOrderMapper extends BaseMapper<InsFeeFollowOrder> {
+
+    /**
+     * 私有协议跟单结算报表 多表联查分组统计
+     */
+    List<FollowCompanyFeeVO> selectFollowCompanySettlementReport(@Param("query") SettlementReportQueryVo queryVo);
+
 }

+ 4 - 0
tenant/organization/src/main/java/com/jzg/organization/service/ReceivableService.java

@@ -501,4 +501,8 @@ public interface ReceivableService extends IService<InsPlyIncome> {
      * @date 2026/6/22 11:40
      */
     HttpResult<String> deletePlatformSettlementById(String id);
+
+    Boolean deleteFollowInvoiceById(String id);
+
+    List<FollowCompanyFeeVO> followCompanySuperviseSettlementReport(SettlementReportQueryVo settlementReportQueryVo);
 }

+ 46 - 0
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -563,6 +563,51 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         return insPlyIncomeInvoiceMapper.deleteById(invoiceId) > 0;
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean deleteFollowInvoiceById(String invoiceId) {
+        log.info("私有协议-跟单开票记录-删除: id=[{}]", invoiceId);
+        QueryWrapper<InsPlyFollowInvoiceLink> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(InsPlyFollowInvoiceLink::getInvoiceId, invoiceId);
+        queryWrapper.lambda().eq(InsPlyFollowInvoiceLink::getIsDelete, 0);
+        List<InsPlyFollowInvoiceLink> insPlyFollowInvoiceLinks = insPlyFollowInvoiceLinkMapper.selectList(queryWrapper);
+
+        if (CollUtil.isNotEmpty(insPlyFollowInvoiceLinks)){
+            List<String> ids = insPlyFollowInvoiceLinks.stream().map(InsPlyFollowInvoiceLink::getId).toList();
+            List<String> followIds = insPlyFollowInvoiceLinks.stream().map(InsPlyFollowInvoiceLink::getFollowId).toList();
+            insPlyFollowInvoiceLinkMapper.deleteByIds(ids);
+            return insFeeFollowOrderMapper.deleteByIds(followIds) > 0;
+        }
+        return Boolean.FALSE;
+    }
+
+    @Override
+    public List<FollowCompanyFeeVO> followCompanySuperviseSettlementReport(SettlementReportQueryVo settlementReportQueryVo) {
+        log.info("私有协议-跟单结算记录-结算报表: settlementReportQueryVo=[{}]", JSONUtil.toJsonStr(settlementReportQueryVo));
+
+        List<FollowCompanyFeeVO> followCompanyFeeVos = insFeeFollowOrderMapper.selectFollowCompanySettlementReport(settlementReportQueryVo);
+        // 查询所有保险公司,匹配保险公司的id和名称
+        HttpResult<Map<String, EsmInsCompany>> mapHttpResult = esmInsCompanyClient.queryAllCompanyMap();
+        Map<String, EsmInsCompany> data = mapHttpResult.getData();
+        if (CollUtil.isEmpty(data)){
+            return followCompanyFeeVos;
+        }
+        for (FollowCompanyFeeVO followCompanyFeeVo : followCompanyFeeVos) {
+            followCompanyFeeVo.setCompanyName(null != data.get(followCompanyFeeVo.getPartnerCompanyId()) ? data.get(followCompanyFeeVo.getPartnerCompanyId()).getName() : "");
+            followCompanyFeeVo.setTotalUnSettlementAmount(followCompanyFeeVo.getTotalInvoiced().subtract(followCompanyFeeVo.getTotalSettlementAmount()));
+        }
+        return followCompanyFeeVos;
+    }
+
+    /**
+     * BigDecimal安全相加工具:null值转为0
+     */
+    private BigDecimal addBigDecimal(BigDecimal base, BigDecimal num) {
+        if (num == null) {
+            return base;
+        }
+        return base.add(num);
+    }
 
     /**
      * 填充必要的字段
@@ -2347,6 +2392,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
 
         // 更新关联订单
         batchModifyVo.setOrderNos(orderNos);
+        log.info("batchModifyVo=[{}]", JSONUtil.toJsonStr(batchModifyVo));
         HttpResult<String> updateOrdersRes = insFeeOrdersClient.updateOrdersBatch(batchModifyVo);
         log.info("更新车险订单的结果:updateOrdersRes=[{}]", JSONUtil.toJsonStr(updateOrdersRes));
         return true;

+ 2 - 0
tenant/organization/src/main/java/com/jzg/organization/service/impl/SysDistributionSettingServiceImpl.java

@@ -136,6 +136,8 @@ public class SysDistributionSettingServiceImpl extends ServiceImpl<SysDistributi
 
     @Override
     public Page<SysDistributionListVo> distributorList(Page page, SysDistributionListVo sysDistributionListVo) {
+        String systemCode = baseController.getSystemCode();
+        log.info("查询分销员信息:systemCode=[{}],sysDistributionListVo=[{}]",systemCode,JSONUtil.toJsonStr(sysDistributionListVo));
         Page<SysDistributionListVo> pageResult = sysDistributionSettingMapper.distributorList(page,sysDistributionListVo);
         pageResult.getRecords().forEach(item->{
             // 初始化保费

+ 92 - 0
tenant/organization/src/main/resources/mapper/InsFeeFollowOrderMapper.xml

@@ -0,0 +1,92 @@
+<?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.organization.mapper.InsFeeFollowOrderMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.jzg.commons.entity.finance.po.InsFeeFollowOrder">
+        <id column="id" property="id" />
+        <result column="year" property="year" />
+        <result column="month" property="month" />
+        <result column="company_id" property="companyId" />
+        <result column="partner_company_id" property="partnerCompanyId" />
+        <result column="receivable_premium" property="receivablePremium" />
+        <result column="signing_time" property="signingTime" />
+        <result column="invoiced" property="invoiced" />
+        <result column="uninvoiced" property="uninvoiced" />
+        <result column="invoiced_amount_time" property="invoicedAmountTime" />
+        <result column="reconciliation_amount" property="reconciliationAmount" />
+        <result column="falsely_increased_difference" property="falselyIncreasedDifference" />
+        <result column="falsely_increased_reason" property="falselyIncreasedReason" />
+        <result column="system_code" property="systemCode" />
+        <!-- 继承自 BaseModel 的公共字段 -->
+        <result column="create_by" property="createBy" />
+        <result column="create_time" property="createTime" />
+        <result column="update_by" property="updateBy" />
+        <result column="update_time" property="updateTime" />
+        <result column="is_delete" property="isDelete" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, `year`, `month`, company_id, partner_company_id, receivable_premium,
+        signing_time, invoiced, uninvoiced, invoiced_amount_time, reconciliation_amount,
+        falsely_increased_difference, falsely_increased_reason, system_code,
+        create_by, create_time, update_by, update_time, is_delete
+    </sql>
+
+    <!-- 根据主键查询 -->
+    <select id="selectById" parameterType="java.lang.String" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_Column_List" />
+        FROM ins_fee_follow_order
+        WHERE id = #{id} AND is_delete = 0
+    </select>
+
+
+    <select id="selectFollowCompanySettlementReport" resultType="com.jzg.commons.entity.finance.vo.FollowCompanyFeeVO">
+        SELECT
+        ffo.partner_company_id AS partnerCompanyId,
+        COALESCE(SUM(ffo.invoiced), 0.00) AS totalInvoiced,
+        COALESCE(SUM(ffo.uninvoiced), 0.00) AS totalUnInvoiced,
+        COALESCE(SUM(sett.actual_received_amount), 0.00) AS totalSettlementAmount,
+        COALESCE(SUM(ffo.reconciliation_amount), 0.00) AS totalReceivable
+        FROM ins_fee_follow_order ffo
+        -- 跟单订单关联发票中间表
+        INNER JOIN ins_ply_follow_invoice_link link
+        ON ffo.id = link.follow_id AND link.is_delete = 0
+        -- 关联发票主表
+        INNER JOIN ins_ply_income_invoice inv
+        ON link.invoice_id = inv.id AND inv.is_delete = 0
+        -- 左连结算表(无结算数据时金额为0)
+        LEFT JOIN ins_ply_income_invoice_settlement sett
+        ON inv.id = sett.invoice_id AND sett.is_delete = 0
+        <where>
+            ffo.is_delete = 0
+            -- 保险公司companyId筛选
+            <if test="query.companyId != null and query.companyId != ''">
+                AND ffo.company_id = #{query.companyId}
+            </if>
+            -- 跟单订单创建时间范围
+            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
+                AND ffo.create_time BETWEEN #{query.startTime} AND #{query.endTime}
+            </if>
+            -- 发票状态筛选
+            <if test="query.status != null">
+                AND inv.status = #{query.status}
+            </if>
+            -- 开票时间范围
+            <if test="query.invoiceStartTime != null and query.invoiceStartTime != '' and query.invoiceEndTime != null and query.invoiceEndTime != ''">
+                AND inv.invoice_time BETWEEN #{query.invoiceStartTime} AND #{query.invoiceEndTime}
+            </if>
+            -- 结算创建时间范围(子查询过滤结算时间)
+            <if test="query.settlementStartTime != null and query.settlementStartTime != '' and query.settlementEndTime != null and query.settlementEndTime != ''">
+                AND sett.create_time BETWEEN #{query.settlementStartTime} AND #{query.settlementEndTime}
+            </if>
+        </where>
+        GROUP BY ffo.partner_company_id
+    </select>
+
+
+</mapper>

+ 3 - 0
tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

@@ -230,6 +230,9 @@
         (COALESCE(ipi.jq_supervise_costs_premiums, 0) + COALESCE(ipi.sy_supervise_costs_premiums, 0) + COALESCE(ipi.jy_supervise_costs_premiums, 0)) AS superviseCostsPremiums,
         -- 3. 总应收跟单费 (修复了括号位置错误,并为最后一个字段补充了默认值 0)
         (COALESCE(ipi.jq_other_costs_premiums, 0) + COALESCE(ipi.sy_other_costs_premiums, 0) + COALESCE(ipi.jy_other_costs_premiums, 0)) AS otherCostsPremiums,
+        (COALESCE(ipi.jq_supervise_costs_proportion, 0) + COALESCE(ipi.jq_other_costs_proportion, 0)) AS jqTotalProportion,
+        (COALESCE(ipi.sy_supervise_costs_proportion, 0) + COALESCE(ipi.sy_other_costs_proportion, 0)) AS syTotalProportion,
+        (COALESCE(ipi.jy_supervise_costs_proportion, 0) + COALESCE(ipi.jy_other_costs_proportion, 0)) AS jyTotalProportion,
         ipi.jq_supervise_costs_premiums,
         ipi.sy_supervise_costs_premiums,
         ipi.jy_supervise_costs_premiums,