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

Merge remote-tracking branch 'origin/master'

lixiaolong 2 месяцев назад
Родитель
Сommit
e50e33879f

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

@@ -51,6 +51,9 @@ public class FollowCompanyFeeVO {
     /** 累计应收  totalReceivable */
     private BigDecimal totalReceivable;
 
+    /** 对账金额  totalReceivable */
+    private BigDecimal totalReconciliationAmount;
+
     /**
      * 开票记录id
      */

+ 30 - 5
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -802,7 +802,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         Map<String, List<FollowCompanyFeeVO>> followGroupMap = followCompanyFeeVos.stream()
                 .collect(Collectors.groupingBy(this::buildGroupKey));
 
-        // 【核心优化】提前收集所有需要查询的ID,批量查询,彻底解决循环N+1
+        // 提前收集所有需要查询的ID,批量查询,彻底解决循环N+1
         Set<String> allFollowIds = new HashSet<>();
         Set<String> allSettlementIds = new HashSet<>();
         followGroupMap.values().forEach(list -> {
@@ -841,7 +841,12 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
             BigDecimal receivablePremium = Optional.ofNullable(firstFollow)
                     .map(InsFeeFollowOrder::getReceivablePremium)
                     .orElse(BigDecimal.ZERO);
+            // 对账金额
+            BigDecimal reconciliationAmount = Optional.ofNullable(firstFollow)
+                    .map(InsFeeFollowOrder::getReconciliationAmount)
+                    .orElse(BigDecimal.ZERO);
             vo.setTotalReceivable(receivablePremium);
+            vo.setTotalReconciliationAmount(reconciliationAmount);
 
             // 已开票总额
             BigDecimal totalInvoiced = followIds.stream()
@@ -850,7 +855,8 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                     .map(InsFeeFollowOrder::getInvoiced)
                     .reduce(BigDecimal.ZERO, BigDecimal::add);
             vo.setTotalInvoiced(totalInvoiced);
-            vo.setTotalUnInvoiced(receivablePremium.subtract(totalInvoiced));
+            // 根据需求,未开票总金额 = 对账金额 - 已开票金额
+            vo.setTotalUnInvoiced(reconciliationAmount.subtract(totalInvoiced));
 
             // 已结算总额
             BigDecimal totalSettlementAmount = settlementIds.stream()
@@ -1111,7 +1117,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 platformCompanyFeeVo.setTotalPaymentDifference(BigDecimal.ZERO);
             }
             //platformCompanyFeeVo.setTotalUnSettlementAmount(BigDecimalUtil.subtract(BigDecimalUtil.subtract(platformCompanyFeeVo.getTotalReceivable(),platformCompanyFeeVo.getTotalSettlementAmount()), platformCompanyFeeVo.getTotalPaymentDifference()));
-            platformCompanyFeeVo.setTotalUnSettlementAmount(BigDecimalUtil.subtract(platformCompanyFeeVo.getTotalReceivable(),platformCompanyFeeVo.getTotalSettlementAmount()));
+            platformCompanyFeeVo.setTotalUnSettlementAmount(BigDecimalUtil.subtract(platformCompanyFeeVo.getTotalReceivable(),BigDecimalUtil.subtract(platformCompanyFeeVo.getTotalSettlementAmount(),platformCompanyFeeVo.getTotalPaymentDifference())));
         }
         if (StrUtil.isNotBlank(settlementReportQueryVo.getStatus())){
             if ("1".equals(settlementReportQueryVo.getStatus())){
@@ -3971,12 +3977,31 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                     if (StrUtil.isEmpty(search)) {
                         return true;
                     }
+                    List<String> companyIds = Arrays.asList(search.split(","));
+                    HttpResult parentIds = null;
+                    if (companyIds.size() <= 2){
+                        parentIds = esmInsCompanyClient.getParentIds(companyIds);
+                    }
                     if ("等于".equalsIgnoreCase(type) || "包含".equalsIgnoreCase(type)) {
-                        List<String> companyIds = Arrays.asList(search.split(","));
+                        if (null != parentIds && parentIds.isSuccess()){
+                            List<String> data = (List<String>) parentIds.getData();
+                            if (CollUtil.isNotEmpty(data) && data.contains(insPlyIncome.getPartnerCompanyId())){
+                                return true;
+                            }else{
+                                return false;
+                            }
+                        }
                         return companyIds.contains(insPlyIncome.getPartnerCompanyId());
                     }
                     if ("不等于".equalsIgnoreCase(type) || "不包含".equalsIgnoreCase(type)) {
-                        List<String> companyIds = Arrays.asList(search.split(","));
+                        if (null != parentIds && parentIds.isSuccess()){
+                            List<String> data = (List<String>) parentIds.getData();
+                            if (CollUtil.isNotEmpty(data) && !data.contains(insPlyIncome.getPartnerCompanyId())){
+                                return true;
+                            }else{
+                                return false;
+                            }
+                        }
                         return !companyIds.contains(insPlyIncome.getPartnerCompanyId());
                     }
                     return true;

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

@@ -1574,16 +1574,13 @@
             <if test="invoiceRecordQueryVo.invoiceParty != null and invoiceRecordQueryVo.invoiceParty != ''">
                 AND ipii.invoice_party = #{invoiceRecordQueryVo.invoiceParty}
             </if>
+            <if test="invoiceRecordQueryVo.settlementStatus != null and invoiceRecordQueryVo.settlementStatus != ''">
+                AND ipii.status = #{invoiceRecordQueryVo.settlementStatus}
+            </if>
             <if test="invoiceRecordQueryVo.companyNameSimple != null and invoiceRecordQueryVo.companyNameSimple != ''">
                 AND eic.id = #{invoiceRecordQueryVo.companyNameSimple}
             </if>
         </where>
-        <if test="invoiceRecordQueryVo.settlementStatus != null and invoiceRecordQueryVo.settlementStatus != ''">
-            HAVING CASE
-            WHEN ipii.receivable_supervise_premium = SUM(ipiis.actual_received_amount) THEN '1'
-            ELSE '0'
-            END = #{invoiceRecordQueryVo.settlementStatus}
-        </if>
         GROUP BY
         ipii.id,
         ipii.receivable_supervise_premium,