diff --git a/application/api/controller/Search.php b/application/api/controller/Search.php index 20d1586..d233e5f 100644 --- a/application/api/controller/Search.php +++ b/application/api/controller/Search.php @@ -100,4 +100,59 @@ class Search extends BaseCom return V(1, '获取成功', $lists); } + + + //搜索 + public function search_list() + { + $search = input('search', ''); + + if(is_numeric($search)){ + $where = [ + 'user_code' => $search, + 'status' => 1 + ]; + $where1 = [ + 'room_number' => $search, + 'apply_status' => 2, + 'type_id' => ['<>',6], + 'room_status' => 1 + ]; + }else{ + $where = [ + 'nickname' => ['like', '%'.$search . '%'], + 'status' => 1 + ]; + $where1 = [ + 'room_name' => ['like', '%'.$search . '%'], + 'apply_status' => 2, + 'type_id' => ['<>',6], + 'room_status' => 1 + ]; + } + + $users = db::name('user')->field('id as user_id,nickname,avatar,user_code,sex')->where($where)->select(); + + if(isset($users)){ + foreach ($users as &$v){ + $v['room_id'] = 0; + //是否在房间 + $is_room = db::name('vs_room_visitor')->where(['user_id' => $v['user_id'], 'is_delete' => 1])->order('id desc')->value('room_id'); + if ($is_room) { + $v['room_id'] = $is_room; + } + $v['icon'][0] = model('UserData')->user_wealth_icon($v['user_id']);//财富图标 + $v['icon'][1] = model('UserData')->user_charm_icon($v['user_id']);//魅力图标 + } + } + + $rooms = db::name('vs_room')->field('id as room_id,room_name,room_cover,room_number,label_id,today_hot_value')->where($where1)->select(); + if(isset($rooms)){ + foreach ($rooms as $vv){ + $vv['label_icon'] = db::name('vs_room_label')->where('id', $vv['label_id'])->value('label_icon'); + $vv['hot_value'] = $vv['today_hot_value']; + } + } + return V(1, '获取成功', ['users' => $users, 'rooms' => $rooms]); + } } \ No newline at end of file