sunpengfei
2025-12-01 37df521a037702e4c0710011c7378cc5f9238fba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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);
            }
        }
    }
}