/** * 订单统计 * @method statistics * @return [type] [description] */ public function statistics() { $nums = RobotOrder::select(DB::raw('COUNT(*) as counts'))->get()[0]; $pay_nums = RobotOrder::select(DB::raw('COUNT(*) as counts'))->where('status', 3)->get()[0]; return view('orderStatistics')->with(['nums' => $nums, 'pay_nums' => $pay_nums]); }
/** * 单个用户的“订单历史” * @method showOrderHistory * @return Response [description] */ public function showOrderHistory($id) { $start_time = Carbon::now('Asia/ShangHai')->startOfMonth(); $end_time = Carbon::now('Asia/ShangHai')->endOfDay(); $orders = RobotOrder::where('user_id', $id)->paginate(10); $consume_all = RobotOrder::select(DB::raw('SUM(price) as value'))->where('user_id', $id)->get(); $consume_month = RobotOrder::select(DB::raw('SUM(price) as value'))->where('user_id', $id)->whereBetween('pay_time', [$start_time, $end_time])->get(); return view('userorderhistory')->with(['orders' => $orders, 'user_id' => $id, 'consume_all' => $consume_all, 'consume_month' => $consume_month]); }