|
@@ -3,6 +3,7 @@
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
use app\common\controller\Api;
|
|
|
+use think\Cache;
|
|
|
use think\Db;
|
|
|
use app\common\model\wallet;
|
|
|
use Redis;
|
|
@@ -2105,11 +2106,11 @@ $resArray['money'] = $money; //返回给前端的计算结果
|
|
|
|
|
|
//给出备选用户
|
|
|
$map = [
|
|
|
- 'status' =>1, //未封禁用户
|
|
|
'gender' => $this->auth->gender == 1 ? 0 : 1, //异性
|
|
|
+ 'is_active' => 1, //在线的
|
|
|
+ 'status' =>1, //未封禁用户
|
|
|
// 'is_online' => 0, //不在语聊间的
|
|
|
'is_livebc' => 0, //不在直播的
|
|
|
- 'is_active' => 1, //在线的
|
|
|
// 'real_status' => 1, //真人认证
|
|
|
// 'idcard_status' => 1, //实名认证
|
|
|
// 'id' => ['NOT IN',$my_follow] //不是好友的
|
|
@@ -2125,30 +2126,39 @@ $resArray['money'] = $money; //返回给前端的计算结果
|
|
|
$map['open_match_video'] = 1;
|
|
|
}
|
|
|
|
|
|
- $lists = Db::name('user')->field('id,nickname,username,avatar')->where($map)->order('is_active desc, active_time desc')->page($this->page,100)->select();
|
|
|
- //$lists = $this->fliter_user($lists,100);
|
|
|
-
|
|
|
- $lists = list_domain_image($lists,['avatar,audio_bio']);
|
|
|
-
|
|
|
- $mt_user_greet_content = Db::name('user_greet_content');
|
|
|
- foreach ($lists as &$v) {
|
|
|
- $info = $mt_user_greet_content->where(['user_id' => $v['id'], 'is_default' => 1])->find();
|
|
|
- if ($info) {
|
|
|
- if ($info['type'] == 0) {
|
|
|
- $v['greet_content'] = $info['content'];
|
|
|
- } elseif ($info['type'] == 1) {
|
|
|
- $v['greet_content'] = '[语音]';
|
|
|
- } elseif ($info['type'] == 2) {
|
|
|
- $v['greet_content'] = '[图片]';
|
|
|
+ $key = md5(json_encode($map));// 根据搜索条件做Key
|
|
|
+ $lists = Cache::remember("getrandomuser_{$key}",function () use ($map){
|
|
|
+ $lists = Db::name('user')
|
|
|
+ ->field('id,nickname,username,avatar')
|
|
|
+ ->where($map)
|
|
|
+ ->order('is_active desc, active_time desc')
|
|
|
+ ->page($this->page,100)
|
|
|
+ ->select();
|
|
|
+ //$lists = $this->fliter_user($lists,100);
|
|
|
+
|
|
|
+ $lists = list_domain_image($lists,['avatar,audio_bio']);
|
|
|
+
|
|
|
+ $mt_user_greet_content = Db::name('user_greet_content');
|
|
|
+ foreach ($lists as &$v) {
|
|
|
+ $info = $mt_user_greet_content->where(['user_id' => $v['id'], 'is_default' => 1])->find();
|
|
|
+ if ($info) {
|
|
|
+ if ($info['type'] == 0) {
|
|
|
+ $v['greet_content'] = $info['content'];
|
|
|
+ } elseif ($info['type'] == 1) {
|
|
|
+ $v['greet_content'] = '[语音]';
|
|
|
+ } elseif ($info['type'] == 2) {
|
|
|
+ $v['greet_content'] = '[图片]';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $v['greet_content'] = '';
|
|
|
}
|
|
|
- } else {
|
|
|
- $v['greet_content'] = '';
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- $count = Db::name('user')->where(['is_active' => 1])->count('id');
|
|
|
+ return $lists;
|
|
|
+ },60);
|
|
|
|
|
|
- $return_data['count'] = config('site.randomuser_num') > 0 ? config('site.randomuser_num') + $count : $count;
|
|
|
+// $count = Db::name('user')->where(['is_active' => 1])->count('id');
|
|
|
+//
|
|
|
+// $return_data['count'] = config('site.randomuser_num') > 0 ? config('site.randomuser_num') + $count : $count;
|
|
|
$return_data['list'] = $lists;
|
|
|
|
|
|
$this->success('success',$return_data);
|