|
@@ -89,8 +89,7 @@ class UserCenter extends Common
|
|
|
// 获取贵族信息
|
|
|
$nobleInfo = $this->userModel->getUserNobleInfo($user_id);
|
|
|
// 查看者是否已关注
|
|
|
- $followid = \app\common\model\UserFansFollow::where(["fans_id"=>$this->auth->id,"user_id"=>$user_id])->value("id");
|
|
|
- $userInfo["is_follow"] = $followid>0?1:0;
|
|
|
+ $userInfo["is_follow"] = $this->is_follow($this->auth->id,$user_id);
|
|
|
|
|
|
$userInfo = json_decode(json_encode($userInfo),true);
|
|
|
$userInfo = array_merge($userInfo,$nobleInfo);
|
|
@@ -112,10 +111,8 @@ class UserCenter extends Common
|
|
|
$party = \app\common\model\Party::where('id',$livingUserPartyId)->field('id,room_type')->find();
|
|
|
$userInfo['party_info'] = ['party_id' => $party['id'], 'room_type' => $party['room_type']];
|
|
|
}
|
|
|
- $blackWhere['user_id'] = $this->auth->id;
|
|
|
- $blackList = model('UserBlacklist')->where($blackWhere)->select();
|
|
|
- $blackIds = !empty($blackList) ? array_column($blackList,'black_user_id') : [];
|
|
|
- $userInfo['is_black'] = in_array($user_id,$blackIds) ? 1 : 0;
|
|
|
+
|
|
|
+ $userInfo['is_black'] = $this->is_black($this->auth->id,$user_id);
|
|
|
|
|
|
$memberinfo = Db::name('guild_member')->alias('m')->field('m.id as `member_id`,m.user_id,guild.name,guild.image,guild.member,guild.desc')->join('guild','m.guild_id = guild.id','LEFT')->where(['m.user_id'=>$user_id,'m.status'=>1])->find();
|
|
|
if ($memberinfo) {
|
|
@@ -439,53 +436,7 @@ class UserCenter extends Common
|
|
|
$this->success(1,$list);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取附近的人
|
|
|
- * (消息-同城)
|
|
|
- */
|
|
|
- /*public function getSamecityList(){
|
|
|
-
|
|
|
- if(!$this->auth->city_id){
|
|
|
- $this->success(1,[]);
|
|
|
- }
|
|
|
-
|
|
|
- $where = [
|
|
|
- 'status' => 'normal',
|
|
|
- 'city_id'=> $this->auth->city_id,
|
|
|
- ];
|
|
|
-
|
|
|
- //排除黑名单的
|
|
|
- $black_ids = Db::name('user_blacklist')->where('user_id',$this->auth->id)->column('black_user_id');
|
|
|
- if(!empty($black_ids)){
|
|
|
- $where['id'] = ['NOTIN',$black_ids];
|
|
|
- }
|
|
|
-
|
|
|
- $list = Db::name('user')->where($where)->where('id','neq',$this->auth->id)->field('id,nickname,avatar,gender,desc')->order('id desc')->autopage()->select();
|
|
|
- $list = list_domain_image($list,['avatar']);
|
|
|
-
|
|
|
- if(!empty($list)){
|
|
|
- foreach($list as $key => &$val){
|
|
|
- //关注
|
|
|
- $val['is_follow'] = $this->is_follow($val['id'],$this->auth->id);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $this->success(1,$list);
|
|
|
- }*/
|
|
|
|
|
|
- //是否关注
|
|
|
- /*private function is_follow($user_id,$fans_id){
|
|
|
- $where = [
|
|
|
- 'user_id' => $user_id,
|
|
|
- 'fans_id' => $fans_id,
|
|
|
- ];
|
|
|
- $check = Db::name('user_fans_follow')->where($where)->find();
|
|
|
- if($check){
|
|
|
- return 1;
|
|
|
- }else{
|
|
|
- return 0;
|
|
|
- }
|
|
|
- }*/
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -799,173 +750,9 @@ class UserCenter extends Common
|
|
|
$this->success("获取成功!",\app\common\model\UserAnchorType::select());
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 加入黑名单
|
|
|
- */
|
|
|
- public function addBlacklist() {
|
|
|
- Db::startTrans();
|
|
|
- try {
|
|
|
- $black_user_id = $this->request->request('black_user_id'); // 黑名单用户ID
|
|
|
- if (!$black_user_id) {
|
|
|
- throw new Exception(__('Invalid parameters'));
|
|
|
- }
|
|
|
- $userblacklistModel = new \app\common\model\UserBlacklist();
|
|
|
- $data = [];
|
|
|
- $data["user_id"] = $this->auth->id;
|
|
|
- $data["black_user_id"] = $black_user_id;
|
|
|
- if($userblacklistModel->where($data)->find()) $this->error(__('已在黑名单!'));
|
|
|
- $data["createtime"] = time();
|
|
|
- $res = $userblacklistModel->insertGetId($data);
|
|
|
- if(!$res) {
|
|
|
- throw new Exception("网络错误,请稍后重试");
|
|
|
- }
|
|
|
- //im加入黑名单
|
|
|
- $tenimService = new TenimService();
|
|
|
- $params = [
|
|
|
- 'user_id' => $this->auth->id,
|
|
|
- 'black_user_ids' => [(string)$black_user_id],
|
|
|
- ];
|
|
|
- $imResult = $tenimService->addBlack($params);
|
|
|
- if (!$imResult['status']) {
|
|
|
- throw new Exception($imResult['msg']);
|
|
|
- }
|
|
|
- Db::commit();
|
|
|
- $this->success("加入成功!");
|
|
|
- } catch (Exception $e) {
|
|
|
- Db::rollback();
|
|
|
- $this->error($e->getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * 获取黑名单用户
|
|
|
- */
|
|
|
- public function getBlacklist() {
|
|
|
- $page = $this->request->request('page',1); // 分页
|
|
|
- $pageNum = $this->request->request('pageNum',10); // 分页
|
|
|
- // 分页搜索构建
|
|
|
- $pageStart = ($page-1)*$pageNum;
|
|
|
- $userblacklistModel = new \app\common\model\UserBlacklist();// ->limit($pageStart,$pageNum)
|
|
|
- $where = [];
|
|
|
- $where["a.user_id"] = $this->auth->id;
|
|
|
- $list = $userblacklistModel->alias("a")
|
|
|
- ->field("a.id,a.black_user_id,u.avatar,u.nickname,u.level,u.gender")
|
|
|
- ->join("hx_user u","u.id = a.black_user_id")
|
|
|
- ->where($where)
|
|
|
- ->limit($pageStart,$pageNum)
|
|
|
- ->select();
|
|
|
- if($list) {
|
|
|
- $this->success("获取成功!",$list);
|
|
|
- } else {
|
|
|
- $this->success("数据为空",[]);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * 移除用户黑名单
|
|
|
- */
|
|
|
- public function removeUserBlack() {
|
|
|
- Db::startTrans();
|
|
|
- try {
|
|
|
- $id = $this->request->request('id'); // 黑名单ID
|
|
|
- $userId = $this->request->request('user_id'); // 用户ID
|
|
|
- if (!$id && !$userId) {
|
|
|
- throw new Exception(__('Invalid parameters'));
|
|
|
- }
|
|
|
-
|
|
|
- $userblacklistModel = new \app\common\model\UserBlacklist();
|
|
|
- $where = [];
|
|
|
- $id && $where["id"] = $id;
|
|
|
- if ($userId) {
|
|
|
- $where['user_id'] = $this->auth->id;
|
|
|
- $where['black_user_id'] = $userId;
|
|
|
- }
|
|
|
- $userBlack = $userblacklistModel->where($where)->find();
|
|
|
- if (empty($userBlack)) {
|
|
|
- throw new Exception('未找到黑名单信息');
|
|
|
- }
|
|
|
- $blackUserId = isset($userBlack['black_user_id']) ? $userBlack['black_user_id'] : 0;
|
|
|
- $res = false;
|
|
|
- if (!empty($userBlack)) {
|
|
|
- $res = $userblacklistModel->where($where)->delete();
|
|
|
- }
|
|
|
- if(!$res) {
|
|
|
- $this->error("网络错误,请稍后重试!");
|
|
|
- }
|
|
|
- //im加入黑名单
|
|
|
- if (!empty($blackUserId)) {
|
|
|
- $tenimService = new TenimService();
|
|
|
- $params = [
|
|
|
- 'user_id' => $this->auth->id,
|
|
|
- 'black_user_ids' => [(string)$blackUserId],
|
|
|
- ];
|
|
|
- $imResult = $tenimService->delBlack($params);
|
|
|
- if (!$imResult['status']) {
|
|
|
- throw new Exception($imResult['msg']);
|
|
|
- }
|
|
|
- }
|
|
|
- Db::commit();
|
|
|
- $this->success("移除成功!",$res);
|
|
|
- } catch (Exception $e) {
|
|
|
- Db::rollback();
|
|
|
- $this->error($e->getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * 举报用户
|
|
|
- */
|
|
|
- /*public function addReport() {
|
|
|
- $ruser_id = $this->request->request('ruser_id'); // 被举报用户ID
|
|
|
- $content = $this->request->request('content'); // 举报内容
|
|
|
- $image = $this->request->request('image'); // 图片描述(多个用半角逗号隔开)
|
|
|
- if (!$ruser_id) {
|
|
|
- $this->error(__('Invalid parameters'));
|
|
|
- }
|
|
|
-
|
|
|
- $userreportModel = new \app\common\model\UserReport();
|
|
|
- $data = [];
|
|
|
- $data["user_id"] = $this->auth->id;
|
|
|
- $data["reportable_id"] = $ruser_id;
|
|
|
- $data['reportable_type'] = $this->getModelName('user');
|
|
|
- $data["content"] = $content;
|
|
|
- $data["image"] = $image;
|
|
|
- $data["createtime"] = time();
|
|
|
- $res = $userreportModel->insertGetId($data);
|
|
|
- if($res) {
|
|
|
- $this->success("举报成功!");
|
|
|
- } else {
|
|
|
- $this->error("网络错误,请稍后重试");
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
- /**
|
|
|
- * 举报
|
|
|
- */
|
|
|
- /*public function addReportNew() {
|
|
|
- $params = $this->request->param();
|
|
|
- $validate = new Report();
|
|
|
- $result = $validate->check($params);
|
|
|
- if (!$result) {
|
|
|
- $this->error($validate->getError());
|
|
|
- }
|
|
|
-
|
|
|
- $userreportModel = new \app\common\model\UserReport();
|
|
|
- $data = [];
|
|
|
- $data["user_id"] = $this->auth->id;
|
|
|
- $data["reportable_id"] = $params['reportable_id'];
|
|
|
-
|
|
|
- $data['reportable_type'] = $this->getModelName($params['reportable_type']);
|
|
|
- $data["content"] = $params['content'];
|
|
|
- $data["image"] = $params['image'];
|
|
|
- $data["createtime"] = time();
|
|
|
- $res = $userreportModel->insertGetId($data);
|
|
|
- if($res) {
|
|
|
- $this->success("举报成功!");
|
|
|
- } else {
|
|
|
- $this->error("网络错误,请稍后重试");
|
|
|
- }
|
|
|
- }*/
|
|
|
|
|
|
/**
|
|
|
* redis 数据恢复---非redis数据丢失请勿使用!!!!
|