Files
portal-api/app/Services/Plesk/PleskServicePlanService.php
baodev0andClaude Opus 5.5 30898ea46f feat: email gửi tay/nhắc gia hạn, gói hosting, sửa dữ liệu sản phẩm
- Gửi email theo template cho 1 khách, tab lịch sử email, nhắc gia hạn dịch vụ hàng loạt
- Mail lưu from/bcc/sent_by; mẫu MARKETING và mẫu cũ trong TemplateSeeder
- Gói hosting: giới hạn, trạng thái, lấy plan Plesk qua CLI gateway
- Backfill payment_method và ngày đơn hàng còn thiếu
- Bổ sung field CPU/RAM/Disk/Băng thông cho loại sản phẩm vps và cloud

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 11:32:05 +07:00

40 lines
1.1 KiB
PHP

<?php
namespace App\Services\Plesk;
use App\Models\DnsServer;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Log;
class PleskServicePlanService
{
public function __construct(private PleskService $plesk)
{
}
/**
* @return list<string>|null
*/
public function names(DnsServer $server): ?array
{
try {
$response = $this->plesk->client($server, 15)
->post($this->plesk->url($server, 'cli', '/service_plan/call'), ['params' => ['--list']]);
} catch (ConnectionException $e) {
Log::error('Plesk service plan list failed', ['error' => $e->getMessage(), 'server_id' => $server->id]);
return null;
}
if (!$response->successful() || (int) $response->json('code', 1) !== 0) {
Log::error('Plesk service plan list failed', ['status' => $response->status(), 'server_id' => $server->id]);
return null;
}
$lines = preg_split('/\R/', (string) $response->json('stdout', ''));
return array_values(array_unique(array_filter(array_map('trim', $lines), 'strlen')));
}
}