| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<CustomerInteractionDto> customerInteractions(ReceiptPaymentDto receiptPaymentDto) { |
| | | ArrayList<CustomerInteractionDto> result = new ArrayList<>(); |
| | | List<CustomerInteractionDto> customerInteractionDtos = receiptPaymentMapper.customerInteractions(receiptPaymentDto); |
| | | if(CollectionUtils.isEmpty(customerInteractionDtos)){ |
| | | return result; |
| | | } |
| | | // 应收总金额金额计算 |
| | | BigDecimal amountTotal = BigDecimal.ZERO; |
| | | Map<LocalDate, List<CustomerInteractionDto>> dateListMap = customerInteractionDtos.stream().collect( |
| | | Collectors.groupingBy( |
| | | CustomerInteractionDto::getHappenTime, |
| | | LinkedHashMap::new, |
| | | Collectors.toList() |
| | | ) |
| | | ); |
| | | for (LocalDate localDate : dateListMap.keySet()) { |
| | | BigDecimal currentReceiptAmount = BigDecimal.ZERO; |
| | | BigDecimal invoiceAmount = BigDecimal.ZERO; |
| | | BigDecimal currentDateTotal = BigDecimal.ZERO; |
| | | List<CustomerInteractionDto> customerInteractionDtoList = dateListMap.get(localDate); |
| | | // 计算当天收款数 |
| | | currentReceiptAmount = customerInteractionDtoList.stream() |
| | | .filter(item ->item.getType() == 0) |
| | | .map(CustomerInteractionDto::getReceiptAmount) |
| | | .reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | // 计算当天开票数 |
| | | invoiceAmount = customerInteractionDtoList.stream() |
| | | .filter(item ->item.getType() == 1) |
| | | .map(CustomerInteractionDto::getInvoiceAmount) |
| | | .reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | // 计算当日汇总 |
| | | currentDateTotal = currentDateTotal.add(invoiceAmount).subtract(currentReceiptAmount); |
| | | CustomerInteractionDto customerInteractionDto = new CustomerInteractionDto(); |
| | | customerInteractionDto.setHappenTime(localDate); |
| | | customerInteractionDto.setInvoiceAmount(invoiceAmount); |
| | | customerInteractionDto.setReceiptAmount(currentReceiptAmount); |
| | | amountTotal = customerInteractionDto.getInvoiceAmount().subtract(customerInteractionDto.getReceiptAmount()); |
| | | customerInteractionDto.setUnReceiptAmount(amountTotal); |
| | | result.add(customerInteractionDto); |
| | | } |
| | | ArrayList<CustomerInteractionDto> newResult = new ArrayList<>(); |
| | | for (int i = 0; i < result.size(); i++) { |
| | | CustomerInteractionDto customerInteractionDto = result.get(i); |
| | | if (i == 0) { |
| | | customerInteractionDto.setUnReceiptAmount(customerInteractionDto.getInvoiceAmount().subtract(customerInteractionDto.getReceiptAmount())); |
| | | }else { |
| | | CustomerInteractionDto customerInteractionDto1 = result.get(i-1); |
| | | customerInteractionDto.setUnReceiptAmount(customerInteractionDto1.getUnReceiptAmount() |
| | | .add(customerInteractionDto.getInvoiceAmount()).subtract(customerInteractionDto.getReceiptAmount())); |
| | | } |
| | | newResult.add(customerInteractionDto); |
| | | } |
| | | return newResult; |
| | | public List<InvoiceLedgerDto> customerInteractions(InvoiceLedgerDto receiptPaymentDto) { |
| | | return receiptPaymentMapper.invoiceLedgerSalesAccount(receiptPaymentDto); |
| | | } |
| | | |
| | | /** |