Преглед изворни кода

Merge remote-tracking branch 'origin/dev_jzg_lipf_v20260518'

jiakai пре 4 месеци
родитељ
комит
af50fa3bba

+ 10 - 8
commons/src/main/java/com/jzg/commons/entity/finance/dto/CompanySuperviseSettlementReportDto.java

@@ -43,10 +43,10 @@ public class CompanySuperviseSettlementReportDto implements Serializable {
     private String followFee;
 
     @Schema(description = "手续费已开票金额")
-    private String SxfInvoicedAmount;
+    private String sxfInvoicedAmount;
 
     @Schema(description = "手续费未开票金额")
-    private String SxfUnInvoicedAmount;
+    private String sxfUnInvoicedAmount;
 
     @Schema(description = "跟单费已开票金额")
     private String gdfInvoicedAmount;
@@ -60,13 +60,15 @@ public class CompanySuperviseSettlementReportDto implements Serializable {
     @Schema(description = "平台未开票金额")
     private String ptUnInvoicedAmount;
 
-    @Schema(description = "已结算金额")
-    private String settledAmount;
+    @Schema(description = "手续费已结算金额")
+    private String sxfSettledAmount;
+    @Schema(description = "手续费未结算金额")
+    private String sxfUnSettledAmount;
 
-
-
-    @Schema(description = "未结算金额")
-    private String unSettledAmount;
+    @Schema(description = "跟单费已结算金额")
+    private String gdfSettledAmount;
+    @Schema(description = "跟单费未结算金额")
+    private String gdfUnSettledAmount;
 
     @Schema(description = "子保险公司数据")
     private List<CompanySuperviseSettlementReportDto> children;

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

@@ -242,6 +242,9 @@ public class InsPlyIncome extends BaseModel {
     @ExcelProperty("业务来源")
     private String businessSource;
 
+    @Schema(description = "结算时间")
+    private LocalDateTime settlementTime;
+
     // 设置初始值为0, 未结算
     @Schema(description = "结算状态(编码)")
     @ExcelProperty("结算状态(编码)")

+ 2 - 0
tenant/insurance/quotation-commons/src/main/java/com/jzg/quotation/commons/utils/DateUtil.java

@@ -31,6 +31,8 @@ public class DateUtil {
 
     public static final String CST_TIME_PATTERN = "EEE MMM dd HH:mm:ss zzz yyyy";
 
+    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
     /**
      * 格式化时间,格式为 yyyyMMddHHmmss
      *

+ 11 - 3
tenant/insurance/quotation-summary/src/main/resources/mapper/InsFeeAuditMapper.xml

@@ -80,9 +80,17 @@
         LEFT JOIN ins_orders_external_policy ioep on ioep.order_no = io.id AND ioep.is_delete=0
         <where>
             and ifa.is_delete=0
-            <if test="param.receiveUser != null and param.receiveUser != ''">
-                and ifa.receive_user = #{param.receiveUser}
-            </if>
+            <choose>
+                <when test="param.receiveUser != null and param.receiveUser != ''">
+                    and ifa.receive_user = #{param.receiveUser}
+                </when>
+                <when test="param.isProblem != null and param.isProblem == 1">
+                    and ifa.receive_user is NOT NULL
+                </when>
+                <otherwise>
+                    and ifa.receive_user is NULL
+                </otherwise>
+            </choose>
             <if test="param.auditType != null">
                 and ifa.audit_type = #{param.auditType}
             </if>

+ 29 - 0
tenant/organization/src/main/java/com/jzg/organization/entity/dto/CalRes.java

@@ -0,0 +1,29 @@
+package com.jzg.organization.entity.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+public class CalRes implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = -5675648603773452297L;
+    private String companyId;
+
+    private BigDecimal amount;
+
+    @Schema(description = "手续费结算金额")
+    private BigDecimal sxfSettlement;
+
+    @Schema(description = "跟单费结算金额")
+    private BigDecimal gdfSettlement;
+
+    @Schema(description = "结算金额")
+    private BigDecimal settlement;
+
+
+}

+ 10 - 8
tenant/organization/src/main/java/com/jzg/organization/mapper/ReceivableMapper.java

@@ -13,10 +13,10 @@ import com.jzg.commons.entity.finance.vo.ReceivableQueryVo;
 import com.jzg.commons.entity.finance.vo.SettlementQueryVo;
 import com.jzg.commons.entity.finance.vo.SettlementReportQueryVo;
 import com.jzg.commons.entity.po.EsmInsCompany;
+import com.jzg.organization.entity.dto.CalRes;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
-import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
@@ -214,17 +214,19 @@ public interface ReceivableMapper extends BaseMapper<InsPlyIncome> {
      * @author lipf
      * @date 2026/6/1 17:57
      */
-    Map<String,BigDecimal> queryInvoicedAmount(@Param("systemCode") String systemCode,
-                                   @Param("invoiceType") List<Integer> invoiceType,
-                                   @Param("invoiceStartDate") String invoiceStartDate,
-                                   @Param("invoiceEndDate") String invoiceEndDate);
+    //@MapKey("companyId")
+    List<CalRes> queryInvoicedAmount(@Param("systemCode") String systemCode,
+                                     @Param("invoiceType") List<Integer> invoiceType,
+                                     @Param("invoiceStartDate") String invoiceStartDate,
+                                     @Param("invoiceEndDate") String invoiceEndDate);
 
     /**
      * 查询已结算金额
      *
      * @param systemCode 租户代码
-     * @param invoiceType
-     * @return
+     * @return List<CalRes>
      */
-    Map<String, BigDecimal> querySettledAmount(String systemCode, List<Integer> invoiceType);
+    List<CalRes> querySettledAmount(@Param("systemCode") String systemCode,
+                                               @Param("settledStartDate") String settledStartDate,
+                                               @Param("settledEndDate") String settledEndDate);
 }

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

@@ -13,6 +13,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.time.LocalDateTime;
 import java.util.List;
 
 public interface ReceivableService extends IService<InsPlyIncome> {
@@ -94,10 +95,12 @@ public interface ReceivableService extends IService<InsPlyIncome> {
 
     /**
      * 更新应收订单结算状态
+     *
      * @param invoiceType
+     * @param settlementTime
      * @return
      */
-    boolean updateIncomeSettlementStatus(String invoiceType, List<String> invoiceIds);
+    boolean updateIncomeSettlementStatus(String invoiceType, List<String> invoiceIds, LocalDateTime settlementTime);
 
     /**
      * 结算

+ 80 - 62
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -36,6 +36,7 @@ import com.jzg.commons.util.idgen.IdGenerate;
 import com.jzg.organization.client.EsmInsCompanyClient;
 import com.jzg.organization.client.InsFeeOrdersClient;
 import com.jzg.organization.client.InsOrdersClient;
+import com.jzg.organization.entity.dto.CalRes;
 import com.jzg.organization.excel.listener.*;
 import com.jzg.organization.mapper.*;
 import com.jzg.organization.service.ReceivableService;
@@ -848,8 +849,8 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
     }
 
     @Override
-    public boolean updateIncomeSettlementStatus(String invoiceType, List<String> invoiceIds) {
-        log.info("更新结算状态: invoiceType=[{}],invoiceIds=[{}]",  invoiceType, JSONUtil.toJsonStr(invoiceIds));
+    public boolean updateIncomeSettlementStatus(String invoiceType, List<String> invoiceIds, LocalDateTime settlementTime) {
+        log.info("更新结算状态: invoiceType=[{}],invoiceIds=[{}],settlementTime=[{}]", invoiceType, JSONUtil.toJsonStr(invoiceIds), settlementTime);
         if (CollectionUtils.isEmpty(invoiceIds)) {
             return false;
         }
@@ -858,22 +859,31 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         result = switch (invoiceType) {
             case number -> baseMapper.update(new LambdaUpdateWrapper<InsPlyIncome>()
                     .in(InsPlyIncome::getId, invoiceIds)
-                    .set(InsPlyIncome::getSuperviseSettlement, number));
+                    .set(InsPlyIncome::getSuperviseSettlement, number)
+                    .set(InsPlyIncome::getSettlementTime,settlementTime)
+            );
             case "2" -> baseMapper.update(new LambdaUpdateWrapper<InsPlyIncome>()
                     .in(InsPlyIncome::getId, invoiceIds)
-                    .set(InsPlyIncome::getOtherSettlement, number));
+                    .set(InsPlyIncome::getOtherSettlement, number)
+                    .set(InsPlyIncome::getSettlementTime,settlementTime));
             case "3" -> baseMapper.update(new LambdaUpdateWrapper<InsPlyIncome>()
                     .in(InsPlyIncome::getId, invoiceIds)
-                    .set(InsPlyIncome::getJySuperviseSettlement, number));
+                    .set(InsPlyIncome::getJySuperviseSettlement, number)
+                    .set(InsPlyIncome::getSettlementTime,settlementTime));
             case "4" -> baseMapper.update(new LambdaUpdateWrapper<InsPlyIncome>()
                     .in(InsPlyIncome::getId, invoiceIds)
-                    .set(InsPlyIncome::getJyOtherSettlement, number));
+                    .set(InsPlyIncome::getJyOtherSettlement, number)
+                    .set(InsPlyIncome::getSettlementTime,settlementTime));
             case "5" -> baseMapper.update(new LambdaUpdateWrapper<InsPlyIncome>()
                     .in(InsPlyIncome::getId, invoiceIds)
-                    .set(InsPlyIncome::getPlatformSuperviseSettlement, number).set(InsPlyIncome::getSettlementStatus, number));
+                    .set(InsPlyIncome::getPlatformSuperviseSettlement, number)
+                    .set(InsPlyIncome::getSettlementTime,settlementTime)
+                    .set(InsPlyIncome::getSettlementStatus, number));
             case "6" -> baseMapper.update(new LambdaUpdateWrapper<InsPlyIncome>()
                     .in(InsPlyIncome::getId, invoiceIds)
-                    .set(InsPlyIncome::getPlatformOtherSettlement, number).set(InsPlyIncome::getSettlementStatus, number));
+                    .set(InsPlyIncome::getPlatformOtherSettlement, number)
+                    .set(InsPlyIncome::getSettlementTime,settlementTime)
+                    .set(InsPlyIncome::getSettlementStatus, number));
             default -> 0;
         };
         return result > 0;
@@ -909,8 +919,9 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
     public boolean platformSettlement(PlatformSettlementVo platformSettlementVo) {
         SettlementVo settlementVo = platformSettlementVo.getSettlementVo();
         InvoicingVo invoicingVo = platformSettlementVo.getInvoicingVo();
-
         log.info("平台结算:platformSettlement=[{}]", JSONUtil.toJsonStr(platformSettlementVo));
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        LocalDateTime settlementDateTime = LocalDateTime.parse(platformSettlementVo.getSettlementVo().getReceivePaymentDate(), formatter);
         try {
             // ============================开票逻辑============================
             invoicingVo.setReceivablePremium(this.getReceivableAmount(invoicingVo));
@@ -986,7 +997,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 invoice.setStatus("1");
                 insPlyIncomeInvoiceMapper.insert(invoice);
                 // 判断是需要更新哪个字段
-                this.updateIncomeSettlementStatus(invoice.getInvoiceType(), invoicingVo.getIncomeIds());
+                this.updateIncomeSettlementStatus(invoice.getInvoiceType(), invoicingVo.getIncomeIds(), settlementDateTime);
             }else{
                 log.info("invoiceId=[{}], 还剩[{}]钱没有结算",settlementVo.getInvoicingId(), surplusPremium.subtract(settlementVo.getActualReceivedAmount()));
             }
@@ -1361,7 +1372,13 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean settlement(SettlementVo settlementVo) {
-        log.info("结算:settlementVo=[{}]", JSONUtil.toJsonStr(settlementVo));
+        log.info("结算:settlementVo=[{}].DateTimeFormatter", JSONUtil.toJsonStr(settlementVo));
+        AssertionUtils.isFail(StrUtil.isEmpty(settlementVo.getReceivePaymentDate()), "结算日期不能为空");
+
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        LocalDateTime settlementDateTime = LocalDateTime.parse(settlementVo.getReceivePaymentDate(), formatter);
+
+
         try {
             // 获取应收的金额
             InsPlyIncomeInvoice insPlyIncomeInvoice = insPlyIncomeInvoiceMapper.selectById(settlementVo.getInvoicingId());
@@ -1410,7 +1427,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                                 .eq(InsPlyIncomeInvoiceLink::getInvoiceId, settlementVo.getInvoicingId()))
                         .forEach(item -> incomeIds.add(item.getIncomeId()));
                 // 判断是需要更新哪个字段
-                this.updateIncomeSettlementStatus(insPlyIncomeInvoice.getInvoiceType(), incomeIds);
+                this.updateIncomeSettlementStatus(insPlyIncomeInvoice.getInvoiceType(), incomeIds, settlementDateTime);
             }else{
                 log.info("invoiceId=[{}], 还剩[{}]钱没有结算",settlementVo.getInvoicingId(), surplusPremium.subtract(settlementVo.getActualReceivedAmount()));
             }
@@ -2563,10 +2580,9 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         // 累计应收金额, 应收手续费(手续费), 应收手续费(手续费)
         List<CompanySuperviseSettlementReportDto> allCompaniesIncomeDatas = baseMapper.queryCumulativeAccountsReceivable(systemCode);
         allCompaniesIncomeDatas = allCompaniesIncomeDatas.stream().peek(action-> action.setId(action.getCompanyId())).toList();
-        // for test
-        //allCompaniesIncomeDatas = allCompaniesIncomeDatas.stream().filter(action-> "1738811735599338932".equals(action.getCompanyId())).toList();
-        // temp, 将不可变对象变成 可变对象
-        // allCompaniesIncomeDatas = new ArrayList<>(allCompaniesIncomeDatas);
+        // for test, 查看一家公司的数据,将不可变对象变成 可变对象
+//        allCompaniesIncomeDatas = allCompaniesIncomeDatas.stream().filter(action-> "1738811735599338932".equals(action.getCompanyId())).toList();
+//        allCompaniesIncomeDatas = new ArrayList<>(allCompaniesIncomeDatas);
         if (CollUtil.isEmpty(allCompaniesIncomeDatas)) {
             String msg = String.format("租户%s下暂时没有手续费",systemCode);
             log.info(msg);
@@ -2594,10 +2610,8 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
     private List<CompanySuperviseSettlementReportDto> calStatisAmount(List<CompanySuperviseSettlementReportDto> allCompaniesIncomeDatas,
                                                                       SettlementReportQueryVo queryVo,
                                                                       String systemCode) {
-        log.info("计算保险公司的统计维度。 要计算的保险公司的个数[{}]", CollUtil.size(allCompaniesIncomeDatas));
-
+        log.info("计算保险公司的统计维度。 要计算的保险公司的个数[{}].queryVo=[{}], systemCode=[{}]", CollUtil.size(allCompaniesIncomeDatas), JSONUtil.toJsonStr(queryVo), systemCode);
         Map<String, EsmInsCompany> bsMap = esmInsCompanyClient.queryAllCompanyMap().getData();
-
         // companyId -> dto
         Map<String, CompanySuperviseSettlementReportDto> companyMap;
         companyMap = allCompaniesIncomeDatas.stream()
@@ -2616,54 +2630,55 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
 
         // 已开票(手续费)
         // 已开票(跟单费)
-        Map<String, BigDecimal> sxfInvoicedAmountMap = baseMapper.queryInvoicedAmount(systemCode, List.of(1, 3), queryVo.getInvoiceStartTime(), queryVo.getInvoiceEndTime());
-        Map<String, BigDecimal> gdfInvoicedAmountMap = baseMapper.queryInvoicedAmount(systemCode, List.of(2, 4), queryVo.getInvoiceStartTime(), queryVo.getInvoiceEndTime());
-        Map<String, BigDecimal> ptInvoicedAmountMap = baseMapper.queryInvoicedAmount(systemCode, List.of(4, 6), queryVo.getInvoiceStartTime(), queryVo.getInvoiceEndTime());
 
+        List<CalRes> calRes;
+        calRes = baseMapper.queryInvoicedAmount(systemCode, List.of(1, 3), queryVo.getInvoiceStartTime(), queryVo.getInvoiceEndTime());
+        Map<String, BigDecimal> sxfInvoicedAmountMap = calRes.stream().collect(Collectors.toMap(CalRes::getCompanyId, CalRes::getAmount, (o1,o2)->o1));
+        calRes = baseMapper.queryInvoicedAmount(systemCode, List.of(2, 4), queryVo.getInvoiceStartTime(), queryVo.getInvoiceEndTime());
+        Map<String, BigDecimal> gdfInvoicedAmountMap = calRes.stream().collect(Collectors.toMap(CalRes::getCompanyId, CalRes::getAmount, (o1,o2)->o1));
+        calRes = baseMapper.queryInvoicedAmount(systemCode, List.of(4, 6), queryVo.getInvoiceStartTime(), queryVo.getInvoiceEndTime());
+        Map<String, BigDecimal> ptInvoicedAmountMap =calRes.stream().collect(Collectors.toMap(CalRes::getCompanyId, CalRes::getAmount, (o1,o2)->o1));
+
+        // 结算费用 
+        calRes = baseMapper.querySettledAmount(systemCode, queryVo.getInvoiceStartTime(), queryVo.getInvoiceEndTime());
+        Map<String, BigDecimal> sxfSettledAmountMap = calRes.stream().collect(Collectors.toMap(CalRes::getCompanyId, CalRes::getSxfSettlement, (o1,o2)->o1));
+        Map<String, BigDecimal> gdfSettledAmountMap = calRes.stream().collect(Collectors.toMap(CalRes::getCompanyId, CalRes::getGdfSettlement, (o1,o2)->o1));
+
+        // 计算已开票和未开票
         for (String companyId : companyMap.keySet()) {
+            log.info("计算保险公司的开票金额:companyId=[{}]",companyId);
             CompanySuperviseSettlementReportDto companySuperviseSettlementReportDto = companyMap.get(companyId);
-            if(sxfInvoicedAmountMap != null){
-                BigDecimal sxf = sxfInvoicedAmountMap.getOrDefault(companyId, BigDecimal.ZERO);
-                companySuperviseSettlementReportDto.setSxfInvoicedAmount(Objects.toString(sxf,BigDecimal.ZERO+""));
-            }else{
-                companySuperviseSettlementReportDto.setSxfInvoicedAmount(BigDecimal.ZERO+"");
-            }
-            if(gdfInvoicedAmountMap != null){
-                BigDecimal gdf = gdfInvoicedAmountMap.getOrDefault(companyId,BigDecimal.ZERO);
-                companySuperviseSettlementReportDto.setGdfInvoicedAmount(Objects.toString(gdf,BigDecimal.ZERO+""));
-            }else{
-                companySuperviseSettlementReportDto.setGdfInvoicedAmount(Objects.toString(BigDecimal.ZERO));
-            }
-            if(ptInvoicedAmountMap != null){
-                BigDecimal pt = ptInvoicedAmountMap.getOrDefault(companyId, BigDecimal.ZERO);
-                companySuperviseSettlementReportDto.setPtInvoicedAmount(Objects.toString(BigDecimal.ZERO));
-            }else{
-                companySuperviseSettlementReportDto.setPtInvoicedAmount(Objects.toString(BigDecimal.ZERO));
-            }
-
+            BigDecimal sxf = sxfInvoicedAmountMap.getOrDefault(companyId, BigDecimal.ZERO);
+            companySuperviseSettlementReportDto.setSxfInvoicedAmount(Objects.toString(sxf,BigDecimal.ZERO+""));
+            BigDecimal gdf = gdfInvoicedAmountMap.getOrDefault(companyId, BigDecimal.ZERO);
+            companySuperviseSettlementReportDto.setGdfInvoicedAmount(Objects.toString(gdf,BigDecimal.ZERO+""));
+            BigDecimal pt = ptInvoicedAmountMap.getOrDefault(companyId, BigDecimal.ZERO);
+            companySuperviseSettlementReportDto.setPtInvoicedAmount(Objects.toString(pt,BigDecimal.ZERO+""));
+
+            CompanySuperviseSettlementReportDto dto;
+            dto = companyMap.get(companyId);
+            companySuperviseSettlementReportDto.setSxfUnInvoicedAmount(BigDecimalUtil.subtract(new BigDecimal(dto.getSuperviseFee()),sxf).toString());
+            companySuperviseSettlementReportDto.setGdfUnInvoicedAmount(BigDecimalUtil.subtract(new BigDecimal(dto.getFollowFee()),gdf).toString());
+
+            BigDecimal sxfS = sxfSettledAmountMap.getOrDefault(companyId, BigDecimal.ZERO);
+            BigDecimal gdfS = gdfSettledAmountMap.getOrDefault(companyId, BigDecimal.ZERO);
+            companySuperviseSettlementReportDto.setSxfSettledAmount(Objects.toString(sxfS, BigDecimal.ZERO+""));
+            companySuperviseSettlementReportDto.setSxfUnSettledAmount(BigDecimalUtil.subtract(sxf,sxfS).toString());
+
+            companySuperviseSettlementReportDto.setGdfSettledAmount(Objects.toString(gdfS, BigDecimal.ZERO+""));
+            companySuperviseSettlementReportDto.setGdfUnSettledAmount(BigDecimalUtil.subtract(gdf,gdfS).toString());
+
+            // 当起始日期有值的时候,计算的没有意义
             if(StrUtil.isNotEmpty(queryVo.getInvoiceStartTime())){
-                companySuperviseSettlementReportDto.setSxfUnInvoicedAmount("-"+queryVo.getInvoiceStartTime());
-                companySuperviseSettlementReportDto.setGdfUnInvoicedAmount("-"+queryVo.getInvoiceStartTime());
-                companySuperviseSettlementReportDto.setPtUnInvoicedAmount("-"+queryVo.getInvoiceStartTime());
-            }else{
-                // TODO 计算
+                companySuperviseSettlementReportDto.setSxfUnInvoicedAmount("-");
+                companySuperviseSettlementReportDto.setGdfUnInvoicedAmount("-");
+                companySuperviseSettlementReportDto.setPtUnInvoicedAmount("-");
+            }
+            if(StrUtil.isNotEmpty(queryVo.getSettlementStartTime())){
+                companySuperviseSettlementReportDto.setSxfUnSettledAmount("-");
+                companySuperviseSettlementReportDto.setGdfUnSettledAmount("-");
             }
         }
-
-        // 已结算(手续费)
-        // 已结算(跟单费)
-//        Map<String, BigDecimal> sxfSettlementedAmount = baseMapper.querySettledAmount(systemCode,List.of(1,3));
-//        Map<String, BigDecimal> gdfSettlementedAmount = baseMapper.querySettledAmount(systemCode,List.of(2,4));
-//        Map<String, BigDecimal> ptSettlementedAmount = baseMapper.querySettledAmount(systemCode,List.of(4,6));
-
-
-        // 未开票(手续费)
-        // 未开票(跟单费)
-
-
-        // 未结算(手续费)
-        // 未结算(跟单费)
-
         return new ArrayList<>(companyMap.values().stream().toList());
     }
 
@@ -2766,7 +2781,10 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
             tree.putExtra("gdfUnInvoicedAmount",dto.getGdfUnInvoicedAmount());
             tree.putExtra("ptInvoicedAmount",dto.getPtInvoicedAmount());
             tree.putExtra("ptUnInvoicedAmount",dto.getPtUnInvoicedAmount());
-            tree.putExtra("settledAmount",dto.getSettledAmount());
+            tree.putExtra("sxfSettledAmount",dto.getSxfSettledAmount());
+            tree.putExtra("sxfUnSettledAmount",dto.getSxfUnSettledAmount());
+            tree.putExtra("gdfSettledAmount",dto.getGdfSettledAmount());
+            tree.putExtra("gdfUnSettledAmount",dto.getGdfUnSettledAmount());
         });
         log.info("树形结构构建:一级数据[{}]个", CollUtil.size(build));
         return build;

+ 27 - 21
tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

@@ -1555,10 +1555,10 @@
         and ipi.system_code = #{systemCode}
     </select>
     <!-- 查询已开票金额 lipf 2026年6月1日17:58:42 -->
-    <select id="queryInvoicedAmount" resultType="map">
+    <select id="queryInvoicedAmount" resultType="com.jzg.organization.entity.dto.CalRes">
         select
-        a.company_id,
-        sum(a.amount)
+        a.company_id as companyId,  <!-- 加上别名,与 @MapKey 对应 -->
+        sum(a.amount) as amount     <!-- 加上别名,MyBatis 会自动映射为 Map 的 value -->
         from
         (
         select
@@ -1597,29 +1597,35 @@
         ) a  group by  a.company_id
     </select>
     <!-- 查询已结算金额 lipf 2026年6月1日18:12:08  -->
-    <select id="querySettledAmount" resultType="java.math.BigDecimal">
+    <select id="querySettledAmount" resultType="com.jzg.organization.entity.dto.CalRes">
         select
-        sum(COALESCE(ipiis.actual_received_amount, 0))
+        a.company_id ,
+        sum(COALESCE(a.jq_supervise_costs_premiums, 0)+ COALESCE(a.sy_supervise_costs_premiums, 0)+ coalesce(a.jy_supervise_costs_proportion, 0 )) as sxf_settlement,
+        sum(COALESCE(a.jq_other_costs_premiums, 0)+ COALESCE(a.sy_other_costs_premiums, 0)+ coalesce(a.jy_other_costs_premiums, 0 )) as gdf_settlement
         from
-        ins_ply_income_invoice_settlement ipiis
-        where
-        ipiis.invoice_id in (
+        (
         select
-        ipiil.invoice_id
-        from
-        ins_ply_income_invoice_link ipiil
-        left join ins_ply_income_invoice ipii on
-        ipiil.invoice_id = ipii.id
-        and ipii.invoice_type in (1, 3 )
-        and ipiil.income_id in (
-        SELECT
-        id
+        ipi.company_id ,
+        ipi.jq_supervise_costs_premiums,
+        ipi.sy_supervise_costs_premiums,
+        ipi.jy_supervise_costs_proportion,
+        ipi.jq_other_costs_premiums,
+        ipi.sy_other_costs_premiums,
+        ipi.jy_other_costs_premiums,
+        ipi.settlement_status ,
+        ipi.settlement_time
         from
         ins_ply_income ipi
-        where
-        ipi.system_code = 'TYBX'))
-        and ipiis.create_time >= cast('2026-05-01' as datetime)
-        and ipiis.create_time &lt; cast('2026-06-02' as datetime)
+        <where>
+            ipi.settlement_status = 1
+            <if test="settledStartDate != null and settledStartDate != ''">
+                and ipi.settlement_time >= cast( '${settledStartDate}' as datetime)
+            </if>
+            <if test="settledEndDate != null and settledEndDate != ''">
+                and ipi.settlement_time &lt; cast('${settledEndDate}' as datetime)
+            </if>
+        </where> ) a
+        group by  a.company_id
     </select>
 
     <!--    <select id="getReceivableList" resultType="com.jzg.commons.entity.finance.po.InsPlyIncome">-->