123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- /**
- * 访问足迹
- */
- class Uservisit extends Api
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = ['*'];
- //我的访问列表
- public function my_visit_list(){
- $list = Db::name('user_visit')
- ->alias('visit')
- ->join('user','visit.to_uid = user.id','LEFT')
- ->join('user_remark ur', 'ur.to_user_id = user.id and ur.user_id = '.$this->auth->id, 'LEFT')
- ->field('user.id,user.nickname,user.avatar,user.bio,user.birthday,user.gender,ur.nickname_remark')
- ->where('visit.uid',$this->auth->id)->order('visit.updatetime desc')->autopage()->select();
- $list = list_domain_image($list,['avatar']);
- $list = list_birthday_age($list);
- foreach ($list as &$val) {
- $val['nickname'] = !empty($val['nickname_remark']) ? $val['nickname_remark'] : $val['nickname'];
- }
- $this->success('success',$list);
- }
- //访问我的人列表
- public function visit_me_list(){
- $time = Db::name('user_visit_time')->where(['user_id' => $this->auth->id])->find();
- if ($time) {
- Db::name('user_visit_time')->where(['user_id' => $this->auth->id])->setField('visittime', time());
- } else {
- Db::name('user_visit_time')->insertGetId(['user_id' => $this->auth->id, 'visittime' => time()]);
- }
- $list = Db::name('user_visit')
- ->alias('visit')
- ->join('user','visit.uid = user.id','LEFT')
- ->join('user_remark ur', 'ur.to_user_id = user.id and ur.user_id = '.$this->auth->id, 'LEFT')
- ->field('user.id,user.nickname,user.avatar,visit.updatetime,ur.nickname_remark')
- ->where('visit.to_uid',$this->auth->id)->order('visit.updatetime desc')->autopage()->select();
- $list = list_domain_image($list,['avatar']);
- // $list = list_birthday_age($list);
- //查询会员
- $user_wallet = Db::name('user_wallet')->where('user_id',$this->auth->id)->find();
- $is_vip = $this->is_vip($user_wallet['vip_endtime'],$user_wallet['vip_level']);
- if ($this->auth->gender == 1 && $is_vip == 0) {
- $is_show = 0;
- } else {
- $is_show = 1; //是否正常显示信息: 1显示 0不显示
- }
- $mt_user_greet = Db::name('user_greet'); //是否打过招呼
- foreach ($list as &$v) {
- $v['updatetime'] = get_last_time($v['updatetime']);
- $v['is_show'] = $is_show;
- //查询是否搭讪过
- $count = $mt_user_greet->where(['user_id' => $this->auth->id, 'user_to_id' => $v['id']])->count('id');
- if ($count) {
- $v['is_chat'] = 1; //是否打过招呼: 1是 0否
- } else {
- $v['is_chat'] = 0; //是否打过招呼: 1是 0否
- }
- if ($is_show == 0) {
- $v['id'] = 0;
- $v['nickname'] = 'Ta偷偷来过';
- $v['avatar'] = config('avatar_girl');
- }
- $v['nickname'] = !empty($v['nickname_remark']) ? $v['nickname_remark'] : $v['nickname'];
- }
- $this->success('success',$list);
- }
- //谁看过我汇总
- public function visitlist(){
- $time = Db::name('user_visit_time')->where(['user_id' => $this->auth->id])->value('visittime');
- $where = [];
- if ($time) {
- $where['updatetime'] = ['gt', $time];
- }
- $list = [];
- $count = Db::name('user_visit')->where(['to_uid' => $this->auth->id])->where($where)->count('id');
- if ($count) {
- $uid_list = Db::name('user_visit')->field('uid')->where(['to_uid' => $this->auth->id])->where($where)->limit(9)->column('uid');
- $mt_user = Db::name('user');
- foreach ($uid_list as &$v) {
- $avatar = $mt_user->where(['id' => $v])->value('avatar');
- $list[] = one_domain_image($avatar);
- }
- }
- $data['count'] = $count;
- $data['list'] = $list;
- $this->success('success',$data);
- }
- //查看某人
- public function visit_one(){
- //放到usercenter/getuserinfo里了
- }
- }
|