瀏覽代碼

派对设置1=房管,2=禁言,3=拉黑,4=踢出

lizhen_gitee 1 年之前
父節點
當前提交
e40fb14518
共有 2 個文件被更改,包括 22 次插入12 次删除
  1. 17 12
      application/api/controller/Party.php
  2. 5 0
      application/common/library/Easemob.php

+ 17 - 12
application/api/controller/Party.php

@@ -1197,10 +1197,10 @@ class Party extends Api
     }
 
     //腾讯im设置管理员
-    private function setGroupAdmin($user_id,$party_id,$status)
+    private function setGroupAdmin($user_id,$easemob_room_id)
     {
-        $tenIm = new Tenim();
-        return $tenIm->setUpIMAdmin($user_id, $party_id,$status);
+        $easemob = new Easemob();
+        $easemob->room_promoteRoomAdmin($user_id,$easemob_room_id);
     }
 
     /**
@@ -1215,19 +1215,21 @@ class Party extends Api
             $this->error(__('Invalid parameters'));
         }
 
+        //2=禁言,3=拉黑,4=踢出 ,都要有时间
         if($item>1 && $time<=0) {
             $this->error(__('时间设置有误'));
         }
 
-        $partyUserId = \app\common\model\Party::where('id', $party_id)->value('user_id');
-        if ($partyUserId == $user_id && in_array($item, [2, 3, 4])) {
+        //不能对房主恶意操作
+        $partyinfo = \app\common\model\Party::where('id', $party_id)->field('user_id,easemob_room_id')->find();
+        if ($partyinfo['user_id'] == $user_id && in_array($item, [2, 3, 4])) {
             $this->error("您当前无权限操作!");
         }
 
         // 获取用户信息
-        $userInfo = \app\common\model\User::field("avatar,nickname,gender,level")->where(["id"=>$user_id])->find();
+        $userInfo = \app\common\model\User::field("avatar,nickname,gender")->where(["id"=>$user_id])->find();
         if(!$userInfo) $this->error("用户信息获取失败!");
-        // 贵族防踢。
+
 
 
         $data = [];
@@ -1235,13 +1237,16 @@ class Party extends Api
         $data["avatar"] = $userInfo->avatar;
         $data["nickname"] = $userInfo->nickname;
         $data["gender"] = $userInfo->gender;
-        $data["level"] = $userInfo->level;
         $data["item"] = $item;
         $data["time"] = $time;
         $data["createtime"] = time();
 
         $res = $this->redis->hSet("party_manage_".$party_id,$user_id."-".$item,serialize($data));
 
+        if ($item==1) {
+            $this->setGroupAdmin($user_id,$partyinfo['easemob_room_id']);
+        }
+
         if($res !== false) {
             $this->success("设置成功!",$data);
         } else {
@@ -1602,7 +1607,7 @@ class Party extends Api
         }
 
         $userauthid = $this->auth->id;
-        $money_to_jewel = config('site.money_to_jewel') ?: 10; //余额兑换钻石
+        $money_to_jewel = config('site.money_to_jewel') ?: 10; //余额兑换金币
 
         // 不可以赠送给自己
         //if(in_array($userauthid,$user_id_arr)) $this->error("不可以赠送给自己!");
@@ -1668,7 +1673,7 @@ class Party extends Api
             $giftCountValue = $giftInfo["value"] * $number * $userCount;
             $user_jewel = model('wallet')->getWallet($this->auth->id,'jewel');
             if($user_jewel < $giftCountValue){
-                $this->error("您的钻石余额不足!");
+                $this->error("您的金币余额不足!");
             }
 
         }
@@ -1726,7 +1731,7 @@ class Party extends Api
                 } else {
                     $res1 = true;
 
-                    // 扣除当前用户钻石余额
+                    // 扣除当前用户金币余额
                     $rs_wallet = model('wallet')->lockChangeAccountRemain($userauthid, $giftValue, '-', 0, "赠送礼物:'" . $giftInfo["name"] . "',扣除" . $giftValue . "金币!", 3,'jewel');
                     if($rs_wallet['status'] == false){
                         Db::rollback();
@@ -1845,7 +1850,7 @@ class Party extends Api
                     \app\common\model\TaskLog::tofinish($this->auth->id,"OBHqCX4g",$number);
                     */
                     // +message
-                    //\app\common\model\Message::addMessage($user_id,"礼物通知","收到 ".$this->auth->nickname." 赠送的".$giftInfo["name"]." x".$number." 价值 ".$giftValue ." 钻石");
+                    //\app\common\model\Message::addMessage($user_id,"礼物通知","收到 ".$this->auth->nickname." 赠送的".$giftInfo["name"]." x".$number." 价值 ".$giftValue ." 金币");
 
                     $allVal = $allVal + $hotValue;
 

+ 5 - 0
application/common/library/Easemob.php

@@ -229,6 +229,11 @@ class Easemob {
     //批量移除聊天室成员
     //获取聊天室管理员列表
     //添加聊天室管理员
+    public function room_promoteRoomAdmin($roomId, $newadmin){
+        $newadmin = ''.$newadmin.'';
+        $rs = $this->room->promoteRoomAdmin($roomId, $newadmin);
+        return $rs;
+    }
     //移除聊天室管理员
 
     //////////////////管理黑名单///////////