feat: add bulk delete with validation to IP Pool and update provisioning logic and email notifications

This commit is contained in:
pbao9
2026-05-13 15:41:56 +07:00
parent 1bbba4e158
commit ae3b681aaa
8 changed files with 242 additions and 101 deletions
@@ -64,19 +64,23 @@ class SendVmCredentialsEmailJob implements ShouldQueue
$orderItem = $vm->order?->orderItems?->first();
$months = (int) ($orderItem?->months ?? 0);
$osGroupName = $vm->os?->osGroup?->name ?? '';
$isWindows = str_contains(strtolower($osGroupName), 'windows');
$osUsername = $isWindows ? 'Administrator' : 'root';
$emailData = [
'company_name' => $settingValue->company ?? 'Thế Giới Số',
'company_logo' => $settingValue->logo ?? '',
'client_name' => trim($customer->firstname . ' ' . $customer->lastname),
'client_name' => $customer->fullname ?? '',
'product_name' => $orderItem?->getProductAttribute()?->name ?? 'Cloud VPS',
'product_billing' => $this->billingLabel($months),
'product_price' => $orderItem ? number_format((float) $orderItem->price, 0, ',', '.') : 'N/A',
'service_host' => $vm->ip ?? 'N/A',
'service_username' => $vm->user,
'service_username' => $osUsername,
'service_port' => $vm->port,
'service_password' => $vm->plain_password ?? '(xem tài khoản quản lý)',
'os_name' => $vm->os
? (($vm->os->osGroup?->name ?? '') . ' ' . $vm->os->version)
? (($osGroupName . ' ' . $vm->os->version))
: 'Unknown OS',
'service_due_exp' => $vm->next_due_date
? date('d/m/Y', (int) $vm->next_due_date)
@@ -117,7 +121,7 @@ class SendVmCredentialsEmailJob implements ShouldQueue
// Notify admin with VM credentials after successful provisioning
$order = $vm->order;
AdminOrderNotificationJob::dispatch([
'customer_name' => trim($customer->firstname . ' ' . $customer->lastname),
'customer_name' => $customer->fullname ?? '',
'customer_email' => $customer->email,
'client_ip' => null,
'order_num' => $order?->order_num ?? $order?->id ?? 'N/A',
@@ -127,7 +131,7 @@ class SendVmCredentialsEmailJob implements ShouldQueue
'total' => $orderItem?->price ?? 0,
'created_at' => $order?->created_at?->format('d/m/Y H:i:s') ?? now()->format('d/m/Y H:i:s'),
'ip' => $vm->ip ?? '',
'username' => $vm->user ?? '',
'username' => $osUsername,
'password' => $vm->plain_password ?? '',
]);