|
@@ -314,188 +314,6 @@ class Usercenter extends Api
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
- //这里不用连user_active表,完全使用user表的active_time,user_active表只做离线用
|
|
|
- //同城
|
|
|
- public function samecity(){
|
|
|
- $gender = input_post('gender','all');
|
|
|
- $agemin = input_post('agemin',0);
|
|
|
- $agemax = input_post('agemax',100);
|
|
|
-
|
|
|
- if(empty($this->auth->cityname) || empty($this->auth->longitude) || empty($this->auth->latitude)){
|
|
|
- // $this->success('success',[]);
|
|
|
- }
|
|
|
-
|
|
|
- $map = [
|
|
|
- 'user.status' => 1,
|
|
|
- // 'user.cityname' => $this->auth->cityname,
|
|
|
- 'user.id' => ['neq',$this->auth->id],
|
|
|
- // 'user.longitude' => ['neq',''],
|
|
|
- // 'user.latitude' => ['neq',''],
|
|
|
- // 'user.is_online|user.is_livebc' => 1, //完全不考虑直播与语聊的权重,只用活跃做排序
|
|
|
- 'user.active_time' => ['gt',time()-86400],
|
|
|
- ];
|
|
|
- if($gender != 'all'){
|
|
|
- $map['user.gender'] = $gender;
|
|
|
- }
|
|
|
-
|
|
|
- $map['user.birthday'] = ['between',[time() - $agemax * 31536000,time() - $agemin * 31536000]];
|
|
|
-
|
|
|
- //dump($map);
|
|
|
- $field = [
|
|
|
- 'user.id','user.username','user.nickname','user.birthday','user.height','user.longitude','user.latitude','user.avatar','user.audio_bio','user.bio','user.gender','user.active_time'
|
|
|
- ];
|
|
|
- $list = Db::name('user')->alias('user')->field($field)->where($map)->order('user.active_time desc')->autopage()->select();
|
|
|
- //dump($list);
|
|
|
-
|
|
|
- $list = list_domain_image($list,['avatar']);
|
|
|
-
|
|
|
- foreach($list as $key => $one){
|
|
|
- $one['age'] = birthtime_to_age($one['birthday']);
|
|
|
- // $one['distance'] = $this->calc_map_distance([$this->auth->longitude,$this->auth->latitude],[$one['longitude'],$one['latitude']]);
|
|
|
- $one['distance'] = rand(0,10).'km';
|
|
|
-
|
|
|
- //状态
|
|
|
- $one['active_text'] = '刚刚离线';
|
|
|
- if($one['active_time'] > time()-21600){
|
|
|
- $one['active_text'] = '1小时内在线';
|
|
|
- }
|
|
|
- if($one['active_time'] > time()-3600){
|
|
|
- $one['active_text'] = '在线';
|
|
|
- }
|
|
|
-
|
|
|
- $list[$key] = $one;
|
|
|
- }
|
|
|
-
|
|
|
- $this->success('success',$list);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- //附近
|
|
|
- public function nearuser(){
|
|
|
- $gender = input_post('gender','all');
|
|
|
- $agemin = input_post('agemin',0);
|
|
|
- $agemax = input_post('agemax',100);
|
|
|
-
|
|
|
- if(empty($this->auth->cityname) || empty($this->auth->longitude) || empty($this->auth->latitude)){
|
|
|
- // $this->success('success',[]);
|
|
|
- }
|
|
|
-
|
|
|
- //经过地图测算和公式推算,经度纬度 0.1即为11公里
|
|
|
- $map = [
|
|
|
- 'user.status' => 1,
|
|
|
- ////'user.cityname' => $this->auth->cityname,
|
|
|
- 'user.id' => ['neq',$this->auth->id],
|
|
|
- // '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.active_time' => ['gt',time()-86400],
|
|
|
- ];
|
|
|
- if($gender != 'all'){
|
|
|
- $map['user.gender'] = $gender;
|
|
|
- }
|
|
|
-
|
|
|
- $map['user.birthday'] = ['between',[time() - $agemax * 31536000,time() - $agemin * 31536000]];
|
|
|
-
|
|
|
- //dump($map);
|
|
|
- $field = [
|
|
|
- 'user.id','user.username','user.nickname','user.birthday','user.height','user.longitude','user.latitude','user.avatar','user.audio_bio','user.bio','user.gender','user.active_time'
|
|
|
- ];
|
|
|
-
|
|
|
- $list = Db::name('user')->alias('user')->field($field)->where($map)->order('user.active_time desc')->autopage()->select();
|
|
|
- //dump($list);exit;
|
|
|
-
|
|
|
- $list = list_domain_image($list,['avatar']);
|
|
|
-
|
|
|
- foreach($list as $key => $one){
|
|
|
- $one['age'] = birthtime_to_age($one['birthday']);
|
|
|
- //$one['distance'] = $this->calc_map_distance([$this->auth->longitude,$this->auth->latitude],[$one['longitude'],$one['latitude']]);
|
|
|
- $one['distance'] = rand(0,10).'km';
|
|
|
-
|
|
|
- //状态
|
|
|
- $one['active_text'] = '刚刚离线';
|
|
|
- if($one['active_time'] > time()-21600){
|
|
|
- $one['active_text'] = '1小时内在线';
|
|
|
- }
|
|
|
- if($one['active_time'] > time()-3600){
|
|
|
- $one['active_text'] = '在线';
|
|
|
- }
|
|
|
-
|
|
|
- $list[$key] = $one;
|
|
|
- }
|
|
|
-
|
|
|
- $this->success('success',$list);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- //因为接受者拿不到发起者的uid,废弃了
|
|
|
- //视频和语音,接收方使用,如果是性别劣势方,检查钱是否够用
|
|
|
- public function video_audio_moneycheck(){
|
|
|
- //检测用户,发起方的uid
|
|
|
- $to_user_id = input_post('from_user_id');
|
|
|
- $to_user_info = Db::name('user')->field('id,real_status,gender')->where('id',$to_user_id)->find();
|
|
|
- if(!$to_user_info){
|
|
|
- $this->error('不存在的用户');
|
|
|
- }
|
|
|
-
|
|
|
- //扣费金币
|
|
|
- $type = input_post('type','video'); //类型
|
|
|
- $price = $type == 'video' ? config('site.video_min_price') : config('site.audio_min_price');
|
|
|
-
|
|
|
- //发起用户的分数,被发起用户的分数。按性别给分
|
|
|
- $auth_level = 0;
|
|
|
- $tous_level = 0;
|
|
|
-
|
|
|
- //打分
|
|
|
- if($this->auth->gender == 0 && $this->auth->real_status == 1){
|
|
|
- $auth_level = 30;//实名女最高
|
|
|
- }
|
|
|
- if($this->auth->gender == 0 && $this->auth->real_status != 1){
|
|
|
- $auth_level = 20;//未实名女次之
|
|
|
- }
|
|
|
- if($this->auth->gender == 1){
|
|
|
- $auth_level = 10;//男性最低
|
|
|
- }
|
|
|
- if($to_user_info['gender'] == 0 && $to_user_info['real_status'] == 1){
|
|
|
- $tous_level = 30;
|
|
|
- }
|
|
|
- if($to_user_info['gender'] == 0 && $to_user_info['real_status'] != 1){
|
|
|
- $tous_level = 20;
|
|
|
- }
|
|
|
- if($to_user_info['gender'] == 1){
|
|
|
- $tous_level = 10;
|
|
|
- }
|
|
|
-
|
|
|
- //同性不收钱
|
|
|
- //都是男的,不扣钱
|
|
|
- //都是实名认证的女性,不扣钱
|
|
|
- //都是未实名认证的女性,不扣钱
|
|
|
- if($auth_level == $tous_level){
|
|
|
- $price = 0;
|
|
|
- $this->success('success');
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //扣钱uid,收钱uid,收钱free_video
|
|
|
- //分数少扣钱,分数多收益
|
|
|
- if($auth_level < $tous_level){
|
|
|
- $kou_user = $this->auth->id;
|
|
|
- }else{
|
|
|
- $kou_user = $to_user_info['id'];
|
|
|
- }
|
|
|
-
|
|
|
- //需要扣我的(接收方的)钱,判断钱是否够
|
|
|
- if($price > 0 && $kou_user == $this->auth->id){
|
|
|
- Db::startTrans();
|
|
|
- $gold = model('wallet')->getWallet($kou_user,'gold');
|
|
|
- if(bccomp($price,$gold) == 1){
|
|
|
- Db::rollback();
|
|
|
- $this->error('金币不足');
|
|
|
- }
|
|
|
- Db::commit();
|
|
|
- }
|
|
|
- $this->success('success');
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* 是否关注
|
|
@@ -1498,7 +1316,7 @@ $resArray['money'] = $money; //返回给前端的计算结果
|
|
|
$query = Db::name('user')
|
|
|
->field('id,nickname,username,avatar')
|
|
|
->where($map)
|
|
|
- ->order('is_active desc, active_time desc');
|
|
|
+ ->order('is_active desc, logintime desc');
|
|
|
|
|
|
if ($size == 1){
|
|
|
$query->limit(10);
|