chenrui
2025-06-09 3512270362c77fe45bc68ab7b6f28bd1bd2f8bfb
src/main/resources/mapper/sales/ReceiptPaymentMapper.xml
@@ -188,4 +188,51 @@
        ORDER BY T1.receipt_payment_date DESC
    </select>
    <select id="customerInteractions" resultType="com.ruoyi.sales.dto.CustomerInteractionDto">
        SELECT
            *
        FROM
            (
                SELECT
                    receipt_payment_amount AS receiptAmount,
                    receipt_payment_date AS happenTime,
                    0 AS type,
                    0 AS invoiceAmount
                FROM
                    receipt_payment
                WHERE
                    invoice_ledger_id IN (
                        SELECT
                            id
                        FROM
                            invoice_ledger
                        WHERE
                            invoice_registration_product_id IN (
                                SELECT
                                    id
                                FROM
                                    invoice_registration_product
                                WHERE
                                    sales_ledger_id IN ( SELECT id FROM sales_ledger WHERE customer_id =  #{customerId} ))) UNION
                SELECT
                    0 AS receiptAmount,
                    invoice_date AS happenTime,
                    1 AS type,
                    invoice_total AS invoiceAmount
                FROM
                    invoice_ledger
                WHERE
                    invoice_registration_product_id IN (
                        SELECT
                            id
                        FROM
                            invoice_registration_product
                        WHERE
                            sales_ledger_id IN ( SELECT id FROM sales_ledger WHERE customer_id = #{customerId} ))
                  AND invoice_date IS NOT NULL
            ) T1
        ORDER BY
            T1.happenTime ASC
    </select>
</mapper>