浏览代码

送礼物优化

lizhen_gitee 1 年之前
父节点
当前提交
92ff7a04ba
共有 2 个文件被更改,包括 27 次插入5 次删除
  1. 5 4
      application/api/controller/Party.php
  2. 22 1
      application/index/controller/Plantask.php

+ 5 - 4
application/api/controller/Party.php

@@ -2303,15 +2303,16 @@ class Party extends Api
             $this->redis->hSet("user_jewel_top3",$party_info['id'],json_encode($avatarArr));
 
         }
+        return $avatarArr;
 
-        //[环信]更新财富榜前3。
-        $easemob = new Easemob();
+        //[环信]更新财富榜前3。放到异步了
+        /*$easemob = new Easemob();
         $matedata = [
             'wealth_top3_userlist'  => json_encode($avatarArr),
         ];
-        $easemob->room_setRoomCustomAttributeForced($party_info['easemob_room_id'],$party_info['user_id'],$matedata);
+        $easemob->room_setRoomCustomAttributeForced($party_info['easemob_room_id'],$party_info['user_id'],$matedata);*/
+
 
-        return $avatarArr;
     }
 
     /**

+ 22 - 1
application/index/controller/Plantask.php

@@ -4,7 +4,7 @@ namespace app\index\controller;
 
 use think\Controller;
 
-use app\common\library\Tlssigapiv2;
+use Redis;
 use think\Db;
 use app\common\library\Easemob;
 class Plantask extends Controller
@@ -26,6 +26,17 @@ class Plantask extends Controller
         }
 
         try {
+            //redis
+            $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']);
+            }
+
             $money_to_jewel = config('site.money_to_jewel') ?: 10; //余额兑换金币
 //            $getempirical_conf = config("site.getempirical");
 
@@ -106,6 +117,16 @@ class Plantask extends Controller
                 //增加送礼用户的财富等级
                 $res_wealth = \app\common\model\User::add_wealth_level($giftuserparty['user_id'],$giftValue);
 
+                // tcp 获取房间用户周前三名 getPartyUserTop里面摘出来的一部分
+                //[环信]更新财富榜前3。
+                $avatarArr = $redis->hGet("user_jewel_top3",$partyInfo['id']);
+                $easemob = new Easemob();
+                $matedata = [
+                    'wealth_top3_userlist'  => $avatarArr,
+                ];
+                $easemob->room_setRoomCustomAttributeForced($partyInfo['easemob_room_id'],$partyInfo['user_id'],$matedata);
+
+                //结束
                 $rs_up = Db::name('gift_user_party')->where('id',$giftuserparty['id'])->update(['task_status'=>1]);
                 if($rs_up === false){
                     Db::rollback();