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
@@ -2,11 +2,31 @@
namespace App\Http\Resources\Api\Client\Service;
use App\Models\ModuleHostingPleskClient;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\Crypt;
class ServiceClientDetailResource extends JsonResource
{
/** Plesk panel login (persisted, reusable) — separate from the one-time FTP password, which is never stored. */
private function resolvePleskCredentials($hosting): ?array
{
$client = ModuleHostingPleskClient::query()
->where('customer_id', $hosting->customer_id)
->where('dns_manager_server_id', $hosting->dns_manager_server_id)
->first();
if (!$client) {
return null;
}
return [
'login' => $client->login,
'password' => Crypt::decryptString($client->password),
];
}
/**
* Transform the resource into an array.
*
@@ -50,6 +70,8 @@ class ServiceClientDetailResource extends JsonResource
$order = $orderItem?->order;
$vm = $this->resource->vmware;
$product = $orderItem?->product;
$hosting = $this->resource->hostingAccount;
$pleskCredentials = $hosting ? $this->resolvePleskCredentials($hosting) : null;
return [
'id' => $this->id,
@@ -81,6 +103,17 @@ class ServiceClientDetailResource extends JsonResource
'ip' => $vm->ip ?? null,
'dns' => $vm->dns ?? null,
] : null,
'hosting' => $hosting ? [
'ip_address' => $hosting->server?->ip_address,
'plesk_url' => $hosting->server?->ip_address
? "http://{$hosting->server->ip_address}:{$hosting->server->panel_port}/"
: null,
'hosting_plan' => $hosting->hosting_plan,
'ftp_username' => $hosting->ftp_username,
'username' => $pleskCredentials['login'] ?? null,
'password' => $pleskCredentials['password'] ?? null,
'status' => $hosting->status,
] : null,
];
}
}