alias('black') ->join('user','black.uid = user.id','LEFT') ->join('user_wallet uw','user.id = uw.user_id','LEFT') ->field('user.id,user.username,user.nickname,user.avatar,user.bio,user.birthday,user.gender,user.attribute,uw.vip_endtime') ->where('black.black_uid',$this->auth->id)->order('black.id desc')->autopage()->select(); $list = list_domain_image($list,['avatar']); if(!empty($list)){ foreach($list as $key => &$val){ //用户年龄 $val['age'] = birthtime_to_age($val['birthday']); unset($val['birthday']); //用户vip $val['is_vip'] = $val['vip_endtime'] > time() ? 1 : 0; unset($val['vip_endtime']); } } $this->success('success',$list); } //我拉黑的人列表 public function my_black_list(){ $list = Db::name('user_black') ->alias('black') ->join('user','black.black_uid = user.id','LEFT') ->join('user_wallet uw','user.id = uw.user_id','LEFT') ->field('user.id,user.username,user.nickname,user.avatar,user.bio,user.birthday,user.gender,user.attribute,uw.vip_endtime') ->where('black.uid',$this->auth->id)->order('black.id desc')->autopage()->select(); $list = list_domain_image($list,['avatar']); if(!empty($list)){ foreach($list as $key => &$val){ //用户年龄 $val['age'] = birthtime_to_age($val['birthday']); unset($val['birthday']); //用户vip $val['is_vip'] = $val['vip_endtime'] > time() ? 1 : 0; unset($val['vip_endtime']); } } $this->success('success',$list); } //拉黑某人 public function black_one(){ $black_uid = input('black_uid',0); if(!$black_uid){ $this->error(__('Invalid parameters')); } $checkuser = Db::name('user')->find($black_uid); if(empty($checkuser)){ $this->error('此用户不存在'); } if($black_uid == $this->auth->id){ $this->error('不能拉黑自己'); } $map = [ 'uid' => $this->auth->id, 'black_uid' => $black_uid, ]; $check = Db::name('user_black')->where($map)->find(); if($check){ $this->error('已经拉黑了此人'); } $id = Db::name('user_black')->insertGetId($map); $this->success('操作成功',$id); } //取消拉黑某人 public function un_black_one(){ $black_uid = input('black_uid',0); if(!$black_uid){ $this->error(__('Invalid parameters')); } $map = [ 'uid' => $this->auth->id, 'black_uid' => $black_uid, ]; //不检查,全删 $rs = Db::name('user_black')->where($map)->delete(); $this->success('操作成功'); } }