diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 85ec06d..ccffc4a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -58,9 +58,11 @@ jobs: exit 1 fi - composer install --optimize-autoloader --no-interaction --no-dev + composer install - php artisan migrate --force + composer dump-autoload + + php artisan migrate php artisan config:clear php artisan optimize diff --git a/app/Services/VirtualMachine/VmIpReservationService.php b/app/Services/VirtualMachine/VmIpReservationService.php index c44c6c4..1924a04 100644 --- a/app/Services/VirtualMachine/VmIpReservationService.php +++ b/app/Services/VirtualMachine/VmIpReservationService.php @@ -24,18 +24,18 @@ class VmIpReservationService public function reserve(int $networkId, int $hostId, string $dns): ?array { return DB::transaction(function () use ($networkId, $hostId, $dns) { - // ponytail: exclude only IPs with an actual VM assigned, not stale __pending__ reservations - $usedIps = ModuleIpAddress::where('module_network_id', $networkId) - ->where('vm_name', '!=', '__pending__') + // Exclude IPs that have any active reservation (real VM or pending). + // Also accept status='reserved' in ip_pools so stale reservations + // (ip_pool row stuck as 'reserved' with no matching module_ip_addresses row) + // are recoverable without manual DB cleanup. + $allUsedIps = ModuleIpAddress::where('module_network_id', $networkId) ->lockForUpdate() ->pluck('ip') ->toArray(); $ipPool = IpPool::where('module_network_id', $networkId) - ->where('status', 'free') - ->whereNotNull('gateway') - ->where('gateway', '!=', '') - ->whereNotIn('ip_address', $usedIps) + ->whereIn('status', ['free', 'reserved']) + ->whereNotIn('ip_address', $allUsedIps) ->lockForUpdate() ->inRandomOrder() ->first(); diff --git a/database/migrations/2026_07_13_000002_fix_ip_pools_gateway_and_remove_gateway_ip.php b/database/migrations/2026_07_13_000002_fix_ip_pools_gateway_and_remove_gateway_ip.php new file mode 100644 index 0000000..c67a6fc --- /dev/null +++ b/database/migrations/2026_07_13_000002_fix_ip_pools_gateway_and_remove_gateway_ip.php @@ -0,0 +1,29 @@ +where('module_network_id', 1) + ->where('ip_address', '103.90.224.1') + ->delete(); + + // Backfill gateway cho toàn bộ pool network_id=1 + DB::table('ip_pools') + ->where('module_network_id', 1) + ->whereNull('gateway') + ->update(['gateway' => '103.90.224.1']); + } + + public function down(): void + { + DB::table('ip_pools') + ->where('module_network_id', 1) + ->update(['gateway' => null]); + } +}; diff --git a/resources/views/emails/customer/vm-creation-failed.blade.php b/resources/views/emails/customer/vm-creation-failed.blade.php index 6d6239f..d1418c3 100644 --- a/resources/views/emails/customer/vm-creation-failed.blade.php +++ b/resources/views/emails/customer/vm-creation-failed.blade.php @@ -1,74 +1,184 @@ - - - - - - Thông báo lỗi khởi tạo máy chủ - - - -
-
-
-
⚠️
-

Lỗi khởi tạo máy chủ ảo

-

Đơn hàng #{{ $orderNum ?? 'N/A' }} - Cần xử lý

-
+@php + $appName = $appName ?? config('app.name', 'Thế Giới Số'); + $fullName = $customerName ?? 'Quý khách'; + $orderNum = $orderNum ?? 'N/A'; + $productName = $productName ?? 'N/A'; + $invoiceUrl = $invoiceUrl ?? rtrim((string) env('FRONTEND_URL', config('app.url')), '/') . '/hoa-don'; + $supportEmail = $supportEmail ?? 'support@tgs.com.vn'; + $supportPhone = $supportPhone ?? '1900. 6119'; +@endphp -
-

- Xin chào {{ $customerName ?? 'Quý khách' }},
- Rất tiếc, hệ thống gặp sự cố khi khởi tạo máy chủ ảo cho đơn hàng của bạn. Đội ngũ kỹ thuật của chúng tôi đã được thông báo và sẽ xử lý sớm nhất có thể. -

- - - - - -
Mã đơn hàng#{{ $orderNum ?? 'N/A' }}
Sản phẩm{{ $productName ?? 'N/A' }}
- - -
- {{ $errorMessage ?? 'Lỗi không xác định' }} -
- - - -
- Nếu cần hỗ trợ khẩn cấp, vui lòng liên hệ:
- 📧 Email: {{ $supportEmail ?? 'support@tgs.com.vn' }}
- 📞 Điện thoại: {{ $supportPhone ?? '' }} -
-
- - -
-
- - + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + +
+
⚠️
+

+ Thông báo về đơn hàng #{{ $orderNum }} +

+
+ Đội ngũ kỹ thuật đang xử lý yêu cầu của Quý khách +
+
+ + + + + + +
+
 
+
Xin chào {{ $fullName }},
+
 
+
+ Chúng tôi đã nhận được yêu cầu khởi tạo dịch vụ cho đơn hàng của Quý khách. Hiện tại hệ thống đang trong quá trình xử lý và đội ngũ kỹ thuật của {{ $appName }} đã được thông báo để hỗ trợ nhanh nhất có thể. +
+
 
+
Thông tin đơn hàng:
+
    + Mã đơn hàng: #{{ $orderNum }}
+
    + Sản phẩm: {{ $productName }}
+
 
+
+ Quý khách không cần thực hiện thêm bất kỳ thao tác nào. Chúng tôi sẽ liên hệ lại khi dịch vụ được kích hoạt thành công. +
+
 
+ +
 
+
+ Nếu cần hỗ trợ khẩn cấp, Quý khách vui lòng liên hệ qua email {{ $supportEmail }} hoặc tổng đài {{ $supportPhone }}. +
+
 
+
+ Email này được gửi tự động. Vui lòng không trả lời email này. +
+
 
+
+
+
+ + + + + + + + + + + + + + + + + + +
+ + + + + + +
 
+
 
+ + + + + + + + + + + + + + +
  + Premium HOSTING +   + Cloud SERVER +   + EMAIL DOANH NGHIỆP +   + Thiết Kế WEBSITE +  
+
 
+ + + + + + +
 
+
+
+ + + + + + + + + + + + +
 
+

+ CÔNG TY CỔ PHẦN GIẢI PHÁP CÔNG NGHỆ THẾ GIỚI SỐ
+ Địa chỉ: 128/38 Tân Hương, Phường Phú Thọ Hòa, Thành Phố Hồ Chí Minh
+ Tel: (028) 7309. 7379 - Tổng đài: {{ $supportPhone }}
+ Email: {{ $supportEmail }}
+ + www.TGS.com.vn & + www.thegioiso.CLOUD & + www.thegioiSERVER.com & + www.CloudEmail.vn + +

+

+ + + + 🥇Thế Giới Số🥇- Premium HOSTING • CLOUD • SERVER & WEBSITE | 15+ năm Phụng Sự 🚀 + + + +

+
 
+
+