🐛 Fix birthday check in

This commit is contained in:
2025-09-24 21:37:59 +08:00
parent 7bc94a9646
commit 50efe62bac

View File

@@ -300,10 +300,22 @@ public class AccountEventService(
Content = localizer[$"FortuneTipNegativeContent_{index}"].Value Content = localizer[$"FortuneTipNegativeContent_{index}"].Value
})); }));
// The 5 is specialized, keep it alone.
var checkInLevel = (CheckInResultLevel)Random.Next(Enum.GetValues<CheckInResultLevel>().Length - 1);
var accountBirthday = await db.AccountProfiles
.Where(x => x.AccountId == user.Id)
.Select(x => x.Birthday)
.FirstOrDefaultAsync();
var now = SystemClock.Instance.GetCurrentInstant().InUtc().Date;
if (accountBirthday.HasValue && accountBirthday.Value.InUtc().Date == now)
checkInLevel = CheckInResultLevel.Special;
var result = new CheckInResult var result = new CheckInResult
{ {
Tips = tips, Tips = tips,
Level = (CheckInResultLevel)Random.Next(Enum.GetValues<CheckInResultLevel>().Length), Level = checkInLevel,
AccountId = user.Id, AccountId = user.Id,
RewardExperience = 100, RewardExperience = 100,
RewardPoints = backdated.HasValue ? null : 10, RewardPoints = backdated.HasValue ? null : 10,
@@ -311,7 +323,6 @@ public class AccountEventService(
CreatedAt = backdated ?? SystemClock.Instance.GetCurrentInstant(), CreatedAt = backdated ?? SystemClock.Instance.GetCurrentInstant(),
}; };
var now = SystemClock.Instance.GetCurrentInstant().InUtc().Date;
try try
{ {
if (result.RewardPoints.HasValue) if (result.RewardPoints.HasValue)