From 31e3262412a109ca6df6618b4df0724d11fcc906 Mon Sep 17 00:00:00 2001 From: Pham Bao Date: Sun, 10 Aug 2025 22:27:20 +0700 Subject: [PATCH] update layout control vm --- .../frontend/ServiceController.php | 19 +++++++++++++++++++ .../service/partials/renewal-modal.blade.php | 14 +++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/frontend/ServiceController.php b/app/Http/Controllers/frontend/ServiceController.php index 74dbd49..fa359be 100644 --- a/app/Http/Controllers/frontend/ServiceController.php +++ b/app/Http/Controllers/frontend/ServiceController.php @@ -825,16 +825,35 @@ class ServiceController extends Controller $months = $request->plan === 'other' ? (int) ($request->months ?? 1) : (int) $request->plan; $productId = $this->sanitizeInput($request->product_id); + // Fetch product price based on invoice item link + $invoiceItem = InvoiceItem::whereHas('invoice', function ($q) use ($user) { + $q->where('customer_id', $user->id); + }) + ->where('product_type', 4) // VPS + ->whereHas('invoice', fn($q) => $q->where('status', '!=', 0)) + ->first(); + + $product = $invoiceItem?->getProductAttribute(); + $unitPrice = (int) ($product?->price_sale ?? $product?->price ?? 0); + $total = $unitPrice * max($months, 1); + Log::info('Khách yêu cầu gia hạn dịch vụ', [ 'user_id' => $user->id, 'product_vmware_id' => $productId, 'months' => $months, + 'unit_price' => $unitPrice, + 'total' => $total, ]); // TODO: implement actual renewal billing/workflow return response()->json([ 'error' => false, 'message' => __('Yêu cầu gia hạn đã được ghi nhận'), + 'data' => [ + 'unit_price' => $unitPrice, + 'months' => $months, + 'total' => $total, + ], ]); } catch (\Exception $e) { Log::error('Lỗi renew', [ diff --git a/resources/views/frontend/service/partials/renewal-modal.blade.php b/resources/views/frontend/service/partials/renewal-modal.blade.php index 4478de6..8f88854 100644 --- a/resources/views/frontend/service/partials/renewal-modal.blade.php +++ b/resources/views/frontend/service/partials/renewal-modal.blade.php @@ -1,7 +1,14 @@ @props(['invoice']) -
+
{{ __('Gia hạn dịch vụ') }} {{ __('Chọn thời hạn gia hạn hoặc nhập số tháng mong muốn.') }} @@ -30,6 +37,11 @@
+
+
{{ __('Đơn giá / tháng') }}
+
{{ __('Tổng tiền') }}
+
+
{{ __('Hủy') }}