update layout control vm

This commit is contained in:
Pham Bao
2025-08-10 22:27:20 +07:00
parent 8758927c1d
commit 31e3262412
2 changed files with 32 additions and 1 deletions
@@ -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', [