get('times'); $os = $request->get('os'); $query = Orders::alias('o')->with('admin') ->leftJoin('admins a','a.id = o.admin_id') ->order('o.admin_id','desc') ->group('a.id,a.name,o.admin_id') ->fieldRaw(' count(o.id) as orders, SUM(o.total_price) as total_price, SUM(CASE WHEN (o.os = 1 AND o.order_status = 4) OR (o.os = 3 AND o.order_status = 2) OR (o.os = 2 AND o.order_status = 5) THEN 1 ELSE 0 END) as assets, SUM(CASE WHEN (o.os = 1 AND o.order_status = 4) OR (o.os = 3 AND o.order_status = 2) OR (o.os = 2 AND o.order_status = 5) THEN asset_price ELSE 0 END) as asset_price, SUM(CASE WHEN (o.os = 1 AND o.order_status = 5) OR (o.os = 3 AND o.order_status = 4) OR (o.os = 2 AND o.order_status = 1) THEN 1 ELSE 0 END) AS nopays, SUM(CASE WHEN (o.os = 1 AND o.order_status = 5) OR (o.os = 3 AND o.order_status = 4) OR (o.os = 2 AND o.order_status = 1) THEN actual_price ELSE 0 END) AS nopay_price, o.admin_id,a.name'); if($times) { $query->whereBetween('o.create_at',[strtotime($times[0])*1000,strtotime($times[1])*1000+999]); } if($os) { $query->where('o.os', $os); } $list = $query->select(); return $this->success($list, null, ['oss' => Orders::OSS]); } /** * 在线时长 */ public function online(Request $request) { $times = $request->get('times'); $admin = $request->get('admin'); $online = new Onlines(); $list = $online->online($admin, $times); return $this->success($list); } public function anchor(Request $request) { $times = $request->get('times'); $admin = $request->get('admin'); if(!empty($times) && is_array($times) && count($times) >= 2) { $start = date('Y-m-d 00:00:00',strtotime($times[0])); $end = date('Y-m-d 23:59:59',strtotime($times[1])); }else{ $start = date('Y-m-01 00:00:00'); $end = date('Y-m-d 23:59:59'); } if($admin) { $admins = Admins::where('is_anchor', 1)->where('username', $admin)->select(); }else{ $admins = Admins::where('is_anchor', 1)->select(); } foreach($admins as $admin) { $admin->works = Works::where('admin_id', $admin->id)->where('status',1)->whereBetween('start',[$start, $end])->order('start','asc')->select()->append(['total']); } return $this->success($admins->hidden(['password','remember_token'])); } public function sale(Request $request) { $query = Sales::with(['admin'])->order('date','desc')->order("id",'asc'); $admin = $request->get('admin'); if($admin) { $admin_id = Admins::where('username', $admin)->value('id'); $query->where('admin_id', $admin_id); } $times = $request->get('times'); if($times) { $start = date('Ymd', strtotime($times[0])); $end = date('Ymd', strtotime($times[1])); $query->whereBetween('date',[$start,$end]); } $list = $query->paginate($request->get('limit')); return $this->success($list); } }