فهرست منبع

修改bug:
平台应收,结算报表不对,只结算了一辆泰康199.5
平台的保险公司报表需要单独统计,根据对接人来统计

jiakai 3 ماه پیش
والد
کامیت
a26ec926de

+ 2 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/CompanySuperviseSettlementReportDto.java

@@ -20,6 +20,8 @@ public class CompanySuperviseSettlementReportDto implements Serializable {
     private static final long serialVersionUID = -2428003756552348627L;
     private static final long serialVersionUID = -2428003756552348627L;
     @Schema(description = "保险公司Id")
     @Schema(description = "保险公司Id")
     private String companyId;
     private String companyId;
+    @Schema(description = "对接人手机号")
+    private String contactPersonPhone;
 
 
     @Schema(description = "保险公司Id")
     @Schema(description = "保险公司Id")
     private String id;
     private String id;

+ 6 - 0
commons/src/main/java/com/jzg/commons/entity/finance/po/InsPlyIncomeInvoice.java

@@ -61,4 +61,10 @@ public class InsPlyIncomeInvoice extends BaseModel {
 
 
     @Schema(description = "租户代码")
     @Schema(description = "租户代码")
     private String systemCode;
     private String systemCode;
+
+    @Schema(description = "对接人名称")
+    private String contactPerson;
+
+    @Schema(description = "对接人手机号")
+    private String contactPersonPhone;
 }
 }

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

@@ -1,6 +1,7 @@
 package com.jzg.commons.entity.finance.vo;
 package com.jzg.commons.entity.finance.vo;
 
 
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import lombok.Data;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
@@ -15,6 +16,12 @@ public class FollowCompanyFeeVO {
 
 
     private String companyId;
     private String companyId;
 
 
+    @Schema(description = "对接人")
+    private String contactPerson;
+
+    @Schema(description = "对接人手机号")
+    private String contactPersonPhone;
+
     /** 分支保险公司ID partner_company_id */
     /** 分支保险公司ID partner_company_id */
     private String partnerCompanyId;
     private String partnerCompanyId;
 
 
@@ -30,6 +37,9 @@ public class FollowCompanyFeeVO {
     /** 未结算总金额  totalInvoiced - totalSettlementAmount */
     /** 未结算总金额  totalInvoiced - totalSettlementAmount */
     private BigDecimal totalUnSettlementAmount;
     private BigDecimal totalUnSettlementAmount;
 
 
+    /** 回款差额 */
+    private BigDecimal totalPaymentDifference;
+
     /** 累计应收  totalReceivable */
     /** 累计应收  totalReceivable */
     private BigDecimal totalReceivable;
     private BigDecimal totalReceivable;
 
 

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

@@ -16,6 +16,12 @@ public class SettlementReportQueryVo extends PageRequest {
     @Schema(description = "保险公司id")
     @Schema(description = "保险公司id")
     private String companyId;
     private String companyId;
 
 
+    @Schema(description = "对接人")
+    private String contactPerson;
+
+    @Schema(description = "对接人手机号")
+    private String contactPersonPhone;
+
     @Schema(description = "创建开始时间")
     @Schema(description = "创建开始时间")
     private String startTime;
     private String startTime;
 
 

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

@@ -717,6 +717,18 @@ public class ReceivableController {
         return HttpResult.ok(receivableService.followCompanySuperviseSettlementReport(settlementReportQueryVo));
         return HttpResult.ok(receivableService.followCompanySuperviseSettlementReport(settlementReportQueryVo));
     }
     }
 
 
+    /**
+     * 平台保险公司报表统计接口
+     *
+     * @author jk
+     * @date 2026/5/28 11:15
+     */
+    @PostMapping("/platformCompanySuperviseSettlementReport")
+    @Operation(summary = "平台公司结算报表")
+    public HttpResult<List<FollowCompanyFeeVO>> platformCompanySuperviseSettlementReport(@RequestBody SettlementReportQueryVo settlementReportQueryVo) {
+        return HttpResult.ok(receivableService.platformCompanySuperviseSettlementReport(settlementReportQueryVo));
+    }
+
     /**
     /**
      * 设置指定发票为结算完成状态
      * 设置指定发票为结算完成状态
      *
      *

+ 2 - 6
tenant/organization/src/main/java/com/jzg/organization/mapper/ReceivableMapper.java

@@ -4,12 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jzg.commons.entity.finance.dto.*;
 import com.jzg.commons.entity.finance.dto.*;
 import com.jzg.commons.entity.finance.po.*;
 import com.jzg.commons.entity.finance.po.*;
-import com.jzg.commons.entity.finance.vo.InvoiceRecordQueryVo;
-import com.jzg.commons.entity.finance.vo.InvoiceRecordResult;
-import com.jzg.commons.entity.finance.vo.InvoicingVo;
-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.finance.vo.*;
 import com.jzg.commons.entity.po.EsmInsCompany;
 import com.jzg.commons.entity.po.EsmInsCompany;
 import com.jzg.organization.entity.dto.CalRes;
 import com.jzg.organization.entity.dto.CalRes;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
@@ -277,4 +272,5 @@ public interface ReceivableMapper extends BaseMapper<InsPlyIncome> {
      */
      */
     BigDecimal querySettledAmountByInvoiceIds(@Param("invoiceIdList") List<String> invoiceIdList);
     BigDecimal querySettledAmountByInvoiceIds(@Param("invoiceIdList") List<String> invoiceIdList);
 
 
+    List<FollowCompanyFeeVO> selectPlatformCompanySettlementReport(@Param("query") SettlementReportQueryVo settlementReportQueryVo);
 }
 }

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

