maven
10 小时以前 8e14fa84f6f2dfdda8a739400fca80ac73dca874
src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java
@@ -138,7 +138,9 @@
     */
    @Override
    public int updatePaymentRegistration(PaymentRegistration paymentRegistration) {
        TicketRegistration ticketRegistration = ticketRegistrationMapper.selectById(paymentRegistration.getTicketRegistrationId());
        PaymentRegistration paymentRegistration1 = paymentRegistrationMapper.selectById(paymentRegistration.getId());
        TicketRegistration ticketRegistration = ticketRegistrationMapper.selectById(paymentRegistration.getTicketRegistrationId()==null?paymentRegistration1.getTicketRegistrationId():paymentRegistration.getTicketRegistrationId());
        List<PaymentRegistration> paymentRegistrations = paymentRegistrationMapper.selectList(new QueryWrapper<PaymentRegistration>()
                .eq("ticket_registration_id", paymentRegistration.getTicketRegistrationId()).ne("id", paymentRegistration.getId()));
@@ -218,10 +220,10 @@
                            new QueryWrapper<SalesLedgerProduct>().eq("sales_ledger_id", id).eq("type",2)
                    ).stream())
                    .collect(Collectors.toList());
            payableAmount = salesLedgerProducts.stream()
                    .map(SalesLedgerProduct::getTaxInclusiveTotalPrice)
                    .filter(Objects::nonNull)
                    .reduce(BigDecimal.ZERO, BigDecimal::add);
//            payableAmount = salesLedgerProducts.stream()
//                    .map(SalesLedgerProduct::getTaxInclusiveTotalPrice)
//                    .filter(Objects::nonNull)
//                    .reduce(BigDecimal.ZERO, BigDecimal::add);
            // 来票金额计算
            List<TicketRegistration> ticketRegistrations = purchaseLedgers.stream()
@@ -245,6 +247,11 @@
                    .map(PaymentRegistration::getCurrentPaymentAmount)
                    .filter(Objects::nonNull)
                    .reduce(BigDecimal.ZERO, BigDecimal::add);
            // 核心过滤逻辑:当paymentAmount和invoiceAmount同时为0时,跳过该记录
            if (BigDecimal.ZERO.compareTo(paymentAmount) == 0 && BigDecimal.ZERO.compareTo(invoiceAmount) == 0) {
                continue; // 跳过当前供应商,不加入结果集
            }
            // 详情分页处理
            detailPageNum = detailPageNum != null ? detailPageNum : 1;
@@ -299,6 +306,8 @@
            result.add(res);
        }
        // 修正总条数:过滤后需要重新计算总条数
        resultPage.setTotal(result.size());
        resultPage.setRecords(result);
        return resultPage;
    }
@@ -367,6 +376,7 @@
    public List<PaymentHistoryRecordVo> getPaymentRecordList(Long supplierId) {
        List<PaymentHistoryRecordVo> paymentRecordList = paymentRegistrationMapper.getPaymentRecordList(supplierId);
        List<PaymentHistoryRecordVo> result = new ArrayList<>();
        List<PaymentHistoryRecordVo> newResult = new ArrayList<>();
        // 应付总金额金额计算
        BigDecimal amountTotal = BigDecimal.ZERO;
        if(CollectionUtils.isNotEmpty(paymentRecordList)) {
@@ -403,8 +413,20 @@
                result.add(paymentHistoryRecordVo);
            }
            for (int i = 0; i < result.size(); i++) {
                PaymentHistoryRecordVo paymentHistoryRecordVo = result.get(i);
                if (i == 0) {
                    paymentHistoryRecordVo.setPayableAmount(paymentHistoryRecordVo.getInvoiceAmount().subtract(paymentHistoryRecordVo.getCurrentPaymentAmount()));
                }else {
                    PaymentHistoryRecordVo paymentHistoryRecordVo1 = result.get(i-1);
                    paymentHistoryRecordVo.setPayableAmount(paymentHistoryRecordVo1.getPayableAmount()
                            .add(paymentHistoryRecordVo.getInvoiceAmount()).subtract(paymentHistoryRecordVo.getCurrentPaymentAmount()));
                }
                newResult.add(paymentHistoryRecordVo);
            }
        }
        return result;
        return newResult;
    }
    /**
@@ -418,6 +440,37 @@
        return paymentRegistrationMapper.paymentHistoryListPage(page, paymentRegistrationDto);
    }
    @Override
    public Boolean delete(Long[] ids) {
        for (Long id : ids) {
            List<ProductRecord> productRecords = productRecordMapper.selectList(new QueryWrapper<ProductRecord>().lambda().eq(ProductRecord::getTicketRegistrationId, id));
            for (ProductRecord productRecord : productRecords) {
                SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(productRecord.getSaleLedgerProjectId());
                salesLedgerProduct.setTicketsNum(salesLedgerProduct.getTicketsNum().subtract(productRecord.getTicketsNum()));
                salesLedgerProduct.setTicketsAmount(salesLedgerProduct.getTicketsAmount().subtract(productRecord.getTicketsAmount()));
                salesLedgerProduct.setFutureTickets(salesLedgerProduct.getFutureTickets().add(productRecord.getTicketsNum()));
                salesLedgerProduct.setFutureTicketsAmount(salesLedgerProduct.getFutureTicketsAmount().add(productRecord.getTicketsAmount()));
                salesLedgerProductMapper.updateById(salesLedgerProduct);
            }
            ticketRegistrationMapper.delete(new QueryWrapper<TicketRegistration>().lambda().eq(TicketRegistration::getId, id));
            productRecordMapper.delete(new QueryWrapper<ProductRecord>().lambda().eq(ProductRecord::getTicketRegistrationId, id));
        }
        return true;
    }
    @Override
    public int delPaymentRegistration(Long id) {
//        PaymentRegistration paymentRegistration = paymentRegistrationMapper.selectById(id);
//        TicketRegistration ticketRegistration = ticketRegistrationMapper.selectById(paymentRegistration.getTicketRegistrationId());
//        if (ticketRegistration != null) {
//            ticketRegistration.setPaymentAmountTotal(ticketRegistration.getPaymentAmountTotal().subtract(paymentRegistration.getCurrentPaymentAmount()));
//            ticketRegistration.setUnPaymentAmountTotal(ticketRegistration.getUnPaymentAmountTotal().add(paymentRegistration.getCurrentPaymentAmount()));
//            ticketRegistrationMapper.updateById(ticketRegistration);
//        }
        return paymentRegistrationMapper.deleteById(id);
    }
    // 批量查询采购台账(当月)
    private Map<Long, List<PurchaseLedger>> batchQueryPurchaseLedgers(List<Long> supplierIds, LocalDate startDate, LocalDate endDate) {
        LambdaQueryWrapper<PurchaseLedger> query = new LambdaQueryWrapper<>();