using Microsoft.Extensions.Logging;
using SqlSugar;
using Volo.Abp.BackgroundWorkers.Hangfire;
using Yi.Framework.AiHub.Application.Contracts.IServices;
using Yi.Framework.AiHub.Domain.Entities;
using Yi.Framework.AiHub.Domain.Entities.OpenApi;
using Yi.Framework.AiHub.Domain.Managers;
using Yi.Framework.Rbac.Domain.Entities;
using Yi.Framework.SqlSugarCore.Abstractions;

namespace Yi.Abp.Web.Jobs.ai_hub;

/// <summary>
/// VIP过期自动卸载任务
/// </summary>
public class VipExpireJob : HangfireBackgroundWorkerBase
{
    private readonly IRechargeService _rechargeService;

    public VipExpireJob(IRechargeService rechargeService)
    {
        _rechargeService = rechargeService;
        RecurringJobId = "VIP过期自动卸载";
        // 每天凌晨0点执行一次
        CronExpression = "0 0 0 * * ?";
    }

    public override async Task DoWorkAsync(CancellationToken cancellationToken = new CancellationToken())
    {
        await _rechargeService.RemoveVipRoleByExpireAsync();
    }
}