| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.dto.SupplierManageDto; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.common.vo.FileVo; |
| | | import com.ruoyi.sales.dto.InvoiceLedgerDto; |
| | | import com.ruoyi.sales.excel.InvoiceLedgerExcelDto; |
| | | import com.ruoyi.sales.mapper.InvoiceLedgerFileMapper; |
| | | import com.ruoyi.sales.mapper.InvoiceLedgerMapper; |
| | | import com.ruoyi.sales.mapper.ReceiptPaymentMapper; |
| | | import com.ruoyi.sales.pojo.InvoiceLedger; |
| | | import com.ruoyi.sales.pojo.InvoiceLedgerFile; |
| | | import com.ruoyi.sales.pojo.ReceiptPayment; |
| | | import com.ruoyi.sales.service.InvoiceLedgerService; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.util.Collections; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.YearMonth; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private InvoiceLedgerFileMapper invoiceLedgerFileMapper; |
| | | |
| | | @Autowired |
| | | private ReceiptPaymentMapper receiptPaymentMapper; |
| | | |
| | | /** |
| | | * 开票台账新增 |
| | |
| | | return invoiceLedgerMapper.invoiceLedgerList(invoiceLedgerDto); |
| | | } |
| | | |
| | | /** |
| | | * 客户销售记录 |
| | | * @param page |
| | | * @param invoiceLedgerDto |
| | | * @return |
| | | */ |
| | | @Override |
| | | public IPage<InvoiceLedgerDto> invoiceLedgerSalesAccount(Page page, InvoiceLedgerDto invoiceLedgerDto) { |
| | | IPage<InvoiceLedgerDto> invoiceLedgerDtoIPage = invoiceLedgerMapper.invoiceLedgerSalesAccount(page, invoiceLedgerDto); |
| | | for (InvoiceLedgerDto record : invoiceLedgerDtoIPage.getRecords()) { |
| | | QueryWrapper<ReceiptPayment> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("customer_id", record.getCustomerId()); |
| | | List<ReceiptPayment> receiptPaymentList = receiptPaymentMapper.selectList(queryWrapper); |
| | | BigDecimal totalAmount = BigDecimal.ZERO; |
| | | if(!CollectionUtils.isEmpty(receiptPaymentList)){ |
| | | for (ReceiptPayment receiptPayment : receiptPaymentList) { |
| | | totalAmount = totalAmount.add(receiptPayment.getInvoiceAmount()); |
| | | } |
| | | } |
| | | BigDecimal unReceiptPaymentAmount = record.getInvoiceAmount().subtract(totalAmount); |
| | | record.setReceiptPaymentAmount(totalAmount); |
| | | record.setUnReceiptPaymentAmount(unReceiptPaymentAmount); |
| | | } |
| | | return invoiceLedgerDtoIPage; |
| | | } |
| | | |
| | | @Override |
| | | public BigDecimal getInvoiceAmount() { |
| | | LocalDate now = LocalDate.now(); |
| | | YearMonth currentMonth = YearMonth.from(now); |
| | | |
| | | // 创建LambdaQueryWrapper |
| | | LambdaQueryWrapper<InvoiceLedger> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.ge(InvoiceLedger::getInvoiceDate, currentMonth.atDay(1).atStartOfDay()) // 大于等于本月第一天 |
| | | .lt(InvoiceLedger::getInvoiceDate, currentMonth.plusMonths(1).atDay(1).atStartOfDay()); // 小于下月第一天 |
| | | |
| | | // 执行查询并计算总和 |
| | | List<InvoiceLedger> invoiceLedgers = invoiceLedgerMapper.selectList(queryWrapper); |
| | | |
| | | BigDecimal totalContractAmount = invoiceLedgers.stream() |
| | | .map(InvoiceLedger::getInvoiceAmount) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | return totalContractAmount; |
| | | } |
| | | |
| | | } |