Update source into github
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Order;
|
||||
use App\Models\OrderItem;
|
||||
use App\Models\Invoice;
|
||||
use App\Jobs\VirtualMachine\Create\CreateVirtualMachineJob;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class TestFullVMProcess extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'test:full-vm-process {order_id}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Test full VM creation process and VM ID saving';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$orderId = $this->argument('order_id');
|
||||
|
||||
$this->info("Testing full VM process for Order #{$orderId}");
|
||||
|
||||
try {
|
||||
// Tìm order
|
||||
$order = Order::with(['orderItems.addons', 'customer'])->find($orderId);
|
||||
if (!$order) {
|
||||
$this->error("Order #{$orderId} not found!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
$this->info("Found order: {$order->order_num}");
|
||||
$this->info("Customer: {$order->customer->email}");
|
||||
$this->info("Order items count: " . $order->orderItems->count());
|
||||
|
||||
// Tìm invoice
|
||||
$invoice = Invoice::where('order_id', $orderId)->first();
|
||||
if (!$invoice) {
|
||||
$this->error("Invoice for Order #{$orderId} not found!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
$this->info("Found invoice: #{$invoice->id}");
|
||||
$this->info("Current VM ID: " . ($invoice->vm_id ?? 'NULL'));
|
||||
|
||||
// Test từng order item
|
||||
foreach ($order->orderItems as $item) {
|
||||
$this->info("\n--- Testing Order Item #{$item->id} ---");
|
||||
$this->info("Product Type: {$item->product_type}");
|
||||
$this->info("Server Name: {$item->server_name}");
|
||||
$this->info("Addons count: " . $item->addons->count());
|
||||
|
||||
if ($item->addons->count() > 0) {
|
||||
$this->info("Addons:");
|
||||
foreach ($item->addons as $addon) {
|
||||
$this->info(" - {$addon->addonItems->name}: {$addon->qty} {$addon->addonItems->prefix}");
|
||||
}
|
||||
}
|
||||
|
||||
// Dispatch job để test
|
||||
$this->info("Dispatching CreateVirtualMachineJob...");
|
||||
CreateVirtualMachineJob::dispatch($item);
|
||||
|
||||
$this->info("Job dispatched successfully!");
|
||||
}
|
||||
|
||||
$this->info("\n✅ Full VM process test completed!");
|
||||
$this->info("Check logs for detailed information about the process.");
|
||||
|
||||
return 0;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->error("Error: " . $e->getMessage());
|
||||
Log::error('TestFullVMProcess error: ' . $e->getMessage());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user