maven
5 天以前 74dfb82a264f1b779e50058145953caca907f6f2
src/main/java/com/ruoyi/purchase/service/impl/TicketRegistrationServiceImpl.java
@@ -21,6 +21,7 @@
import com.ruoyi.purchase.mapper.ProductRecordMapper;
import com.ruoyi.purchase.mapper.PurchaseLedgerMapper;
import com.ruoyi.purchase.mapper.TicketRegistrationMapper;
import com.ruoyi.purchase.pojo.PaymentRegistration;
import com.ruoyi.purchase.pojo.ProductRecord;
import com.ruoyi.purchase.pojo.PurchaseLedger;
import com.ruoyi.purchase.pojo.TicketRegistration;
@@ -134,7 +135,7 @@
        BeanUtils.copyProperties(ticketRegistrationDto, ticketRegistration);
        ticketRegistration.setPurchaseContractNumber(purchaseLedger.getPurchaseContractNumber());
        ticketRegistration.setTenantId(purchaseLedger.getTenantId());
        ticketRegistration.setIssueDate(ticketRegistrationDto.getIssueDate());
        ticketRegistration.setIssueDate(ticketRegistrationDto.getEntryDate());
        ticketRegistration.setContractAmount(purchaseLedger.getContractAmount());
        ticketRegistration.setSalesLedgerId(purchaseLedger.getSalesLedgerId());
        ticketRegistration.setEnterDate(ticketRegistrationDto.getEnterDate());
@@ -164,11 +165,11 @@
                    productRecord.setSaleLedgerProjectId(salesLedgerProduct.getId());
                    productRecord.setId(null);
                    productRecord.setType("2");
                     insert = productRecordMapper.insert(productRecord);
                    insert += productRecordMapper.insert(productRecord);
                }
                if (insert <= 0) {
                    throw new RuntimeException("产品开票数都为0,请检查");
                }
            }
            if (insert <= 0) {
                throw new RuntimeException("产品开票数都为0,请检查");
            }
        }
        // 迁移临时文件到正式目录
@@ -221,13 +222,10 @@
            Path formalFilePath = formalDirPath.resolve(formalFilename);
            try {
                // 执行文件迁移(使用原子操作确保安全性)
                Files.move(
                        Paths.get(tempFile.getTempPath()),
                        formalFilePath,
                        StandardCopyOption.REPLACE_EXISTING,
                        StandardCopyOption.ATOMIC_MOVE
                );
                // 原子移动失败,使用复制+删除
                Files.copy(Paths.get(tempFile.getTempPath()), formalFilePath, StandardCopyOption.REPLACE_EXISTING);
                Files.deleteIfExists(Paths.get(tempFile.getTempPath()));
                log.info("文件迁移成功: {} -> {}", tempFile.getTempPath(), formalFilePath);
                // 更新文件记录(关联到业务ID)
@@ -264,8 +262,16 @@
        // 修改产品信息
        for (ProductRecord productRecord : productRecords) {
            ticketRegistrations.get(0).setInvoiceAmount(ticketRegistrations.get(0).getInvoiceAmount().subtract(productRecords.get(0).getTicketsAmount()));
            ticketRegistrationMapper.updateById(ticketRegistrations.get(0));
            BigDecimal subtract = ticketRegistrations.get(0).getInvoiceAmount().subtract(productRecords.get(0).getTicketsAmount());
            // 小于等于0删除 ,大于0修改
            if(subtract.compareTo(BigDecimal.ZERO) <= 0){
                ticketRegistrationMapper.deleteById(ticketRegistrations.get(0));
                // 删除付款流水记录
                paymentRegistrationMapper.delete(new LambdaQueryWrapper<PaymentRegistration>().eq(PaymentRegistration::getTicketRegistrationId, ticketRegistrations.get(0).getId()));
            }else if(subtract.compareTo(BigDecimal.ZERO) > 0){
                ticketRegistrations.get(0).setInvoiceAmount(subtract);
                ticketRegistrationMapper.updateById(ticketRegistrations.get(0));
            }
            LambdaQueryWrapper<SalesLedgerProduct> salesLedgerProductLambdaQueryWrapper = new LambdaQueryWrapper<>();
            salesLedgerProductLambdaQueryWrapper.eq(SalesLedgerProduct::getId, productRecord.getSaleLedgerProjectId())
                    .eq(SalesLedgerProduct::getType, 2);
@@ -323,9 +329,13 @@
    @Override
    public IPage<TicketRegistration> selectTicketRegistrationListPage(Page page, TicketRegistration ticketRegistration) {
        LambdaQueryWrapper<TicketRegistration> queryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.isNotBlank(ticketRegistration.getPurchaseContractNumber())) {
            queryWrapper.like(TicketRegistration::getPurchaseContractNumber, ticketRegistration.getPurchaseContractNumber())
                    .like(TicketRegistration::getSupplierName, ticketRegistration.getSupplierName());
        if (StringUtils.isNotBlank(ticketRegistration.getSupplierNameOrContractNo())) {
            queryWrapper.and(wrapper -> wrapper
                    .like(TicketRegistration::getPurchaseContractNumber, ticketRegistration.getSupplierNameOrContractNo())
                    .or()
                    .like(TicketRegistration::getSupplierName, ticketRegistration.getSupplierNameOrContractNo())
                    .or()
                    .like(TicketRegistration::getSalesContractNo, ticketRegistration.getSupplierNameOrContractNo()));
        }
        if (!ObjectUtils.isEmpty(ticketRegistration.getIssueDateStart()) && !ObjectUtils.isEmpty(ticketRegistration.getIssueDateEnd())) {
            queryWrapper.between(TicketRegistration::getIssueDate, LocalDate.parse(ticketRegistration.getIssueDateStart(), DateTimeFormatter.ofPattern("yyyy-MM-dd")), LocalDate.parse(ticketRegistration.getIssueDateEnd(), DateTimeFormatter.ofPattern("yyyy-MM-dd")));
@@ -353,8 +363,13 @@
            if (ticketRegistration.getStatus()) {
                ticketRegistrationIPage.getRecords().removeIf(receiptPaymentDto1 -> new BigDecimal("0.00").equals(receiptPaymentDto1.getUnPaymentAmountTotal()));
                ticketRegistrationIPage.setTotal(ticketRegistrationIPage.getRecords().size());
            }
        }
        ticketRegistrationIPage.getRecords().forEach(item -> {
            // 已付款金额 == 待付款金额
            item.setStatusName(item.getPaymentAmountTotal().compareTo(item.getInvoiceAmount()) == 0 ? "已完成付款" : "未完成付款");
        });
        return ticketRegistrationIPage;
    }