| | |
| | | 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; |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | try { |
| | | // 执行文件迁移(使用原子操作确保安全性) |
| | | Files.move( |
| | | Paths.get(tempFile.getTempPath()), |
| | | formalFilePath, |
| | | StandardCopyOption.REPLACE_EXISTING, |
| | | StandardCopyOption.ATOMIC_MOVE |
| | | ); |
| | | // 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) |
| | |
| | | |
| | | // 修改产品信息 |
| | | 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); |
| | |
| | | for (SalesLedgerProduct salesLedgerProduct : salesLedgerProducts) { |
| | | salesLedgerProduct.setFutureTickets(salesLedgerProduct.getFutureTickets().add(productRecord.getTicketsNum())); |
| | | salesLedgerProduct.setFutureTicketsAmount(salesLedgerProduct.getFutureTicketsAmount().add(productRecord.getTicketsAmount())); |
| | | salesLedgerProduct.setTicketsAmount(salesLedgerProduct.getTaxInclusiveTotalPrice().subtract(salesLedgerProduct.getFutureTicketsAmount())); |
| | | salesLedgerProduct.setTicketsNum(salesLedgerProduct.getQuantity().subtract(salesLedgerProduct.getFutureTickets())); |
| | | salesLedgerProductMapper.updateById(salesLedgerProduct); |
| | | |
| | | } |
| | |
| | | @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"))); |
| | |
| | | |
| | | 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; |
| | | } |
| | | |
| | |
| | | List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductService.selectSalesLedgerProductList(salesLedgerProduct); |
| | | purchaseLedgerDto.setProductData(salesLedgerProducts); |
| | | List<CommonFile> commonFiles = commonFileMapper.selectList(new LambdaQueryWrapper<CommonFile>() |
| | | .eq(CommonFile::getType, FileNameType.PURCHASELEDGER.getValue()) |
| | | .eq(CommonFile::getType, FileNameType.PURCHASE.getValue()) |
| | | .eq(CommonFile::getCommonId, id)); |
| | | purchaseLedgerDto.setSalesLedgerFiles(commonFiles); |
| | | return purchaseLedgerDto; |
| | |
| | | |
| | | // 批量更新(需要 MyBatis 提供批量更新方法) |
| | | if (!updateList.isEmpty()) { |
| | | AtomicBoolean isUpdated = new AtomicBoolean(true); |
| | | updateList.forEach(product -> { |
| | | // 非空校验,任一字段为空则抛出异常 |
| | | if (product.getQuantity() == null) { |
| | | throw new BaseException("数量不能为空"); |
| | | if (product.getQuantity() != null) { |
| | | isUpdated.set(false); |
| | | } |
| | | if (product.getTicketsNum() == null) { |
| | | throw new BaseException("已开票数量不能为空"); |
| | | if (product.getTicketsNum() != null) { |
| | | isUpdated.set(false); |
| | | } |
| | | if (product.getTaxInclusiveTotalPrice() == null) { |
| | | throw new BaseException("含税总价不能为空"); |
| | | if (product.getTaxInclusiveTotalPrice() != null) { |
| | | isUpdated.set(false); |
| | | } |
| | | if (product.getTicketsAmount() == null) { |
| | | throw new BaseException("本次来票金额(元)不能为空"); |
| | | if (product.getTicketsAmount() != null) { |
| | | isUpdated.set(false); |
| | | } |
| | | |
| | | // 计算 futureTickets(直接使用 BigDecimal 计算,避免精度丢失) |
| | |
| | | product.setType(type); |
| | | salesLedgerProductMapper.updateById(product); |
| | | }); |
| | | if(isUpdated.get()){ |
| | | throw new RuntimeException("来票数不可全部为空"); |
| | | } |
| | | } |
| | | } |
| | | |