| | |
| | | <result property="systemNo" column="system_no" /> |
| | | <result property="billName" column="bill_name" /> |
| | | <result property="customerName" column="customer_name" /> |
| | | <result property="payee" column="payee" /> |
| | | |
| | | <result property="responsiblePerson" column="responsible_person" /> |
| | | <result property="responsibleLeader" column="responsible_leader" /> |
| | | <result property="settlementMethod" column="settlement_method" /> |
| | | <result property="businessType" column="business_type" /> |
| | | <result property="promotionRequirement" column="promotion_requirement" /> |
| | | <result property="isInternalSettlement" column="is_internal_settlement" /> |
| | | <result property="internalSettlementUnit" column="internal_settlement_unit" /> |
| | | <result property="documentCount" column="document_count" /> |
| | | <result property="totalAmount" column="total_amount" /> |
| | | <result property="currency" column="currency" /> |
| | | <result property="discountAmount" column="discount_amount" /> |
| | | <result property="receivedAmount" column="received_amount" /> |
| | | <result property="pendingAmount" column="pending_amount" /> |
| | | <result property="exchangeRate" column="exchange_rate" /> |
| | | <result property="cnyAmount" column="cny_amount" /> |
| | | <result property="periodType" column="period_type" /> |
| | | <result property="businessStartDate" column="business_start_date" /> |
| | | <result property="businessEndDate" column="business_end_date" /> |
| | | |
| | | |
| | | <result property="billingStartDate" column="billing_start_date" /> |
| | | <result property="billingEndDate" column="billing_end_date" /> |
| | | <result property="billGenerateDate" column="bill_generate_date" /> |
| | | <result property="billSendDate" column="bill_send_date" /> |
| | | |
| | | <result property="billDueDate" column="bill_due_date" /> |
| | | <result property="status" column="status" /> |
| | | <result property="remark" column="remark" /> |
| | | <result property="createBy" column="create_by" /> |
| | | <result property="createTime" column="create_time" /> |
| | | <result property="updateBy" column="update_by" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | |
| | | <result property="dueIn30Days" column="due_in_30_days" /> |
| | | <result property="overdueAmount" column="overdue_amount" /> |
| | | |
| | | <result property="overdue1To30Days" column="overdue_1_to_30_days" /> |
| | | <result property="overdue31To60Days" column="overdue_31_to_60_days" /> |
| | | <result property="overdue61To90Days" column="overdue_61_to_90_days" /> |
| | |
| | | |
| | | <!-- 查询应收账单账龄分析列表 --> |
| | | <select id="selectReceivableBillAgingAnalysisList" parameterType="com.ruoyi.cwgl.domain.ReceivableBillManagement" resultMap="ReceivableBillAgingAnalysisVoResult"> |
| | | <include refid="selectReceivableBillManagementVo"/> |
| | | SELECT |
| | | thisTab.*, |
| | | rib_latest.latest_invoice_time as latestInvoiceTime, |
| | | COALESCE(rib_total.total_invoice_amount, 0) as totalInvoiceAmount, |
| | | CASE |
| | | WHEN thisTab.pending_amount > COALESCE(rib_total.total_invoice_amount, 0) |
| | | THEN thisTab.pending_amount - COALESCE(rib_total.total_invoice_amount, 0) |
| | | ELSE 0 |
| | | END as unInvoicedAmount |
| | | FROM receivable_bill_management thisTab |
| | | |
| | | -- 获取最新开票日期 |
| | | LEFT JOIN ( |
| | | SELECT head_id, MAX(invoice_time) as latest_invoice_time |
| | | FROM receivable_invoice_business |
| | | WHERE status = 1 |
| | | GROUP BY head_id |
| | | ) rib_latest ON thisTab.id = rib_latest.head_id |
| | | |
| | | -- 获取开票总金额 |
| | | LEFT JOIN ( |
| | | SELECT head_id, SUM(invoicing_amount) as total_invoice_amount |
| | | FROM receivable_invoice_business |
| | | WHERE status = 1 |
| | | GROUP BY head_id |
| | | ) rib_total ON thisTab.id = rib_total.head_id |
| | | |
| | | <where> |
| | | <include refid="whereCondition"/> |
| | | <if test="systemNo != null and systemNo != ''"> and thisTab.system_no = #{systemNo}</if> |
| | | <if test="customerName != null and customerName != ''"> and thisTab.customer_name like concat('%', #{customerName}, '%')</if> |
| | | |
| | | </where> |
| | | ORDER BY customer_name, bill_due_date |
| | | </select> |
| | |
| | | <!-- 查询应收账单账款分析列表 --> |
| | | <select id="selectReceivableBillAccountAnalysisList" parameterType="com.ruoyi.cwgl.domain.ReceivableBillManagement" resultType="com.ruoyi.cwgl.domain.vo.ReceivableBillAccountAnalysisVo"> |
| | | SELECT |
| | | id, |
| | | system_no as systemNo, |
| | | bill_name as billName, |
| | | customer_name as customerName, |
| | | payee, |
| | | responsible_person as responsiblePerson, |
| | | responsible_leader as responsibleLeader, |
| | | settlement_method as settlementMethod, |
| | | business_type as businessType, |
| | | promotion_requirement as promotionRequirement, |
| | | settlement_category as settlementCategory, |
| | | settlement_period as settlementPeriod, |
| | | total_amount as totalAmount, |
| | | received_amount as receivedAmount, |
| | | pending_amount as pendingAmount, |
| | | thisTab.id, |
| | | thisTab.system_no as systemNo, |
| | | thisTab.bill_name as billName, |
| | | thisTab.customer_name as customerName, |
| | | thisTab.payee, |
| | | thisTab.responsible_person as responsiblePerson, |
| | | thisTab.responsible_leader as responsibleLeader, |
| | | thisTab.settlement_method as settlementMethod, |
| | | thisTab.business_type as businessType, |
| | | thisTab.promotion_requirement as promotionRequirement, |
| | | thisTab.settlement_category as settlementCategory, |
| | | thisTab.settlement_period as settlementPeriod, |
| | | thisTab.total_amount as totalAmount, |
| | | thisTab.received_amount as receivedAmount, |
| | | thisTab.pending_amount as pendingAmount, |
| | | thisTab.nc_settlement_date as ncSettlementDate, |
| | | thisTab.nc_settlement_amount as ncSettlementAmount, |
| | | thisTab.account_remark as accountRemark, |
| | | thisTab.overdue_interest as overdueInterest, |
| | | thisTab.bill_due_date as billDueDate, |
| | | thisTab.overdue_days as overdueDays, |
| | | thisTab.status, |
| | | thisTab.create_time as createTime, |
| | | thisTab.update_time as updateTime, |
| | | |
| | | -- 开票相关字段 |
| | | rib_latest.invoice_time as latestInvoiceTime, |
| | | COALESCE(rib_total.total_invoice_amount, 0) as totalInvoiceAmount, |
| | | CASE |
| | | WHEN total_amount > 0 THEN ROUND((received_amount / total_amount) * 100, 2) |
| | | WHEN thisTab.total_amount > COALESCE(rib_total.total_invoice_amount, 0) |
| | | THEN thisTab.total_amount - COALESCE(rib_total.total_invoice_amount, 0) |
| | | ELSE 0 |
| | | END as collectionRate, |
| | | nc_settlement_date as ncSettlementDate, |
| | | nc_settlement_amount as ncSettlementAmount, |
| | | CASE |
| | | WHEN total_amount > 0 THEN ROUND((nc_settlement_amount / total_amount) * 100, 2) |
| | | ELSE 0 |
| | | END as ncSettlementRate, |
| | | account_remark as accountRemark, |
| | | overdue_interest as overdueInterest, |
| | | bill_due_date as billDueDate, |
| | | overdue_days as overdueDays, |
| | | status, |
| | | create_time as createTime, |
| | | update_time as updateTime, |
| | | CASE |
| | | WHEN pending_amount = 0 THEN '已结清' |
| | | WHEN overdue_days > 0 THEN '逾期' |
| | | WHEN bill_due_date IS NOT NULL AND bill_due_date > CURDATE() THEN '未到期' |
| | | ELSE '待处理' |
| | | END as agingStatus, |
| | | CASE |
| | | WHEN pending_amount = 0 THEN '已结算' |
| | | WHEN nc_settlement_amount IS NOT NULL AND nc_settlement_amount > 0 THEN 'NC已结算' |
| | | ELSE '待结算' |
| | | END as settlementStatus, |
| | | CASE |
| | | WHEN nc_settlement_date IS NOT NULL THEN '已对接' |
| | | ELSE '未对接' |
| | | END as ncSyncStatus |
| | | FROM receivable_bill_management |
| | | END as unInvoicedAmount, |
| | | |
| | | -- 还款相关字段 |
| | | rbsd_latest.latest_repayment_date as latestRepaymentDate, |
| | | COALESCE(rbsd_latest.latest_repayment_amount, 0) as latestRepaymentAmount |
| | | |
| | | FROM receivable_bill_management thisTab |
| | | |
| | | -- 获取最新开票日期 |
| | | LEFT JOIN ( |
| | | SELECT head_id, MAX(invoice_time) as invoice_time |
| | | FROM receivable_invoice_business |
| | | WHERE status = 1 |
| | | GROUP BY head_id |
| | | ) rib_latest ON thisTab.id = rib_latest.head_id |
| | | |
| | | -- 获取开票总金额 |
| | | LEFT JOIN ( |
| | | SELECT head_id, SUM(invoicing_amount) as total_invoice_amount |
| | | FROM receivable_invoice_business |
| | | WHERE status = 1 |
| | | GROUP BY head_id |
| | | ) rib_total ON thisTab.id = rib_total.head_id |
| | | |
| | | -- 获取最新还款信息 |
| | | LEFT JOIN ( |
| | | SELECT |
| | | r1.bill_id, |
| | | r1.receipt_date as latest_repayment_date, |
| | | r1.receipt_amount as latest_repayment_amount |
| | | FROM receivable_bill_settlement_detail r1 |
| | | INNER JOIN ( |
| | | SELECT bill_id, MAX(receipt_date) as max_receipt_date |
| | | FROM receivable_bill_settlement_detail |
| | | WHERE deleted = 0 |
| | | GROUP BY bill_id |
| | | ) r2 ON r1.bill_id = r2.bill_id AND r1.receipt_date = r2.max_receipt_date |
| | | WHERE r1.deleted = 0 |
| | | -- 如果同一天有多条记录,取金额最大的那条 |
| | | AND r1.receipt_amount = ( |
| | | SELECT MAX(receipt_amount) |
| | | FROM receivable_bill_settlement_detail r3 |
| | | WHERE r3.bill_id = r1.bill_id AND r3.receipt_date = r1.receipt_date AND r3.deleted = 0 |
| | | ) |
| | | ) rbsd_latest ON thisTab.id = rbsd_latest.bill_id |
| | | |
| | | <where> |
| | | <include refid="whereCondition"/> |
| | | <if test="systemNo != null and systemNo != ''"> and thisTab.system_no = #{systemNo}</if> |
| | | <if test="customerName != null and customerName != ''"> and thisTab.customer_name like concat('%', #{customerName}, '%')</if> |
| | | |
| | | </where> |
| | | ORDER BY customer_name, bill_due_date |
| | | ORDER BY thisTab.customer_name, thisTab.bill_due_date |
| | | </select> |
| | | |
| | | </mapper> |