@@ -505,4 +505,6 @@ public interface ReceivableService extends IService<InsPlyIncome> {
     Boolean deleteFollowInvoiceById(String id);
     Boolean deleteFollowInvoiceById(String id);
 
 
     List<FollowCompanyFeeVO> followCompanySuperviseSettlementReport(SettlementReportQueryVo settlementReportQueryVo);
     List<FollowCompanyFeeVO> followCompanySuperviseSettlementReport(SettlementReportQueryVo settlementReportQueryVo);
+
+    List<FollowCompanyFeeVO> platformCompanySuperviseSettlementReport(SettlementReportQueryVo settlementReportQueryVo);
 }
 }

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

@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateTime;
 import cn.hutool.core.lang.tree.Tree;
 import cn.hutool.core.lang.tree.Tree;
 import cn.hutool.core.lang.tree.TreeNodeConfig;
 import cn.hutool.core.lang.tree.TreeNodeConfig;
 import cn.hutool.core.lang.tree.TreeUtil;
 import cn.hutool.core.lang.tree.TreeUtil;
+import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.EasyExcel;
@@ -601,6 +602,23 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         return followCompanyFeeVos;
         return followCompanyFeeVos;
     }
     }
 
 
+    @Override
+    public List<FollowCompanyFeeVO> platformCompanySuperviseSettlementReport(SettlementReportQueryVo settlementReportQueryVo) {
+        log.info("平台协议-结算记录-结算报表: settlementReportQueryVo=[{}]", JSONUtil.toJsonStr(settlementReportQueryVo));
+
+        List<FollowCompanyFeeVO> platformCompanyFeeVos = baseMapper.selectPlatformCompanySettlementReport(settlementReportQueryVo);
+        // 过滤掉对接人和对接人手机号为空的数据
+        List<FollowCompanyFeeVO> list = platformCompanyFeeVos.stream().filter(plat -> StrUtil.isNotBlank(plat.getContactPerson()) && StrUtil.isNotBlank(plat.getContactPersonPhone())).toList();
+        // 查询所有保险公司,匹配保险公司的id和名称
+        HttpResult<Map<String, EsmInsCompany>> mapHttpResult = esmInsCompanyClient.queryAllCompanyMap();
+        Map<String, EsmInsCompany> data = mapHttpResult.getData();
+        for (FollowCompanyFeeVO platformCompanyFeeVo : list) {
+            platformCompanyFeeVo.setCompanyName(null != data.get(platformCompanyFeeVo.getCompanyId()) ? data.get(platformCompanyFeeVo.getCompanyId()).getName() : "");
+            platformCompanyFeeVo.setTotalUnSettlementAmount(BigDecimal.ZERO);
+        }
+        return list;
+    }
+
     /**
     /**
      * BigDecimal安全相加工具:null值转为0
      * BigDecimal安全相加工具:null值转为0
      */
      */
