chenrui
5 天以前 63ccaee5545740122a9d58983aa75d9da9de7530
回款登记功能修改
已修改6个文件
149 ■■■■■ 文件已修改
src/main/java/com/ruoyi/sales/mapper/InvoiceLedgerMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/mapper/ReceiptPaymentMapper.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/service/impl/InvoiceLedgerServiceImpl.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/service/impl/ReceiptPaymentServiceImpl.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/sales/InvoiceLedgerMapper.xml 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/sales/ReceiptPaymentMapper.xml 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/mapper/InvoiceLedgerMapper.java
@@ -41,7 +41,7 @@
     * @param invoiceLedgerDto
     * @return
     */
    IPage<InvoiceLedgerDto> invoiceLedgerSalesAccount(Page page, InvoiceLedgerDto invoiceLedgerDto);
    IPage<InvoiceLedgerDto> invoiceLedgerSalesAccount(Page page,@Param("invoiceLedgerDto") InvoiceLedgerDto invoiceLedgerDto);
    /**
     * 产品开票台账详情
src/main/java/com/ruoyi/sales/mapper/ReceiptPaymentMapper.java
@@ -8,6 +8,8 @@
import com.ruoyi.sales.pojo.ReceiptPayment;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
public interface ReceiptPaymentMapper extends BaseMapper<ReceiptPayment> {
    IPage<ReceiptPaymentDto> receiptPaymentListPage(Page page, @Param("receiptPaymentDto") ReceiptPaymentDto receiptPaymentDto);
@@ -28,4 +30,13 @@
     * @return
     */
    InvoiceLedgerDto invoiceInfo(Integer id);
    /**
     * 计算前多少条数据回款金额综合
     * @param customerId
     * @param total
     * @return
     */
    BigDecimal getReceiptAmount(@Param("customerId") Integer customerId, @Param("total") long total);
}
src/main/java/com/ruoyi/sales/service/impl/InvoiceLedgerServiceImpl.java
@@ -242,20 +242,6 @@
    @Override
    public IPage<InvoiceLedgerDto> invoiceLedgerSalesAccount(Page page, InvoiceLedgerDto invoiceLedgerDto) {
        IPage<InvoiceLedgerDto> invoiceLedgerDtoIPage = invoiceLedgerMapper.invoiceLedgerSalesAccount(page, invoiceLedgerDto);
//        for (InvoiceLedgerDto record : invoiceLedgerDtoIPage.getRecords()) {
//            QueryWrapper<ReceiptPayment> queryWrapper = new QueryWrapper<>();
//            queryWrapper.eq("customer_id", record.getCustomerId());
//            List<ReceiptPayment> receiptPaymentList = receiptPaymentMapper.selectList(queryWrapper);
//            BigDecimal totalAmount = BigDecimal.ZERO;
//            if(!CollectionUtils.isEmpty(receiptPaymentList)){
//                for (ReceiptPayment receiptPayment : receiptPaymentList) {
//                    totalAmount = totalAmount.add(receiptPayment.getInvoiceAmount());
//                }
//            }
//            BigDecimal unReceiptPaymentAmount = record.getInvoiceAmount().subtract(totalAmount);
//            record.setReceiptPaymentAmount(totalAmount);
//            record.setUnReceiptPaymentAmount(unReceiptPaymentAmount);
//        }
        return invoiceLedgerDtoIPage;
    }
