Fix retention bonus and allow it to be claimed after midnight

This commit is contained in:
Yury
2025-05-02 09:15:45 +03:00
parent 21a243dfed
commit 2e9e86d5da
@@ -43,9 +43,9 @@ public class UpdateRetentionBonus : ICloudScriptFunction<FYRetentionBonusRequest
}; };
} }
var now = (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds(); var currentMidnight = (int)new DateTimeOffset(DateTime.UtcNow.Date, TimeSpan.Zero).ToUnixTimeSeconds();
var nextClaimTime = retentionBonus.LastClaimTime.Seconds + 60 * 60 * 24 * 2; var nextClaimTime = retentionBonus.LastClaimTime.Seconds + 60 * 60 * 24;
if (now < nextClaimTime) { if (currentMidnight < nextClaimTime) {
return new FYRetentionBonusResult return new FYRetentionBonusResult
{ {
UserId = userId, UserId = userId,
@@ -58,7 +58,7 @@ public class UpdateRetentionBonus : ICloudScriptFunction<FYRetentionBonusRequest
var bonusData = JsonSerializer.Deserialize<Dictionary<string, TitleDataRetentionBonusInfo>>(titleData["RetentionBonusData"]); var bonusData = JsonSerializer.Deserialize<Dictionary<string, TitleDataRetentionBonusInfo>>(titleData["RetentionBonusData"]);
retentionBonus.DaysClaimed++; retentionBonus.DaysClaimed++;
retentionBonus.LastClaimTime.Seconds = now; retentionBonus.LastClaimTime.Seconds = currentMidnight;
retentionBonus.ClaimedAll = retentionBonus.DaysClaimed >= 14; retentionBonus.ClaimedAll = retentionBonus.DaysClaimed >= 14;
// TODO: Currently only CB2 bonuses are considered // TODO: Currently only CB2 bonuses are considered