using Furion;
|
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.Jobs
|
{
|
/// <summary>
|
/// 刷新渠道钱包状态
|
/// </summary>
|
[JobDetail("RefreshChannelWalletSignStatusJob", Description = "刷新渠道钱包状态", Concurrent = false)]
|
[PeriodMinutes(5)]
|
public class RefreshChannelWalletSignStatusJob(
|
ChannelWalletRepository channelWalletRepository,
|
ChannelWalletService channelWalletService
|
) : IJob
|
{
|
private readonly ChannelWalletRepository channelWalletRepository = channelWalletRepository;
|
private readonly ChannelWalletService channelWalletService = channelWalletService;
|
|
public async Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken)
|
{
|
var env = App.GetConfig<string>("Environment");
|
if (env != "Local")
|
{
|
var wallets = await channelWalletRepository.GetQueryable()
|
.Where(it =>
|
it.Identity != null
|
&& it.Identity != ""
|
&& it.SignStatus < EnumWalletSignStatus.Normal)
|
.ToListAsync();
|
foreach (var wallet in wallets)
|
{
|
await channelWalletService.GetEnterpriseWalletBalance(wallet);
|
}
|
await channelWalletRepository.UpdateNowAsync(wallets);
|
}
|
}
|
}
|
}
|