|
@@ -3,11 +3,11 @@
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
use app\common\controller\Api;
|
|
|
+use app\utils\RedisUtil;
|
|
|
use think\Request;
|
|
|
use getusersig\getusersig;
|
|
|
use tencentim\tencentim;
|
|
|
use think\Db;
|
|
|
-use Redis;
|
|
|
|
|
|
|
|
|
* 腾讯im接口
|
|
@@ -485,10 +485,7 @@ exit;
|
|
|
if($groupInfo["ErrorCode"] == 0) $groupsites[] = $groupInfo["GroupInfo"][0];
|
|
|
|
|
|
|
|
|
- $redis = new Redis();
|
|
|
- $redisconfig = config("redis");
|
|
|
- $redis->connect($redisconfig["host"], $redisconfig["port"]);
|
|
|
- $redis->HDel("online_".$v["GroupId"],$user_id);
|
|
|
+ RedisUtil::getInstance('online',$v["GroupId"])->HDel($user_id);
|
|
|
}
|
|
|
|
|
|
$this->downSite($user_id,$groupsites);
|
|
@@ -506,10 +503,7 @@ exit;
|
|
|
$userInfo = \app\common\model\User::field("avatar")->where(["id"=>$user_id])->find();
|
|
|
$userAvatar = isset($userInfo["avatar"])?$userInfo["avatar"]:"";
|
|
|
|
|
|
- $redis = new Redis();
|
|
|
- $redisconfig = config("redis");
|
|
|
- $redis->connect($redisconfig["host"], $redisconfig["port"]);
|
|
|
- $redisData = $redis->get("party_".$party_id);
|
|
|
+ $redisData = RedisUtil::getInstance('party',$party_id)->get();
|
|
|
if(!$redisData) {
|
|
|
return true;
|
|
|
}
|
|
@@ -519,8 +513,7 @@ exit;
|
|
|
$partyuser = isset($partyInfo["party_user"])?$partyInfo["party_user"]:"";
|
|
|
if(is_array($partyuser)) foreach($partyuser as $k => $v) if($v === $userAvatar) unset($partyInfo["party_user"][$k]);
|
|
|
|
|
|
- $redis->set("party_".$party_id,json_encode($partyInfo));
|
|
|
-
|
|
|
+ RedisUtil::getInstance('party',$party_id)->set(json_encode($partyInfo));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -531,10 +524,7 @@ exit;
|
|
|
if (!$party_id || !$user_id) {
|
|
|
return false;
|
|
|
}
|
|
|
- $redis = new Redis();
|
|
|
- $redisconfig = config("redis");
|
|
|
- $redis->connect($redisconfig["host"], $redisconfig["port"]);
|
|
|
- $data=unserialize($redis->hGet("party_lineup",$party_id));
|
|
|
+ $data=unserialize(RedisUtil::getInstance('party_lineup')->hGet($party_id));
|
|
|
|
|
|
$num = 0;
|
|
|
$send = false;
|
|
@@ -545,7 +535,7 @@ exit;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- $redis->hSet("party_lineup",$party_id,serialize($data));
|
|
|
+ RedisUtil::getInstance('party_lineup')->hSet($party_id,serialize($data));
|
|
|
|
|
|
if($send) {
|
|
|
is_array($data) && $num = count($data);
|
|
@@ -665,15 +655,11 @@ exit;
|
|
|
|
|
|
}elseif($input['EventType'] == 103){
|
|
|
|
|
|
- $redis = new Redis();
|
|
|
- $redisconfig = config("redis");
|
|
|
- $redis->connect($redisconfig["host"], $redisconfig["port"]);
|
|
|
-
|
|
|
$userId = $input['EventInfo']['UserId'];
|
|
|
- $redis->hSet("online_" . $roomId, $userId, $userId);
|
|
|
+ RedisUtil::getInstance('online',$roomId)->hSet($userId, $userId);
|
|
|
|
|
|
|
|
|
- $redis->hSet("livingUser",$userId,$roomId);
|
|
|
+ RedisUtil::getInstance('livingUser')->hSet($userId,$roomId);
|
|
|
|
|
|
|
|
|
$partyInfo = $redis->get("party_" . $roomId);
|
|
@@ -700,34 +686,30 @@ exit;
|
|
|
|
|
|
}elseif($input['EventType'] == 104){
|
|
|
|
|
|
- $redis = new Redis();
|
|
|
- $redisconfig = config("redis");
|
|
|
- $redis->connect($redisconfig["host"], $redisconfig["port"]);
|
|
|
-
|
|
|
$userId = $input['EventInfo']['UserId'];
|
|
|
- $redis->HDel("online_" . $roomId, $userId);
|
|
|
+ RedisUtil::getInstance('online',$roomId)->HDel($userId);
|
|
|
|
|
|
|
|
|
- $redis->hDel("livingUser",$userId);
|
|
|
+ RedisUtil::getInstance('livingUser')->hDel($userId);
|
|
|
|
|
|
|
|
|
- $partyInfo = $redis->get("party_" . $roomId);
|
|
|
+ $partyInfo = RedisUtil::getInstance('party',$roomId)->get();
|
|
|
if ($partyInfo) {
|
|
|
$partyInfo = json_decode($partyInfo, true);
|
|
|
- $memCount = count($redis->hGetAll("online_" . $roomId));
|
|
|
+ $memCount = count(RedisUtil::getInstance('online',$roomId)->hGetAll());
|
|
|
if ($memCount <= 0) {
|
|
|
$partyInfo["is_online"] = 0;
|
|
|
- $redis->set("party_" . $roomId, json_encode($partyInfo));
|
|
|
+ RedisUtil::getInstance('party',$roomId)->set(json_encode($partyInfo));
|
|
|
\app\common\model\Party::update(["is_online" => 0], ["id" => $roomId]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $liveInfo = $redis->get("livebc_" . $roomId);
|
|
|
+ $liveInfo = RedisUtil::getInstance('livebc',$roomId)->get();
|
|
|
if ($liveInfo) {
|
|
|
$liveInfo = json_decode($liveInfo, true);
|
|
|
if($input['EventInfo']['Role'] == 20){
|
|
|
$liveInfo["is_online"] = 0;
|
|
|
- $redis->set("livebc_" . $roomId, json_encode($liveInfo));
|
|
|
+ RedisUtil::getInstance('livebc',$roomId)->set(json_encode($liveInfo));
|
|
|
\app\common\model\Party::update(["is_online" => 0], ["id" => $roomId]);
|
|
|
$rs_user = Db::name('user')->where('id',$userId)->update(['is_livebc'=>0]);
|
|
|
}
|
|
@@ -782,14 +764,11 @@ exit;
|
|
|
|
|
|
|
|
|
|
|
|
- $redis = new Redis();
|
|
|
- $redisconfig = config("redis");
|
|
|
- $redis->connect($redisconfig["host"], $redisconfig["port"]);
|
|
|
- $livingUserPartyId = $redis->hGet("livingUser", $info["To_Account"]);
|
|
|
+ $livingUserPartyId = RedisUtil::getInstance('livingUser')->hGet($info["To_Account"]);
|
|
|
if ($livingUserPartyId) {
|
|
|
|
|
|
- $redis->hDel("livingUser", $info["To_Account"]);
|
|
|
- $redis->HDel("online_" . $livingUserPartyId, $info["To_Account"]);
|
|
|
+ RedisUtil::getInstance('livingUser')->hDel( $info["To_Account"]);
|
|
|
+ RedisUtil::getInstance('online',$livingUserPartyId)->HDel($info["To_Account"]);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -805,10 +784,7 @@ exit;
|
|
|
if($groupInfo["ErrorCode"] == 0) $groupsites[] = $groupInfo["GroupInfo"][0];
|
|
|
|
|
|
|
|
|
- $redis = new Redis();
|
|
|
- $redisconfig = config("redis");
|
|
|
- $redis->connect($redisconfig["host"], $redisconfig["port"]);
|
|
|
- $redis->HDel("online_".$v["GroupId"],$info["To_Account"]);
|
|
|
+ RedisUtil::getInstance('online',$v["GroupId"])->HDel($info["To_Account"]);
|
|
|
|
|
|
|
|
|
$this->updatePosition($info["To_Account"],$v["GroupId"]);
|
|
@@ -817,24 +793,24 @@ exit;
|
|
|
$this->cancelLineup($info["To_Account"],$v["GroupId"]);
|
|
|
|
|
|
|
|
|
- $partyInfo = $redis->get("party_".$v["GroupId"]);
|
|
|
+ $partyInfo = RedisUtil::getInstance('party',$v["GroupId"])->get();
|
|
|
if($partyInfo) {
|
|
|
$partyInfo = json_decode($partyInfo,true);
|
|
|
- $memCount = count($redis->hGetAll("online_".$v["GroupId"]));
|
|
|
+ $memCount = count(RedisUtil::getInstance('online',$v["GroupId"])->hGetAll());
|
|
|
if($memCount <= 0) {
|
|
|
$partyInfo["is_online"] = 0;
|
|
|
- $redis->set("party_".$v["GroupId"],json_encode($partyInfo));
|
|
|
+ RedisUtil::getInstance('party',$v["GroupId"])->set(json_encode($partyInfo));
|
|
|
\app\common\model\Party::update(["is_online"=>0],["id"=>$v["GroupId"]]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $liveInfo = $redis->get("live_".$v["GroupId"]);
|
|
|
+ $liveInfo = RedisUtil::getInstance('live',$v["GroupId"])->get();
|
|
|
if($liveInfo) {
|
|
|
$liveInfo = json_decode($liveInfo,true);
|
|
|
- $memCount = count($redis->hGetAll("online_".$v["GroupId"]));
|
|
|
+ $memCount = count(RedisUtil::getInstance('online',$v["GroupId"])->hGetAll());
|
|
|
if($memCount <= 0) {
|
|
|
$liveInfo["is_online"] = 0;
|
|
|
- $redis->set("live_".$v["GroupId"],json_encode($liveInfo));
|
|
|
+ RedisUtil::getInstance('live',$v["GroupId"])->set(json_encode($liveInfo));
|
|
|
\app\common\model\Party::update(["is_online"=>0],["id"=>$v["GroupId"]]);
|
|
|
}
|
|
|
}
|
|
@@ -847,12 +823,9 @@ exit;
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -872,33 +845,30 @@ exit;
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|