| | |
| | | package com.ruoyi.sales.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | import com.ruoyi.other.pojo.TempFile; |
| | | import com.ruoyi.sales.dto.SalesLedgerDto; |
| | | import com.ruoyi.sales.mapper.CommonFileMapper; |
| | | import com.ruoyi.sales.mapper.InvoiceRegistrationProductMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.pojo.CommonFile; |
| | | import com.ruoyi.sales.pojo.InvoiceRegistrationProduct; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.sales.service.ISalesLedgerService; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.data.redis.core.script.DefaultRedisScript; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.io.IOException; |
| | | import java.lang.reflect.Field; |
| | |
| | | |
| | | private final TempFileMapper tempFileMapper; |
| | | |
| | | @Autowired |
| | | private InvoiceRegistrationProductMapper invoiceRegistrationProductMapper; |
| | | |
| | | @Value("${file.upload-dir}") |
| | | private String uploadDir; |
| | | |
| | |
| | | LambdaQueryWrapper<SalesLedgerProduct> productWrapper = new LambdaQueryWrapper<>(); |
| | | productWrapper.eq(SalesLedgerProduct::getSalesLedgerId, salesLedger.getId()); |
| | | List<SalesLedgerProduct> products = salesLedgerProductMapper.selectList(productWrapper); |
| | | // 查询未开票金额/未开票数 |
| | | if (CollectionUtils.isNotEmpty(products)) { |
| | | QueryWrapper<InvoiceRegistrationProduct> productQueryWrapper = new QueryWrapper<>(); |
| | | List<Long> productIds = products.stream().map(SalesLedgerProduct::getId).collect(Collectors.toList()); |
| | | productQueryWrapper.in("sales_ledger_product_id", productIds); |
| | | List<InvoiceRegistrationProduct> invoiceRegistrationProductList = invoiceRegistrationProductMapper.selectList(productQueryWrapper); |
| | | if(CollectionUtils.isNotEmpty(invoiceRegistrationProductList)){ |
| | | for (SalesLedgerProduct product : products) { |
| | | for (InvoiceRegistrationProduct invoiceRegistrationProduct : invoiceRegistrationProductList) { |
| | | Integer salesLedgerProductId = invoiceRegistrationProduct.getSalesLedgerProductId(); |
| | | Long id = product.getId(); |
| | | if( null != id && null != salesLedgerProductId && id == salesLedgerProductId.longValue()){ |
| | | product.setFutureTickets(Long.valueOf(invoiceRegistrationProduct.getNoInvoiceNum())); |
| | | product.setFutureTicketsAmount(invoiceRegistrationProduct.getNoInvoiceAmount()); |
| | | } |
| | | } |
| | | } |
| | | }else { |
| | | for (SalesLedgerProduct product : products) { |
| | | product.setFutureTickets(product.getQuantity().longValue()); |
| | | product.setFutureTicketsAmount(product.getTaxInclusiveTotalPrice()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 3.查询上传文件 |
| | | LambdaQueryWrapper<CommonFile> salesLedgerFileWrapper = new LambdaQueryWrapper<>(); |
| | |
| | | if (salesLedgerDto.getTempFileIds() != null && !salesLedgerDto.getTempFileIds().isEmpty()) { |
| | | migrateTempFilesToFormal(salesLedger.getId(), salesLedgerDto.getTempFileIds()); |
| | | } |
| | | |
| | | return 1; |
| | | } catch (IOException e) { |
| | | throw new BaseException("文件迁移失败: " + e.getMessage()); |