update
This commit is contained in:
@@ -2,9 +2,12 @@
|
||||
|
||||
namespace App\Services\Api\Client;
|
||||
|
||||
use App\Http\Services\Telegram;
|
||||
use App\Mail\Admin\TrialRegistrationRequest as TrialRegistrationRequestMail;
|
||||
use App\Mail\Customer\VerifyAccount as VerifyAccountMail;
|
||||
use App\Mail\Customer\Welcome as WelcomeMail;
|
||||
use App\Models\RefreshToken;
|
||||
use App\Models\Setting;
|
||||
use App\Repositories\Api\Client\ClientRepositoryInterface;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -85,9 +88,50 @@ class ClientAuthService
|
||||
|
||||
$this->sendVerifyEmail($client, $code);
|
||||
|
||||
if (!empty($data['trial_config'])) {
|
||||
$this->notifyAdminTrialRegistration($client, $data['trial_config']);
|
||||
}
|
||||
|
||||
return ['client' => $client];
|
||||
}
|
||||
|
||||
/**
|
||||
* Báo admin (email + Telegram) khi khách hàng đăng ký dùng thử Cloud VPS.
|
||||
*/
|
||||
protected function notifyAdminTrialRegistration($client, array $trialConfig): void
|
||||
{
|
||||
try {
|
||||
$setting = Setting::where('key', 'setting')->first();
|
||||
$settingValue = $setting ? json_decode((string) $setting->value, true) : [];
|
||||
$adminEmail = $settingValue['admin_email'] ?? null;
|
||||
|
||||
if ($adminEmail) {
|
||||
Mail::to($adminEmail)->send(new TrialRegistrationRequestMail([
|
||||
'company_name' => $settingValue['company'] ?? config('app.name', 'Portal Admin'),
|
||||
'customer_name' => $client->fullname,
|
||||
'customer_email' => $client->email,
|
||||
'customer_phone' => $client->phone,
|
||||
'cpu' => $trialConfig['cpu'] ?? null,
|
||||
'ram' => $trialConfig['ram'] ?? null,
|
||||
'ssd' => $trialConfig['ssd'] ?? null,
|
||||
'os' => $trialConfig['os'] ?? null,
|
||||
'other' => $trialConfig['other'] ?? null,
|
||||
'created_at' => now()->format('d/m/Y H:i:s'),
|
||||
]));
|
||||
} else {
|
||||
Log::warning('Trial registration admin email not sent: admin_email not configured.', [
|
||||
'customer_id' => $client->id,
|
||||
]);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('Send trial registration admin email failed: ' . $e->getMessage(), [
|
||||
'customer_id' => $client->id,
|
||||
]);
|
||||
}
|
||||
|
||||
(new Telegram())->SendTrialRegistration($client, $trialConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* Xác thực OTP — kích hoạt tài khoản, trả về token.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user