|
@@ -23,10 +23,24 @@ class Party extends Common
|
|
|
protected $noNeedLogin = ['updatePartyInfo','getPatyType','addUserPositionToParty', 'clearMoney','clearCharm','getPartyRankList','getDefaultBackground','getPartGifList','getPartHeadgifList','isNotalk','getMusicList','updateTops','handleParty'];
|
|
|
protected $noNeedRight = ['*'];
|
|
|
|
|
|
+ protected $redis;
|
|
|
+
|
|
|
public function __construct(Request $request = null)
|
|
|
{
|
|
|
$this->roomTypeArr = [1=>"party",2=>"live"];
|
|
|
|
|
|
+ //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']);
|
|
|
+ }
|
|
|
+ $this->redis = $redis;
|
|
|
+
|
|
|
parent::__construct($request);
|
|
|
}
|
|
|
|
|
@@ -81,15 +95,7 @@ class Party extends Common
|
|
|
|
|
|
|
|
|
// 判断派对是否存在
|
|
|
- $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']);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
$where = [];
|
|
|
$where["user_id"] = $user_id;
|
|
@@ -199,9 +205,9 @@ class Party extends Common
|
|
|
$partyInfo["type_name"] = $partyTypeName;
|
|
|
|
|
|
// 加入缓存排序,rediskey:派对热度
|
|
|
- $redis->zAdd($this->roomTypeArr[$room_type]."Rank", $partyInfo['party_hot'], $partyInfo["id"]);
|
|
|
+ $this->redis->zAdd($this->roomTypeArr[$room_type]."Rank", $partyInfo['party_hot'], $partyInfo["id"]);
|
|
|
// 加入缓存,rediskey:派对详情
|
|
|
- $redis->set($this->roomTypeArr[$room_type]."_".$partyInfo["id"],json_encode($partyInfo));
|
|
|
+ $this->redis->set($this->roomTypeArr[$room_type]."_".$partyInfo["id"],json_encode($partyInfo));
|
|
|
|
|
|
if($room_type != 2) {
|
|
|
// 创建公会
|
|
@@ -251,19 +257,11 @@ class Party extends Common
|
|
|
$res = $partyInfo->delete();
|
|
|
if($res !== false) {
|
|
|
// 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']);
|
|
|
- }
|
|
|
+
|
|
|
//rediskey:派对热度
|
|
|
- $redis->zRem($this->roomTypeArr[$room_type]."Rank",$party_id);
|
|
|
+ $this->redis->zRem($this->roomTypeArr[$room_type]."Rank",$party_id);
|
|
|
//rediskey:派对详情
|
|
|
- $redis->del($this->roomTypeArr[$room_type]."_".$party_id);
|
|
|
+ $this->redis->del($this->roomTypeArr[$room_type]."_".$party_id);
|
|
|
$this->success("删除成功!");
|
|
|
} else {
|
|
|
$this->error("删除失败!");
|
|
@@ -285,17 +283,9 @@ class Party extends Common
|
|
|
$start = ($thispage-1)*$pagenum;
|
|
|
$end = $start+($pagenum-1);
|
|
|
// 获取排序
|
|
|
- $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']);
|
|
|
- }
|
|
|
+
|
|
|
//rediskey:派对热度
|
|
|
- $redisPartyRankList = $redis->zRevRange($this->roomTypeArr[$room_type]."Rank",0,-1,true);
|
|
|
+ $redisPartyRankList = $this->redis->zRevRange($this->roomTypeArr[$room_type]."Rank",0,-1,true);
|
|
|
|
|
|
$partyModel = new \app\common\model\Party();
|
|
|
if(!$redisPartyRankList) {
|
|
@@ -314,17 +304,17 @@ class Party extends Common
|
|
|
foreach($sqlPartyList as $k => $v) {
|
|
|
// 加入缓存排序
|
|
|
//rediskey:派对热度
|
|
|
- $redis->zAdd($this->roomTypeArr[$room_type]."Rank", $v['party_hot'], $v["id"]);
|
|
|
+ $this->redis->zAdd($this->roomTypeArr[$room_type]."Rank", $v['party_hot'], $v["id"]);
|
|
|
// 设置冠名
|
|
|
$sqlPartyList[$k]["naming"] = isset($userInfoArr[$v["naming"]])?$userInfoArr[$v["naming"]]:[];
|
|
|
// 设置房主头像
|
|
|
$sqlPartyList[$k]["avatar"] = isset($userInfoArr[$v["user_id"]])?$userInfoArr[$v["user_id"]]["avatar"]:[];
|
|
|
// 加入缓存
|
|
|
//rediskey:派对详情
|
|
|
- $redis->set($this->roomTypeArr[$room_type]."_".$v["id"],json_encode($v));
|
|
|
+ $this->redis->set($this->roomTypeArr[$room_type]."_".$v["id"],json_encode($v));
|
|
|
}
|
|
|
//rediskey:派对热度
|
|
|
- $redisPartyRankList = $redis->zRevRange($this->roomTypeArr[$room_type]."Rank",0,-1,true);
|
|
|
+ $redisPartyRankList = $this->redis->zRevRange($this->roomTypeArr[$room_type]."Rank",0,-1,true);
|
|
|
}
|
|
|
}
|
|
|
if($redisPartyRankList) {
|
|
@@ -352,21 +342,10 @@ class Party extends Common
|
|
|
$start = ($thispage-1)*$pagenum;
|
|
|
$end = $start+($pagenum-1);
|
|
|
|
|
|
- // 获取排序
|
|
|
- $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']);
|
|
|
- }
|
|
|
-
|
|
|
//rediskey:派对热度
|
|
|
- $redisPartyRankList = $redis->zRevRange("partyRank",0,-1,true);
|
|
|
+ $redisPartyRankList = $this->redis->zRevRange("partyRank",0,-1,true);
|
|
|
//rediskey:派对热度
|
|
|
- $redisLiveRankList = $redis->zRevRange("liveRank",0,-1,true);
|
|
|
+ $redisLiveRankList = $this->redis->zRevRange("liveRank",0,-1,true);
|
|
|
|
|
|
$roomService = new RoomService();
|
|
|
if(!$redisPartyRankList) {//party
|
|
@@ -412,15 +391,7 @@ class Party extends Common
|
|
|
$room_type = input('room_type',1); // 房间类型
|
|
|
$party_id = input("party_id");// 派对ID
|
|
|
if (!$party_id) $this->error(__('Invalid parameters'));
|
|
|
- $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']);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
$res = [];
|
|
|
// 获取今天
|
|
@@ -434,30 +405,30 @@ class Party extends Common
|
|
|
$num = 50;
|
|
|
|
|
|
// 获取50条财富排行日记录
|
|
|
- $getday = $redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_get_".$party_id.":".$day."d",0,$num-1,true);
|
|
|
+ $getday = $this->redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_get_".$party_id.":".$day."d",0,$num-1,true);
|
|
|
$res['getRankListDay'] = $userModel->rankList($getday);
|
|
|
|
|
|
// 获取50条财富排行日记录
|
|
|
- $today = $redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_to_".$party_id.":".$day."d",0,$num-1,true);
|
|
|
+ $today = $this->redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_to_".$party_id.":".$day."d",0,$num-1,true);
|
|
|
$res['toRankListDay'] = $userModel->rankList($today);
|
|
|
|
|
|
|
|
|
// 获取50条财富排行周记录
|
|
|
- $getweek = $redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_get_".$party_id.":".$weekday."w",0,$num-1,true);
|
|
|
+ $getweek = $this->redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_get_".$party_id.":".$weekday."w",0,$num-1,true);
|
|
|
$res['getRankListWeek'] = $userModel->rankList($getweek);
|
|
|
|
|
|
// 获取50条贡献排行周记录
|
|
|
- $toweek = $redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_to_".$party_id.":".$weekday."w",0,$num-1,true);
|
|
|
+ $toweek = $this->redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_to_".$party_id.":".$weekday."w",0,$num-1,true);
|
|
|
$res['toRankListWeek'] = $userModel->rankList($toweek);
|
|
|
|
|
|
|
|
|
|
|
|
// 获取50条财富排行月记录
|
|
|
- $toweek = $redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_get_".$party_id.":".$monthday."m",0,$num-1,true);
|
|
|
+ $toweek = $this->redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_get_".$party_id.":".$monthday."m",0,$num-1,true);
|
|
|
$res['getRankListMonth'] = $userModel->rankList($toweek);
|
|
|
|
|
|
// 获取50条贡献排行周记录
|
|
|
- $toweek = $redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_to_".$party_id.":".$monthday."m",0,$num-1,true);
|
|
|
+ $toweek = $this->redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_to_".$party_id.":".$monthday."m",0,$num-1,true);
|
|
|
$res['toRankListMonth'] = $userModel->rankList($toweek);
|
|
|
|
|
|
return $this->success("获取成功!",$res);
|
|
@@ -473,17 +444,9 @@ class Party extends Common
|
|
|
if (!$party_id || !$party_hot) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
- $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']);
|
|
|
- }
|
|
|
+
|
|
|
// 更新热度
|
|
|
- $redis->zIncrBy($this->roomTypeArr[$room_type]."Rank", $party_hot, $party_id);
|
|
|
+ $this->redis->zIncrBy($this->roomTypeArr[$room_type]."Rank", $party_hot, $party_id);
|
|
|
return $this->success("更新成功!");
|
|
|
}
|
|
|
|
|
@@ -525,16 +488,8 @@ class Party extends Common
|
|
|
|
|
|
if(in_array($position,[5,6,7,8])) return $this->success("设置成功!");
|
|
|
|
|
|
- $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']);
|
|
|
- }
|
|
|
- $redisData = $redis->get($this->roomTypeArr[$room_type]."_".$party_id);
|
|
|
+
|
|
|
+ $redisData = $this->redis->get($this->roomTypeArr[$room_type]."_".$party_id);
|
|
|
if($redisData) {
|
|
|
$partyInfo = json_decode($redisData,true);
|
|
|
if($upOrdown == 1) {
|
|
@@ -547,7 +502,7 @@ class Party extends Common
|
|
|
if(isset($partyInfo["party_user"])) unset($partyInfo["party_user"][$position]);
|
|
|
}
|
|
|
// sort($partyInfo["party_user"]);
|
|
|
- $redis->set($this->roomTypeArr[$room_type]."_".$party_id,json_encode($partyInfo));
|
|
|
+ $this->redis->set($this->roomTypeArr[$room_type]."_".$party_id,json_encode($partyInfo));
|
|
|
}
|
|
|
|
|
|
return $this->success("设置成功!");
|
|
@@ -565,17 +520,9 @@ class Party extends Common
|
|
|
if (!$party_id) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
- $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']);
|
|
|
- }
|
|
|
|
|
|
- $res = $redis->hGetAll("online_".$party_id);
|
|
|
+
|
|
|
+ $res = $this->redis->hGetAll("online_".$party_id);
|
|
|
$user_ids = [];$userList = [];
|
|
|
if($res) $user_ids = array_values($res);
|
|
|
// 获取用户列表信息
|
|
@@ -595,13 +542,12 @@ class Party extends Common
|
|
|
/** 连续进房提示
|
|
|
* @param $user_id
|
|
|
* @param $party_id
|
|
|
- * @param $redis
|
|
|
* @return int
|
|
|
*/
|
|
|
- private function getUserJoinPartyDays($user_id, $party_id,$redis)
|
|
|
+ private function getUserJoinPartyDays($user_id, $party_id)
|
|
|
{
|
|
|
$days = 1;
|
|
|
- $joinPartyDays = $redis->hGet("joinParty_days",$user_id."-".$party_id);
|
|
|
+ $joinPartyDays = $this->redis->hGet("joinParty_days",$user_id."-".$party_id);
|
|
|
if ($joinPartyDays){
|
|
|
$joinPartyDaysArr = explode('-',$joinPartyDays);
|
|
|
$oldTime = (int)$joinPartyDaysArr[0];
|
|
@@ -613,15 +559,15 @@ class Party extends Common
|
|
|
if ($yesterdayStartTime <= $oldTime && $oldTime < $todayStartTime){
|
|
|
$days = (int)$joinPartyDaysArr[1];
|
|
|
$days++;
|
|
|
- $redis->hSet("joinParty_days", $user_id . "-" . $party_id, time().'-'. $days);
|
|
|
+ $this->redis->hSet("joinParty_days", $user_id . "-" . $party_id, time().'-'. $days);
|
|
|
}elseif($todayStartTime <= $oldTime && $oldTime <= $todayEndTime){
|
|
|
//今天登录过 days
|
|
|
$days = (int)$joinPartyDaysArr[1];
|
|
|
} else {
|
|
|
- $redis->hSet("joinParty_days", $user_id . "-" . $party_id, time().'-1');
|
|
|
+ $this->redis->hSet("joinParty_days", $user_id . "-" . $party_id, time().'-1');
|
|
|
}
|
|
|
}else{
|
|
|
- $redis->hSet("joinParty_days", $user_id . "-" . $party_id, time().'-1');
|
|
|
+ $this->redis->hSet("joinParty_days", $user_id . "-" . $party_id, time().'-1');
|
|
|
}
|
|
|
return $days;
|
|
|
}
|
|
@@ -637,41 +583,33 @@ class Party extends Common
|
|
|
$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']);
|
|
|
- }
|
|
|
- $redis->zAdd("party_user_".$party_id,$this->auth->u_id,$user_id);
|
|
|
- $redis->hSet("online_".$party_id,$user_id,$user_id); //新增的
|
|
|
+
|
|
|
+ $this->redis->zAdd("party_user_".$party_id,$this->auth->u_id,$user_id);
|
|
|
+ $this->redis->hSet("online_".$party_id,$user_id,$user_id); //新增的
|
|
|
|
|
|
// 判断当前用户是否存在在直播间通过切换过来的
|
|
|
- $livingUserPartyId = $redis->hGet("livingUser", $user_id);
|
|
|
+ $livingUserPartyId = $this->redis->hGet("livingUser", $user_id);
|
|
|
if ($livingUserPartyId) {
|
|
|
if($livingUserPartyId != $party_id){
|
|
|
// 扣除房间在线人数
|
|
|
- $redis->HDel("online_" . $livingUserPartyId, $user_id);
|
|
|
+ $this->redis->HDel("online_" . $livingUserPartyId, $user_id);
|
|
|
//首页用户头像
|
|
|
- $redis->zRem("party_user_".$livingUserPartyId, $user_id);
|
|
|
+ $this->redis->zRem("party_user_".$livingUserPartyId, $user_id);
|
|
|
// 扣除在线用户在房间情况
|
|
|
- $redis->hDel("livingUser", $user_id);
|
|
|
+ $this->redis->hDel("livingUser", $user_id);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// 记录在线用户在房间情况
|
|
|
- $redis->hSet("livingUser", $user_id, $party_id);
|
|
|
+ $this->redis->hSet("livingUser", $user_id, $party_id);
|
|
|
|
|
|
|
|
|
// 判断当前用户是否被该房间设置限制 //项目:1=房管,2=禁言,3=拉黑,4=踢出
|
|
|
$lsetList = [];
|
|
|
|
|
|
for($i=1;$i<=4;$i++) {
|
|
|
- $hgetlist = $redis->hGet("party_manage_".$party_id,$user_id."-".$i);
|
|
|
+ $hgetlist = $this->redis->hGet("party_manage_".$party_id,$user_id."-".$i);
|
|
|
|
|
|
$hgetlist = unserialize($hgetlist);
|
|
|
|
|
@@ -700,13 +638,13 @@ class Party extends Common
|
|
|
}
|
|
|
|
|
|
// 判断派对密码
|
|
|
- $partyInfo = $redis->get($this->roomTypeArr[$room_type]."_".$party_id);
|
|
|
+ $partyInfo = $this->redis->get($this->roomTypeArr[$room_type]."_".$party_id);
|
|
|
if($partyInfo) {
|
|
|
$partyInfo = json_decode($partyInfo,true);
|
|
|
|
|
|
if($partyInfo["is_close"] == 1) $this->error("该房间已被关闭!");
|
|
|
//if($partyInfo["status"] != 1) $this->error("该房间为预创建房间,请联系管理员正式开通!");
|
|
|
- $partyManage = $redis->hGet("party_manage_".$party_id,$user_id."-1");
|
|
|
+ $partyManage = $this->redis->hGet("party_manage_".$party_id,$user_id."-1");
|
|
|
if(isset($partyInfo["party_pass"]) && $partyInfo["party_pass"] && $partyInfo["user_id"] != $user_id && empty($partyManage)) {
|
|
|
if(($party_pass != $partyInfo["party_pass"] || strlen($party_pass) != 4) && $this->auth->is_manager == 0) {
|
|
|
$this->error("派对密码不正确!");
|
|
@@ -732,7 +670,7 @@ class Party extends Common
|
|
|
}
|
|
|
|
|
|
// 获取用户魅力值
|
|
|
- $users = $redis->zRange("hourCharm_".$party_id,0,-1,true);
|
|
|
+ $users = $this->redis->zRange("hourCharm_".$party_id,0,-1,true);
|
|
|
$u = [];
|
|
|
if($users) {
|
|
|
foreach($users as $k => $v) $u[] = [
|
|
@@ -744,7 +682,7 @@ class Party extends Common
|
|
|
|
|
|
|
|
|
// 获取用户排行榜前三名头像
|
|
|
- $heads = $redis->hGet("user_jewel_top3",$party_id);
|
|
|
+ $heads = $this->redis->hGet("user_jewel_top3",$party_id);
|
|
|
$lsetList["userJewelTop3"] = $heads?json_decode($heads,true):[];
|
|
|
|
|
|
|
|
@@ -764,7 +702,7 @@ class Party extends Common
|
|
|
}
|
|
|
$partyInfo["party_hot"] = $this->changeW($partyInfo["party_hot"]);
|
|
|
$partyInfo['is_new'] = $partyInfo["status"] == 0 ? 1 : 0;
|
|
|
- $partyInfo['join_days'] = $this->getUserJoinPartyDays($user_id,$party_id,$redis);
|
|
|
+ $partyInfo['join_days'] = $this->getUserJoinPartyDays($user_id,$party_id);
|
|
|
$lsetList["partyInfo"] = $partyInfo;
|
|
|
|
|
|
return $this->success("加入成功!",$lsetList);
|
|
@@ -780,22 +718,14 @@ class Party extends Common
|
|
|
if (!$user_id || !$party_id) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
- $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']);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
// 判断当前用户是否被该房间设置限制 //项目:1=房管,2=禁言,3=拉黑,4=踢出
|
|
|
$lsetList = [];
|
|
|
$lsetList["is_notalk"] = 0;
|
|
|
$lsetList["notalk_time"] = 0;
|
|
|
|
|
|
- $hgetlist = $redis->hGet("party_manage_".$party_id,$user_id."-2");
|
|
|
+ $hgetlist = $this->redis->hGet("party_manage_".$party_id,$user_id."-2");
|
|
|
|
|
|
$hgetlist = unserialize($hgetlist);
|
|
|
$restime = time() - intval($hgetlist["createtime"]);
|
|
@@ -818,44 +748,36 @@ class Party extends Common
|
|
|
}
|
|
|
$user_u_id = $this->auth->u_id;
|
|
|
$userId = $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']);
|
|
|
- }
|
|
|
|
|
|
- $redis->zRem("party_user_".$party_id,$userId);
|
|
|
+
|
|
|
+ $this->redis->zRem("party_user_".$party_id,$userId);
|
|
|
|
|
|
// 处理online_party_id
|
|
|
- //$redis->connect($redisconfig["host"], $redisconfig["port"]);
|
|
|
- $redis->HDel("online_" . $party_id, $this->auth->id);
|
|
|
+ //$this->redis->connect($redisconfig["host"], $redisconfig["port"]);
|
|
|
+ $this->redis->HDel("online_" . $party_id, $this->auth->id);
|
|
|
|
|
|
// 扣除在线用户在房间情况
|
|
|
- $redis->hDel("livingUser", $this->auth->id);
|
|
|
+ $this->redis->hDel("livingUser", $this->auth->id);
|
|
|
|
|
|
// 更新房间在线状态
|
|
|
- $partyInfo = $redis->get("party_" . $party_id);
|
|
|
+ $partyInfo = $this->redis->get("party_" . $party_id);
|
|
|
if ($partyInfo) {
|
|
|
$partyInfo = json_decode($partyInfo, true);
|
|
|
- $memCount = count($redis->hGetAll("online_" . $party_id));
|
|
|
+ $memCount = count($this->redis->hGetAll("online_" . $party_id));
|
|
|
if ($memCount <= 0) {
|
|
|
$partyInfo["is_online"] = 0;
|
|
|
- $redis->set("party_" . $party_id, json_encode($partyInfo));
|
|
|
+ $this->redis->set("party_" . $party_id, json_encode($partyInfo));
|
|
|
\app\common\model\Party::update(["is_online" => 0], ["id" => $party_id]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $liveInfo = $redis->get("live_" . $party_id);
|
|
|
+ $liveInfo = $this->redis->get("live_" . $party_id);
|
|
|
if ($liveInfo) {
|
|
|
$liveInfo = json_decode($liveInfo, true);
|
|
|
- $memCount = count($redis->hGetAll("online_" . $party_id));
|
|
|
+ $memCount = count($this->redis->hGetAll("online_" . $party_id));
|
|
|
if ($memCount <= 0) {
|
|
|
$liveInfo["is_online"] = 0;
|
|
|
- $redis->set("live_" . $party_id, json_encode($liveInfo));
|
|
|
+ $this->redis->set("live_" . $party_id, json_encode($liveInfo));
|
|
|
\app\common\model\Party::update(["is_online" => 0], ["id" => $party_id]);
|
|
|
}
|
|
|
}
|
|
@@ -869,16 +791,8 @@ class Party extends Common
|
|
|
$u_id = input('u_id',0,"intval"); // 用户u_id
|
|
|
$party_id = input('party_id',0,"intval"); // 直播间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']);
|
|
|
- }*/
|
|
|
-// $userids = $redis->zRange("party_user_".$party_id,0,-1,true);
|
|
|
+
|
|
|
+// $userids = $this->redis->zRange("party_user_".$party_id,0,-1,true);
|
|
|
// $useridArr = [];
|
|
|
// if($userids)foreach($userids as $k => $v) $useridArr[$v] = $k; // 因为array_slip 不能交换数字啊
|
|
|
// $userid = isset($useridArr[$u_id])?$useridArr[$u_id]:0;
|
|
@@ -901,22 +815,14 @@ class Party extends Common
|
|
|
if (!$party_id || !$user_id || ($type != 1 && $type != 0)) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
- $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']);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
$partyModel = new \app\common\model\Party();
|
|
|
$data = [];
|
|
|
$where = [];
|
|
|
$where["id"] = $party_id;
|
|
|
$partyInfo = $partyModel->where(["id"=>$party_id])->find();
|
|
|
- $getredisPartyInfo = $redis->get($this->roomTypeArr[$partyInfo->room_type].'_'.$party_id);
|
|
|
+ $getredisPartyInfo = $this->redis->get($this->roomTypeArr[$partyInfo->room_type].'_'.$party_id);
|
|
|
$redisPartyInfo = json_decode($getredisPartyInfo,true);
|
|
|
if($type == 1) {
|
|
|
$data["naming"] = $user_id;
|
|
@@ -927,7 +833,7 @@ class Party extends Common
|
|
|
$data["naming"] = 0;
|
|
|
$redisPartyInfo["naming"] = [];
|
|
|
}
|
|
|
- $redis->set($this->roomTypeArr[$partyInfo->room_type].'_'.$party_id,json_encode($redisPartyInfo));
|
|
|
+ $this->redis->set($this->roomTypeArr[$partyInfo->room_type].'_'.$party_id,json_encode($redisPartyInfo));
|
|
|
$res = $partyModel->update($data,$where);
|
|
|
if($res !== false) {
|
|
|
$this->success("操作成功!");
|
|
@@ -1084,20 +990,12 @@ class Party extends Common
|
|
|
// 获取派对类型
|
|
|
if($party_type) $data["type_name"] = \app\common\model\PartyType::where(["id"=>$party_type])->value("name");
|
|
|
// 存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']);
|
|
|
- }
|
|
|
- $partyInfo = $redis->get($this->roomTypeArr[$room_type]."_".$party_id);
|
|
|
+
|
|
|
+ $partyInfo = $this->redis->get($this->roomTypeArr[$room_type]."_".$party_id);
|
|
|
if($partyInfo) {
|
|
|
$partyInfo = json_decode($partyInfo,true);
|
|
|
$partyInfo = array_replace($partyInfo,$data);
|
|
|
- $redis->set($this->roomTypeArr[$room_type]."_".$party_id,json_encode($partyInfo));
|
|
|
+ $this->redis->set($this->roomTypeArr[$room_type]."_".$party_id,json_encode($partyInfo));
|
|
|
}
|
|
|
|
|
|
$this->success("房间设置成功!",$data);
|
|
@@ -1156,15 +1054,7 @@ class Party extends Common
|
|
|
$this->error("对方已开通".$nobleLevel['name']."贵族,踢出房间失败!");
|
|
|
}
|
|
|
|
|
|
- $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']);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
$data = [];
|
|
|
$data["user_id"] = $user_id;
|
|
@@ -1176,7 +1066,7 @@ class Party extends Common
|
|
|
$data["time"] = $time;
|
|
|
$data["createtime"] = time();
|
|
|
|
|
|
- $res = $redis->hSet("party_manage_".$party_id,$user_id."-".$item,serialize($data));
|
|
|
+ $res = $this->redis->hSet("party_manage_".$party_id,$user_id."-".$item,serialize($data));
|
|
|
|
|
|
if($res !== false) {
|
|
|
$this->success("设置成功!",$data);
|
|
@@ -1196,18 +1086,10 @@ class Party extends Common
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
$time = time();
|
|
|
- $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']);
|
|
|
- }
|
|
|
|
|
|
|
|
|
- $hget=$redis->hGetAll("party_manage_".$party_id);
|
|
|
+
|
|
|
+ $hget=$this->redis->hGetAll("party_manage_".$party_id);
|
|
|
$list=array();
|
|
|
foreach($hget as $key=>$val) {
|
|
|
if(substr($key,-2) == "-".$item){
|
|
@@ -1233,16 +1115,8 @@ class Party extends Common
|
|
|
if (!$id || !in_array($item,[1,2,3,4])) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
- $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']);
|
|
|
- }
|
|
|
- $res = $redis->hDel("party_manage_".$party_id,$id."-".$item);
|
|
|
+
|
|
|
+ $res = $this->redis->hDel("party_manage_".$party_id,$id."-".$item);
|
|
|
if($res !== false) {
|
|
|
$this->success("移除成功!",$res);
|
|
|
} else {
|
|
@@ -1270,20 +1144,12 @@ class Party extends Common
|
|
|
$res = $partyModel->update($data,$where);
|
|
|
if($res) {
|
|
|
// 存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']);
|
|
|
- }
|
|
|
- $partyInfo = $redis->get($this->roomTypeArr[$room_type]."_".$party_id);
|
|
|
+
|
|
|
+ $partyInfo = $this->redis->get($this->roomTypeArr[$room_type]."_".$party_id);
|
|
|
if($partyInfo) {
|
|
|
$partyInfo = json_decode($partyInfo,true);
|
|
|
$partyInfo = array_replace($partyInfo,$data);
|
|
|
- $redis->set($this->roomTypeArr[$room_type]."_".$party_id,json_encode($partyInfo));
|
|
|
+ $this->redis->set($this->roomTypeArr[$room_type]."_".$party_id,json_encode($partyInfo));
|
|
|
}
|
|
|
|
|
|
$this->success("更新成功!",$res);
|
|
@@ -1308,16 +1174,8 @@ class Party extends Common
|
|
|
if(!$partyUser) $this->error(__('房间信息未找到!'));
|
|
|
// $is_home = $partyUser == $userInfo->id?1:0;
|
|
|
|
|
|
- $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']);
|
|
|
- }
|
|
|
- $data = unserialize($redis->hGet("party_lineup",$party_id));
|
|
|
+
|
|
|
+ $data = unserialize($this->redis->hGet("party_lineup",$party_id));
|
|
|
$data[$userid]["user_id"] = $userInfo['id'];
|
|
|
$data[$userid]["avatar"] = $userInfo['avatar'];
|
|
|
$data[$userid]["mai_id"] = $mai_id;
|
|
@@ -1327,7 +1185,7 @@ class Party extends Common
|
|
|
$data[$userid]["gender"] = $userInfo['gender'];
|
|
|
|
|
|
$res = false;
|
|
|
- $data && $res = $redis->hSet("party_lineup",$party_id,serialize($data));
|
|
|
+ $data && $res = $this->redis->hSet("party_lineup",$party_id,serialize($data));
|
|
|
|
|
|
$data = array_values($data);
|
|
|
if($res !== false) {
|
|
@@ -1348,16 +1206,8 @@ class Party extends Common
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
$userid = $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']);
|
|
|
- }
|
|
|
- $data=unserialize($redis->hGet("party_lineup",$party_id));
|
|
|
+
|
|
|
+ $data=unserialize($this->redis->hGet("party_lineup",$party_id));
|
|
|
if($data && $is_empty != 1) {
|
|
|
foreach($data as $k => $v) {
|
|
|
if($v["user_id"] == $user_id) {
|
|
@@ -1368,7 +1218,7 @@ class Party extends Common
|
|
|
}
|
|
|
// unset($data[$userid]);
|
|
|
if($is_empty == 1) $data = [];
|
|
|
- $redis->hSet("party_lineup",$party_id,serialize($data));
|
|
|
+ $this->redis->hSet("party_lineup",$party_id,serialize($data));
|
|
|
|
|
|
|
|
|
$this->success("移除成功!");
|
|
@@ -1382,16 +1232,8 @@ class Party extends Common
|
|
|
if (!$party_id) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
- $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']);
|
|
|
- }
|
|
|
- $data = $redis->hGet("party_lineup",$party_id);
|
|
|
+
|
|
|
+ $data = $this->redis->hGet("party_lineup",$party_id);
|
|
|
$dataArr = unserialize($data);
|
|
|
$datas = [];
|
|
|
is_array($dataArr) && $datas=array_values($dataArr);
|
|
@@ -1424,16 +1266,8 @@ class Party extends Common
|
|
|
|
|
|
$user_id = $this->auth->id;
|
|
|
// 存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']);
|
|
|
- }
|
|
|
- $partyInfo = $redis->get($this->roomTypeArr[$room_type]."_".$party_id);
|
|
|
+
|
|
|
+ $partyInfo = $this->redis->get($this->roomTypeArr[$room_type]."_".$party_id);
|
|
|
if($partyInfo) {
|
|
|
$partyInfo = json_decode($partyInfo,true);
|
|
|
} else {
|
|
@@ -1447,14 +1281,14 @@ class Party extends Common
|
|
|
$data = [];
|
|
|
$data["status"] = 0;
|
|
|
$data["is_pass"] = $partyInfo["party_pass"]?1:0;
|
|
|
- $partyManage = $redis->hGet("party_manage_".$party_id,$user_id."-1");
|
|
|
+ $partyManage = $this->redis->hGet("party_manage_".$party_id,$user_id."-1");
|
|
|
if($partyInfo["user_id"] == $user_id || $this->auth->is_manager == 1 || !empty($partyManage)){ $data["is_pass"] = 0;}
|
|
|
|
|
|
if($is_miniprogram == 1) { // 小程序单独处理
|
|
|
// 判断当前用户是否被该房间设置限制 //项目:1=房管,2=禁言,3=拉黑,4=踢出
|
|
|
$lsetList = [];
|
|
|
for($i=1;$i<=4;$i++) {
|
|
|
- $hgetlist = $redis->hGet("party_manage_".$party_id,$user_id."-".$i);
|
|
|
+ $hgetlist = $this->redis->hGet("party_manage_".$party_id,$user_id."-".$i);
|
|
|
|
|
|
$hgetlist = unserialize($hgetlist);
|
|
|
$restime = time() - intval($hgetlist["createtime"]);
|
|
@@ -1682,15 +1516,7 @@ class Party extends Common
|
|
|
$returnData = [];
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
- $redis = new Redis();
|
|
|
- $redisconfig = config("redis");
|
|
|
- $redis->connect($redisconfig["host"], $redisconfig["port"], 86400 * 31);
|
|
|
- if ($redisconfig['redis_pwd']) {
|
|
|
- $redis->auth($redisconfig['redis_pwd']);
|
|
|
- }
|
|
|
- if($redisconfig['redis_selectdb'] > 0){
|
|
|
- $redis->select($redisconfig['redis_selectdb']);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
// 获取当天零点
|
|
|
$day = date("Ymd");
|
|
@@ -1809,17 +1635,17 @@ class Party extends Common
|
|
|
$i++;
|
|
|
if($party_id > 0) {
|
|
|
// 添加redis记录做财富排行榜日榜用
|
|
|
- $redis->zIncrBy($this->roomTypeArr[$room_type] . "_jewel_get_" . $party_id . ":" . $day . "d", $hotValue, $user_id);
|
|
|
+ $this->redis->zIncrBy($this->roomTypeArr[$room_type] . "_jewel_get_" . $party_id . ":" . $day . "d", $hotValue, $user_id);
|
|
|
// 添加redis记录做财富排行榜周榜用
|
|
|
- $redis->zIncrBy($this->roomTypeArr[$room_type] . "_jewel_get_" . $party_id . ":" . $weekday . "w", $hotValue, $user_id);
|
|
|
+ $this->redis->zIncrBy($this->roomTypeArr[$room_type] . "_jewel_get_" . $party_id . ":" . $weekday . "w", $hotValue, $user_id);
|
|
|
// 添加redis记录做财富排行榜月榜用
|
|
|
- $redis->zIncrBy($this->roomTypeArr[$room_type] . "_jewel_get_" . $party_id . ":" . $monthday . "m", $hotValue, $user_id);
|
|
|
+ $this->redis->zIncrBy($this->roomTypeArr[$room_type] . "_jewel_get_" . $party_id . ":" . $monthday . "m", $hotValue, $user_id);
|
|
|
// 添加redis记录做贡献排行榜日榜用
|
|
|
- $redis->zIncrBy($this->roomTypeArr[$room_type] . "_jewel_to_" . $party_id . ":" . $day . "d", $giftValue, $userauthid);
|
|
|
+ $this->redis->zIncrBy($this->roomTypeArr[$room_type] . "_jewel_to_" . $party_id . ":" . $day . "d", $giftValue, $userauthid);
|
|
|
// 添加redis记录做贡献排行榜周榜用
|
|
|
- $redis->zIncrBy($this->roomTypeArr[$room_type] . "_jewel_to_" . $party_id . ":" . $weekday . "w", $giftValue, $userauthid);
|
|
|
+ $this->redis->zIncrBy($this->roomTypeArr[$room_type] . "_jewel_to_" . $party_id . ":" . $weekday . "w", $giftValue, $userauthid);
|
|
|
// 添加redis记录做贡献排行榜月榜用
|
|
|
- $redis->zIncrBy($this->roomTypeArr[$room_type] . "_jewel_to_" . $party_id . ":" . $monthday . "m", $giftValue, $userauthid);
|
|
|
+ $this->redis->zIncrBy($this->roomTypeArr[$room_type] . "_jewel_to_" . $party_id . ":" . $monthday . "m", $giftValue, $userauthid);
|
|
|
|
|
|
// tcp 更新用户魅力值
|
|
|
$this->updateUserCharm($party_id, $user_id, $hotValue);
|
|
@@ -1867,7 +1693,7 @@ class Party extends Common
|
|
|
}
|
|
|
|
|
|
// 获取用户魅力值
|
|
|
- $users = $redis->zRange("hourCharm_".$party_id,0,-1,true);
|
|
|
+ $users = $this->redis->zRange("hourCharm_".$party_id,0,-1,true);
|
|
|
$u = [];
|
|
|
if($users) {
|
|
|
foreach($users as $k => $v) $u[] = [
|
|
@@ -1998,23 +1824,15 @@ class Party extends Common
|
|
|
$partyInfo->party_hot = $party_hot_value;
|
|
|
$partyInfo->save();
|
|
|
// 更新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']);
|
|
|
- }
|
|
|
- $redis->zAdd($this->roomTypeArr[$room_type]."Rank", $partyInfo['party_hot'], $partyInfo["id"]);
|
|
|
+
|
|
|
+ $this->redis->zAdd($this->roomTypeArr[$room_type]."Rank", $partyInfo['party_hot'], $partyInfo["id"]);
|
|
|
|
|
|
// 更新redis 加入缓存
|
|
|
- $redPartyInfo = $redis->get($this->roomTypeArr[$room_type]."_".$partyInfo["id"]);
|
|
|
+ $redPartyInfo = $this->redis->get($this->roomTypeArr[$room_type]."_".$partyInfo["id"]);
|
|
|
if($redPartyInfo) {
|
|
|
$redPartyInfo = json_decode($redPartyInfo,true);
|
|
|
$redPartyInfo["party_hot"] = $party_hot_value;
|
|
|
- $redis->set($this->roomTypeArr[$room_type]."_".$partyInfo["id"],json_encode($redPartyInfo));
|
|
|
+ $this->redis->set($this->roomTypeArr[$room_type]."_".$partyInfo["id"],json_encode($redPartyInfo));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2037,15 +1855,7 @@ class Party extends Common
|
|
|
* 用户赠送礼物后房间内用户排行,贡献榜前三名
|
|
|
*/
|
|
|
private function getPartyUserTop($party_id,$room_type) {
|
|
|
- $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"));
|
|
@@ -2055,7 +1865,7 @@ class Party extends Common
|
|
|
// 获取条数
|
|
|
$num = 3;
|
|
|
// 获取3条财富排行周记录
|
|
|
- $getweek = $redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_to_".$party_id.":".$day."d",0,$num-1,true);
|
|
|
+ $getweek = $this->redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_to_".$party_id.":".$day."d",0,$num-1,true);
|
|
|
$userList = $userModel->rankList($getweek);
|
|
|
$avatarArr = [];
|
|
|
if($userList) {
|
|
@@ -2063,7 +1873,7 @@ class Party extends Common
|
|
|
$v["jewel"] > 0 && $avatarArr[] = $v["avatar"];
|
|
|
}
|
|
|
// 加入缓存做备份
|
|
|
- $redis->hSet("user_jewel_top3",$party_id,json_encode($avatarArr));
|
|
|
+ $this->redis->hSet("user_jewel_top3",$party_id,json_encode($avatarArr));
|
|
|
// // 发送tcp
|
|
|
// $tcpArr = [];
|
|
|
// $tcpArr['type'] = "changeRoomUserTop";
|
|
@@ -2084,18 +1894,10 @@ class Party extends Common
|
|
|
* 用户赠送礼物后房间内用户魅力值增加
|
|
|
*/
|
|
|
private function updateUserCharm($party_id,$user_id,$giftValue) {
|
|
|
- $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']);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
// 获取用户魅力值
|
|
|
- $users = $redis->zRange("hourCharm_".$party_id,0,-1,true);
|
|
|
+ $users = $this->redis->zRange("hourCharm_".$party_id,0,-1,true);
|
|
|
|
|
|
if(!$users) $users[$user_id] = 0;
|
|
|
|
|
@@ -2104,7 +1906,7 @@ class Party extends Common
|
|
|
} else {
|
|
|
$value = $giftValue;
|
|
|
}
|
|
|
- $redis->zAdd("hourCharm_".$party_id,$value,$user_id);
|
|
|
+ $this->redis->zAdd("hourCharm_".$party_id,$value,$user_id);
|
|
|
|
|
|
return true;
|
|
|
|
|
@@ -2121,20 +1923,12 @@ class Party extends Common
|
|
|
$this->error("请输入派对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']);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
if ($userId) {
|
|
|
- $redis->zRem("hourCharm_" . $party_id, $userId);
|
|
|
+ $this->redis->zRem("hourCharm_" . $party_id, $userId);
|
|
|
} else {
|
|
|
- $redis->del("hourCharm_" . $party_id);
|
|
|
+ $this->redis->del("hourCharm_" . $party_id);
|
|
|
}
|
|
|
|
|
|
$this->success("操作成功!");
|
|
@@ -2188,15 +1982,7 @@ class Party extends Common
|
|
|
if($monty < 10) $monty = "0".$monty;
|
|
|
$premonth = date("Y").$monty."01";
|
|
|
|
|
|
- $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']);
|
|
|
- }
|
|
|
+
|
|
|
// 获取所有派对ID
|
|
|
$party_ids = \app\common\model\Party::where(["status"=>1])->column("id");
|
|
|
// 获取数据
|
|
@@ -2212,14 +1998,14 @@ class Party extends Common
|
|
|
];
|
|
|
foreach($keys as $key) {
|
|
|
// 备份数据
|
|
|
- $redisData = $redis->zRevRange($key,0,-1,true);
|
|
|
+ $redisData = $this->redis->zRevRange($key,0,-1,true);
|
|
|
if($redisData) {
|
|
|
$keyInfo = \app\common\model\RedisTops::where(["key"=>$key])->find();
|
|
|
$data = ["party_id"=>$v,"key"=>$key,"value"=>json_encode($redisData),"createtime" => $time];
|
|
|
if(!$keyInfo) {
|
|
|
$res = \app\common\model\RedisTops::insert($data);
|
|
|
// 清理数据
|
|
|
- $res && $redis->zRemRangeByRank($key,0,-1);
|
|
|
+ $res && $this->redis->zRemRangeByRank($key,0,-1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2230,18 +2016,10 @@ class Party extends Common
|
|
|
public function handleParty() {
|
|
|
return false;
|
|
|
$partyList = \app\common\model\Party::where('is_online',1)->select();
|
|
|
- $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']);
|
|
|
- }
|
|
|
|
|
|
-// $redis->del("online_" . 3);die;
|
|
|
-// $redis->hSet("online_" . 3, 4, 4);die;
|
|
|
+
|
|
|
+// $this->redis->del("online_" . 3);die;
|
|
|
+// $this->redis->hSet("online_" . 3, 4, 4);die;
|
|
|
foreach ($partyList as $party){
|
|
|
|
|
|
|
|
@@ -2249,38 +2027,38 @@ class Party extends Common
|
|
|
$roomId = $party['id'];
|
|
|
|
|
|
|
|
|
- $redis->HDel("online_" . $roomId, $userId);
|
|
|
+ $this->redis->HDel("online_" . $roomId, $userId);
|
|
|
|
|
|
// 扣除在线用户在房间情况
|
|
|
- $redis->hDel("livingUser",$userId);
|
|
|
+ $this->redis->hDel("livingUser",$userId);
|
|
|
|
|
|
// // 更新房间在线状态
|
|
|
- $partyInfo = $redis->get("party_" . $roomId);
|
|
|
+ $partyInfo = $this->redis->get("party_" . $roomId);
|
|
|
if ($partyInfo) {
|
|
|
$partyInfo = json_decode($partyInfo, true);
|
|
|
- $memCount = count($redis->hGetAll("online_" . $roomId));
|
|
|
+ $memCount = count($this->redis->hGetAll("online_" . $roomId));
|
|
|
if ($memCount <= 0) {
|
|
|
dump($roomId.'--1---');
|
|
|
$partyInfo["is_online"] = 0;
|
|
|
- $redis->set("party_" . $roomId, json_encode($partyInfo));
|
|
|
+ $this->redis->set("party_" . $roomId, json_encode($partyInfo));
|
|
|
\app\common\model\Party::update(["is_online" => 0], ["id" => $roomId]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $liveInfo = $redis->get("live_" . $roomId);
|
|
|
+ $liveInfo = $this->redis->get("live_" . $roomId);
|
|
|
if ($liveInfo) {
|
|
|
$liveInfo = json_decode($liveInfo, true);
|
|
|
- $memCount = count($redis->hGetAll("online_" . $roomId));
|
|
|
+ $memCount = count($this->redis->hGetAll("online_" . $roomId));
|
|
|
if ($memCount <= 0) {
|
|
|
dump($roomId.'---2--');
|
|
|
$liveInfo["is_online"] = 0;
|
|
|
- $redis->set("live_" . $roomId, json_encode($liveInfo));
|
|
|
+ $this->redis->set("live_" . $roomId, json_encode($liveInfo));
|
|
|
\app\common\model\Party::update(["is_online" => 0], ["id" => $roomId]);
|
|
|
}else{
|
|
|
dump($roomId.'---3--');
|
|
|
- $redis->del("online_" . $roomId);
|
|
|
+ $this->redis->del("online_" . $roomId);
|
|
|
$liveInfo["is_online"] = 0;
|
|
|
- $redis->set("live_" . $roomId, json_encode($liveInfo));
|
|
|
+ $this->redis->set("live_" . $roomId, json_encode($liveInfo));
|
|
|
\app\common\model\Party::update(["is_online" => 0], ["id" => $roomId]);
|
|
|
}
|
|
|
}
|