using Furion; using Furion.DatabaseAccessor; using Furion.EventBus; using Furion.Schedule; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ApiTools.Core { /// /// 刷新渠道钱包交易状态 /// [JobDetail("RefreshChannelWalletTransactionStatusJob", Description = "刷新渠道钱包交易状态", Concurrent = false)] [PeriodMinutes(5)] public class RefreshChannelWalletTransactionStatusJob( ChannelWalletRepository channelWalletRepository, ChannelWalletTransactionRepository channelWalletTransactionRepository, ChannelWalletService channelWalletService ) : IJob { private readonly ChannelWalletRepository channelWalletRepository = channelWalletRepository; private readonly ChannelWalletTransactionRepository channelWalletTransactionRepository = channelWalletTransactionRepository; private readonly ChannelWalletService channelWalletService = channelWalletService; public async Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken) { //var env = App.GetConfig("Environment"); //if (env != "Local") //{ var transactions = await channelWalletTransactionRepository.GetQueryable(false) .Where(it => it.TransactionStatus == EnumWalletTransactionStatus.WaitPay || it.TransactionStatus == EnumWalletTransactionStatus.Dealing) .ToListAsync(); var walletIds = transactions.Select(it => it.WalletId).Distinct().ToList(); var wallets = await channelWalletRepository.GetQueryable(false) .Where(it => walletIds.Contains(it.Id)) .ToListAsync(); foreach (var transaction in transactions) { var wallet = wallets.FirstOrDefault(it => it.Id == transaction.WalletId); if (wallet != null) { // 查询交易详情 await channelWalletService.GetTransactionDetail(wallet, transaction); // 下载回单 await channelWalletService.DownloadEreceiptUrl(wallet, transaction); } } //} } } }