Browse Source

派对收藏与初始化

lizhen_gitee 1 year ago
parent
commit
66c7f01b0d
1 changed files with 35 additions and 66 deletions
  1. 35 66
      application/api/controller/Party.php

+ 35 - 66
application/api/controller/Party.php

@@ -138,15 +138,15 @@ class Party extends Common
             //[环信]初始化8个麦位
             //[环信]初始化已点歌曲列表
             $matedata = [
-                'seat1'  => json_decode([]),
-                'seat2'  => json_decode([]),
-                'seat3'  => json_decode([]),
-                'seat4'  => json_decode([]),
-                'seat5'  => json_decode([]),
-                'seat6'  => json_decode([]),
-                'seat7'  => json_decode([]),
-                'seat8'  => json_decode([]),
-                'waitsing_list'  => json_decode([]),
+                'seat1'  => json_encode([]),
+                'seat2'  => json_encode([]),
+                'seat3'  => json_encode([]),
+                'seat4'  => json_encode([]),
+                'seat5'  => json_encode([]),
+                'seat6'  => json_encode([]),
+                'seat7'  => json_encode([]),
+                'seat8'  => json_encode([]),
+                'waitsing_list'  => json_encode([]),
             ];
             $rs = $easemob->room_setRoomCustomAttributeForced($easemob_room_id,$this->auth->id,$matedata);
 
@@ -350,7 +350,9 @@ class Party extends Common
             $redis->select($redisconfig['redis_selectdb']);
         }
         $redisPartyRankList = $redis->zRevRange("partyRank",0,-1,true);
+        dump($redisPartyRankList);
         $redisLiveRankList = $redis->zRevRange("liveRank",0,-1,true);
+        dump($redisLiveRankList);
 
         $roomService = new RoomService();
         if(!$redisPartyRankList) {//party
@@ -731,9 +733,16 @@ class Party extends Common
         $heads = $redis->hGet("user_jewel_top3",$party_id);
         $lsetList["userJewelTop3"] = $heads?json_decode($heads,true):[];
 
-        // 判断当前用户是否收藏了此房间
-        $cellection = $redis->hGet("room_cellection",$user_id."-".$party_id);
-        $lsetList["is_cellection"] = $cellection?1:0;
+
+        // 获取是否被当前用户关注
+        $lsetList["is_follow"] = 0;
+        $where = [];
+        $where["user_id"] = $user_id;
+        $where["party_id"] = $party_id;
+        if(Db::name('party_follow')->where($where)->find()) {
+            $lsetList["is_follow"] = 1;
+        }
+
         if(isset($partyInfo["type_name"]) && $partyInfo["type_name"]) {
 //            $partyInfo["type_name"] = $partyInfo["type_name"];
         } else {
@@ -914,40 +923,28 @@ class Party extends Common
     }
 
     /**
-     * 派对收藏
+     * 派对关注
      */
-    public function cellectionParty() {
+    public function followparty() {
         $party_id = input('party_id',0,"intval"); // 直播间ID
         if (!$party_id) {
             $this->error(__('Invalid parameters'));
         }
         $user_id = $this->auth->id;
-        $redis = new Redis();
-        $redisconfig = config("redis");
-        $redis->connect($redisconfig["host"], $redisconfig["port"]);
-        if ($redisconfig['redis_pwd']) {
-            $redis->auth($redisconfig['redis_pwd']);
-        }
-        if($redisconfig['redis_selectdb'] > 0){
-            $redis->select($redisconfig['redis_selectdb']);
-        }
 
-        $partycellectionModel = new \app\common\model\PartyCellection();
         // 添加记录
         $data = [];
         $data["user_id"] = $user_id;
         $data["party_id"] = $party_id;
-        if($partycellectionModel->where($data)->find()) {
-            $res = $partycellectionModel->where($data)->delete();
-            $redis->hDel("room_cellection",$user_id."-".$party_id);
-            return $this->success("取消收藏成功!",$res);
+        if(Db::name('party_follow')->where($data)->find()) {
+            $res = Db::name('party_follow')->where($data)->delete();
+
+            $this->success("已取消关注");
         }
         $data["createtime"] = time();
-        $res = $partycellectionModel->insert($data);
-
-        $redis->hSet("room_cellection",$user_id."-".$party_id,1);
+        $res = Db::name('party_follow')->insert($data);
 
-        return $this->success("收藏成功!",$res);
+        $this->success("已关注");
     }
 
     /**
@@ -959,7 +956,6 @@ class Party extends Common
         // 分页搜索构建
         $pageStart = ($page-1)*$pageNum;
         $partycellectionModel = new \app\common\model\PartyCellection();
-        $userModel = new \app\common\model\User();
         $where = [];
         $where["a.user_id"] = $this->auth->id;
         $where["r.room_type"] = 1;
@@ -972,34 +968,7 @@ class Party extends Common
             ->select();
 
         if($list) {
-//            $redis = new Redis();
-//            $redisconfig = config("redis");
-//            $redis->connect($redisconfig["host"], $redisconfig["port"]);
-            /*if ($redisconfig['redis_pwd']) {
-                $redis->auth($redisconfig['redis_pwd']);
-            }
-            if($redisconfig['redis_selectdb'] > 0){
-                $redis->select($redisconfig['redis_selectdb']);
-            }*/
-//            // 获取本周第一天
-//            $weekday = $this->firstOfWeek(date("Y-m-d H:i:s"));
-//            // 获取redis 中 用户排行榜前五名
-//            foreach($list as $k => $v) {
-//                $getweek = $redis->zRevRange("party_jewel_get_".$v["r_id"].":".$weekday,0,4,true);
-//                $userlist = $userModel->rankList($getweek);
-//                if($userlist) {
-//                    $users = [];
-//                    foreach($userlist as $m => $n) {
-//                        $users[] = $n["avatar"];
-//                    }
-//                    $list[$k]["users"] = $users;
-//                } else {
-//                    $list[$k]["users"] = [];
-//                }
-//
-//                $mod = isset($v["party_type_id"])?intval($v["party_type_id"])%5:1;
-//                $list[$k]["party_type_color"] = $mod == 0?5:$mod;
-//            }
+
 
             $users = [];
             foreach($list as $k => $v) {
@@ -1023,7 +992,6 @@ class Party extends Common
         }
         $user_id = $this->auth->id;
         $partyModel = new \app\common\model\Party();
-        $partycellectionModel = new \app\common\model\PartyCellection();
         $userModel = new \app\common\model\User();
         // 获取主体信息
         $where = [];
@@ -1044,14 +1012,15 @@ class Party extends Common
                 $partyInfo["type_name"] = "普通房";
             }
 
-            // 获取是否被当前用户收藏
-            $partyInfo["is_sellection"] = 0;
+            // 获取是否被当前用户关注
+            $partyInfo["is_follow"] = 0;
             $where = [];
             $where["user_id"] = $user_id;
             $where["party_id"] = $party_id;
-            if($partycellectionModel->where($where)->find()) {
-                $partyInfo["is_sellection"] = 1;
+            if(Db::name('party_follow')->where($where)->find()) {
+                $partyInfo["is_follow"] = 1;
             }
+
             // 获取房主信息
             $where = [];
             $where["id"] = $partyInfo["user_id"];