Ver Fonte

私有协议-保险公司报表bug修复

解决未结算金额计算不对的问题
lipf há 1 mês atrás
pai
commit
f298bd52f1

+ 6 - 3
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -404,6 +404,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         if("5".equals(incomeDataVO.getInvoiceType()) || "6".equals(incomeDataVO.getInvoiceType())){
             incomeDataVO.setAgreementType("1");
         }
+
         List<InsPlyIncome> incomes =  baseMapper.queryIncomeDatasByOrderIds(orderNos,companyId,incomeDataVO.getInvoiceType(),incomeDataVO.getAgreementType());
         log.info("根据订单号查询出[{}]条记录。 orderNos =[{}]",CollUtil.size(incomes), JSONUtil.toJsonStr(orderNos));
         // 需要查询未结算的数据 modify by lipf 2026年6月4日11:06:50
@@ -5724,6 +5725,10 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         // 1. 先将有数据的保险公司进行汇总
         // 累计应收金额, 应收手续费(手续费)
         List<CompanySuperviseSettlementReportDto> allCompaniesIncomeDatas = baseMapper.queryCumulativeAccountsReceivable(systemCode, queryVo);
+
+//        allCompaniesIncomeDatas = allCompaniesIncomeDatas.stream().filter(action->{
+//            return "1738811735599312496".equals(action.getPartnerCompanyId());
+//        }).toList();
         // 结算状态在上面的sql进行过筛选了,后面就不再筛选了
         queryVo.setStatus(null);
 
@@ -5912,7 +5917,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
             BigDecimal sxfS = sxfSettledAmountMap.getOrDefault(companyId, BigDecimal.ZERO);
             BigDecimal overinflatedAmount = sxfOverinflatedAmountMap.getOrDefault(companyId, BigDecimal.ZERO);
             companySuperviseSettlementReportDto.setSxfSettledAmount(Objects.toString(sxfS, BigDecimal.ZERO+""));
-            companySuperviseSettlementReportDto.setSxfUnSettledAmount(BigDecimalUtil.subtract(sxf,BigDecimalUtil.add(sxfS,sxfSettledDiffAmountMap.getOrDefault(companyId, BigDecimal.ZERO))).toString());
+            companySuperviseSettlementReportDto.setSxfUnSettledAmount(BigDecimalUtil.subtract(sxf,BigDecimalUtil.subtract(sxfS,sxfSettledDiffAmountMap.getOrDefault(companyId, BigDecimal.ZERO))).toString());
             companySuperviseSettlementReportDto.setTotalOverinflatedAmount(Objects.toString(overinflatedAmount, BigDecimal.ZERO+""));
             companySuperviseSettlementReportDto.setSettlementPaymentDifference(Objects.toString(sxfSettledDiffAmountMap.getOrDefault(companyId, BigDecimal.ZERO)) );
             // 当起始日期有值的时候,计算的没有意义
@@ -5991,8 +5996,6 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
             dto.setId(reportList.get(0).getCompanyId());
             result.add(dto);
         }
-
-
         log.info("填充父级目录后,保险公司级别的数据[{}]条,原先的数据条数是[{}]条", CollUtil.size(allCompaniesIncomeDatas),count);
         result = result.stream()
                 .peek(action->{

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

@@ -308,6 +308,9 @@
     <!--根据保司id和订单号进行过滤 2026年5月12日15:06:40  lipf  -->
     <select id="queryIncomeDatasByOrderIds" resultType="com.jzg.commons.entity.finance.po.InsPlyIncome">
         <include refid="query"/>
+        <if test="companyId != null and companyId != ''">
+            AND ipi.partner_company_id = #{companyId}
+        </if>
         <if test="agreementType != null and agreementType != ''">
             and ipi.agreement_type = #{agreementType}
         </if>
@@ -2068,9 +2071,8 @@
         a.company_id ,
         sum(COALESCE(a.actual_received_amount, 0)) as settlement,sum(a.overinflatedAmount) overinflatedAmount
         from
-        (
-        select distinct ins.id,
-        ipi.company_id ,
+        ( select distinct ins.id,
+        ipi.partner_company_id as company_id,
         COALESCE(ins.actual_received_amount, 0) as actual_received_amount,
         COALESCE(ins.settlement_payment_difference,0) as overinflatedAmount
         from ins_ply_income_invoice_settlement ins