lizhen_gitee 3 years ago
parent
commit
3a6e879cc6
2 changed files with 22 additions and 11 deletions
  1. 12 3
      application/api/controller/Livebc.php
  2. 10 8
      application/index/controller/Test.php

+ 12 - 3
application/api/controller/Livebc.php

@@ -203,7 +203,6 @@ class Livebc extends Api
         dump($avatarArr);
     }
 
-
     //准备返回数据,刷礼物的总值,刷礼物人数,榜一信息
     public function outlivebc(){
         $party_id = input('party_id');
@@ -221,9 +220,19 @@ class Livebc extends Api
         // 获取3条财富排行周记录
         $getweek = $redis->zRevRange("livebc_jewel_to_".$party_id,0,$num-1,true);
         $userList = $userModel->rankList($getweek);
+        dump($getweek);
+        dump($userList);
 
-        //主播共获得礼物值
-        //$valuesum = $redis->get('livebc_jewel_get_'.$party_id,$this->auth->id);
+        $avatarArr = [];
+        if($userList) {
+            foreach($userList as $k => $v) {
+                $v["jewel"] > 0 && $avatarArr[] = $v["avatar"];
+            }
+            // 加入缓存做备份
+            $redis->hSet("user_jewel_top3",$party_id,json_encode($avatarArr));
+            //$redis->hSet("livebc_jewel_top3",$party_id,json_encode($avatarArr));
+        }
+        dump($avatarArr);
 
     }
 

+ 10 - 8
application/index/controller/Test.php

@@ -7,12 +7,12 @@ use Redis;
 class Test
 {
 
-    public function redis(){
-
-        $partyUserTop = $this->getPartyUserTop(54);
-    }
+    public function outlivebc(){
+        $party_id = input('party_id');
+        if(empty($party_id)){
+            $this->error();
+        }
 
-    private function getPartyUserTop($party_id) {
         $redis = new Redis();
         $redisconfig = config("redis");
         $redis->connect($redisconfig["host"], $redisconfig["port"]);
@@ -36,16 +36,18 @@ class Test
             //$redis->hSet("livebc_jewel_top3",$party_id,json_encode($avatarArr));
         }
         dump($avatarArr);
+
     }
 
     public function clear(){
-        $user_id = 26;
+        $paery_id = 54;
         //清空房间排行榜
         $redis = new Redis();
         $redisconfig = config("redis");
         $redis->connect($redisconfig["host"], $redisconfig["port"]);
-        $redis->del('livebc_jewel_to_' . $user_id);
-        $redis->hDel("livebc_jewel_top3",$user_id);
+        $redis->del('livebc_jewel_to_' . $paery_id);
+        $redis->del('livebc_jewel_get_' . $paery_id);
+        $redis->hDel("user_jewel_top3",$paery_id);
     }