|
@@ -193,14 +193,41 @@ class Topicdongtai extends Api
|
|
|
$order = input('orderby','new');
|
|
|
$orderby = 'dt.toptime desc,dt.id desc';
|
|
|
//关注
|
|
|
+ $where_follow = '';
|
|
|
if($order == 'follow'){
|
|
|
+ //关注的人
|
|
|
$follow_user_ids = Db::name('user_follow')->where(['uid'=>$this->auth->id])->column('follow_uid');
|
|
|
- $where['dt.user_id'] = ['IN',$follow_user_ids];
|
|
|
+ if(!empty($follow_user_ids)){
|
|
|
+ $where_follow .= '(dt.user_id IN ('.implode(',',$follow_user_ids).'))';
|
|
|
+ }
|
|
|
+ //关注的话题
|
|
|
+ $where_topic = "";
|
|
|
+ $follow_topic_ids= Db::name('user_follow_topic')->where(['uid'=>$this->auth->id])->column('topic_id');
|
|
|
+ if(!empty($follow_topic_ids)){
|
|
|
+ if(!empty($follow_user_ids)){
|
|
|
+ $where_follow .= ' or ';
|
|
|
+ }
|
|
|
+
|
|
|
+ $where_topic .= "(";
|
|
|
+ foreach($follow_topic_ids as $ck => $cv){
|
|
|
+ $where_topic .= "FIND_IN_SET('".$cv."',dt.topic_ids)";
|
|
|
+
|
|
|
+ if($ck+1 < count($follow_topic_ids)){
|
|
|
+ $where_topic .= " or ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $where_topic .= ")";
|
|
|
+
|
|
|
+ $where_follow .= $where_topic;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
//附近,根据距离排序
|
|
|
if($order == 'near'){
|
|
|
// $where['dt.cityname'] = $this->auth->cityname;
|
|
|
- $orderby = 'distance asc,dt.toptime desc,';
|
|
|
+ $orderby = 'distance asc,dt.toptime desc';
|
|
|
}
|
|
|
|
|
|
//性别
|
|
@@ -216,10 +243,10 @@ class Topicdongtai extends Api
|
|
|
}
|
|
|
|
|
|
//排除黑名单的
|
|
|
- $where2 = [];
|
|
|
+ $where_black = [];
|
|
|
$black_ids = Db::name('user_black')->where(['uid'=>$this->auth->id])->column('black_uid');
|
|
|
if(!empty($black_ids)){
|
|
|
- $where2['dt.user_id'] = ['NOTIN',$black_ids];
|
|
|
+ $where_black['dt.user_id'] = ['NOTIN',$black_ids];
|
|
|
}
|
|
|
|
|
|
//列表
|
|
@@ -232,8 +259,9 @@ class Topicdongtai extends Api
|
|
|
->join('user_wallet uw','user.id = uw.user_id','LEFT')
|
|
|
->field($field)
|
|
|
->where($where)
|
|
|
- ->where($where2)
|
|
|
->where($where_exp)
|
|
|
+ ->where($where_follow)
|
|
|
+ ->where($where_black)
|
|
|
->order($orderby)
|
|
|
->autopage()->select();
|
|
|
$list = list_domain_image($list,['images','audio_file','avatar']);
|