|
@@ -558,10 +558,10 @@ class Index extends Api
|
|
|
|
|
|
$this->success('筛选年龄段', $list);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public function nearuser()
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -574,13 +574,13 @@ class Index extends Api
|
|
|
|
|
|
|
|
|
$map = [
|
|
|
+ 'user.gender' => $this->auth->gender == 1 ? 0 : 1,
|
|
|
'user.status' => 1,
|
|
|
-
|
|
|
- 'user.id' => ['neq',$this->auth->id],
|
|
|
'user.is_kefu' => 0,
|
|
|
+
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
];
|
|
|
|
|
@@ -609,12 +609,6 @@ class Index extends Api
|
|
|
|
|
|
}
|
|
|
|
|
|
- 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 = list_domain_image($list,['avatar']);
|
|
|
|
|
@@ -663,6 +656,27 @@ class Index extends Api
|
|
|
$mt_area = Db::name('area');
|
|
|
$time = time();
|
|
|
|
|
|
+ $hometown_cityid = [];
|
|
|
+ $user_to_id = [];
|
|
|
+ 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');
|
|
|
+
|
|
|
+
|
|
|
+ $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;
|
|
|
} else {
|
|
|
$v['is_chat'] = 0;
|
|
|
}
|
|
|
- $vip_endtime = $mt_user_wallet->where(['user_id' => $v['id']])->find();
|
|
|
- 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;
|
|
|
} else {
|
|
|
$v['is_vip'] = 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'] = '';
|
|
|
}
|