🐛 Fix birthday check in
This commit is contained in:
@@ -300,18 +300,29 @@ 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,
|
||||||
BackdatedFrom = backdated.HasValue ? SystemClock.Instance.GetCurrentInstant() : null,
|
BackdatedFrom = backdated.HasValue ? SystemClock.Instance.GetCurrentInstant() : null,
|
||||||
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)
|
||||||
@@ -398,4 +409,4 @@ public class AccountEventService(
|
|||||||
};
|
};
|
||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user