From 06930b1830c2a8eb87d08cac4ae0a62dec350b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Sun, 24 May 2026 16:32:18 +0300 Subject: [PATCH] refactor(webhook): Phase 3 Task 3.5 - remove notifyLowBalance/notifyZeroBalance from NotificationService --- app/app/Services/NotificationService.php | 48 ------------------------ 1 file changed, 48 deletions(-) diff --git a/app/app/Services/NotificationService.php b/app/app/Services/NotificationService.php index 48dbea7a..867c0632 100644 --- a/app/app/Services/NotificationService.php +++ b/app/app/Services/NotificationService.php @@ -5,11 +5,9 @@ declare(strict_types=1); namespace App\Services; use App\Mail\InvoicePaidNotification; -use App\Mail\LowBalanceNotification; use App\Mail\NewLeadNotification; use App\Mail\ReminderDueNotification; use App\Mail\TopupSuccessNotification; -use App\Mail\ZeroBalanceNotification; use App\Mail\ZeroBalancePausedMail; use App\Models\Deal; use App\Models\InAppNotification; @@ -147,52 +145,6 @@ class NotificationService } } - /** - * Уведомление о низком балансе. Триггер: ProcessWebhookJob после - * lead_charge, если balance_leads <= threshold. - * - * Получатели: все активные user'ы тенанта с new_lead.email=true - * (на MVP: те же что и для new_lead — обычно владелец и менеджеры). - * По prefs `low_balance.email`. - */ - public function notifyLowBalance(Tenant $tenant, int $thresholdLeads): void - { - $title = "Низкий баланс — {$tenant->balance_leads} лидов осталось"; - $body = "Порог уведомления: {$thresholdLeads} лидов"; - - foreach ($this->recipientsForEvent($tenant, self::EVENT_LOW_BALANCE, self::CHANNEL_EMAIL) as $user) { - $this->sendEmail($user, self::EVENT_LOW_BALANCE, new LowBalanceNotification($user, $tenant, $thresholdLeads)); - } - foreach ($this->recipientsForEvent($tenant, self::EVENT_LOW_BALANCE, self::CHANNEL_INAPP) as $user) { - $this->notifyInApp($user, self::EVENT_LOW_BALANCE, $title, $body, [ - 'tenant_id' => $tenant->id, - 'balance_leads' => $tenant->balance_leads, - 'threshold_leads' => $thresholdLeads, - ]); - } - } - - /** - * Уведомление о нулевом балансе и отклонении лидов. - * Триггер: ProcessWebhookJob::logRejection(zero_balance) в первом - * RejectedDealsLog за последний час (anti-spam: не более 1 email/час - * на тенант, проверка в caller). - */ - public function notifyZeroBalance(Tenant $tenant): void - { - $title = 'Баланс закончился — лиды отклоняются'; - $body = 'Пополните баланс в разделе Биллинг'; - - foreach ($this->recipientsForEvent($tenant, self::EVENT_ZERO_BALANCE, self::CHANNEL_EMAIL) as $user) { - $this->sendEmail($user, self::EVENT_ZERO_BALANCE, new ZeroBalanceNotification($user, $tenant)); - } - foreach ($this->recipientsForEvent($tenant, self::EVENT_ZERO_BALANCE, self::CHANNEL_INAPP) as $user) { - $this->notifyInApp($user, self::EVENT_ZERO_BALANCE, $title, $body, [ - 'tenant_id' => $tenant->id, - ]); - } - } - /** * Уведомление об auto-pause проекта на нулевом балансе (Plan 4 Task 6). *