using Microsoft.Extensions.Logging;
using TakeoutSaaS.Application.App.Stores.Services;

namespace TakeoutSaaS.Module.Scheduler.Jobs;

/// <summary>
/// 门店资质过期检查任务。
/// </summary>
public sealed class QualificationExpiryCheckJob(
    IStoreSchedulerService schedulerService,
    ILogger<QualificationExpiryCheckJob> logger)
{
    /// <summary>
    /// 执行资质过期检查。
    /// </summary>
    public async Task ExecuteAsync()
    {
        // 1. 执行资质过期检查
        var updated = await schedulerService.CheckQualificationExpiryAsync(DateTime.UtcNow, CancellationToken.None);

        // 2. (空行后) 记录执行结果
        logger.LogInformation("定时任务：门店资质过期检查执行完成，更新 {UpdatedCount} 家门店", updated);
    }
}
