public function getExpressById($id) { return Express::where('id', $id)->first(); }
/** * 订单详情 * @author Hanxiang * @param $number 订单号 * @return view */ public function detail($number) { $order = Order::where('order_number', $number)->first(); if (count($order) == 0) { abort(404); } // Buyer Info $buyer = Buyer::find($order->buyer_id); if (count($buyer) == 0) { $buyer = new \stdClass(); //TODO $wxUser = new \stdClass(); //TODO } else { $wxUser = $buyer->wxUser; } $total = 0; $quantity = 0; $orderItems = OrderItem::where('order_id', $order->id)->get(); foreach ($orderItems as $oi) { $total += $oi->item_total; $quantity += $oi->quantity; $supplier = Item::find($oi->item_id)->supplier; $oi->supplier = $supplier; } $order->totalPrice = $total; $order->totalQuantity = $quantity; $expresses = Express::where('status', 1)->orderBy('sort')->get(); $express = Express::find($order->express_id); if (count($express) == 0) { $express = new \stdClass(); $express->name = ''; } $order->expressObj = $express; $commission = $order->commission; if (!$commission) { $commission = new \stdClass(); $commission->amount = 0; $order->commission = $commission; } return view('admin.orders.detail')->with('order', $order)->with('buyer', $buyer)->with('wxUser', $wxUser)->with('orderItems', $orderItems)->with('expresses', $expresses); }