Enhance user plan management and update related endpoints
- Added new configuration options for user plans in `.env.example`, including `Plans__MaxCustomConfigCount` and `Plans__MinCustomConfigCount`. - Introduced `MapPlanEndpoints` in `Program.cs` to handle plan-related API routes. - Implemented `SetUserPlan` endpoint in `RoleEndpoints` to allow admins to assign plans to users. - Removed deprecated role request approval endpoints from `AdminSupportEndpoints`. - Updated `ITelegramNotifier` and related classes to reflect changes in role request handling and payment notifications. - Refactored role management commands to remove `MaxConfigs` and focus on `MaxIpLimit` and billing settings. - Enhanced billing request handling to accommodate plan changes instead of role changes. - Updated various interfaces and command handlers to support new plan management features.
This commit is contained in:
+4
-4
@@ -33,7 +33,7 @@ public sealed class CreatePaymentRequestCommandHandler(
|
||||
if (!profile.BillingEnabled)
|
||||
return Result.Failure<PaymentRequestDto>(BillingErrors.NotEnabled);
|
||||
|
||||
if (profile.MaxConfigs == RoleQuota.Unlimited)
|
||||
if (profile.ConfigQuota == RoleQuota.Unlimited)
|
||||
return Result.Failure<PaymentRequestDto>(BillingErrors.UnlimitedRoleNotSupported);
|
||||
|
||||
var pricing = await dbContext.PricingSettings.AsNoTracking().FirstOrDefaultAsync(cancellationToken);
|
||||
@@ -54,16 +54,16 @@ public sealed class CreatePaymentRequestCommandHandler(
|
||||
.PricingDiscountTiers.AsNoTracking()
|
||||
.Where(t => t.PricingSettingsId == pricing.Id)
|
||||
.ToListAsync(cancellationToken);
|
||||
var discountPercent = PricingDiscount.ResolvePercent(discountTiers, profile.MaxConfigs);
|
||||
var discountPercent = PricingDiscount.ResolvePercent(discountTiers, profile.ConfigQuota);
|
||||
|
||||
var amount = PricingDiscount.Apply(rate * profile.MaxConfigs * command.Period.ToMonths(), discountPercent);
|
||||
var amount = PricingDiscount.Apply(rate * profile.ConfigQuota * command.Period.ToMonths(), discountPercent);
|
||||
|
||||
var claimed = await AdvisoryLock.RunAsync(
|
||||
dbContext,
|
||||
userId,
|
||||
async lockedCancellationToken =>
|
||||
{
|
||||
// RoleChangeTopUp не считается активной подписной заявкой — доплата за смену роли не
|
||||
// PlanChangeTopUp не считается активной подписной заявкой — доплата за смену тарифа не
|
||||
// должна мешать пользователю продлить/оформить обычную подписку.
|
||||
var hasActiveRequest = await dbContext.PaymentRequests.AnyAsync(
|
||||
r =>
|
||||
|
||||
Reference in New Issue
Block a user