feat: nhắc gia hạn QR theo dịch vụ, failover server hosting, CCCD admin, log cấp phát dịch vụ

- Mail campaign: mẫu nhắc gia hạn thanh toán QR, chọn dịch vụ + chu kỳ từng dòng (renewal_services)
- Hosting: nhiều server Plesk cho một gói (service_plan_servers), chuyển server khi server chết
- Admin xem/sửa giấy tờ định danh khách, tuỳ chọn gia hạn cho khách, nhật ký cấp phát dịch vụ
- Đánh dấu mẫu email dịch vụ là non-marketing

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
baodev0
2026-10-30 18:36:41 +07:00
co-authored by Claude Sonnet 5.5
parent 047c23beff
commit 55a834a2f8
53 changed files with 1463 additions and 119 deletions
@@ -22,6 +22,7 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use App\Support\ServiceProvisionLog;
use App\Jobs\VirtualMachine\Provision\Concerns\ManagesIpReservation;
/**
@@ -228,6 +229,8 @@ class AssignIpToGuestJob implements ShouldQueue
'attempt' => $attempt,
]);
ServiceProvisionLog::forVm($this->moduleVmwareId, 'provision_step', 'Đã gán IP cho máy chủ', ['ip' => $ip]);
// CPU/RAM config was already applied by UpdateVmConfigJob before IP assignment.
ChangePasswordViaVsphereJob::dispatch(
$this->moduleVmwareId,
@@ -247,6 +250,7 @@ class AssignIpToGuestJob implements ShouldQueue
ModuleVmware::where('id', $this->moduleVmwareId)->update(['status' => 0]);
Service::where('vm_id', $this->moduleVmwareId)->update(['status' => 'failed']);
ServiceProvisionLog::forVm($this->moduleVmwareId, 'provision_failed', "Gán IP thất bại sau {$maxAttempts} lần thử", ['stage' => 'assign_ip']);
// Notify admin via Telegram with order/customer context
try {
@@ -311,6 +315,7 @@ class AssignIpToGuestJob implements ShouldQueue
ModuleVmware::where('id', $this->moduleVmwareId)->update(['status' => 0]);
Service::where('vm_id', $this->moduleVmwareId)->update(['status' => 'failed']);
ServiceProvisionLog::forVm($this->moduleVmwareId, 'provision_failed', 'Gán IP thất bại — ' . $e->getMessage(), ['stage' => 'assign_ip']);
}
// ─────────────────────────────────────────────────────────────────────────
@@ -16,6 +16,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use App\Support\ServiceProvisionLog;
/**
* ChangePasswordViaVsphereJob
@@ -91,6 +92,8 @@ class ChangePasswordViaVsphereJob implements ShouldQueue
// Provisioning complete — activate the service record
Service::where('vm_id', $this->moduleVmwareId)->update(['status' => 'active']);
ServiceProvisionLog::forVm($this->moduleVmwareId, 'provision_step', 'Đã đặt mật khẩu máy chủ');
// [8] Send credentials email — IP + new password are both ready at this point
SendVmCredentialsEmailJob::dispatch($this->moduleVmwareId);
@@ -112,6 +115,7 @@ class ChangePasswordViaVsphereJob implements ShouldQueue
ModuleVmware::where('id', $this->moduleVmwareId)->update(['status' => 0]);
Service::where('vm_id', $this->moduleVmwareId)->update(['status' => 'failed']);
ServiceProvisionLog::forVm($this->moduleVmwareId, 'provision_failed', 'Đặt mật khẩu máy chủ thất bại — ' . $e->getMessage(), ['stage' => 'set_password']);
}
// ─────────────────────────────────────────────────────────────────────────
@@ -18,6 +18,7 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use App\Support\ServiceProvisionLog;
/**
* RetryProvisioningOrchestrator
@@ -337,6 +338,8 @@ class RetryProvisioningOrchestrator implements ShouldQueue
$service->save();
ServiceProvisionLog::record($service, 'provision_completed', 'Khởi tạo lại hoàn tất — dịch vụ đã hoạt động', ['ip' => $moduleVmware->ip]);
if (!$moduleVmware->service_id) {
$moduleVmware->update(['service_id' => $service->id]);
}
@@ -19,6 +19,7 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use App\Support\ServiceProvisionLog;
/**
* SendVmCredentialsEmailJob
@@ -154,6 +155,8 @@ class SendVmCredentialsEmailJob implements ShouldQueue
'service_id' => $service->id,
]);
ServiceProvisionLog::record($service, 'provision_completed', 'Khởi tạo hoàn tất — dịch vụ đã hoạt động', ['ip' => $vm->ip]);
Log::info('SendVmCredentialsEmailJob: service activated', [
'module_vmware_id' => $vm->id,
'service_id' => $service->id,
@@ -22,6 +22,7 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use App\Support\TlsHttpClientFactory;
use Illuminate\Support\Facades\Log;
use App\Support\ServiceProvisionLog;
/**
* UpdateVmConfigJob
@@ -208,6 +209,10 @@ class UpdateVmConfigJob implements ShouldQueue
$moduleVmware->update(['cpu' => $totalCpu, 'ram_mb' => $totalRam * 1024]);
if (! $isManualOverride) {
ServiceProvisionLog::forVm($this->moduleVmwareId, 'provision_step', "Đã cấu hình CPU/RAM ({$totalCpu} vCPU, {$totalRam} GB)");
}
if ($isManualOverride) {
$this->syncServiceAddons($moduleVmware, $totalCpu, $totalRam, $logger);
return;
@@ -227,6 +232,7 @@ class UpdateVmConfigJob implements ShouldQueue
ModuleVmware::where('id', $this->moduleVmwareId)->update(['status' => 0]);
Service::where('vm_id', $this->moduleVmwareId)->update(['status' => 'failed']);
ServiceProvisionLog::forVm($this->moduleVmwareId, 'provision_failed', 'Cấu hình CPU/RAM thất bại — ' . $e->getMessage(), ['stage' => 'update_config']);
try {
$telegram = app(Telegram::class);