| | |
| | | * @param invoiceLedgerDto |
| | | * @return |
| | | */ |
| | | IPage<InvoiceLedgerDto> invoiceLedgerSalesAccount(Page page, InvoiceLedgerDto invoiceLedgerDto); |
| | | IPage<InvoiceLedgerDto> invoiceLedgerSalesAccount(Page page,@Param("invoiceLedgerDto") InvoiceLedgerDto invoiceLedgerDto); |
| | | |
| | | /** |
| | | * 产品开票台账详情 |
| | |
| | | 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); |
| | |
| | | * @return |
| | | */ |
| | | InvoiceLedgerDto invoiceInfo(Integer id); |
| | | |
| | | /** |
| | | * 计算前多少条数据回款金额综合 |
| | | * @param customerId |
| | | * @param total |
| | | * @return |
| | | */ |
| | | BigDecimal getReceiptAmount(@Param("customerId") Integer customerId, @Param("total") long total); |
| | | |
| | | } |
| | |
| | | @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; |
| | | } |
| | | |
| | |
| | | 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; |
| | |
| | | */ |
| | | @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; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | <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"> |
| | |
| | | <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"> |
| | |
| | | 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> |