|
@@ -394,200 +394,7 @@ class UserController extends ApiBaseController{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 按照时间线展现帖子列表
|
|
|
- * 当前日期的帖子没有显示完后,会追加当天剩余帖子数.并传递实际数据偏移量给前端
|
|
|
- */
|
|
|
- public function actionInfoByTimeline(){
|
|
|
- $user_id = Yii::app()->getRequest()->getParam("user_id");
|
|
|
- $uid = Yii::app()->getRequest()->getParam("to_user_id");
|
|
|
- $user_name = Yii::app()->getRequest()->getParam("user_name");
|
|
|
- if($user_name){
|
|
|
- $criteria = new EMongoCriteria();
|
|
|
- $criteria->user_name('==',$user_name);
|
|
|
- $res = RUser::model()->find($criteria);
|
|
|
- if(!$res){
|
|
|
- CommonFn::requestAjax(false,CommonFn::getMessage('user','user_not_exist'),array(),204);
|
|
|
- }else{
|
|
|
- $uid = $res->_id;
|
|
|
- }
|
|
|
- }
|
|
|
- $page = intval(Yii::app()->getRequest()->getParam("page",1));
|
|
|
- if(empty($page)){
|
|
|
- $page = 1;
|
|
|
- }
|
|
|
- $offset = Yii::app()->getRequest()->getParam('offset',0);
|
|
|
- if(empty($user_id) && empty($uid)){
|
|
|
- CommonFn::requestAjax(false,CommonFn::getMessage('user','id_not_empty'),201);
|
|
|
- }
|
|
|
- if($uid){
|
|
|
- if($user_id){
|
|
|
- $user_node = new UserNodeRecord($user_id);
|
|
|
- $relation = $user_node->relation($uid);
|
|
|
- }
|
|
|
- }
|
|
|
- if($user_id){
|
|
|
- $id = $user_id;
|
|
|
- }
|
|
|
- if($uid){
|
|
|
- $id = $uid;
|
|
|
- }
|
|
|
- $model = new RUser();
|
|
|
- $user_obj = CommonFn::apigetObJ($id,"ZUser",CommonFn::getMessage('user','id_not_exist'),201);
|
|
|
- $user_data = $model->parseRow($user_obj->attributes);
|
|
|
- $user_data['relation'] = isset($relation)?$relation:0;
|
|
|
- //获取用户帖子信息
|
|
|
- $topic_model = new ZTopic();
|
|
|
- $user_topics = array();
|
|
|
- $pagesize = 20;
|
|
|
- $page_offset = ($page - 1) * $pagesize;
|
|
|
- if(!$offset){
|
|
|
- $offset = $offset > 0 && $page_offset < $offset ? $offset : $page_offset;
|
|
|
- }
|
|
|
- $criteria = new EMongoCriteria();
|
|
|
- $criteria->user('==',$user_obj->_id);
|
|
|
- $criteria->status("==",1);
|
|
|
- $criteria->limit($pagesize)->sort('time',EMongoCriteria::SORT_DESC)->offset($offset);
|
|
|
- $model = new Topic();
|
|
|
- $cursor = $model->findAll($criteria);
|
|
|
- $rows = CommonFn::getRows($cursor);
|
|
|
- $rows = $model->parse($rows);
|
|
|
- //获取有追加数据
|
|
|
- if(count($rows)<1){
|
|
|
- $data = array(
|
|
|
- 'user' => $user_data,
|
|
|
- 'topic_list' => array(),
|
|
|
- 'offset' => $offset,
|
|
|
- );
|
|
|
- CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),$data,200,array('is_more'=>0));
|
|
|
- }
|
|
|
- $last_topic = $rows[count($rows)-1];
|
|
|
- $append_data = $topic_model->getAppendDateByDate($uid,$last_topic['last_post_time']);
|
|
|
- if($append_data){
|
|
|
- $rows = array_merge($rows,$append_data);
|
|
|
- }
|
|
|
- //按时间顺序排列
|
|
|
- foreach($rows as $row ){
|
|
|
- $user_topics[$row['date']]['time'] = $row['date'];
|
|
|
- $user_topics[$row['date']]['data'][] = $row;
|
|
|
- }
|
|
|
- $user_topics = array_values($user_topics);
|
|
|
-
|
|
|
- $current_offset = count($rows)+$offset; //当前实际数据偏移值
|
|
|
- if(count($rows)<20){
|
|
|
- $is_more = 0;
|
|
|
- }else{
|
|
|
- $is_more = 1;
|
|
|
- }
|
|
|
- //追加到用户数据中
|
|
|
- $data = array(
|
|
|
- 'user' => $user_data,
|
|
|
- 'topic_list' => $user_topics,
|
|
|
- 'offset' => $current_offset
|
|
|
- );
|
|
|
- CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),$data,200,array('is_more'=>$is_more));
|
|
|
- }
|
|
|
-
|
|
|
- //用户收藏信息接口
|
|
|
- public function actionFavList(){
|
|
|
- $user_id = Yii::app()->getRequest()->getParam("user_id");
|
|
|
- $page = intval(Yii::app()->getRequest()->getParam("page",1));
|
|
|
- if(empty($page)){
|
|
|
- $page = 1;
|
|
|
- }
|
|
|
- //获取用户收藏信息
|
|
|
- $user = CommonFn::apigetObJ($user_id,'ZUser',CommonFn::getMessage('user','id_not_exist'),201);
|
|
|
- $pagesize = Yii::app()->params['userFavsPageSize'];
|
|
|
- $conditions = array(
|
|
|
- 'user'=>array('==',$user->_id)
|
|
|
- );
|
|
|
- $order = array(
|
|
|
- 'time'=>'desc',
|
|
|
- );
|
|
|
- $model = new Fav();
|
|
|
- $pagedata = CommonFn::getPagedata($model,$page,$pagesize,$conditions,$order);
|
|
|
- $user_favs = $pagedata['res'];
|
|
|
- if(!empty($user_favs)){
|
|
|
- foreach ($user_favs as $key => $value) {
|
|
|
- if($value['fav_obj']['status']!=1){
|
|
|
- unset($user_favs[$key]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- $data = array();
|
|
|
- foreach($user_favs as $fav){
|
|
|
- $z_like = new ZLike();
|
|
|
- $like = $z_like->getLikeByLikeObj($user_id,$fav['fav_obj']['id']);
|
|
|
- if(empty($like)){
|
|
|
- $fav['fav_obj']['is_liked'] = false;
|
|
|
- }else{
|
|
|
- $fav['fav_obj']['is_liked'] = true;
|
|
|
- }
|
|
|
- $data[] = $fav['fav_obj'];
|
|
|
- }
|
|
|
- CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),$data,200,array('sum_count' => $pagedata['sum_count'],'sum_page'=>$pagedata['sum_page'],'page_size'=>$pagedata['page_size'],'current_page'=>$pagedata['current_page']));
|
|
|
- }
|
|
|
-
|
|
|
- //用户帖子列表页面
|
|
|
- public function actionTopicList(){
|
|
|
- $user_id = Yii::app()->getRequest()->getParam("user_id");
|
|
|
- $uid = Yii::app()->getRequest()->getParam("to_user_id");
|
|
|
- $page = intval(Yii::app()->getRequest()->getParam("page",1));
|
|
|
- if(empty($page)){
|
|
|
- $page = 1;
|
|
|
- }
|
|
|
- $offset = Yii::app()->getRequest()->getParam('offset',0);
|
|
|
-
|
|
|
- if(empty($user_id) && empty($uid)){
|
|
|
- CommonFn::requestAjax(false,CommonFn::getMessage('user','id_not_empty'),201);
|
|
|
- }
|
|
|
- if($user_id){
|
|
|
- $id = $user_id;
|
|
|
- $time_list_flag = true;
|
|
|
- }
|
|
|
- if($uid){
|
|
|
- $id = $uid;
|
|
|
- $time_list_flag = false;
|
|
|
- }
|
|
|
-
|
|
|
- //获取用户帖子列表
|
|
|
- $topic_model = new ZTopic();
|
|
|
- $user_topics = array();
|
|
|
- $rows = $topic_model->getUserTopic($id,$page,$offset);
|
|
|
- if(count($rows)<1){
|
|
|
- $data = array(
|
|
|
- 'topic_list' => array(),
|
|
|
- 'offset' => $offset,
|
|
|
- );
|
|
|
- CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),$data);
|
|
|
- }
|
|
|
-
|
|
|
- if($time_list_flag){
|
|
|
- //获取有追加数据
|
|
|
- $last_topic = $rows[count($rows)-1];
|
|
|
- $append_data = $topic_model->getAppendDateByDate($id,$last_topic['last_post_time']);
|
|
|
- if($append_data){
|
|
|
- $rows = array_merge($rows,$append_data);
|
|
|
- }
|
|
|
-
|
|
|
- //按时间顺序排列
|
|
|
- foreach($rows as $row ){
|
|
|
- $user_topics[$row['date']]['time'] = $row['date'];
|
|
|
- $user_topics[$row['date']]['data'][] = $row;
|
|
|
- }
|
|
|
- $user_topics = array_values($user_topics);
|
|
|
-
|
|
|
- }else{
|
|
|
- $user_topics = $rows;
|
|
|
- }
|
|
|
- $current_offset = count($rows); //当前实际数据偏移值
|
|
|
-
|
|
|
- $data = array(
|
|
|
- 'topic_list' => $user_topics,
|
|
|
- 'offset' => $current_offset,
|
|
|
- );
|
|
|
- CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),$data);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
//修改用户资料
|
|
|
public function actionEdit(){
|
|
@@ -664,347 +471,5 @@ class UserController extends ApiBaseController{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //用户爪币记录
|
|
|
- public function actionScoreLog(){
|
|
|
- $user_id = Yii::app()->getRequest()->getParam("user_id");
|
|
|
- $page = intval(Yii::app()->getRequest()->getParam("page",1));
|
|
|
- if(empty($page)){
|
|
|
- $page = 1;
|
|
|
- }
|
|
|
- if(empty($user_id) ){
|
|
|
- CommonFn::requestAjax(false,CommonFn::getMessage('user','id_not_exist'),201);
|
|
|
- }
|
|
|
- if($user_id){
|
|
|
- $id = $user_id;
|
|
|
- }
|
|
|
- $deviceid = Yii::app()->request->getParam('device_id');
|
|
|
- //设置首次访问时间,保证一次浏览的回复列表不变
|
|
|
- $actiontime = CommonFn::getFirstTime(ActionTimeRedis::TYPE_GET_SCORELOG,$deviceid,$page);
|
|
|
- $pagesize = Yii::app()->params['userScoreLogPageSize'];
|
|
|
- $conditions = array(
|
|
|
- 'user'=>array('==',$id),
|
|
|
- 'time'=>array('<=',$actiontime)
|
|
|
- );
|
|
|
- $order = array(
|
|
|
- 'time'=>'desc',
|
|
|
- );
|
|
|
- $model = new UserScoreLog();
|
|
|
- $pagedata = CommonFn::getPagedata($model,$page,$pagesize,$conditions,$order);
|
|
|
- $logs = $pagedata['res'];
|
|
|
- CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),$logs,200,array('sum_count' => $pagedata['sum_count'],'sum_page'=>$pagedata['sum_page'],'page_size'=>$pagedata['page_size'],'current_page'=>$pagedata['current_page']));
|
|
|
- }
|
|
|
-
|
|
|
- //用户拒绝接受推送
|
|
|
- public function actionSetPush(){
|
|
|
- $user_id = Yii::app()->getRequest()->getParam("user_id");
|
|
|
- $user = CommonFn::apigetObJ($user_id,"ZUser",CommonFn::getMessage('user','id_not_exist'),201);
|
|
|
- if($user->receive_push == 0){
|
|
|
- $user->receive_push = 1;
|
|
|
- if($user->update(array('receive_push'),true)){
|
|
|
- CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),array('op'=>'receive'));
|
|
|
- }
|
|
|
- }else{
|
|
|
- $user->receive_push = 0;
|
|
|
- if($user->update(array('receive_push'),true)){
|
|
|
- CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),array('op'=>'unreceive'));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //用户分享成功后增加爪币
|
|
|
- public function actionShareSuccess(){
|
|
|
- $user_id = Yii::app()->getRequest()->getParam("user_id");
|
|
|
- $user = CommonFn::apigetObJ($user_id,"ZUser",CommonFn::getMessage('user','id_not_exist'),201);
|
|
|
- $add_score = $this->addScore($user_id,'score_share');
|
|
|
- $result = array();
|
|
|
- if($add_score['status']){
|
|
|
- $add_score['score_change'] = $add_score['score'];
|
|
|
- $add_score['current_score'] = $add_score['current_score'];
|
|
|
- $add_score['score_type'] = '分享成功';
|
|
|
- CommonFn::requestAjax(true,'分享增加爪币成功',array(),301,$add_score);
|
|
|
- }else{
|
|
|
- CommonFn::requestAjax(false,'分享增加爪币失败');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //用户申请认证接口
|
|
|
- public function actionApplyCertify(){
|
|
|
- $data = array();
|
|
|
- $data['content'] = '您好,目前握爪仅开放认证宠物医生、营养师、训犬师、美容师,认证需要您相关的资格证书或学校就读证书照片及您与证书合影的照片,直接在私信里发给爪爪就好了。';
|
|
|
- $data['from_user'] = Yii::app()->params['kefu_user'];
|
|
|
- $data['to_user'] = Yii::app()->request->getParam('user_id','');
|
|
|
- $date = date('Ymd');
|
|
|
- $Key = HelperKey::generateUserActionKey('applycertify',$date,$data['to_user']);
|
|
|
- $status = UserActionRedis::get($Key);
|
|
|
- if($status){
|
|
|
- CommonFn::requestAjax(false,'你今天已提交过认证申请,请不要重复申请');
|
|
|
- }else{
|
|
|
- UserActionRedis::set($Key,true);
|
|
|
- }
|
|
|
- $data['voice'] = json_decode(Yii::app()->request->getParam('voice'),true);
|
|
|
- $data['video'] = json_decode(Yii::app()->request->getParam('video'),true);
|
|
|
- $data['pics'] = json_decode(Yii::app()->request->getParam('pics'),true);
|
|
|
- $z_message = new ZMessage();
|
|
|
- $result = $z_message->addMessage($data);
|
|
|
- if($result['status']){
|
|
|
- CommonFn::requestAjax(true,'已提交认证申请');
|
|
|
- }else{
|
|
|
- CommonFn::requestAjax(false,'提交申请失败,请重试');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //用户加与取消关注接口
|
|
|
- public function actionFollow(){
|
|
|
- $user_id = Yii::app()->getRequest()->getParam("user_id");
|
|
|
- $user = CommonFn::apigetObJ($user_id,"ZUser",CommonFn::getMessage('user','id_not_exist'),201);
|
|
|
- $f_id = Yii::app()->getRequest()->getParam("to_user_id");
|
|
|
- $f_id_list = json_decode(Yii::app()->getRequest()->getParam("to_user_list"),true);
|
|
|
- if(!$f_id_list && !CommonFn::isMongoId($f_id)){
|
|
|
- CommonFn::requestAjax(false,CommonFn::getMessage('message','params_illegal'));
|
|
|
- }
|
|
|
- $user_node = new UserNodeRecord($user->_id);
|
|
|
- //批量关注
|
|
|
- if(is_array($f_id_list) && !empty($f_id_list)){
|
|
|
- foreach ($f_id_list as $value) {
|
|
|
- $user_node->follow($value);
|
|
|
- }
|
|
|
- CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),array('op'=>'follow','follow_count'=>$user_node->follow_count(),'fans_count'=>$user_node->follower_count()));
|
|
|
- }
|
|
|
- if($user_node->is_following($f_id)){
|
|
|
- $user_node->unfollow($f_id);
|
|
|
- $op = 'unfollow';
|
|
|
- $message = '取消关注成功';
|
|
|
- }else{
|
|
|
- $user_node->follow($f_id);
|
|
|
- $message = '关注成功';
|
|
|
- $op = 'follow';
|
|
|
- }
|
|
|
- CommonFn::requestAjax(true,$message,array('op'=>$op,'follow_count'=>$user_node->follow_count(),'fans_count'=>$user_node->follower_count()));
|
|
|
- }
|
|
|
-
|
|
|
- //好友帖子列表
|
|
|
- public function actionFriendsTopicList(){
|
|
|
- $last_obj_id = Yii::app()->getRequest()->getParam("last_object_id",'');
|
|
|
- $user_id = Yii::app()->getRequest()->getParam("user_id");
|
|
|
- $user = CommonFn::apigetObJ($user_id,"ZUser",CommonFn::getMessage('user','id_not_exist'),201);
|
|
|
- if(CommonFn::isMongoId($last_obj_id)){
|
|
|
- $last_topic_obj = Topic::get(new MongoId($last_obj_id));
|
|
|
- if($last_topic_obj){
|
|
|
- $last_obj_time = $last_topic_obj->time;
|
|
|
- }
|
|
|
- }else{
|
|
|
- $last_obj_time = time();
|
|
|
- }
|
|
|
- if(!isset($last_obj_time)){
|
|
|
- CommonFn::requestAjax(false,CommonFn::getMessage('message','params_illegal'));
|
|
|
- }
|
|
|
- //设置小红点
|
|
|
- // $cache = new ARedisCache();
|
|
|
- // $cache->set('friend_topic_'.$user_id,0);
|
|
|
- $user_node = new UserNodeRecord($user_id);
|
|
|
- $follow_list = $user_node->following();
|
|
|
- $f_ids = array();
|
|
|
- foreach ($follow_list as $key => $value) {
|
|
|
- $f_ids[] = new MongoId($value);
|
|
|
- }
|
|
|
- $conditions = array(
|
|
|
- 'user'=>array('in',$f_ids),
|
|
|
- 'status'=>array('==',1),
|
|
|
- 'time'=>array('<',$last_obj_time)
|
|
|
- );
|
|
|
- $order = array(
|
|
|
- '_id'=>'desc',
|
|
|
- );
|
|
|
- $model = new Topic();
|
|
|
- $pagedata = CommonFn::getPagedataById($model,20,$conditions,$order);
|
|
|
- $topics = $pagedata['res'];
|
|
|
- foreach ($topics as $key=>$value) {
|
|
|
- if($user){
|
|
|
- //判断用户是否收藏过该帖子
|
|
|
- $z_fav = new ZFav();
|
|
|
- $fav = $z_fav->getFavByFavObj($user_id,$value['id']);
|
|
|
- if(empty($fav)){
|
|
|
- $value['is_faved'] = false;
|
|
|
- }else{
|
|
|
- $value['is_faved'] = true;
|
|
|
- }
|
|
|
-
|
|
|
- //判断用户是否喜欢过该帖子
|
|
|
- $z_like = new ZLike();
|
|
|
- $like = $z_like->getLikeByLikeObj($user_id,$value['id']);
|
|
|
- if(empty($like)){
|
|
|
- $value['is_liked'] = false;
|
|
|
- }else{
|
|
|
- $value['is_liked'] = true;
|
|
|
- }
|
|
|
- }else{
|
|
|
- $value['is_faved'] = false;
|
|
|
- $value['is_liked'] = false;
|
|
|
- }
|
|
|
- $topics[$key] = $value;
|
|
|
- }
|
|
|
- $data['topic_list'] = $topics;
|
|
|
- CommonFn::requestAjax(true,'',$data,200,array('has_more' => $pagedata['has_more'],'page_size'=>$pagedata['page_size']));
|
|
|
- }
|
|
|
-
|
|
|
- //我的关注接口
|
|
|
- public function actionFollowList(){
|
|
|
- $user_id = Yii::app()->getRequest()->getParam("user_id");
|
|
|
- $to_user = Yii::app()->getRequest()->getParam("to_user_id");
|
|
|
- $page = Yii::app()->getRequest()->getParam("page");
|
|
|
- $page_size = Yii::app()->getRequest()->getParam("page_size",20);
|
|
|
- if($to_user){
|
|
|
- $uid = $to_user;
|
|
|
- $user_node = new UserNodeRecord($to_user);
|
|
|
- $current_user_node = new UserNodeRecord($user_id);
|
|
|
- $need_refresh = true;
|
|
|
- }else{
|
|
|
- $uid = $user_id;
|
|
|
- $user_node = new UserNodeRecord($user_id);
|
|
|
- }
|
|
|
- $follow_list = $user_node->following();
|
|
|
- $sum = count($follow_list);
|
|
|
- $follow_list = array_slice($follow_list,$page_size*($page-1),$page_size*$page);
|
|
|
- $user_model = new RUser();
|
|
|
- foreach ($follow_list as $key => $f_user) {
|
|
|
- $follow_list[$key] = $user_model->parseRow(RUser::get(new MongoId($f_user)),array('id','user_name','sex','avatar','level','city_info','pets','certify_status','certify_info','can_access'));
|
|
|
- if(isset($need_refresh)){
|
|
|
- $follow_list[$key]['relation'] = $current_user_node->relation($f_user);
|
|
|
- }else{
|
|
|
- $follow_list[$key]['relation'] = $user_node->relation($f_user);
|
|
|
- }
|
|
|
- }
|
|
|
- CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),$follow_list,200,array('sum_count' => $sum ,'sum_page'=> ceil($sum/$page_size),'page_size'=>$page_size,'current_page'=>$page));
|
|
|
- }
|
|
|
-
|
|
|
- //粉丝列表
|
|
|
- public function actionFansList(){
|
|
|
- $user_id = Yii::app()->getRequest()->getParam("user_id");
|
|
|
- $to_user = Yii::app()->getRequest()->getParam("to_user_id");
|
|
|
- $page = Yii::app()->getRequest()->getParam("page");
|
|
|
- $page_size = Yii::app()->getRequest()->getParam("page_size",20);
|
|
|
- if($to_user){
|
|
|
- $uid = $to_user;
|
|
|
- $user_node = new UserNodeRecord($to_user);
|
|
|
- $current_user_node = new UserNodeRecord($user_id);
|
|
|
- $need_refresh = true;
|
|
|
- }else{
|
|
|
- $uid = $user_id;
|
|
|
- $user_node = new UserNodeRecord($user_id);
|
|
|
- }
|
|
|
- $followed_by = $user_node->followed_by();
|
|
|
- $sum = count($followed_by);
|
|
|
- $followed_by = array_slice($followed_by,$page_size*($page-1),$page_size*$page);
|
|
|
- $user_model = new RUser();
|
|
|
- foreach ($followed_by as $key => $f_user) {
|
|
|
- $followed_by[$key] = $user_model->parseRow(RUser::get(new MongoId($f_user)),array('id','user_name','sex','avatar','level','city_info','pets','certify_status','certify_info','can_access'));
|
|
|
- if(isset($need_refresh)){
|
|
|
- $followed_by[$key]['relation'] = $current_user_node->relation($f_user);
|
|
|
- }else{
|
|
|
- $followed_by[$key]['relation'] = $user_node->relation($f_user);
|
|
|
- }
|
|
|
- }
|
|
|
- CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),$followed_by,200,array('sum_count' => $sum ,'sum_page'=> ceil($sum/$page_size),'page_size'=>$page_size,'current_page'=>$page));
|
|
|
- }
|
|
|
-
|
|
|
- //推荐关注用户
|
|
|
- public function actionRecommendUsers(){
|
|
|
- $user_id = Yii::app()->getRequest()->getParam("user_id");
|
|
|
- $city_info = Yii::app()->getRequest()->getParam("city_info");
|
|
|
- $city_info = json_decode($city_info,true);
|
|
|
- $user_obj = CommonFn::apigetObJ($user_id,"ZUser",CommonFn::getMessage('user','id_not_exist'),201);
|
|
|
-
|
|
|
- $user_node = new UserNodeRecord($user_obj->_id);
|
|
|
- $follow_list = $user_node->following();
|
|
|
- $follow_users = array();
|
|
|
- foreach ($follow_list as $key => $value) {
|
|
|
- $follow_users[] = new MongoId($value);
|
|
|
- }
|
|
|
-
|
|
|
- $follow_users[] = $user_obj->_id;
|
|
|
- $criteria = new EMongoCriteria;
|
|
|
- $criteria->certify_status('==',1);
|
|
|
- $criteria->_id('notin',$follow_users);
|
|
|
- $criteria->is_fake_user('!=',1);
|
|
|
- $criteria->sort('last_visit_time',EMongoCriteria::SORT_DESC);
|
|
|
- $criteria->limit(5);
|
|
|
- $cursor = RUser::model()->findAll($criteria);
|
|
|
- $rows = RUser::model()->parse($cursor,true,array('id','user_name','sex','avatar','level','city_info','certify_status','certify_info','can_access'));
|
|
|
- $certify_users = array();
|
|
|
- foreach ($rows as $value) {
|
|
|
- $value['recommend_reason'] = $value['certify_info'];
|
|
|
- $certify_users[] = $value;
|
|
|
- }
|
|
|
-
|
|
|
- $criteria = new EMongoCriteria;
|
|
|
- if(isset($city_info['province']) && $city_info['province']){
|
|
|
- $criteria->city_info->province('==',$city_info['province']);
|
|
|
- }else{
|
|
|
- $criteria->city_info->province('==','上海市');
|
|
|
- }
|
|
|
- $criteria->_id('notin',$follow_users);
|
|
|
- $criteria->is_fake_user('!=',1);
|
|
|
- $criteria->certify_status('!=',1);
|
|
|
- $criteria->sort('last_visit_time',EMongoCriteria::SORT_DESC);
|
|
|
- $criteria->limit(10);
|
|
|
- $cursor = RUser::model()->findAll($criteria);
|
|
|
- $rows = RUser::model()->parse($cursor,true,array('id','user_name','sex','avatar','level','city_info','certify_status','certify_info','can_access'));
|
|
|
- $local_user = array();
|
|
|
- foreach ($rows as $value) {
|
|
|
- $value['recommend_reason'] = '同城用户';
|
|
|
- $local_user[] = $value;
|
|
|
- }
|
|
|
-
|
|
|
- $criteria = new EMongoCriteria;
|
|
|
- if(isset($city_info['province']) && $city_info['province']){
|
|
|
- $criteria->city_info->province('!=',$city_info['province']);
|
|
|
- }else{
|
|
|
- $criteria->city_info->province('!=','上海市');
|
|
|
- }
|
|
|
- $criteria->_id('notin',$follow_users);
|
|
|
- $criteria->is_fake_user('!=',1);
|
|
|
- $criteria->certify_status('!=',1);
|
|
|
- $criteria->sort('posts_count',EMongoCriteria::SORT_DESC);
|
|
|
- $criteria->sort('last_visit_time',EMongoCriteria::SORT_DESC);
|
|
|
- $criteria->limit(5);
|
|
|
- $cursor = RUser::model()->findAll($criteria);
|
|
|
- $rows = RUser::model()->parse($cursor,true,array('id','user_name','sex','avatar','level','city_info','certify_status','certify_info','can_access'));
|
|
|
- $hot_users = array();
|
|
|
- foreach ($rows as $value) {
|
|
|
- $value['recommend_reason'] = '活跃用户';
|
|
|
- $hot_users[] = $value;
|
|
|
- }
|
|
|
-
|
|
|
- $result = array_merge($certify_users,$local_user,$hot_users);
|
|
|
- shuffle($result);
|
|
|
- foreach ($result as $key => $user) {
|
|
|
- $result[$key]['relation'] = $user_node->relation($user['id']);
|
|
|
- }
|
|
|
- CommonFn::requestAjax(true,CommonFn::getMessage('message','operation_success'),array('recommend_list'=>$result));
|
|
|
- }
|
|
|
-
|
|
|
- //用户登出接口
|
|
|
- public function actionLogout(){
|
|
|
- $user_id = Yii::app()->getRequest()->getParam("user_id");
|
|
|
- $xinge_token = Yii::app()->getRequest()->getParam("xinge_token");
|
|
|
- $app_client_id = Yii::app()->getRequest()->getParam("app_client_id");
|
|
|
- require_once(APP_PATH."/protected/vendors/tencent/XingeApp.php");
|
|
|
- if($app_client_id == '2'){
|
|
|
- $xinge_config = Yii::app()->params['xingeConfig']['android'];
|
|
|
- $push = new XingeApp($xinge_config['accessId'],$xinge_config['secretKey']);
|
|
|
- $ret = $push->DeleteTokenOfAccount($user_id,$xinge_token);
|
|
|
- CommonFn::requestAjax(true,'注销成功');
|
|
|
- }elseif($app_client_id == '1'){
|
|
|
- $xinge_ios_config = Yii::app()->params['xingeConfig']['ios'];
|
|
|
- $push = new XingeApp($xinge_ios_config['accessId'],$xinge_ios_config['secretKey']);
|
|
|
- $ret = $push->DeleteTokenOfAccount($user_id,$xinge_token);
|
|
|
- CommonFn::requestAjax(true,'注销成功');
|
|
|
- }else{
|
|
|
- CommonFn::requestAjax(false,'操作失败');
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
}
|