Implement billing status notification and enhance user management integration
- Added `NotifyBillingStatusChangedAsync` method to `IRealtimeNotifier` for notifying clients about changes in billing status. - Updated `BillingConfigResumer` to call the new notification method after modifying billing configurations, ensuring users receive real-time updates. - Enhanced `ListUsersQueryHandler` to include a `BillingPendingReview` property in `UserSummaryDto`, indicating if a user has a pending payment request awaiting confirmation. - Refactored various command handlers to utilize `AdvisoryLock` for managing concurrent requests, preventing race conditions in billing operations. - Updated tests to cover new notification behaviors and ensure proper functionality in billing status management.
This commit is contained in:
@@ -60,6 +60,8 @@ public static class BillingConfigResumer
|
||||
|
||||
config.SetBillingExpiry(newPaidUntil);
|
||||
}
|
||||
|
||||
await notifier.NotifyBillingStatusChangedAsync(userId, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>Заявка на оплату ждёт решения админа (AwaitingConfirmation) — держим клиента рабочим
|
||||
@@ -71,6 +73,7 @@ public static class BillingConfigResumer
|
||||
public static async Task ProtectPendingConfigsAsync(
|
||||
IAppDbContext dbContext,
|
||||
IXuiPanelGateway gateway,
|
||||
IRealtimeNotifier notifier,
|
||||
ILogger logger,
|
||||
Guid userId,
|
||||
CancellationToken cancellationToken
|
||||
@@ -94,6 +97,8 @@ public static class BillingConfigResumer
|
||||
cancellationToken
|
||||
);
|
||||
}
|
||||
|
||||
await notifier.NotifyBillingStatusChangedAsync(userId, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>Приостановка за неуплату — общая для фоновой джобы (BillingService) и немедленной
|
||||
@@ -139,6 +144,8 @@ public static class BillingConfigResumer
|
||||
cancellationToken
|
||||
);
|
||||
}
|
||||
|
||||
await notifier.NotifyBillingStatusChangedAsync(userId, cancellationToken);
|
||||
}
|
||||
|
||||
private static Task<List<VpnConfig>> ActiveOrExpiredConfigsAsync(
|
||||
|
||||
Reference in New Issue
Block a user