From dcbefeaaabeececaf86549e5884a10851f04d45f Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 3 Oct 2025 17:20:58 +0800 Subject: [PATCH] :necktie: Purchase gift requires minimal level --- .../Wallet/SubscriptionGiftController.cs | 20 +++++++------------ .../Wallet/SubscriptionService.cs | 4 ++-- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/DysonNetwork.Pass/Wallet/SubscriptionGiftController.cs b/DysonNetwork.Pass/Wallet/SubscriptionGiftController.cs index 87cc877..98f3df8 100644 --- a/DysonNetwork.Pass/Wallet/SubscriptionGiftController.cs +++ b/DysonNetwork.Pass/Wallet/SubscriptionGiftController.cs @@ -146,19 +146,6 @@ public class SubscriptionGiftController( { error = "You already have an active subscription of this type."; } - else if (subscriptionInfo.RequiredLevel > 0) - { - var profile = await db.AccountProfiles.FirstOrDefaultAsync(p => p.AccountId == currentUser.Id); - if (profile is null || profile.Level < subscriptionInfo.RequiredLevel) - { - error = - $"Account level must be at least {subscriptionInfo.RequiredLevel} to redeem this gift."; - } - else - { - canRedeem = true; - } - } else { canRedeem = true; @@ -197,6 +184,8 @@ public class SubscriptionGiftController( public int? SubscriptionDurationDays { get; set; } = 30; // Subscription lasts 30 days when redeemed } + const int MinimumAccountLevel = 60; + /// /// Purchases a gift subscription. /// @@ -206,6 +195,11 @@ public class SubscriptionGiftController( { if (HttpContext.Items["CurrentUser"] is not SnAccount currentUser) return Unauthorized(); + if (currentUser.Profile.Level < MinimumAccountLevel) + { + return StatusCode(403, "Account level must be at least 60 to purchase a gift."); + } + Duration? giftDuration = null; if (request.GiftDurationDays.HasValue) giftDuration = Duration.FromDays(request.GiftDurationDays.Value); diff --git a/DysonNetwork.Pass/Wallet/SubscriptionService.cs b/DysonNetwork.Pass/Wallet/SubscriptionService.cs index 2e6f069..92cc999 100644 --- a/DysonNetwork.Pass/Wallet/SubscriptionService.cs +++ b/DysonNetwork.Pass/Wallet/SubscriptionService.cs @@ -710,7 +710,7 @@ public class SubscriptionService( // We do not check account level requirement, since it is a gift // Create the subscription from the gift - var cycleDuration = Duration.FromDays(30); // Standard 30-day subscription + var cycleDuration = Duration.FromDays(28); // Standard 28-day subscription var subscription = new SnWalletSubscription { BegunAt = now, @@ -719,7 +719,7 @@ public class SubscriptionService( IsActive = true, IsFreeTrial = false, Status = Shared.Models.SubscriptionStatus.Active, - PaymentMethod = $"gift:{gift.Id}", // Special payment method indicating gift redemption + PaymentMethod = "gift", // Special payment method indicating gift redemption PaymentDetails = new Shared.Models.SnPaymentDetails { Currency = "gift",