Refactor order payment process and enhance invoice details
- Updated `payOrder` method in `OrderControllerRefactor` to accept `orderNum` instead of `id` for better clarity and functionality. - Implemented `findByOrderNum` method in `OrderRepository` to retrieve orders based on order number and customer ID. - Enhanced `InvoiceDetailResource` to include VMware details and removed unnecessary fields. - Added `service_plan_id` to `ProductResource` and updated the `Product` model to establish a relationship with `ServicePlan`. - Created `ServicePlan` and `ServicePlanPlesk` models along with their respective controllers and migrations for managing hosting service plans. - Updated API routes to include endpoints for managing service plans. - Modified email templates to standardize support phone number across various customer communications.
This commit is contained in:
@@ -105,18 +105,14 @@ class OrderControllerRefactor extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function payOrder(int $id, PayOrderRequest $request): JsonResponse
|
||||
public function payOrder(string $orderNum, PayOrderRequest $request): JsonResponse
|
||||
{
|
||||
$order = $this->orderRepository->find($id);
|
||||
$order = $this->orderRepository->findByOrderNum($orderNum, (int) $request->user()->id);
|
||||
|
||||
if (! $order) {
|
||||
return response()->json(['success' => false, 'message' => 'Đơn hàng không tồn tại.'], 404);
|
||||
}
|
||||
|
||||
if ($order->customer_id !== $request->user()->id) {
|
||||
return response()->json(['success' => false, 'message' => 'Không có quyền truy cập.'], 403);
|
||||
}
|
||||
|
||||
$this->orderService->pay($order, $request->payment_method);
|
||||
|
||||
$this->activityLogger->log(
|
||||
@@ -180,6 +176,8 @@ class OrderControllerRefactor extends Controller
|
||||
return response()->json(['success' => false, 'message' => 'Hóa đơn không tồn tại.'], 404);
|
||||
}
|
||||
|
||||
$order->load('vmWare.os.osGroup', 'vmWare.virtualMachine', 'vmWare.service');
|
||||
|
||||
return response()->json(['success' => true, 'data' => new InvoiceDetailResource($order->invoice->setRelation('order', $order))]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user