| | |
| | | package com.ruoyi.purchase.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | |
| | | } |
| | | List<TicketRegistration> ticketRegistrationList = ticketRegistrationMapper.selectList(queryWrapper); |
| | | // 计算已付款金额 |
| | | if(CollectionUtils.isNotEmpty(ticketRegistrationList)){ |
| | | if (CollectionUtils.isNotEmpty(ticketRegistrationList)) { |
| | | List<Long> ids = ticketRegistrationList.stream().map(TicketRegistration::getId).collect(Collectors.toList()); |
| | | List<PaymentRegistrationDto> paymentRegistrationDtoList = paymentRegistrationMapper.countPaymentTotalByTicketRegId(ids); |
| | | for (TicketRegistration registration : ticketRegistrationList) { |
| | | BigDecimal paymentAmountTotal = BigDecimal.ZERO; |
| | | for (PaymentRegistrationDto paymentRegistrationDto : paymentRegistrationDtoList) { |
| | | if(registration.getId().equals(paymentRegistrationDto.getTicketRegistrationId())){ |
| | | if (registration.getId().equals(paymentRegistrationDto.getTicketRegistrationId())) { |
| | | paymentAmountTotal = paymentRegistrationDto.getPaymentAmountTotal(); |
| | | break; |
| | | } |
| | |
| | | |
| | | // 6. 增加采购台账产品开票记录 |
| | | List<SalesLedgerProduct> salesLedgerProducts = ticketRegistrationDto.getProductData(); |
| | | if (CollectionUtils.isNotEmpty(salesLedgerProducts)){ |
| | | if (CollectionUtils.isNotEmpty(salesLedgerProducts)) { |
| | | for (SalesLedgerProduct salesLedgerProduct : salesLedgerProducts) { |
| | | ProductRecord productRecord = new ProductRecord(); |
| | | productRecord.setTicketRegistrationId(ticketRegistration.getId()); |
| | | productRecord.setPurchaseLedgerId(ticketRegistrationDto.getPurchaseLedgerId()); |
| | | productRecord.setCreatedAt(DateUtils.getNowDate()); |
| | | BeanUtils.copyProperties(salesLedgerProduct,productRecord); |
| | | BeanUtils.copyProperties(salesLedgerProduct, productRecord); |
| | | productRecord.setId(null); |
| | | productRecord.setType("2"); |
| | | productRecordMapper.insert(productRecord); |
| | |
| | | @Override |
| | | public List getTicketNo(TicketRegistrationDto ticketRegistrationDto) { |
| | | LambdaQueryWrapper<TicketRegistration> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.select(TicketRegistration::getId,TicketRegistration::getInvoiceNumber,TicketRegistration::getInvoiceAmount) |
| | | .eq(TicketRegistration::getPurchaseLedgerId,ticketRegistrationDto.getId()); |
| | | queryWrapper.select(TicketRegistration::getId, TicketRegistration::getInvoiceNumber, TicketRegistration::getInvoiceAmount) |
| | | .eq(TicketRegistration::getPurchaseLedgerId, ticketRegistrationDto.getId()); |
| | | List<Map<String, Object>> result = ticketRegistrationMapper.selectMaps(queryWrapper); |
| | | // 将下划线命名转换为驼峰命名 |
| | | return result.stream().map(map -> map.entrySet().stream() |
| | |
| | | ).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @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 (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"))); |
| | | } |
| | | IPage<TicketRegistration> ticketRegistrationIPage = ticketRegistrationMapper.selectPage(page, queryWrapper); |
| | | // 计算已付款金额 |
| | | if (CollectionUtils.isNotEmpty(ticketRegistrationIPage.getRecords())) { |
| | | List<Long> ids = ticketRegistrationIPage.getRecords().stream().map(TicketRegistration::getId).collect(Collectors.toList()); |
| | | List<PaymentRegistrationDto> paymentRegistrationDtoList = paymentRegistrationMapper.countPaymentTotalByTicketRegId(ids); |
| | | for (TicketRegistration registration : ticketRegistrationIPage.getRecords()) { |
| | | BigDecimal paymentAmountTotal = BigDecimal.ZERO; |
| | | for (PaymentRegistrationDto paymentRegistrationDto : paymentRegistrationDtoList) { |
| | | if (registration.getId().equals(paymentRegistrationDto.getTicketRegistrationId())) { |
| | | paymentAmountTotal = paymentRegistrationDto.getPaymentAmountTotal(); |
| | | break; |
| | | } |
| | | } |
| | | BigDecimal invoiceAmount = registration.getInvoiceAmount(); |
| | | BigDecimal subtractAmount = invoiceAmount.subtract(paymentAmountTotal); |
| | | registration.setPaymentAmountTotal(paymentAmountTotal); |
| | | registration.setUnPaymentAmountTotal(subtractAmount); |
| | | } |
| | | } |
| | | if (!ObjectUtils.isEmpty(ticketRegistration.getStatus())) { |
| | | |
| | | if (ticketRegistration.getStatus()) { |
| | | ticketRegistrationIPage.getRecords().removeIf(receiptPaymentDto1 -> new BigDecimal("0.00").equals(receiptPaymentDto1.getUnPaymentAmountTotal())); |
| | | } |
| | | } |
| | | return ticketRegistrationIPage; |
| | | } |
| | | |
| | | private void handleSalesLedgerProducts(Long salesLedgerId, List<SalesLedgerProduct> products, Integer type) { |
| | | if (products == null || products.isEmpty()) { |
| | | return; |