1], [['limit'], 'default', 'value' => 20], ]; } public function search() { if(!$this->validate()){ return $this->getModelError(); } $admin_user_ids = SysAdmin::find() ->where(['is_delete' => 0]) ->select('user_id')->column(); $mobile_hash = !empty($this->keywords) ? EncryptHelper::encryptMobilePhone($this->keywords) : null; $query = User::find()->alias('u') ->andWhere([ 'u.is_delete' => 0, ]) ->andWhere(['!=','u.id',1]) // ->andWhere([ // 'not in','u.type',[User::TYPE_STORE,User::TYPE_COACH] // ]) ->andFilterWhere([ 'OR', ['LIKE', 'u.nickname', $this->keywords], ['LIKE', 'u.username', $this->keywords], ['LIKE', 'u.real_name', $this->keywords], ['LIKE', 'u.mobile_phone', $mobile_hash], ]) ->andFilterWhere([ 'u.status' => $this->status, ]) // $cond = $this->is_admin == 0 ? "NOT IN" : "IN"; // $query = $query->andWhere([ // $cond, // 'u.id', // $admin_user_ids // ]) ->select('u.id,u.username,u.nickname,u.avatar_url,u.mobile_phone,u.mobile_prefix,u.email,u.real_name,u.gender,u.birthday,u.status,u.created_at,u.updated_at,u.is_view'); $count = $query->count(); $pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]); $list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['u.created_at' => SORT_DESC])->asArray()->all(); foreach ($list as $index => $item){ $item['gender_cn'] = User::getGender($item['gender']); $item['status_cn'] = User::getStatus($item['status']); $item['created_at_cn'] = date("Y-m-d",$item['created_at']); $item['updated_at_cn'] = date("Y-m-d",$item['updated_at']); $item['mobile_phone'] = empty($item['mobile_phone']) ? '' : EncryptHelper::decryptMobilePhone($item['mobile_phone']); if(empty($item['mobile_phone'])){ $item['mobile_phone'] = ' -- '; } //脱敏 // $item['mobile_phone'] = $item['mobile_phone'] == null ? '--' : Utils::stringDesensitization($item['mobile_phone'], 3,4); $item['real_name'] = $item['real_name'] == null ? '--' : $item['real_name']; $list[$index] = $item; } $data = []; $data['code'] = 0; $data['msg'] = 'ok'; $data['data'] = $list; $data['count'] = $count; return $data; } //查询除admin账号外的所有用户 public function search_user() { if(!$this->validate()){ return $this->getModelError(); } $mobile_hash = !empty($this->keywords) ? EncryptHelper::encryptMobilePhone($this->keywords) : null; $query = User::find()->alias('u') ->where(['!=','u.id',1]) ->andWhere([ 'u.is_delete' => 0 ]) ->andFilterWhere([ 'OR', ['LIKE', 'u.nickname', $this->keywords], ['LIKE', 'u.username', $this->keywords], ['LIKE', 'u.real_name', $this->keywords], ['LIKE', 'u.mobile_phone', $mobile_hash], ]) ->andFilterWhere([ 'u.status' => $this->status, ]) ->select('u.id,u.username,u.nickname,u.avatar_url,u.mobile_phone,u.mobile_prefix,u.email,u.real_name,u.gender,u.birthday,u.status,u.created_at,u.updated_at'); $count = $query->count(); $pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]); $list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['u.created_at' => SORT_DESC])->asArray()->all(); foreach ($list as $index => $item){ $item['gender_cn'] = User::getGender($item['gender']); $item['status_cn'] = User::getStatus($item['status']); $item['created_at_cn'] = date("Y-m-d",$item['created_at']); $item['updated_at_cn'] = date("Y-m-d",$item['updated_at']); $item['mobile_phone'] = empty($item['mobile_phone']) ? '' : EncryptHelper::decryptMobilePhone($item['mobile_phone']); if(empty($item['mobile_phone'])){ $item['mobile_phone'] = ' -- '; } //脱敏 // $item['mobile_phone'] = $item['mobile_phone'] == null ? '--' : Utils::stringDesensitization($item['mobile_phone'], 3,4); $item['real_name'] = $item['real_name'] == null ? '--' : $item['real_name']; $list[$index] = $item; } $data = []; $data['code'] = 0; $data['msg'] = 'ok'; $data['data'] = $list; $data['count'] = $count; return $data; } public function logout_review() { $mobile_hash = !empty($this->keywords) ? EncryptHelper::encryptMobilePhone($this->keywords) : null; $query = UserLogoutReview::find()->alias('ulr') ->select('ulr.*,u.nickname,u.real_name,u.avatar_url,u.mobile_prefix,u.mobile_phone,u.id as user_id') ->leftJoin(['u' => User::tableName()],'ulr.user_id=u.id') ->where([ 'ulr.is_delete' => 0, ]) ->andFilterWhere([ 'OR', ['LIKE', 'u.nickname', $this->keywords], ['LIKE', 'u.username', $this->keywords], ['LIKE', 'u.real_name', $this->keywords], ['LIKE', 'u.mobile_phone', $mobile_hash], ]) ->andFilterWhere([ 'ulr.status' => $this->status, ]); $count = $query->count(); $pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]); $list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['ulr.created_at' => SORT_DESC])->asArray()->all(); foreach ($list as $index => $item){ $item['status_cn'] = UserLogoutReview::getStatus($item['status']); $item['created_at_cn'] = date("Y/m/d H:i",$item['created_at']); $item['mobile_phone'] = empty($item['mobile_phone']) ? '' : EncryptHelper::decryptMobilePhone($item['mobile_phone']); if(empty($item['mobile_phone'])){ $item['mobile_phone'] = ' -- '; } $item['nickname'] = "[{$item['user_id']}]".$item['nickname']; //脱敏 if(!empty($item['real_name']) && $item['nickname'] != $item['real_name']){ $item['nickname'] .= '--'.$item['real_name']; } $list[$index] = $item; } $data = []; $data['code'] = 0; $data['msg'] = 'ok'; $data['data'] = $list; $data['count'] = $count; return $data; } }