Uservisit.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 访问足迹
  7. */
  8. class Uservisit extends Api
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = ['*'];
  12. //我的访问列表
  13. public function my_visit_list(){
  14. $list = Db::name('user_visit')
  15. ->alias('visit')
  16. ->join('user','visit.to_uid = user.id','LEFT')
  17. ->field('user.id,user.nickname,user.avatar,user.bio,user.birthday,user.gender')
  18. ->where('visit.uid',$this->auth->id)->order('visit.updatetime desc')->autopage()->select();
  19. $list = list_domain_image($list,['avatar']);
  20. $list = list_birthday_age($list);
  21. $this->success('success',$list);
  22. }
  23. //访问我的人列表
  24. public function visit_me_list(){
  25. $time = Db::name('user_visit_time')->where(['user_id' => $this->auth->id])->find();
  26. if ($time) {
  27. Db::name('user_visit_time')->where(['user_id' => $this->auth->id])->setField('visittime', time());
  28. } else {
  29. Db::name('user_visit_time')->insertGetId(['user_id' => $this->auth->id, 'visittime' => time()]);
  30. }
  31. $list = Db::name('user_visit')
  32. ->alias('visit')
  33. ->join('user','visit.uid = user.id','LEFT')
  34. ->field('user.id,user.nickname,user.avatar,visit.updatetime')
  35. ->where('visit.to_uid',$this->auth->id)->order('visit.updatetime desc')->autopage()->select();
  36. $list = list_domain_image($list,['avatar']);
  37. // $list = list_birthday_age($list);
  38. //查询会员
  39. $vip_endtime = Db::name('user_wallet')->where(['user_id' => $this->auth->id])->value('vip_endtime');
  40. if ($this->auth->gender == 1 && $vip_endtime < time()) {
  41. $is_show = 0;
  42. } else {
  43. $is_show = 1; //是否正常显示信息: 1显示 0不显示
  44. }
  45. $mt_user_greet = Db::name('user_greet'); //是否打过招呼
  46. foreach ($list as &$v) {
  47. $v['updatetime'] = get_last_time($v['updatetime']);
  48. $v['is_show'] = $is_show;
  49. //查询是否搭讪过
  50. $count = $mt_user_greet->where(['user_id' => $this->auth->id, 'user_to_id' => $v['id']])->count('id');
  51. if ($count) {
  52. $v['is_chat'] = 1; //是否打过招呼: 1是 0否
  53. } else {
  54. $v['is_chat'] = 0; //是否打过招呼: 1是 0否
  55. }
  56. if ($is_show == 0) {
  57. $v['id'] = 0;
  58. $v['nickname'] = 'Ta偷偷来过';
  59. $v['avatar'] = config('avatar_girl');
  60. }
  61. }
  62. $this->success('success',$list);
  63. }
  64. //查看某人
  65. public function visit_one(){
  66. //放到usercenter/getuserinfo里了
  67. }
  68. }