|
@@ -23,7 +23,9 @@ class Topicdongtai extends Api
|
|
|
$topic_ids = input('topic_ids','');
|
|
|
$aite = input('aite','','htmlspecialchars_decode');
|
|
|
$type = input('type',1);
|
|
|
- if(!$content && !$images){
|
|
|
+ $audio_second = input('audio_second',0);
|
|
|
+
|
|
|
+ if(!$content && !$images && !$audio_file){
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
|
|
@@ -33,6 +35,7 @@ class Topicdongtai extends Api
|
|
|
//只保留一个
|
|
|
if($type == 1){
|
|
|
$audio_file = '';
|
|
|
+ $audio_second = 0;
|
|
|
}else{
|
|
|
$images = '';
|
|
|
}
|
|
@@ -47,6 +50,9 @@ class Topicdongtai extends Api
|
|
|
'cityname' => input('cityname',''),
|
|
|
'aite' => $aite,
|
|
|
'is_public' => input('is_public',1),
|
|
|
+ 'audio_second' => $audio_second,
|
|
|
+ 'longitude' => input('longitude',0),
|
|
|
+ 'latitude' => input('latitude',0),
|
|
|
'createtime' => time(),
|
|
|
'updatetime' => time(),
|
|
|
];
|
|
@@ -174,9 +180,10 @@ class Topicdongtai extends Api
|
|
|
$follow_user_ids = Db::name('user_follow')->where(['uid'=>$this->auth->id])->column('follow_uid');
|
|
|
$where['dt.user_id'] = ['IN',$follow_user_ids];
|
|
|
}
|
|
|
- //附近,同城
|
|
|
+ //附近,根据距离排序
|
|
|
if($order == 'near'){
|
|
|
- $where['dt.cityname'] = $this->auth->cityname;
|
|
|
+// $where['dt.cityname'] = $this->auth->cityname;
|
|
|
+ $orderby = 'distance asc';
|
|
|
}
|
|
|
|
|
|
//性别
|
|
@@ -187,7 +194,7 @@ class Topicdongtai extends Api
|
|
|
|
|
|
//属性
|
|
|
$attribute = input('attribute','all');
|
|
|
- if($attribute != 'all'){
|
|
|
+ if($attribute != 'all' && $attribute != 'BOTH'){
|
|
|
$where['user.attribute'] = $attribute;
|
|
|
}
|
|
|
|
|
@@ -199,20 +206,30 @@ class Topicdongtai extends Api
|
|
|
}
|
|
|
|
|
|
//列表
|
|
|
+ $field = 'dt.*,user.nickname,user.avatar,user.gender,user.birthday,user.attribute,uw.vip_endtime';
|
|
|
+ if($order == 'near'){
|
|
|
+ $field .= ',(st_distance(point (' . $this->auth->longitude . ', ' . $this->auth->latitude . '),point(dt.longitude,dt.latitude))*111195) as distance';
|
|
|
+ }
|
|
|
$list = Db::name('topic_dongtai')->alias('dt')
|
|
|
->join('user','dt.user_id = user.id','LEFT')
|
|
|
->join('user_wallet uw','user.id = uw.user_id','LEFT')
|
|
|
- ->field('dt.*,user.nickname,user.avatar,user.gender,user.birthday,user.attribute,uw.vip_endtime')
|
|
|
+ ->field($field)
|
|
|
->where($where)
|
|
|
->where($where2)
|
|
|
->where($where_exp)
|
|
|
- ->order($orderby)->autopage()->select();
|
|
|
+ ->order($orderby)
|
|
|
+ ->autopage()->select();
|
|
|
$list = list_domain_image($list,['images','audio_file','avatar']);
|
|
|
|
|
|
if(!empty($list)){
|
|
|
foreach($list as $key => &$val){
|
|
|
+ //艾特
|
|
|
$val['aite'] = json_decode($val['aite'],true);
|
|
|
|
|
|
+ //距离
|
|
|
+ $val['distance'] = isset($val['distance']) ? $val['distance'] : 0;
|
|
|
+ $val['distance'] = bcdiv(intval($val['distance']),1000,2).'km';
|
|
|
+
|
|
|
//用户年龄
|
|
|
$val['age'] = birthtime_to_age($val['birthday']);
|
|
|
unset($val['birthday']);
|