Пример #1
0
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function show($id)
 {
     $user = User::find($id);
     $orders = Order::with('address')->where('user_id', $id)->orderBy('created_at', 'desc')->paginate(config('wyshop.page_size'));
     //        return $orders;
     $order_status = config('wyshop.order_status');
     return view('admin.order.index', ['orders' => $orders, 'order_status' => $order_status]);
 }
Пример #2
0
 public function callback(Request $request)
 {
     $order = Order::with('payment')->where('sn', '=', $request->get('sn'))->firstOrFail();
     $response = $order->payment->gateway->complete($order->createPurchaseOrder());
     if ($order->payment->gateway->isSuccessful($response)) {
         $order->pay($order->total_amount);
         return redirect($request->getSession()->pull('payment_callback_redirect'));
     } else {
         throw new \Exception($response->getMessage());
     }
 }
Пример #3
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $order = Order::with('address', 'express', 'user', 'order_goods.good')->find($id);
     foreach ($order->order_goods as $k => $v) {
         if (!$v->good) {
             unset($v->good);
             $goods = Good::onlyTrashed()->find($v->good_id);
             $order->order_goods["{$k}"]["good"] = $goods;
         }
     }
     $order_status = config('wyshop.order_status');
     return view('admin.order.edit', ['order' => $order, 'order_status' => $order_status]);
 }
Пример #4
0
 public function update(Request $request, $order_id, $id)
 {
     $order = Order::with('products')->findOrFail($order_id);
     if (!$order->canEdit()) {
         throw new \Exception('not_editable');
     }
     $quantity = $request->json()->get('quantity');
     $new_order_products = [];
     $updated_product = null;
     foreach ($order->products as $index => $product) {
         if ($product->id == $id) {
             $product->quantity = $quantity;
             $product->save();
             $updated_product = $product;
         }
         $new_order_products[] = $product;
     }
     if ($updated_product) {
         $order->calc($new_order_products);
         $order->save();
         return response()->updated($updated_product);
     }
     return response()->noContent();
 }
Пример #5
0
 /**
  * Get the last 8 finished orders
  *
  * @return array
  */
 public function getFinishedOrders()
 {
     $orders = Order::with('products')->whereNotNull('finished')->take(8)->get();
     return $this->prepareResponse($orders);
 }
Пример #6
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $order = \App\Models\Order::with('products')->active()->first();
     view()->share('order', $order);
     return $next($request);
 }
Пример #7
0
 public function changeStatus($statusId, $orderId, $is_service = 0)
 {
     $response = 0;
     try {
         DB::transaction(function () use($statusId, $orderId, &$response, $is_service) {
             $messageData = [];
             $email = '';
             if ($is_service) {
                 $order = ServiceOrder::with('user', 'service_status')->where('id', $orderId)->first();
                 $messageData['status_was'] = $order->service_status->status;
                 $order->service_status_id = $statusId;
                 $order->save();
                 $response = 1;
                 $email = $order->user->email;
                 $messageData['user'] = $order->user->name;
                 $messageData['type'] = 'прочие услуги';
                 $messageData['order_number'] = $order->id;
                 $messageData['status_now'] = ServiceStatus::find($statusId)->status;
             } else {
                 if ($statusId == Order::CANCELED) {
                     $order = Order::with('products_in_order.price', 'user', 'status')->where('id', $orderId)->first();
                     foreach ($order->products_in_order as $product) {
                         $product->price->amount += $product->product_amount;
                         $product->price->save();
                     }
                     //                    $response = Order::CANCELED;
                 } else {
                     $order = Order::with('user', 'status')->where('id', $orderId)->first();
                     //                    if($statusId == Order::COMPLETED) {
                     //                        $response = Order::COMPLETED;
                     //                    } else {
                     //                        $response = 1;
                     //                    }
                 }
                 $messageData['status_was'] = $order->status->status;
                 $order->status_id = $statusId;
                 $order->save();
                 $response = 1;
                 $email = $order->user->email;
                 $messageData['user'] = $order->user->name;
                 $messageData['type'] = 'запчасти грузовых вагонов';
                 $messageData['order_number'] = $order->id;
                 $messageData['status_now'] = Status::find($statusId)->status;
             }
             Mail::send('emails.statusDone', $messageData, function ($message) use($email) {
                 $message->to($email)->subject('Смена статуса заказа');
             });
         });
     } catch (Exception $e) {
         $response = 0;
     }
     //       dd($response);
     echo $response;
 }
Пример #8
0
 public function obligation()
 {
     $obligation = Order::with('order_goods.good')->where('user_id', $this->user->id)->where('status', 0)->get();
     //        $index = array();
     foreach ($obligation as $ob) {
         $sum = 0;
         foreach ($ob->order_goods as $k => $v) {
             $sum += $v->good->price * $v->number;
         }
         $obligation["{$k}"]["xj"] = $sum;
         //            array_push($index,$sum);将得出的小计金额压入数组
     }
     //        return $obligation;
     return view('wechat.obligation', ['obligation' => $obligation]);
 }
Пример #9
0
 public function edit($id)
 {
     $order = Order::with('address', 'express', 'user', 'order_goods.good')->find($id);
     //        return $order;
     return view('admin.order.edit', ['order' => $order]);
 }
Пример #10
0
 public static function getOrders()
 {
     $orders = Order::with('orderproduct.product')->get();
     //print_r($orders);die();
     return $orders;
 }
 public function edit($id)
 {
     $orders = Order::with('address')->where('user_id', $id)->paginate(config('wfhshop.page_size'));
     $order_status = config('wfhshop.order_status');
     return view('admin.order.index', ['orders' => $orders, 'order_status' => $order_status]);
 }
 public function getmycom($id)
 {
     $order = Order::with('order_goods.good', 'comments')->find($id);
     return view('wechat.comment_done', ['order_goods' => $order->order_goods, 'comments' => $order->comments]);
 }
Пример #13
0
 public function getProcessingOrdersForUser($userId)
 {
     return \App\Models\Order::with('products')->where('user_id', $userId)->where('status', 'processing')->get();
 }
 public function show($id)
 {
     $orders = Order::with('address')->where('status', $id)->orderBy('created_at', 'desc')->paginate(config('wfhshop.page_size'));
     $order_status = config('wfhshop.order_status');
     return view('admin.order.show', ['orders' => $orders, 'id' => $id, 'order_status' => $order_status]);
 }