| | |
| | | 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; |
| | | } |
| | | |
| | | /** |