From 83c052ec4ee6def39d736a44bbe60d649f542e7d Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 21 Aug 2025 02:30:59 +0800 Subject: [PATCH] :recycle: Replace check in with recorded experience source --- .../Account/AccountEventService.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/DysonNetwork.Pass/Account/AccountEventService.cs b/DysonNetwork.Pass/Account/AccountEventService.cs index d18f235..1e86f65 100644 --- a/DysonNetwork.Pass/Account/AccountEventService.cs +++ b/DysonNetwork.Pass/Account/AccountEventService.cs @@ -15,7 +15,8 @@ public class AccountEventService( ICacheService cache, IStringLocalizer localizer, PusherService.PusherServiceClient pusher, - SubscriptionService subscriptions + SubscriptionService subscriptions, + Pass.Leveling.ExperienceService experienceService ) { private static readonly Random Random = new(); @@ -327,13 +328,15 @@ public class AccountEventService( result.RewardPoints = null; } - await db.AccountProfiles - .Where(p => p.AccountId == user.Id) - .ExecuteUpdateAsync(s => - s.SetProperty(b => b.Experience, b => b.Experience + result.RewardExperience) - ); db.AccountCheckInResults.Add(result); - await db.SaveChangesAsync(); // Don't forget to save changes to the database + await db.SaveChangesAsync(); // Remember to save changes to the database + if (result.RewardExperience is not null) + await experienceService.AddRecord( + "check-in", + $"Check-in reward on {now:yyyy/MM/dd}", + result.RewardExperience.Value, + user.Id + ); // The lock will be automatically released by the await using statement return result;