♻️ Move the lotteries logic to the wallet service

This commit is contained in:
2026-02-05 16:13:57 +08:00
parent 3c0f5b0e41
commit 3c6ccba74f
8 changed files with 14 additions and 15 deletions

View File

@@ -36,12 +36,6 @@ public static class ScheduledJobsConfiguration
.RepeatForever()) .RepeatForever())
); );
q.AddJob<Lotteries.LotteryDrawJob>(opts => opts.WithIdentity("LotteryDraw"));
q.AddTrigger(opts => opts
.ForJob("LotteryDraw")
.WithIdentity("LotteryDrawTrigger")
.WithCronSchedule("0 0 0 * * ?"));
q.AddJob<SocialCreditValidationJob>(opts => opts.WithIdentity("SocialCreditValidation")); q.AddJob<SocialCreditValidationJob>(opts => opts.WithIdentity("SocialCreditValidation"));
q.AddTrigger(opts => opts q.AddTrigger(opts => opts
.ForJob("SocialCreditValidation") .ForJob("SocialCreditValidation")

View File

@@ -16,7 +16,6 @@ using DysonNetwork.Pass.Auth.OidcProvider.Services;
using DysonNetwork.Pass.Credit; using DysonNetwork.Pass.Credit;
using DysonNetwork.Pass.Handlers; using DysonNetwork.Pass.Handlers;
using DysonNetwork.Pass.Leveling; using DysonNetwork.Pass.Leveling;
using DysonNetwork.Pass.Lotteries;
using DysonNetwork.Pass.Mailer; using DysonNetwork.Pass.Mailer;
using DysonNetwork.Pass.Realm; using DysonNetwork.Pass.Realm;
using DysonNetwork.Pass.Rewind; using DysonNetwork.Pass.Rewind;
@@ -165,7 +164,6 @@ public static class ServiceCollectionExtensions
services.AddScoped<SocialCreditService>(); services.AddScoped<SocialCreditService>();
services.AddScoped<ExperienceService>(); services.AddScoped<ExperienceService>();
services.AddScoped<RealmService>(); services.AddScoped<RealmService>();
services.AddScoped<LotteryService>();
services.AddScoped<AffiliationSpellService>(); services.AddScoped<AffiliationSpellService>();
services.AddScoped<SpotifyPresenceService>(); services.AddScoped<SpotifyPresenceService>();

View File

@@ -121,4 +121,3 @@ public class AppDatabaseFactory : IDesignTimeDbContextFactory<AppDatabase>
return new AppDatabase(optionsBuilder.Options, configuration); return new AppDatabase(optionsBuilder.Options, configuration);
} }
} }

View File

@@ -1,13 +1,12 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Models;
using DysonNetwork.Pass.Permission;
using DysonNetwork.Shared.Auth; using DysonNetwork.Shared.Auth;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using NodaTime; using NodaTime;
namespace DysonNetwork.Pass.Lotteries; namespace DysonNetwork.Wallet.Lotteries;
[ApiController] [ApiController]
[Route("/api/lotteries")] [Route("/api/lotteries")]

View File

@@ -1,6 +1,6 @@
using Quartz; using Quartz;
namespace DysonNetwork.Pass.Lotteries; namespace DysonNetwork.Wallet.Lotteries;
public class LotteryDrawJob(LotteryService lotteryService, ILogger<LotteryDrawJob> logger) : IJob public class LotteryDrawJob(LotteryService lotteryService, ILogger<LotteryDrawJob> logger) : IJob
{ {

View File

@@ -1,9 +1,8 @@
using DysonNetwork.Shared.Models; using DysonNetwork.Shared.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using NodaTime; using NodaTime;
namespace DysonNetwork.Pass.Lotteries; namespace DysonNetwork.Wallet.Lotteries;
public class LotteryOrderMetaData public class LotteryOrderMetaData
{ {

View File

@@ -40,8 +40,16 @@ public static class ScheduledJobsConfiguration
.WithSimpleSchedule(o => o .WithSimpleSchedule(o => o
.WithIntervalInHours(1) .WithIntervalInHours(1)
.RepeatForever()) .RepeatForever())
); );
q.AddJob<Lotteries.LotteryDrawJob>(opts => opts.WithIdentity("LotteryDraw"));
q.AddTrigger(opts => opts
.ForJob("LotteryDraw")
.WithIdentity("LotteryDrawTrigger")
.WithCronSchedule("0 0 0 * * ?"));
}); });
services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true); services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true);
return services; return services;

View File

@@ -10,6 +10,7 @@ using DysonNetwork.Shared.Registry;
using DysonNetwork.Wallet.Localization; using DysonNetwork.Wallet.Localization;
using DysonNetwork.Wallet.Payment; using DysonNetwork.Wallet.Payment;
using DysonNetwork.Wallet.Payment.PaymentHandlers; using DysonNetwork.Wallet.Payment.PaymentHandlers;
using DysonNetwork.Wallet.Lotteries;
namespace DysonNetwork.Wallet.Startup; namespace DysonNetwork.Wallet.Startup;
@@ -101,6 +102,7 @@ public static class ServiceCollectionExtensions
services.AddScoped<PaymentService>(); services.AddScoped<PaymentService>();
services.AddScoped<SubscriptionService>(); services.AddScoped<SubscriptionService>();
services.AddScoped<AfdianPaymentHandler>(); services.AddScoped<AfdianPaymentHandler>();
services.AddScoped<LotteryService>();
services.AddHostedService<BroadcastEventHandler>(); services.AddHostedService<BroadcastEventHandler>();