public function getSales() { $from = Input::get('from'); $to = Input::get('to'); $all_orders = Order::where(function ($q) use($from, $to) { if ($from) { $q->where('created_at', '>=', Carbon::parse($from)); } if ($to) { $q->where('created_at', '<=', Carbon::parse($to)); } })->get(); $paid_orders = Order::where(function ($q) use($from, $to) { $q->where('state', '1'); if ($from) { $q->where('created_at', '>=', Carbon::parse($from)); } if ($to) { $q->where('created_at', '<=', Carbon::parse($to)); } })->get(); $total_summ_paid_orders = 0; foreach ($paid_orders as $order) { $total_summ_paid_orders += $order->sum; } $period = ['from' => $from, 'to' => $to, 'text' => $this->period_text($from, $to)]; return view('admin.stat.sales', ['paid_orders' => $paid_orders, 'orders' => $all_orders, 'total_summ_paid_orders' => number_format($total_summ_paid_orders, 2, ',', ' '), 'period' => $period]); }
/** * List all orders. * * @return \Illuminate\Http\Response */ public function index(Request $request) { // pagination $session_type = 'order'; if (!$request->session()->has('order_by')) { $request->session()->put($session_type . '.order_by', 'created_at'); } if (!$request->session()->has('order_dir')) { $request->session()->put($session_type . '.order_dir', 'desc'); } if ($request->order_by) { $request->session()->put($session_type . '.order_by', $request->order_by); } if ($request->order_dir) { $request->session()->put($session_type . '.order_dir', $request->order_dir); } $limit = $request->session()->get('limit'); $orders = Order::where('shop_id', '=', $request->session()->get('shop'))->where(function ($query) use($request) { if ($request->search) { return $query->where('id', 'LIKE', '%' . $request->search . '%'); } })->orderBy($request->session()->get($session_type . '.order_by'), $request->session()->get($session_type . '.order_dir'))->paginate($limit); $orders->search = $request->search; return view('admin/orders/index', ['orders' => $orders]); }
public function viewOld() { $error = \Session::get('error'); $messages = \Session::get('messages'); $orders = Order::where('status', '=', Constants::ORDER_VALIDATE)->get(); return view('manager.orderValidated', ['orders' => $orders, 'error' => $error, 'messages' => $messages]); }
public function notify(Request $request) { \Log::debug('payment_notify', ['request' => $request]); $input = XML::parse($request->getContent()); if ($input['return_code'] == 'SUCCESS') { $order = Order::where('wx_out_trade_no', $input['out_trade_no'])->firstOrFail(); $address_id = $order->address_id; # 当前订单收货地址id if ($order->isPaid()) { return 'FAIL'; } $order->update(['wx_transaction_id' => $input['transaction_id'], 'cash_payment' => floatval($input['total_fee']) / 100.0]); $order->paid(); /* 发送消息提醒 */ $default_address = Address::where(['id' => $address_id])->first(); $phone = $default_address->phone; $msg = '尊敬的顾客您好!您的订单已经收到,易康商城将尽快为您安排发货,如有任何问题可以拨打客服电话400-1199-802进行咨询,感谢您的惠顾!'; \MessageSender::sendMessage($phone, $msg); // if ($phone = env('ORDER_ADMIN_PHONE')) { // \Log::error($phone); // \MessageSender::sendMessage($phone, $order->toOrderMessageString()); // } $result = \Wechat::paymentNotify(); return $result; } return 'FAIL'; }
/** * Edit a customer. * * @param string $id * * @return Response */ public function edit($id) { $customer = User::find($id); $addresses = Address::where('customer_id', '=', $customer->id)->get(); $orders = Order::where('customer_id', '=', $customer->id)->get(); return view('admin/customers/edit', ['customer' => $customer, 'addresses' => $addresses, 'orders' => $orders]); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $user = Auth::user(); $firmName = $user->firm->organisation_name; $countOfOrders = Order::where('user_id', Auth::user()->id)->count(); $countOfDocuments = Document::where('user_id', Auth::user()->id)->count(); return view('cabinet.index', ['p' => 'cabinet', 'userId' => $user->id, 'firmName' => $firmName, 'countOfOrders' => $countOfOrders, 'countOfDocuments' => $countOfDocuments]); }
/** * Handle the event. * * @param Purchase $event * @return void */ public function handle(Purchase $event) { $customer = $event->customer; $order = $event->order; if (is_null(Order::where('customer_id', $customer->id)->where('order_status_id', '>=', 2)->where('id', '!=', $order->id)->first())) { dispatch(new FirstOrderFeedback($customer)); } }
public function getOrders($id = null) { if ($id) { //details return view('order.details', ['products' => OrderProduct::where('order_id', $id)->get(), 'order' => Order::find($id)]); } else { return view('order.index', ['orders' => Order::where('user_id', Auth::id())->get()]); } }
/** * Handle the event. * * @param Purchase $event * @return void */ public function handle(Purchase $event) { $customer = $event->customer; $upper = $customer->getReferrer(); $order = $event->order; if ($upper && is_null(Order::where('customer_id', $customer->id)->where('order_status_id', '>=', 2)->where('id', '!=', $order->id)->first())) { dispatch(new PatientFirstOrder($upper)); } }
public function success() { $payment = new Payment(config('robokassa.login'), config('robokassa.paymentPassword'), config('robokassa.validationPassword')); if ($payment->validateResult($_GET)) { $order = Order::where('id', $payment->getInvoiceId())->first(); if ($payment->getSum() == $order->sum) { echo 'Успех!'; } } }
public function getIndex() { $state = Input::get('state'); $orders = Order::where(function ($q) use($state) { if ($state) { $q->where('state', '=', $state); } })->paginate(15)->appends(Input::except('page')); return view('admin.orders.index', ['orders' => $orders]); }
public function pastOrders() { $this->isBoss(); $data = Order::where('order_state', 2)->join('users', 'id_user', '=', 'orders.user_id_user')->paginate(1); if ($data->isEmpty()) { return view('layouts.main', ['view' => 'user.noCurOrders', 'header' => 'boss.header', 'nav' => 'boss.nav']); } else { return view('layouts.main', ['view' => 'boss.pastOrders', 'header' => 'boss.header', 'nav' => 'boss.nav', 'orders' => $data]); } }
/** * Show the application dashboard. * * @return Response */ public function show(Request $request) { $stats['categories'] = Category::where('shop_id', '=', $request->session()->get('shop'))->count(); $stats['products'] = Product::where('shop_id', '=', $request->session()->get('shop'))->count(); $stats['customers'] = User::where('shop_id', '=', $request->session()->get('shop'))->count(); $stats['pages'] = Page::where('shop_id', '=', $request->session()->get('shop'))->count(); $stats['blogs'] = Blog::where('shop_id', '=', $request->session()->get('shop'))->count(); $stats['orders'] = Order::where('shop_id', '=', $request->session()->get('shop'))->count(); $stats['revenue'] = Order::where('shop_id', '=', $request->session()->get('shop'))->sum('total'); return view('admin/dashboard', ['stats' => $stats]); }
public function logout() { $connectedUser = Auth::user(); $order = Order::where('user_id', '=', $connectedUser->id)->where('status', '=', Constants::ORDER_IN_PROGRESS)->first(); if ($order) { $order->status = Constants::ORDER_WAITING; $order->user_id = Constants::DEFAULT_USER_ID; $order->save(); } Auth::logout(); return redirect()->route('auth::viewLogin'); }
/** * Display a listing of the resource. * * @return Response */ public function index(Region $region, TrainRoad $trainRoad, Stantion $stantion) { $regionsCount = $region->count(); $tRoadsCount = $trainRoad->count(); $stationsCount = $stantion->count(); $condCount = Condition::count(); $productsCount = Product::count(); $servicesCount = Service::count(); $catCount = Category::count(); $statusesCount = Status::count(); $serviceStatusesCount = ServiceStatus::count(); $newOrdersCount = Order::where('is_new', 1)->count(); $newServiceOrdersCount = ServiceOrder::where('is_new', 1)->count(); $customers = Firm::where('accountant_fio', null)->get(); return view('admin.adminArea', ['regionsCount' => $regionsCount, 'tRoadsCount' => $tRoadsCount, 'stationsCount' => $stationsCount, 'condCount' => $condCount, 'catCount' => $catCount, 'productsCount' => $productsCount, 'servicesCount' => $servicesCount, 'statusesCount' => $statusesCount, 'newOrdersCount' => $newOrdersCount, 'serviceStatusesCount' => $serviceStatusesCount, 'newServiceOrdersCount' => $newServiceOrdersCount, 'customers' => $customers]); }
/** * @SWG\Api( * path="/order/get/{id}", * @SWG\Operation( * nickname="Get order", * method="GET", * summary="Find order by ID", * notes="Returns order status", * type="Order", * authorizations={}, * @SWG\Parameter( * name="id", * description="ID of order", * required=true, * type="integer", * format="int64", * paramType="path", * allowMultiple=false * ), * @SWG\ResponseMessage(code=404, message="Order not found"), * @SWG\ResponseMessage(code=500, message="Internal server error") * ) * ) */ public function get($id) { $statusCode = 200; $response = []; try { $validator = Validator::make(['id' => $id], ['id' => 'required|numeric']); if ($validator->fails()) { $response = ['error' => $validator->errors()]; $statusCode = 500; } else { $orderModel = Models\Order::where('id', $id)->first(); if (!isset($orderModel)) { throw new ModelNotFoundException(); } $orderView = new ModelViews\Order($orderModel); $response = $orderView->get(); } } catch (ModelNotFoundException $e) { $response = ['error' => 'Order doesn\'t exists']; $statusCode = 404; } finally { return \Response::json($response, $statusCode); } }
public static function today() { return Order::where('date', '>', date('Y-m-d 00:00:00'))->where('date', '<', date('Y-m-d 23:59:59'))->first(); }
public function getDeliverinfo (Request $request) { $order_code = $request->input('order_code'); if (empty($order_code)) { return $this->failResponse('empty'); } $info = DeliverInfo::where('order_code', '=', $order_code)->first(); if (empty($info->id)) { return $this->failResponse('not_found'); } $order = Order::where('code', '=', $order_code)->first(); $result = [ 'deliver_code' => $info->code, 'company' => $info->company, 'plate_number' => $order->plate_number ]; return $this->successResponse('result', $result); }
private function wxJsPay($request) { $state = $request->input('state'); $decodeObject = json_decode($state); $user = Auth::user(); $order_code = $decodeObject->order_code; $order = Order::where('code', '=', $order_code)->first(); if (empty($order->id)) { //todo } else if ($order->status > 0) { return view('mobile/payed'); } $good = Good::where('id', '=', $order->gid)->first(); $orderPrice = OrderPrice::where('oid', '=', $order->id)->first(); $receiver = ReceiverInfo::find($order->rid); require_once "lib/WxPay.Api.php"; require_once "lib/WxPay.JsApiPay.php"; $notify_url = $this->debug ? "http://www.51linpai.com:8000/order/wxpay/" : "http://www.51linpai.com/order/wxpay/"; $tools = new \JsApiPay(); $openId = $tools->GetOpenid("", null); $input = new \WxPayUnifiedOrder(); $input->SetBody($good->name); $input->SetAttach($good->code); $input->SetOut_trade_no($order->code); $input->SetTotal_fee($orderPrice->final_price * 100); $input->SetTime_start(date("YmdHis")); $input->SetTime_expire(date("YmdHis", time() + 600)); $input->SetGoods_tag($good->code); $input->SetNotify_url($notify_url); $input->SetTrade_type("JSAPI"); $input->SetOpenid($openId); $jsWxOrder = \WxPayApi::unifiedOrder($input); $jsApiParameters = $tools->GetJsApiParameters($jsWxOrder); //获取共享收货地址js函数参数 $editAddress = $tools->GetEditAddressParameters(); $data = [ 'editAddress' => $editAddress, 'jsApiParameters' => $jsApiParameters, 'order_code' => $order->code, 'price' => $orderPrice->final_price, 'address' => $receiver->city . ' ' . $receiver->district . ' ' . $receiver->address, 'step' => 4, 'header' => '支付订单' ]; return view('mobile/wechat_js_pay', $data); }
public function order() { $user_id = \Auth::user()->id; $orders = Order::where('user_id', $user_id)->orderBy('id', 'desc')->paginate(5); return view('product.order', compact('orders')); }
/** * Display a listing of the resource. * * @return Response */ public function order($id) { $data['orders'] = Order::where($this->camp_id, $id)->get()->toArray(); return view('camps.order', $data); }
public function get_order_by_id($id) { return Order::where('order_id', '=', $id)->get()->toArray(); }
public function filter(FilterOrderRequest $request) { $query = $request->get('orderFilter'); $orders = Order::where('status_code_id', $query)->orderBy('created_at', 'asc')->paginate(self::PAGINATION_SIZE); return view('admin.orders.index', compact('orders')); }
/** * List all orders. * * @return Response */ public function index(Request $request) { $limit = $request->session()->get('limit'); $orders = Order::where('customer_id', Auth::user()->id)->paginate($limit); return view('themes/kudos/orders/index', ['orders' => $orders]); }
protected static function getOrderCount() { return \Cache::remember('enterprise_order_count', 60, function () { return \App\Models\Order::where('order_status_id', '>', '1')->count(); }); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id, $itemId) { $order = Order::where('id', '=', $id)->where('user_id', '=', Auth::user()->id)->first(); $order->items()->findOrFail($itemId)->delete(); $this->recalculateDelivery($order); return $this->orderToJson($order); }
public function my_orders() { $userDetails = User::find(Session::get('user')->id); $orders = Order::where('user_id', '=', Session::get('user')->id)->where('order_status', '!=', 0)->orderBy('id', 'desc')->paginate(10); return view('Frontend.pages.thank-you', compact('userDetails', 'orders')); }
private function composeAdminSidebar() { view()->composer('admin.sidebar', function ($view) { $view->with(['pendingOrderCount' => Order::where('status_code_id', 1)->count(), 'proccessingOrderCount' => Order::where('status_code_id', 2)->count()]); }); }
public function response($id) { $request = Order::where('id', $id)->with('responses')->first(); return view('administration.requests.response.index')->with(compact('request')); }
/** * @return \Illuminate\Database\Eloquent\Builder|static */ public static function getPaidOrdersWithRelated() { return Order::where('order_status_id', '>', 1)->with(['customer', 'commodities' => function ($query) { $query->withTrashed(); }, 'address' => function ($query) { $query->withTrashed(); }])->orderBy('created_at', 'desc'); }