sunpengfei
2025-11-21 2429b458b19de2d1871b97c323ef010711cbba79
feat:开发
1个文件已添加
45 ■■■■■ 已修改文件
ApiTools.Core/Jobs/RefreshChannelWalletSignStatusJob.cs 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ApiTools.Core/Jobs/RefreshChannelWalletSignStatusJob.cs
New file
@@ -0,0 +1,45 @@
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);
            }
        }
    }
}