完成门店管理后端接口与任务
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using TakeoutSaaS.Application.App.Stores.Services;
|
||||
|
||||
namespace TakeoutSaaS.Module.Scheduler.Jobs;
|
||||
|
||||
/// <summary>
|
||||
/// 门店营业状态自动切换任务。
|
||||
/// </summary>
|
||||
public sealed class BusinessStatusAutoSwitchJob(
|
||||
IStoreSchedulerService schedulerService,
|
||||
ILogger<BusinessStatusAutoSwitchJob> logger)
|
||||
{
|
||||
/// <summary>
|
||||
/// 执行自动切换。
|
||||
/// </summary>
|
||||
public async Task ExecuteAsync()
|
||||
{
|
||||
// 1. 执行自动切换
|
||||
var updated = await schedulerService.AutoSwitchBusinessStatusAsync(DateTime.UtcNow, CancellationToken.None);
|
||||
|
||||
// 2. (空行后) 记录执行结果
|
||||
logger.LogInformation("定时任务:门店营业状态自动切换执行完成,更新 {UpdatedCount} 家门店", updated);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,16 @@ public sealed class RecurringJobRegistrar(
|
||||
job => job.ExecuteAsync(),
|
||||
billingOptions.OverdueBillingProcessCron);
|
||||
|
||||
// 4. (空行后) 门店管理自动化任务
|
||||
RecurringJob.AddOrUpdate<BusinessStatusAutoSwitchJob>(
|
||||
"stores.business-status-auto-switch",
|
||||
job => job.ExecuteAsync(),
|
||||
"*/1 * * * *");
|
||||
RecurringJob.AddOrUpdate<QualificationExpiryCheckJob>(
|
||||
"stores.qualification-expiry-check",
|
||||
job => job.ExecuteAsync(),
|
||||
"0 2 * * *");
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user