|
@@ -129,48 +129,30 @@ class Index extends Api
|
|
|
//推荐
|
|
|
//真人认证的,是推荐用户的,可能也要限制vip的
|
|
|
public function tuijian(){
|
|
|
- $cityname = input('cityname','');
|
|
|
+ /*$cityname = input('cityname','');
|
|
|
if(empty($cityname)){
|
|
|
$cityname = $this->auth->cityname;
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
+ //强制条件
|
|
|
$where = [
|
|
|
'user.id' => ['neq',$this->auth->id],
|
|
|
'user.status' => 1,
|
|
|
-// 'user.photo_images' => ['neq',''],
|
|
|
-// 'user.cityname' => $cityname,
|
|
|
'power.yinshen' => 0,
|
|
|
];
|
|
|
|
|
|
- //推荐条件
|
|
|
- $where_tuijian = [
|
|
|
- 'user.idcard_status' => 1,
|
|
|
- 'user.is_tuijian' => 1,
|
|
|
- ];
|
|
|
- if(config('site.index_tuijian_vip_limit') == 1){
|
|
|
- $where_tuijian['wallet.vip_endtime'] = ['gt',time()];
|
|
|
- }
|
|
|
- //推荐条件
|
|
|
-
|
|
|
- $where = array_merge($where,$where_tuijian);
|
|
|
-
|
|
|
- //性别
|
|
|
+ //搜索条件 性别
|
|
|
$gender = input('gender','all');
|
|
|
if($gender != 'all'){
|
|
|
$where['user.gender'] = $gender;
|
|
|
}
|
|
|
- //属性
|
|
|
+ //搜索条件 属性
|
|
|
$attribute = input('attribute','all');
|
|
|
if($attribute != 'all' && $attribute != 'BOTH'){
|
|
|
$where['user.attribute'] = $attribute;
|
|
|
}
|
|
|
- //排除黑名单的
|
|
|
- $where_black = [];
|
|
|
- $black_ids = Db::name('user_black')->where(['uid'=>$this->auth->id])->column('black_uid');
|
|
|
- if(!empty($black_ids)){
|
|
|
- $where_black['user.id'] = ['NOTIN',$black_ids];
|
|
|
- }
|
|
|
- //年龄
|
|
|
+
|
|
|
+ //搜索条件 年龄
|
|
|
$agemin = input('agemin',18);
|
|
|
if($agemin > 18){
|
|
|
$where['user.birthday'] = ['lt',time()-$agemin*31536000];
|
|
@@ -182,6 +164,30 @@ class Index extends Api
|
|
|
if($agemin > 18 && $agemax < 100){
|
|
|
$where['user.birthday'] = ['between',[time()-$agemax*31536000,time()-$agemin*31536000]];
|
|
|
}
|
|
|
+
|
|
|
+ //排除黑名单的
|
|
|
+ $where_black = [];
|
|
|
+ $black_ids = Db::name('user_black')->where(['uid'=>$this->auth->id])->column('black_uid');
|
|
|
+ if(!empty($black_ids)){
|
|
|
+ $where_black['user.id'] = ['NOTIN',$black_ids];
|
|
|
+ }
|
|
|
+
|
|
|
+ //其他条件 与 推荐条件是 或的关系
|
|
|
+ $where_other = [
|
|
|
+ 'user.avatar' => ['neq',''],
|
|
|
+ 'user.idcard_status' => 1,
|
|
|
+ ];
|
|
|
+
|
|
|
+ if(config('site.index_tuijian_vip_limit') == 1){
|
|
|
+ $where_other['wallet.vip_endtime'] = ['gt',time()];
|
|
|
+ }
|
|
|
+
|
|
|
+ //推荐条件
|
|
|
+ $where_tuijian = [
|
|
|
+ 'user.is_tuijian' => 1,
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
//距离
|
|
|
$having_dis = '';
|
|
|
$distancemin = input('distancemin',0);
|
|
@@ -220,10 +226,20 @@ class Index extends Api
|
|
|
->join('user_active active' ,'user.id = active.user_id','LEFT')
|
|
|
->where($where)
|
|
|
->where($where_black)
|
|
|
+ ->where(
|
|
|
+ function($query)use($where_other,$where_tuijian){
|
|
|
+ $query->where(
|
|
|
+ function($query)use($where_other){
|
|
|
+ $query->where($where_other);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ $query->whereOr($where_tuijian);
|
|
|
+ })
|
|
|
->having($having_dis)
|
|
|
->order('user.is_active desc,distance asc')
|
|
|
->autopage()
|
|
|
->select();
|
|
|
+
|
|
|
$list = list_domain_image($list,['avatar','photo_images']);
|
|
|
foreach($list as $key => &$val){
|
|
|
$val['age'] = birthtime_to_age($val['birthday']);
|