@@ -1088,6 +1106,11 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         SettlementVo settlementVo = platformSettlementVo.getSettlementVo();
         SettlementVo settlementVo = platformSettlementVo.getSettlementVo();
         InvoicingVo invoicingVo = platformSettlementVo.getInvoicingVo();
         InvoicingVo invoicingVo = platformSettlementVo.getInvoicingVo();
         log.info("平台结算:platformSettlement=[{}]", JSONUtil.toJsonStr(platformSettlementVo));
         log.info("平台结算:platformSettlement=[{}]", JSONUtil.toJsonStr(platformSettlementVo));
+
+        if (StrUtil.isBlank(platformSettlementVo.getInvoicingVo().getContactPerson())
+                || StrUtil.isBlank(platformSettlementVo.getInvoicingVo().getContactPersonPhone())){
+            throw new SystemException("对接人信息不能为空");
+        }
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         LocalDateTime settlementDateTime = LocalDateTime.parse(platformSettlementVo.getSettlementVo().getReceivePaymentDate(), formatter);
         LocalDateTime settlementDateTime = LocalDateTime.parse(platformSettlementVo.getSettlementVo().getReceivePaymentDate(), formatter);
         try {
         try {
@@ -1111,6 +1134,8 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
             invoice.setOverinflatedAmount(invoicingVo.getOverinflatedAmount());
             invoice.setOverinflatedAmount(invoicingVo.getOverinflatedAmount());
             invoice.setReceivableSupervisePremium(invoicingVo.getReceivablePremium());
             invoice.setReceivableSupervisePremium(invoicingVo.getReceivablePremium());
             invoice.setTaxPoint(invoicingVo.getTaxPoint());
             invoice.setTaxPoint(invoicingVo.getTaxPoint());
+            invoice.setContactPerson(platformSettlementVo.getInvoicingVo().getContactPerson());
+            invoice.setContactPersonPhone(platformSettlementVo.getInvoicingVo().getContactPersonPhone());
 
 
             List<InsPlyIncomeInvoiceLink> invoicingLinkList = new ArrayList<>();
             List<InsPlyIncomeInvoiceLink> invoicingLinkList = new ArrayList<>();
 
 

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

@@ -1920,4 +1920,49 @@
         </where>
         </where>
     </select>
     </select>
 
 
+
+    <select id="selectPlatformCompanySettlementReport" resultType="com.jzg.commons.entity.finance.vo.FollowCompanyFeeVO">
+        SELECT
+        ipi.company_id,
+        ipii.contact_person,
+        ipii.contact_person_phone,
+        COALESCE(SUM(sett.actual_received_amount), 0.00) AS totalSettlementAmount,
+        COALESCE(SUM(ipii.receivable_supervise_premium), 0.00) AS totalReceivable,
+        COALESCE(SUM(sett.settlement_payment_difference), 0.00) AS totalPaymentDifference
+        FROM ins_ply_income ipi
+        LEFT JOIN ins_ply_income_invoice_link ipil ON ipi.id = ipil.income_id AND ipil.is_delete = 0
+        LEFT JOIN ins_ply_income_invoice ipii ON ipil.invoice_id = ipii.id AND ipii.is_delete = 0
+        LEFT JOIN ins_ply_income_invoice_settlement sett ON ipii.id = sett.invoice_id AND sett.is_delete = 0
+        <where>
+            ipi.is_delete = 0
+            <if test="query.companyId != null and query.companyId != ''">
+                AND ipi.company_id = #{query.companyId}
+            </if>
+            <if test="query.contactPersonPhone != null and query.contactPersonPhone != ''">
+                AND ipii.contact_person_phone LIKE CONCAT('%', #{query.contactPersonPhone}, '%')
+            </if>
+            <if test="query.contactPerson != null and query.contactPerson != ''">
+                AND ipii.contact_person LIKE CONCAT('%', #{query.contactPerson}, '%')
+            </if>
+            -- 跟单订单创建时间范围
+            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
+                AND ipii.create_time BETWEEN #{query.startTime} AND #{query.endTime}
+            </if>
+            -- 发票状态筛选
+            <if test="query.status != null">
+                AND ipii.status = #{query.status}
+            </if>
+            -- 开票时间范围
+            <if test="query.invoiceStartTime != null and query.invoiceStartTime != '' and query.invoiceEndTime != null and query.invoiceEndTime != ''">
+                AND ipii.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 ipii.contact_person_phone, ipii.contact_person, ipi.company_id
+    </select>
+
+
 </mapper>
 </mapper>