|
@@ -558,10 +558,10 @@ class Index extends Api
|
|
|
|
|
|
$this->success('筛选年龄段', $list);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public function nearuser()
|
|
|
{
|
|
|
- // if(empty($this->auth->longitude) || empty($this->auth->latitude)){
|
|
|
+// if(empty($this->auth->longitude) || empty($this->auth->latitude)){
|
|
|
// // $this->success('success',[]);
|
|
|
// $this->error('请先开启定位');
|
|
|
// }
|
|
@@ -574,13 +574,13 @@ class Index extends Api
|
|
|
|
|
|
//经过地图测算和公式推算,经度纬度 0.1即为11公里
|
|
|
$map = [
|
|
|
+ 'user.gender' => $this->auth->gender == 1 ? 0 : 1,// 查询异性
|
|
|
'user.status' => 1,
|
|
|
- ////'user.cityname' => $this->auth->cityname,
|
|
|
- 'user.id' => ['neq',$this->auth->id],
|
|
|
'user.is_kefu' => 0,
|
|
|
+// 'user.cityname' => $this->auth->cityname,
|
|
|
// 'user.longitude' => ['between',[$this->auth->longitude - 0.1,$this->auth->longitude + 0.1]],
|
|
|
// 'user.latitude' => ['between',[$this->auth->latitude - 0.1,$this->auth->latitude + 0.1]],
|
|
|
- // 'user.is_online|user.is_livebc' => 1, //完全不考虑直播与语聊的权重,只用活跃做排序
|
|
|
+// 'user.is_online|user.is_livebc' => 1, //完全不考虑直播与语聊的权重,只用活跃做排序
|
|
|
// 'user.active_time' => ['gt',time()-86400],
|
|
|
];
|
|
|
|
|
@@ -609,12 +609,6 @@ class Index extends Api
|
|
|
// $order = 'user.createtime desc';
|
|
|
}
|
|
|
|
|
|
- if($this->auth->gender == 1){
|
|
|
- $map['user.gender'] = 0;
|
|
|
- } else {
|
|
|
- $map['user.gender'] = 1;
|
|
|
- }
|
|
|
-
|
|
|
if ($age_id > 0 && $age_id < 8) {
|
|
|
if ($age_id == 1) {
|
|
|
$agemin = 18;
|
|
@@ -649,9 +643,8 @@ class Index extends Api
|
|
|
|
|
|
//$list = Db::name('user')->alias('user')->field($field)->where($map)->order($order)->autopage()->select();
|
|
|
$list = Db::name('user')->alias('user')->field($field)
|
|
|
- //->join('user_wallet uw','uw.user_id = user.id','LEFT')
|
|
|
+ //->join('user_wallet uw','uw.user_id = user.id','LEFT')
|
|
|
->where($map)->order($order)->autopage()->select();
|
|
|
- //dump($list);exit;
|
|
|
|
|
|
$list = list_domain_image($list,['avatar']);
|
|
|
|
|
@@ -663,6 +656,27 @@ class Index extends Api
|
|
|
$mt_area = Db::name('area'); //城市
|
|
|
$time = time();
|
|
|
|
|
|
+ $hometown_cityid = [];//城市ids
|
|
|
+ $user_to_id = [];//打招呼ids
|
|
|
+ foreach ($list as $key=>$val){
|
|
|
+ $hometown_cityid[] = $val['hometown_cityid'];
|
|
|
+ $user_to_id[] = $val['id'];
|
|
|
+ }
|
|
|
+ // 城市
|
|
|
+ $mt_areas = $mt_area->field(['id','name'])->whereIn('id',$hometown_cityid)->select();
|
|
|
+ $mt_areas = array_column($mt_areas ?? [],'name','id');
|
|
|
+
|
|
|
+ // 是否打过招呼
|
|
|
+ $mt_user_greets = $mt_user_greet->field(['user_to_id','count(id) as num'])->where('user_id', $this->auth->id)->whereIn('user_to_id',$user_to_id)->group('user_to_id')->select();
|
|
|
+ $mt_user_greets = array_column($mt_user_greets ?? [],'num','user_to_id');
|
|
|
+
|
|
|
+ // 是否是vip
|
|
|
+ $mt_user_wallets = $mt_user_wallet->field(['id','user_id','vip_endtime','pay_money'])->whereIn('user_id',$user_to_id)->select();
|
|
|
+
|
|
|
+ // 财富等级
|
|
|
+ $mt_wealth_levels = $mt_wealth_level->order('id desc')->select();
|
|
|
+ $mt_wealth_levels = array_column($mt_wealth_levels ?? [],'name','value');
|
|
|
+
|
|
|
foreach($list as $key => &$v) {
|
|
|
if ($this->auth->gender == 1) { //用户是男的
|
|
|
$age = birthtime_to_age($v['birthday']);
|
|
@@ -701,7 +715,7 @@ class Index extends Api
|
|
|
$v['desc'] = '18岁';
|
|
|
}
|
|
|
if ($v['hometown_cityid']) {
|
|
|
- $hometown_city = $mt_area->where('id',$v['hometown_cityid'])->value('name');
|
|
|
+ $hometown_city = $mt_areas[$v['hometown_cityid']] ?? '';
|
|
|
$hometown_city = ($hometown_city && $v['is_hideaddress'] == 0) ? $hometown_city : '';
|
|
|
if ($hometown_city) {
|
|
|
$v['desc'] .= ' | ' . $hometown_city;
|
|
@@ -713,22 +727,38 @@ class Index extends Api
|
|
|
}
|
|
|
}
|
|
|
//查询是否打过招呼
|
|
|
- $count = $mt_user_greet->where(['user_id' => $this->auth->id, 'user_to_id' => $v['id']])->count('id');
|
|
|
+ $count = $mt_user_greets[$v['id']] ?? 0;
|
|
|
if ($count) {
|
|
|
$v['is_chat'] = 1; //是否打过招呼: 1是 0否
|
|
|
} else {
|
|
|
$v['is_chat'] = 0; //是否打过招呼: 1是 0否
|
|
|
}
|
|
|
- $vip_endtime = $mt_user_wallet->where(['user_id' => $v['id']])->find();//->value('vip_endtime');
|
|
|
- if ($vip_endtime['vip_endtime'] >= $time) {
|
|
|
+
|
|
|
+ $vip_endtime = 0;
|
|
|
+ $pay_money = 0;
|
|
|
+ foreach ($mt_user_wallets as $kk=>$vv){
|
|
|
+ if ($vv['user_id'] == $v['id']) {
|
|
|
+ $vip_endtime = $vv['vip_endtime'];
|
|
|
+ $pay_money = $vv['pay_money'];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($vip_endtime >= $time) {
|
|
|
$v['is_vip'] = 1; //是否是vip: 1是 0否
|
|
|
} else {
|
|
|
$v['is_vip'] = 0; //是否是vip: 1是 0否
|
|
|
}
|
|
|
//查询财富等级
|
|
|
- $wealth_level = $mt_wealth_level->where(['value' => ['elt', $vip_endtime['pay_money']]])->order('id desc')->find();
|
|
|
- if ($wealth_level) {
|
|
|
- $v['wealth_level'] = $wealth_level['name'];
|
|
|
+ if (!empty($mt_wealth_levels)) {
|
|
|
+ $name = '';
|
|
|
+ foreach ($mt_wealth_levels as $kkk=>$vvv){
|
|
|
+ if ($pay_money > $kkk){
|
|
|
+ $name = $vvv;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $v['wealth_level'] = $name;
|
|
|
} else {
|
|
|
$v['wealth_level'] = '';
|
|
|
}
|