| | |
| | | package com.ruoyi.sales.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.basic.enums.ApplicationTypeEnum; |
| | | import com.ruoyi.basic.enums.RecordTypeEnum; |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.framework.web.page.TableDataInfo; |
| | | import com.ruoyi.sales.dto.SalesLedgerDto; |
| | | import com.ruoyi.sales.mapper.ReceiptPaymentMapper; |
| | | import com.ruoyi.sales.pojo.ReceiptPayment; |
| | | import com.ruoyi.sales.pojo.SalesLedger; |
| | | import com.ruoyi.sales.service.ICommonFileService; |
| | | import com.ruoyi.sales.service.ISalesLedgerService; |
| | | import com.ruoyi.sales.vo.SalesLedgerVo; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | |
| | | import java.io.FileNotFoundException; |
| | | import java.io.IOException; |
| | |
| | | |
| | | private ISalesLedgerService salesLedgerService; |
| | | private ICommonFileService commonFileService; |
| | | private ReceiptPaymentMapper receiptPaymentMapper; |
| | | private final FileUtil fileUtil; |
| | | |
| | | /** |
| | |
| | | List<Long> salesLedgerIds = iPage.getRecords().stream().map(SalesLedger::getId).collect(Collectors.toList()); |
| | | |
| | | |
| | | // 查询回款/付款记录 |
| | | List<ReceiptPayment> receiptPayments = Collections.emptyList(); |
| | | if (!CollectionUtils.isEmpty(salesLedgerIds)) { |
| | | receiptPayments = receiptPaymentMapper.selectList(new LambdaQueryWrapper<ReceiptPayment>() |
| | | .in(ReceiptPayment::getSalesLedgerId, salesLedgerIds)); |
| | | } |
| | | |
| | | |
| | | // 转换回款数据, key 为台账ID, value 为该台账的总回款金额 |
| | | Map<Long, BigDecimal> receiptTotals = new HashMap<>(); |
| | | if (!CollectionUtils.isEmpty(receiptPayments)) { |
| | | for (ReceiptPayment receiptPayment : receiptPayments) { |
| | | if (receiptPayment.getSalesLedgerId() != null && receiptPayment.getReceiptPaymentAmount() != null) { |
| | | // 如果 key 存在则相加,不存在则放入 |
| | | receiptTotals.merge(receiptPayment.getSalesLedgerId(), receiptPayment.getReceiptPaymentAmount(), BigDecimal::add); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | for (SalesLedgerVo salesLedgerVo : iPage.getRecords()) { |
| | | Long ledgerId = salesLedgerVo.getId(); |
| | |
| | | |
| | | if (ObjectUtils.isNotEmpty(salesLedgerDto.getStatus())) { |
| | | if (salesLedgerDto.getStatus()) { |
| | | // 清除所有“未开票金额”为 0 的记录 |
| | | iPage.getRecords().removeIf(salesLedger -> |
| | | Objects.equals(salesLedger.getNoInvoiceAmountTotal(), new BigDecimal("0.00"))); |
| | | iPage.setTotal(iPage.getRecords().size()); |
| | | } |
| | | } |