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
@@ -11,14 +11,14 @@ class ServicePlanController extends Controller
{
public function index(): JsonResponse
{
$plans = ServicePlan::with('plesk')->orderBy('title')->get();
$plans = ServicePlan::with('plesk', 'dnsServer')->orderBy('title')->get();
return response()->json(['error' => false, 'data' => $plans]);
}
public function show(int $id): JsonResponse
{
$plan = ServicePlan::with('plesk')->find($id);
$plan = ServicePlan::with('plesk', 'dnsServer')->find($id);
if (!$plan) {
return response()->json(['error' => true, 'message' => 'Không tìm thấy gói hosting.'], 404);
@@ -30,21 +30,23 @@ class ServicePlanController extends Controller
public function store(Request $request): JsonResponse
{
$validated = $request->validate([
'title' => 'required|string|max:255',
'vcpu' => 'required|integer|min:0',
'ram' => 'required|integer|min:0',
'disk' => 'required|integer|min:0',
'domain' => 'required|integer|min:0',
'plesk_plan_name' => 'nullable|string|max:255',
'note' => 'nullable|string',
'title' => 'required|string|max:255',
'vcpu' => 'required|integer|min:0',
'ram' => 'required|integer|min:0',
'disk' => 'required|integer|min:0',
'domain' => 'required|integer|min:0',
'dns_manager_server_id' => 'nullable|integer|exists:dns_manager_servers,id',
'plesk_plan_name' => 'nullable|string|max:255',
'note' => 'nullable|string',
]);
$plan = ServicePlan::create([
'title' => $validated['title'],
'vcpu' => $validated['vcpu'],
'ram' => $validated['ram'],
'disk' => $validated['disk'],
'domain' => $validated['domain'],
'title' => $validated['title'],
'vcpu' => $validated['vcpu'],
'ram' => $validated['ram'],
'disk' => $validated['disk'],
'domain' => $validated['domain'],
'dns_manager_server_id' => $validated['dns_manager_server_id'] ?? null,
]);
$this->savePlesk($plan, $validated);
@@ -52,7 +54,7 @@ class ServicePlanController extends Controller
return response()->json([
'error' => false,
'message' => 'Tạo gói hosting thành công.',
'data' => $plan->load('plesk'),
'data' => $plan->load('plesk', 'dnsServer'),
], 201);
}
@@ -65,21 +67,23 @@ class ServicePlanController extends Controller
}
$validated = $request->validate([
'title' => 'required|string|max:255',
'vcpu' => 'required|integer|min:0',
'ram' => 'required|integer|min:0',
'disk' => 'required|integer|min:0',
'domain' => 'required|integer|min:0',
'plesk_plan_name' => 'nullable|string|max:255',
'note' => 'nullable|string',
'title' => 'required|string|max:255',
'vcpu' => 'required|integer|min:0',
'ram' => 'required|integer|min:0',
'disk' => 'required|integer|min:0',
'domain' => 'required|integer|min:0',
'dns_manager_server_id' => 'nullable|integer|exists:dns_manager_servers,id',
'plesk_plan_name' => 'nullable|string|max:255',
'note' => 'nullable|string',
]);
$plan->update([
'title' => $validated['title'],
'vcpu' => $validated['vcpu'],
'ram' => $validated['ram'],
'disk' => $validated['disk'],
'domain' => $validated['domain'],
'title' => $validated['title'],
'vcpu' => $validated['vcpu'],
'ram' => $validated['ram'],
'disk' => $validated['disk'],
'domain' => $validated['domain'],
'dns_manager_server_id' => $validated['dns_manager_server_id'] ?? null,
]);
$this->savePlesk($plan, $validated);
@@ -87,7 +91,7 @@ class ServicePlanController extends Controller
return response()->json([
'error' => false,
'message' => 'Cập nhật gói hosting thành công.',
'data' => $plan->fresh('plesk'),
'data' => $plan->fresh(['plesk', 'dnsServer']),
]);
}