feat: implement VMware vCenter integration, enhance product pricing display, and update order processing logic.
This commit is contained in:
+59
-3
@@ -22,6 +22,14 @@ Route::prefix('v1')->as('api.')->group(function () {
|
||||
Route::put('update', 'update')->name('update');
|
||||
});
|
||||
});
|
||||
|
||||
Route::middleware(['api.auth'])->controller(OrderController::class)->group(function () {
|
||||
Route::get('orders', 'getClientOrders')->name('orders.list');
|
||||
Route::get('orders/{id}', 'getClientOrderDetail')->name('orders.detail');
|
||||
Route::get('invoices', 'getClientInvoices')->name('invoices.list');
|
||||
Route::get('invoices/{id}', 'getClientInvoiceDetail')->name('invoices.detail');
|
||||
Route::get('dich-vu', 'getClientServices')->name('services.list');
|
||||
});
|
||||
});
|
||||
|
||||
// Services (Products) - Public & Protected Routes
|
||||
@@ -46,8 +54,8 @@ Route::prefix('v1')->as('api.')->group(function () {
|
||||
});
|
||||
});
|
||||
|
||||
// Product Categories - Protected Routes
|
||||
Route::middleware(['api.auth'])->prefix('group')->as('product-categories.')->group(function () {
|
||||
// Product Categories - Public Routes (no auth required)
|
||||
Route::prefix('group')->as('product-categories.')->group(function () {
|
||||
Route::controller(ProductCategoryController::class)->group(function () {
|
||||
Route::get('get-list', 'getCategories')->name('getList');
|
||||
Route::get('{product_categories:slug}', 'getDetailCategory')->name('detail');
|
||||
@@ -55,6 +63,11 @@ Route::prefix('v1')->as('api.')->group(function () {
|
||||
});
|
||||
});
|
||||
|
||||
// Addons - Get available addons for a product
|
||||
Route::prefix('products')->as('products.')->group(function () {
|
||||
Route::get('{productId}/addons', [ServiceController::class, 'getProductAddons'])->name('addons');
|
||||
});
|
||||
|
||||
|
||||
Route::middleware(['api.auth'])->prefix('transaction')->as('transaction.')->group(function () {
|
||||
Route::controller(TransactionController::class)->group(function () {
|
||||
@@ -69,8 +82,51 @@ Route::prefix('v1')->as('api.')->group(function () {
|
||||
|
||||
Route::get('v1/payment/vnpay/return', [TransactionController::class, 'returnCallback']);
|
||||
|
||||
Route::prefix('v1/system')->middleware(['api.auth'])->group(function () {
|
||||
Route::get('get-ticket-console', function (\Illuminate\Http\Request $request, \App\Http\Services\vCenter $serviceVCenter) {
|
||||
$product_id = $request->get('product');
|
||||
if (!$product_id) {
|
||||
return response()->json(['error' => true, 'message' => "Please choose product"]);
|
||||
}
|
||||
$product = \App\Models\ModuleVmware::with('vCenter')->find($product_id);
|
||||
if (!$product) {
|
||||
return response()->json(['error' => true, 'message' => "Can't find product"]);
|
||||
}
|
||||
|
||||
$vcenter = $product->vCenter;
|
||||
|
||||
if (!$vcenter) {
|
||||
return response()->json(['error' => true, 'message' => "Can't find vCenter information"]);
|
||||
}
|
||||
|
||||
if (!$serviceVCenter->loginServer($vcenter)) {
|
||||
return response()->json(['error' => true, 'message' => 'Không thể đăng nhập vào vCenter']);
|
||||
}
|
||||
|
||||
$ConsoleTicket = $serviceVCenter->GetConsoleTickets($product->vmware_id);
|
||||
|
||||
if ($ConsoleTicket === 'Login_Again') {
|
||||
if ($serviceVCenter->loginServer($vcenter)) {
|
||||
$ConsoleTicket = $serviceVCenter->GetConsoleTickets($product->vmware_id);
|
||||
} else {
|
||||
return response()->json(['error' => true, 'message' => 'Không thể đăng nhập lại vào vCenter']);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_string($ConsoleTicket)) {
|
||||
return response()->json(['error' => true, 'message' => "Failed to get console ticket: $ConsoleTicket"]);
|
||||
}
|
||||
|
||||
if ($ConsoleTicket['error']) {
|
||||
return response()->json(['error' => true, 'message' => $ConsoleTicket['data']]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'data' => $ConsoleTicket['data'], // wss://10.10.10.120:443/ticket/...
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Route::any('{any}', function () {
|
||||
@@ -78,4 +134,4 @@ Route::any('{any}', function () {
|
||||
'error' => true,
|
||||
'message' => 'API Route not found'
|
||||
], 404);
|
||||
})->where('any', '.*');
|
||||
})->where('any', '.*');
|
||||
|
||||
Reference in New Issue
Block a user