src/main/java/com/ruoyi/sales/service/impl/ReceiptPaymentServiceImpl.java
@@ -11,6 +11,8 @@
import com.ruoyi.sales.service.ReceiptPaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import java.math.BigDecimal;
import java.time.LocalDate;
@@ -68,7 +70,23 @@
     */
    @Override
    public IPage<ReceiptPaymentDto> receiptPaymentListPage(Page page, ReceiptPaymentDto receiptPaymentDto) {
        return receiptPaymentMapper.receiptPaymentListPage(page, receiptPaymentDto);
        // 计算分页前page.current-1 * limit条数的综合计算已经收回的回款金额
        // 计算已经分页的条数
        long total = (page.getCurrent() - 1) * page.getSize();
        BigDecimal receiptAmount = receiptPaymentMapper.getReceiptAmount(receiptPaymentDto.getCustomerId(), total);
        if(ObjectUtils.isEmpty(receiptAmount)){
            receiptAmount = BigDecimal.ZERO;
        }
        IPage<ReceiptPaymentDto> iPage = receiptPaymentMapper.receiptPaymentListPage(page, receiptPaymentDto);
        // 开票总金额
        BigDecimal invoiceTotal = CollectionUtils.isEmpty(iPage.getRecords()) ? BigDecimal.ZERO : iPage.getRecords().get(0).getInvoiceTotal();
        // 当前应收金额
        BigDecimal currentUnReceiptAmount = invoiceTotal.subtract(receiptAmount);
        for (ReceiptPaymentDto record : iPage.getRecords()) {
            currentUnReceiptAmount = currentUnReceiptAmount.subtract(record.getReceiptPaymentAmount());
            record.setNoReceiptAmount(currentUnReceiptAmount);
        }
        return iPage;
    }
    /**
src/main/resources/mapper/sales/InvoiceLedgerMapper.xml
@@ -111,15 +111,22 @@
    <select id="invoiceLedgerSalesAccount" resultType="com.ruoyi.sales.dto.InvoiceLedgerDto">
        SELECT
            customer_id,
            T2.customer_name,
            SUM( invoice_amount ) invoiceAmount
            T4.id,T4.customer_name ,
            SUM(invoice_total) AS invoice_total,
            IFNULL( T5.receipt_payment_amount , 0 ) AS receipt_payment_amount,
            (invoice_total - receipt_payment_amount) AS unReceipt_payment_amount
        FROM
            invoice_ledger T1
                LEFT JOIN customer T2 ON T1.customer_id = T2.id
        GROUP BY
            customer_id,
            T2.customer_name;
                LEFT JOIN invoice_registration_product T2 ON T1.invoice_registration_product_id = T2.id
                LEFT JOIN sales_ledger T3 ON T3.id = T2.sales_ledger_id
                LEFT JOIN customer T4 ON T4.id = T3.customer_id
                LEFT JOIN ( SELECT invoice_ledger_id, SUM( receipt_payment_amount ) AS receipt_payment_amount FROM receipt_payment GROUP BY invoice_ledger_id ) T5 ON T5.invoice_ledger_id = T1.id
        <where>
            <if test="invoiceLedgerDto.searchText != null and invoiceLedgerDto.searchText != '' ">
                T4.customer_name LIKE CONCAT ('%',#{invoiceLedgerDto.searchText},'%')
            </if>
        </where>
        GROUP BY T4.id,T4.customer_name
    </select>
    <select id="invoiceLedgerProductInfo" resultType="com.ruoyi.sales.dto.InvoiceRegistrationProductDto">
src/main/resources/mapper/sales/ReceiptPaymentMapper.xml
@@ -5,39 +5,31 @@
<mapper namespace="com.ruoyi.sales.mapper.ReceiptPaymentMapper">
    <select id="receiptPaymentListPage" resultType="com.ruoyi.sales.dto.ReceiptPaymentDto">
        SELECT
            T1.id                 ,
            T1.sales_ledger_id        ,
            T1.sales_contract_no      ,
            T1.customer_id            ,
            T1.invoice_no             ,
            T1.invoice_amount         ,
            T1.tax_rate               ,
            T1.receipt_payment_type   ,
            T1.receipt_payment_amount ,
            T1.registrant             ,
            T1.receipt_payment_date   ,
            T1.create_time            ,
            T1.create_user            ,
            T1.update_time            ,
            T1.update_user            ,
            T1.tenant_id,
            T3.customer_contract_no,
            T2.customer_name
        FROM receipt_payment T1
        LEFT JOIN customer T2 ON T1.customer_id = T2.id
        LEFT JOIN sales_ledger T3 ON T1.sales_ledger_id = T3.id
            T4.customer_id,
            IFNULL(T5.invoice_total,0) AS invoice_total,
            T1.receipt_payment_amount,
            T1.receipt_payment_date
        FROM
            receipt_payment T1
        LEFT JOIN invoice_ledger T2 ON T1.invoice_ledger_id = T2.id
        LEFT JOIN invoice_registration_product T3 ON T2.invoice_registration_product_id = T3.id
        LEFT JOIN sales_ledger T4 ON T4.id = T3.sales_ledger_id
        LEFT JOIN (
            SELECT
                T3.customer_id,
                SUM( invoice_total ) AS invoice_total
            FROM
                invoice_ledger T1
            LEFT JOIN invoice_registration_product T2 ON T1.invoice_registration_product_id = T2.id
            LEFT JOIN sales_ledger T3 ON T3.id = T2.sales_ledger_id
            GROUP BY T3.customer_id
        ) T5 ON T5.customer_id = T4.customer_id
        <where>
            <if test="receiptPaymentDto.searchText != null and receiptPaymentDto.searchText != ''">
                AND (
                T2.customer_name LIKE CONCAT('%',#{receiptPaymentDto.searchText},'%')
                OR T1.sales_contract_no LIKE CONCAT('%',#{receiptPaymentDto.searchText},'%')
                )
            </if>
            <if test="receiptPaymentDto.customerId != null">
                AND T1.customer_id = #{receiptPaymentDto.customerId}
                AND T4.customer_id = #{receiptPaymentDto.customerId}
            </if>
        </where>
        ORDER BY  T1.receipt_payment_date ASC
        ORDER BY T1.receipt_payment_date ASC
    </select>
    <select id="receiptPaymentInfo" resultType="com.ruoyi.sales.dto.ReceiptPaymentDto">
@@ -119,4 +111,35 @@
        WHERE T1.id = #{id}
    </select>
    <select id="getReceiptAmount" resultType="java.math.BigDecimal">
        SELECT
            SUM( receipt_payment_amount ) AS total_amount
        FROM
            (
                SELECT
                    T1.receipt_payment_amount
                FROM
                    receipt_payment T1
                        LEFT JOIN invoice_ledger T2 ON T1.invoice_ledger_id = T2.id
                        LEFT JOIN invoice_registration_product T3 ON T2.invoice_registration_product_id = T3.id
                        LEFT JOIN sales_ledger T4 ON T4.id = T3.sales_ledger_id
                        LEFT JOIN (
                        SELECT
                            T3.customer_id,
                            SUM( invoice_total ) AS invoice_total
                        FROM
                            invoice_ledger T1
                                LEFT JOIN invoice_registration_product T2 ON T1.invoice_registration_product_id = T2.id
                                LEFT JOIN sales_ledger T3 ON T3.id = T2.sales_ledger_id
                        GROUP BY
                            T3.customer_id
                    ) T5 ON T5.customer_id = T4.customer_id
                WHERE
                    T4.customer_id = #{customerId}
                ORDER BY
                    T1.receipt_payment_date ASC
                    LIMIT #{total} ) AS limited_rows
    </select>
</mapper>