src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml
@@ -58,36 +58,51 @@
    <select id="getOutboundBatchesByCustomer"
            resultType="com.ruoyi.account.bean.vo.sales.SalesOutboundVo">
        SELECT
            id,
            outbound_batches,
            customer_name,
            shipping_date,
            product_name,
            specification_model,
            tax_rate,
            outbound_amount,
            shipping_no,
            sales_contract_no,
            amount_received
        FROM
            (
                SELECT
        sor.id,
        sor.outbound_batches,
        sl.customer_name,
        sor.create_time as shippingDate,
                    sor.create_time AS shipping_date,
        p.product_name,
        pm.model as specification_model,
                    pm.model AS specification_model,
        slp.tax_rate,
        sor.stock_out_num * slp.tax_inclusive_unit_price as outboundAmount,
                    sor.stock_out_num * slp.tax_inclusive_unit_price AS outbound_amount,
        s.shipping_no,
        sl.sales_contract_no
        FROM stock_out_record sor
        left join shipping_info s on sor.record_id = s.id
                    sl.sales_contract_no,
                    COALESCE ( SUM( acsc.collection_amount ), 0 ) AS amount_received
                FROM
                    stock_out_record sor
                        LEFT JOIN shipping_info s ON sor.record_id = s.id
        LEFT JOIN sales_ledger sl ON s.sales_ledger_id = sl.id
        LEFT JOIN sales_ledger_product slp ON s.sales_ledger_product_id = slp.id and slp.type = 1
        left join product_model pm on slp.product_model_id = pm.id
        left join product p on pm.product_id = p.id
        WHERE sor.record_type='13' and sor.approval_status=1
        and sl.customer_id=#{customerId}
        and sor.id NOT IN (
        SELECT DISTINCT SUBSTRING_INDEX(SUBSTRING_INDEX(a.stock_out_record_ids, ',', n.n), ',', -1)
        FROM account_sales_collection a
        CROSS JOIN (
            SELECT 1 n UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
            SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6
        ) n
        WHERE n.n &lt;= CHAR_LENGTH(a.stock_out_record_ids) - CHAR_LENGTH(REPLACE(a.stock_out_record_ids, ',', '')) + 1
        )
        order by sor.id DESC
                        LEFT JOIN sales_ledger_product slp ON s.sales_ledger_product_id = slp.id
                        AND slp.type = 1
                        LEFT JOIN product_model pm ON slp.product_model_id = pm.id
                        LEFT JOIN product p ON pm.product_id = p.id
                        LEFT JOIN account_sales_collection acsc ON acsc.stock_out_record_ids = sor.id
                WHERE
                    sor.record_type = '13'
                  AND sor.approval_status = 1
                  AND sl.customer_id = #{customerId}
                GROUP BY
                    sor.outbound_batches
                ORDER BY
                    sor.id
            ) tempA
        WHERE
            amount_received &lt; outbound_amount
    </select>
    <select id="selectIncomeStats" resultType="com.ruoyi.home.dto.IncomeExpenseAnalysisDto">
         SELECT DATE_FORMAT(collection_date, #{dateFormat}) AS dateStr,