| | |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.purchase.dto.PaymentHistoryRecordVo; |
| | | import com.ruoyi.purchase.dto.PaymentLedgerDto; |
| | | import com.ruoyi.purchase.dto.PaymentRegistrationDto; |
| | | import com.ruoyi.purchase.mapper.*; |
| | |
| | | |
| | | private PurchaseLedgerMapper purchaseLedgerMapper; |
| | | |
| | | private InvoicePurchaseMapper invoicePurchaseMapper; |
| | | |
| | | private SalesLedgerMapper salesLedgerMapper; |
| | | |
| | | private SupplierManageMapper supplierManageMapper; |
| | |
| | | List<PaymentRegistration> paymentRegistrations = paymentRegistrationMapper.selectList(new QueryWrapper<PaymentRegistration>() |
| | | .eq("ticket_registration_id", registrationDto.getTicketRegistrationId())); |
| | | BigDecimal total = paymentRegistrations.stream().map(PaymentRegistration::getCurrentPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | registrationDto.setUnPaymentAmount(registrationDto.getInvoiceAmount().subtract(total)); |
| | | BigDecimal invoiceAmount = (null != registrationDto.getInvoiceAmount())? registrationDto.getInvoiceAmount() : BigDecimal.ZERO; |
| | | registrationDto.setUnPaymentAmount(invoiceAmount.subtract(total)); |
| | | } |
| | | return list; |
| | | } |
| | |
| | | for (SupplierManage supplierManage : supplierManages) { |
| | | Map<String, Object> res = new HashMap<>(); |
| | | res.put("supplierName", supplierManage.getSupplierName()); |
| | | res.put("supplierId", supplierManage.getId()); |
| | | |
| | | // 应付金额计算 |
| | | BigDecimal payableAmount = BigDecimal.ZERO; |
| | |
| | | .map(PurchaseLedger::getId) |
| | | .filter(Objects::nonNull) |
| | | .flatMap(id -> salesLedgerProductMapper.selectList( |
| | | new QueryWrapper<SalesLedgerProduct>().eq("sales_ledger_id", id) |
| | | new QueryWrapper<SalesLedgerProduct>().eq("sales_ledger_id", id).eq("type",2) |
| | | ).stream()) |
| | | .collect(Collectors.toList()); |
| | | payableAmount = salesLedgerProducts.stream() |
| | |
| | | new LambdaQueryWrapper<ProductRecord>().eq(ProductRecord::getTicketRegistrationId, ticketRegistration.getId()) |
| | | ).stream() |
| | | .map(ProductRecord::getTicketsNum) |
| | | .map(BigDecimal::new) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | detail.put("voteCount", voteCount); |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 查询付款登记列表 |
| | | * |
| | | * @param paymentRegistrationDto 付款登记 |
| | | * @return 付款登记集合 |
| | | */ |
| | | @Override |
| | | public List<PaymentRegistrationDto> paymentHistoryList(PaymentRegistrationDto paymentRegistrationDto) { |
| | | return paymentRegistrationMapper.paymentHistoryList(paymentRegistrationDto); |
| | | } |
| | | |
| | | /** |
| | | * 查询供应商往来记录 |
| | | * @param supplierId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<PaymentHistoryRecordVo> getPaymentRecordList(Long supplierId) { |
| | | List<PaymentHistoryRecordVo> paymentRecordList = paymentRegistrationMapper.getPaymentRecordList(supplierId); |
| | | List<PaymentHistoryRecordVo> result = new ArrayList<>(); |
| | | // 应付总金额金额计算 |
| | | BigDecimal amountTotal = BigDecimal.ZERO; |
| | | if(CollectionUtils.isNotEmpty(paymentRecordList)) { |
| | | Map<LocalDate, List<PaymentHistoryRecordVo>> dateListMap = paymentRecordList.stream().collect( |
| | | Collectors.groupingBy( |
| | | PaymentHistoryRecordVo::getHappenTime, |
| | | LinkedHashMap::new, |
| | | Collectors.toList() |
| | | ) |
| | | ); |
| | | BigDecimal amountDateTotal = BigDecimal.ZERO; |
| | | for (LocalDate localDate : dateListMap.keySet()) { |
| | | BigDecimal currentPaymentAmount = BigDecimal.ZERO; |
| | | BigDecimal invoiceAmount = BigDecimal.ZERO; |
| | | BigDecimal currentDateTotal = BigDecimal.ZERO; |
| | | List<PaymentHistoryRecordVo> paymentHistoryRecordVos = dateListMap.get(localDate); |
| | | // 计算当天汇款数 |
| | | currentPaymentAmount = paymentHistoryRecordVos.stream() |
| | | .filter(item ->item.getType() == 0) |
| | | .map(PaymentHistoryRecordVo::getCurrentPaymentAmount) |
| | | .reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | // 计算今天来票数 |
| | | invoiceAmount = paymentHistoryRecordVos.stream() |
| | | .filter(item ->item.getType() == 1) |
| | | .map(PaymentHistoryRecordVo::getInvoiceAmount) |
| | | .reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | // 计算当日汇总 |
| | | currentDateTotal = currentDateTotal.add(invoiceAmount).subtract(currentPaymentAmount); |
| | | PaymentHistoryRecordVo paymentHistoryRecordVo = new PaymentHistoryRecordVo(); |
| | | paymentHistoryRecordVo.setHappenTime(localDate); |
| | | paymentHistoryRecordVo.setCurrentPaymentAmount(currentPaymentAmount); |
| | | paymentHistoryRecordVo.setInvoiceAmount(invoiceAmount); |
| | | amountTotal = amountTotal.add(currentDateTotal); |
| | | paymentHistoryRecordVo.setPayableAmount(amountTotal); |
| | | result.add(paymentHistoryRecordVo); |
| | | } |
| | | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 查询付款登记列表分页 |
| | | * |
| | | * @param paymentRegistrationDto 付款登记 |
| | | * @return 付款登记集合 |
| | | */ |
| | | @Override |
| | | public IPage<PaymentRegistrationDto> paymentHistoryListPage(Page page, PaymentRegistrationDto paymentRegistrationDto) { |
| | | return paymentRegistrationMapper.paymentHistoryListPage(page, paymentRegistrationDto); |
| | | } |
| | | |
| | | // 批量查询采购台账(当月) |
| | | private Map<Long, List<PurchaseLedger>> batchQueryPurchaseLedgers(List<Long> supplierIds, LocalDate startDate, LocalDate endDate) { |
| | | LambdaQueryWrapper<PurchaseLedger> query = new LambdaQueryWrapper<>(); |