maven
9 小时以前 f8dc8889897431d908c658fb415186d39b963eb6
src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java
@@ -98,6 +98,7 @@
     */
    @Override
    public int insertPaymentRegistration(List<PaymentRegistration> paymentRegistrationList) {
        Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
        for (PaymentRegistration paymentRegistration : paymentRegistrationList) {
            PaymentRegistration byId = paymentRegistration;
            if (!ObjectUtils.isEmpty(paymentRegistration.getId())){
@@ -106,15 +107,16 @@
            PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(paymentRegistration.getPurchaseLedgerId());
            if(null==purchaseLedger) throw new RuntimeException("未找到采购单");
            // 已回款金额
            SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(paymentRegistration.getSaleLedgerProductId());
            SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(paymentRegistration.getSalesLedgerProductId());
            if(null==salesLedgerProduct) throw new RuntimeException("未找到采购单产品");
            if (salesLedgerProduct.getPendingInvoiceTotal().compareTo(paymentRegistration.getCurrentPaymentAmount())<0){
            if (salesLedgerProduct.getPendingTicketsTotal().compareTo(paymentRegistration.getCurrentPaymentAmount())<0){
                throw new RuntimeException("本次回款金额不能大于待回款金额");
            }
            paymentRegistration.setCreateTime(DateUtils.getNowDate());
            paymentRegistration.setUpdateTime(DateUtils.getNowDate());
            salesLedgerProduct.setInvoiceTotal(salesLedgerProduct.getInvoiceTotal().add(paymentRegistration.getCurrentPaymentAmount()));
            salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProduct.getTaxInclusiveTotalPrice().subtract(salesLedgerProduct.getInvoiceTotal()));
            paymentRegistration.setRegistrantId(userId);
            salesLedgerProduct.setTicketsTotal(salesLedgerProduct.getTicketsTotal().add(paymentRegistration.getCurrentPaymentAmount()));
            salesLedgerProduct.setPendingTicketsTotal(salesLedgerProduct.getTaxInclusiveTotalPrice().subtract(salesLedgerProduct.getTicketsTotal()));
            paymentRegistrationMapper.insert(paymentRegistration);
            salesLedgerProductMapper.updateById(salesLedgerProduct);
        }
@@ -456,6 +458,16 @@
        return paymentRegistrationMapper.deleteById(id);
    }
    @Override
    public IPage<PaymentRegistrationDto> supplierNameListPage(Page page, PaymentLedgerDto paymentLedgerDto) {
        return paymentRegistrationMapper.supplierNameListPage(page, paymentLedgerDto);
    }
    @Override
    public List<PaymentRegistrationDto> supplierNameListPageDetails(PaymentLedgerDto paymentLedgerDto) {
        return paymentRegistrationMapper.supplierNameListPageDetails(paymentLedgerDto);
    }
    // 批量查询采购台账(当月)
    private Map<Long, List<PurchaseLedger>> batchQueryPurchaseLedgers(List<Long> supplierIds, LocalDate startDate, LocalDate endDate) {
        LambdaQueryWrapper<PurchaseLedger> query = new LambdaQueryWrapper<>();