fix(account):新增一次收款单后,再次新增剩余金额查询不到对应单据问题修复;
已修改3个文件
84 ■■■■■ 文件已修改
src/main/java/com/ruoyi/account/bean/vo/sales/SalesOutboundVo.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/account/service/impl/sales/AccountSalesCollectionServiceImpl.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/account/bean/vo/sales/SalesOutboundVo.java
@@ -1,5 +1,6 @@
package com.ruoyi.account.bean.vo.sales;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
@@ -52,4 +53,8 @@
    @Schema(description = "销售订单号")
    @Excel(name = "销售订单号")
    private String salesContractNo;
    @Schema(description = "待收款金额")
    @ExcelIgnore
    private BigDecimal amountReceived;
}
src/main/java/com/ruoyi/account/service/impl/sales/AccountSalesCollectionServiceImpl.java
@@ -53,15 +53,15 @@
        if (StringUtils.isEmpty(accountSalesCollection.getCollectionNumber())) {
            accountSalesCollection.setCollectionNumber(genAccountSalesCollectionNo());
        }
        String stockOutRecordIds = accountSalesCollection.getStockOutRecordIds();
        if (stockOutRecordIds != null && !stockOutRecordIds.isEmpty()) {
            List<Long> ids = Arrays.stream(stockOutRecordIds.split(","))
                    .map(Long::valueOf)
                    .toList();
            if (accountSalesCollectionMapper.existsByStockOutRecordId(ids)){
                throw new ServiceException("存在重复的出库单");
            }
        }
//        String stockOutRecordIds = accountSalesCollection.getStockOutRecordIds();
//        if (stockOutRecordIds != null && !stockOutRecordIds.isEmpty()) {
//            List<Long> ids = Arrays.stream(stockOutRecordIds.split(","))
//                    .map(Long::valueOf)
//                    .toList();
//            if (accountSalesCollectionMapper.existsByStockOutRecordId(ids)){
//                throw new ServiceException("存在重复的出库单");
//            }
//        }
        return save(accountSalesCollection);
    }
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,