feat: Enhance service management and transaction handling

- Implemented client access token verification middleware to secure API endpoints.
- Updated ServiceController to fetch active hosting services for authenticated users.
- Refactored OrderController to ensure order retrieval is customer-specific.
- Improved error logging in VmController for unexpected vCenter responses.
- Disabled VNPay auto-deposit in TransactionController, switching to manual deposit flow.
- Enhanced ServiceClientDetailResource to include Plesk credentials for hosting accounts.
- Adjusted VpsServiceResource to dynamically set page type based on product type.
- Added logging for PowerShellService to capture errors in RDP port changes.
- Provisioning job now resolves service plans and logs relevant information for hosting accounts.
- Updated database migrations to add necessary fields for service plans and DNS servers.
- Refactored Service and ServicePlan models to establish relationships with hosting accounts and DNS servers.
This commit is contained in:
baodev0
2026-08-17 11:55:48 +07:00
parent b03ee9fc2d
commit 2deb4ad74e
28 changed files with 489 additions and 229 deletions
@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace App\Jobs\Hosting;
use App\Enums\Server\ServerType;
use App\Models\DnsServer;
use App\Models\OrderItem;
use App\Models\ServicePlan;
use App\Services\Plesk\PleskHostingService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -49,14 +48,50 @@ class ProvisionHostingAccountJob implements ShouldQueue
return;
}
$server = DnsServer::query()
->where('status', 'activated')
->whereIn('type', [ServerType::HOSTING->value, ServerType::BOTH->value])
->first();
$servicePlanId = $this->item->product?->service_plan_id;
$servicePlan = $servicePlanId
? ServicePlan::with(['plesk', 'dnsServer'])->find($servicePlanId)
: null;
$hostingPlan = $servicePlan?->plesk?->plesk_plan_name;
$server = $servicePlan?->dnsServer;
Log::channel('Custom')->info('ProvisionHostingAccountJob resolved service plan', [
'order_item_id' => $this->item->id,
'product_id' => $this->item->product_id,
'product_name' => $this->item->product?->name,
'service_plan_id' => $servicePlanId,
'plesk_plan_name' => $hostingPlan,
'dns_manager_server_id' => $server?->id,
'dns_manager_server_ip' => $server?->ip_address,
]);
if (! $hostingPlan) {
Log::channel('Custom')->error('ProvisionHostingAccountJob failed: no service_plan_plesk mapping for this product', [
'order_item_id' => $this->item->id,
'product_id' => $this->item->product_id,
'service_plan_id' => $servicePlanId,
]);
return;
}
if (! $server) {
Log::channel('Custom')->error('ProvisionHostingAccountJob failed: no active hosting server available', [
'order_item_id' => $this->item->id,
Log::channel('Custom')->error('ProvisionHostingAccountJob failed: service plan has no dns_manager_server_id configured', [
'order_item_id' => $this->item->id,
'product_id' => $this->item->product_id,
'service_plan_id' => $servicePlanId,
]);
return;
}
if (! $server->servesHosting()) {
Log::channel('Custom')->error('ProvisionHostingAccountJob failed: configured server does not serve hosting', [
'order_item_id' => $this->item->id,
'service_plan_id' => $servicePlanId,
'dns_manager_server_id' => $server->id,
'server_type' => $server->type,
]);
return;
@@ -67,12 +102,13 @@ class ProvisionHostingAccountJob implements ShouldQueue
'service_id' => $service->id,
'dns_manager_server_id' => $server->id,
'domain_name' => $domainName,
'hosting_plan' => $this->item->product?->name ?? 'Default',
'hosting_plan' => $hostingPlan,
]);
if ($result['error']) {
Log::channel('Custom')->error('ProvisionHostingAccountJob failed', [
'order_item_id' => $this->item->id,
'hosting_plan' => $hostingPlan,
'message' => $result['message'] ?? 'Unknown error',
]);