Kaynağa Gözat

Merge remote-tracking branch 'origin/dev_jzg_lipf_v20260622' into dev_jzg_lipf_v20260622

lipf 1 ay önce
ebeveyn
işleme
a7561a1f1c

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

@@ -72,6 +72,9 @@ public class SettlementReportQueryVo extends PageRequest {
     @Schema(description = "开票状态 0-未开票 1-已开票")
     private String invoiceStatus;
 
+    @Schema(description = "结算状态 0-已开票未结清 1-已结清 2-未开票")
+    private String settlementStatus;
+
     @Schema(description = "租户代码")
     private String systemCode;
 

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

@@ -284,6 +284,14 @@ public interface ReceivableMapper extends BaseMapper<InsPlyIncome> {
      */
     InsPlyIncomeInvoiceSettlementVo querySettledAmountByInvoiceIds(@Param("invoiceIdList") List<String> invoiceIdList);
 
+    /**
+     * 查询未结清发票数量(status=0的发票数量)
+     *
+     * @param invoiceIdList 发票ID列表
+     * @return 未结清发票数量
+     */
+    int countUnsettledInvoicesByInvoiceIds(@Param("invoiceIdList") List<String> invoiceIdList);
+
     List<PlatformCompanyFeeVO> selectPlatformCompanySettlementReport(@Param("query") SettlementReportQueryVo settlementReportQueryVo);
 
     /**

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

@@ -6313,6 +6313,32 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                     records = records.stream().filter(action-> !"0".equals(action.getUnSettledAmount())).toList();
                 }
             }
+            // 根据结算状态过滤:0-已开票未结清 1-已结清 2-未开票
+            if(StrUtil.isNotEmpty(settlementReportQueryVo.getSettlementStatus())){
+                String settlementStatus = settlementReportQueryVo.getSettlementStatus();
+                if("2".equals(settlementStatus)){
+                    // 未开票:ins_ply_income_invoice没有数据
+                    records = records.stream().filter(action -> StrUtil.isEmpty(action.getInvoiceIds())).toList();
+                } else if("0".equals(settlementStatus)){
+                    // 已开票未结清:有发票数据,且存在status=0的发票
+                    records = records.stream().filter(action -> {
+                        if(StrUtil.isEmpty(action.getInvoiceIds())){
+                            return false;
+                        }
+                        List<String> invoiceIdList = Arrays.asList(action.getInvoiceIds().split(","));
+                        return baseMapper.countUnsettledInvoicesByInvoiceIds(invoiceIdList) > 0;
+                    }).toList();
+                } else if("1".equals(settlementStatus)){
+                    // 已结清:有发票数据,且所有发票status=1
+                    records = records.stream().filter(action -> {
+                        if(StrUtil.isEmpty(action.getInvoiceIds())){
+                            return false;
+                        }
+                        List<String> invoiceIdList = Arrays.asList(action.getInvoiceIds().split(","));
+                        return baseMapper.countUnsettledInvoicesByInvoiceIds(invoiceIdList) == 0;
+                    }).toList();
+                }
+            }
             receiverSettlementReport.setRecords(records);
         }
         return receiverSettlementReport;

+ 1 - 1
tenant/organization/src/main/resources/mapper/InsPlyIncomeInvoiceSettlementMapper.xml

@@ -33,7 +33,7 @@
         ipiis.invoice_id = ipii.id
         <where>
             ipii.invoice_type in (5, 6)
-            and ipiis.receive_payment_date &gt;= #{vo.settlementStartTime} and ipiis.receive_payment_date &lt;= #{vo.settlementEndTime}
+            and ipiis.create_time &gt;= #{vo.settlementStartTime} and ipiis.create_time &lt;= #{vo.settlementEndTime}
             <if test="vo.contactPerson != null and vo.contactPerson != ''">
                 and ipii.contact_person = #{vo.contactPerson}
             </if>

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

@@ -2198,6 +2198,22 @@
         </where>
     </select>
 
+    <!-- 查询未结清发票数量(status=0的发票数量) -->
+    <select id="countUnsettledInvoicesByInvoiceIds" resultType="int">
+        select count(1)
+        from ins_ply_income_invoice ipii
+        <where>
+            ipii.is_delete = 0
+            and ipii.status = 0
+            <if test="invoiceIdList != null and invoiceIdList.size() > 0">
+                and ipii.id in
+                <foreach collection="invoiceIdList" item="item" open="(" separator="," close=")">
+                    ${item}
+                </foreach>
+            </if>
+        </where>
+    </select>
+
 
     <select id="selectPlatformCompanySettlementReport" resultType="com.jzg.commons.entity.finance.vo.PlatformCompanyFeeVO">
         SELECT