|
@@ -0,0 +1,2878 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\api\controller;
|
|
|
+
|
|
|
+use app\common\controller\Api;
|
|
|
+use Redis;
|
|
|
+use think\Db;
|
|
|
+use think\Exception;
|
|
|
+use think\exception\PDOException;
|
|
|
+use think\exception\ValidateException;
|
|
|
+use app\common\service\RoomService;
|
|
|
+use app\common\library\Easemob;
|
|
|
+
|
|
|
+require_once EXTEND_PATH . 'shengwang/src/RtcTokenBuilder2.php';
|
|
|
+require_once EXTEND_PATH . 'shengwang/src/RtmTokenBuilder2.php';
|
|
|
+
|
|
|
+ *
|
|
|
+ * 派对信息接口
|
|
|
+ */
|
|
|
+class Partytest extends Api
|
|
|
+{
|
|
|
+ protected $noNeedLogin = ['test_party_attr','updatePartyInfo','getPatyType','shengwang_token','addUserPositionToParty', 'clearMoney','clearCharm','getPartyRankList','getDefaultBackground','getPartGifList','getPartHeadgifList','isNotalk','getMusicList','updateTops','handleParty'];
|
|
|
+ protected $noNeedRight = ['*'];
|
|
|
+
|
|
|
+ protected $redis;
|
|
|
+
|
|
|
+ public function __construct()
|
|
|
+ {
|
|
|
+ $this->roomTypeArr = [1=>"party",2=>"live"];
|
|
|
+
|
|
|
+
|
|
|
+ $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();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 创建/进入派对
|
|
|
+ */
|
|
|
+ public function createParty() {
|
|
|
+ if(!$this->apiLimit()){
|
|
|
+ $this->error('访问频繁,请稍后重试');
|
|
|
+ }
|
|
|
+
|
|
|
+ $party_logo = input('party_logo');
|
|
|
+ $party_name = input('party_name');
|
|
|
+ $seatnum = input('seatnum');
|
|
|
+ $is_public = input('is_public',1);
|
|
|
+
|
|
|
+ $room_type = 2;
|
|
|
+ $partyModel = new \app\common\model\Party();
|
|
|
+
|
|
|
+ $user_id = $this->auth->id;
|
|
|
+
|
|
|
+ $anchorInfo = [];
|
|
|
+ if($room_type == 2) {
|
|
|
+
|
|
|
+
|
|
|
+ $anchorInfo || $this->error("您还未申请主播!");
|
|
|
+ $anchorInfo->status == 0 && $this->error("您的主播申请信息还未受理,请耐心等待!");
|
|
|
+ $anchorInfo->status == 2 && $this->error("您的主播申请未通过,请重新提交!");*/
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $userAuthInfo = \app\common\model\UserAuth::where(["user_id"=>$user_id])->find();
|
|
|
+ if($userAuthInfo) {
|
|
|
+ if($userAuthInfo->status == 0) {
|
|
|
+ $this->error("您的实名认证还在这审核中...,请耐心等待!");
|
|
|
+ } elseif($userAuthInfo->status == 2) {
|
|
|
+ $this->error("您的实名认证审核未通过,请重新审核!");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $this->error("请先申请实名认证!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if($room_type == 1) {
|
|
|
+
|
|
|
+ $authInfo = model('Guild')->where(["user_id"=>$user_id])->order('id desc')->find();
|
|
|
+ if($authInfo) {
|
|
|
+ if($authInfo->status == 0) {
|
|
|
+ $this->error("您的公会申请还在这审核中...,请耐心等待!");
|
|
|
+ } elseif($authInfo->status == -1) {
|
|
|
+ $this->error("您的公会申请已解散,请重新申请!");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $this->error("请先申请公会!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $where = [];
|
|
|
+ $where["user_id"] = $user_id;
|
|
|
+ $where["room_type"] = $room_type;
|
|
|
+ $sqlPartyInfo = $partyModel->where($where)->find();
|
|
|
+
|
|
|
+ if(!$sqlPartyInfo) {
|
|
|
+
|
|
|
+ $party_type = 8;
|
|
|
+ $party_notice = "请编辑房间公告";
|
|
|
+ $party_notice_detail = "请编辑房间公告内容!";
|
|
|
+
|
|
|
+ $party_ids = $partyModel->column("party_id");
|
|
|
+
|
|
|
+ $party_id = $this->auth->getUinqueId(5,$party_ids);
|
|
|
+ if($party_id > 99999) {
|
|
|
+ $this->error("房间超限,请联系客服");
|
|
|
+ }
|
|
|
+ if ($room_type == 1) {
|
|
|
+ $guildWhere['user_id'] = $user_id;
|
|
|
+ $guildWhere['status'] = 1;
|
|
|
+ $guild = model('Guild')->where($guildWhere)->order('id desc')->find();
|
|
|
+ if (!empty($guild)) {
|
|
|
+ $party_name = $guild['name'].'的房间';
|
|
|
+ $party_logo = $guild['image'];
|
|
|
+ $party_notice = $guild['desc'];
|
|
|
+ $party_notice_detail = $guild['notice'];
|
|
|
+ }
|
|
|
+ $party_type = 7;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $easemob_room_id = $this->easemob_createroom($party_name,$party_logo,$seatnum,$is_public,$room_type);
|
|
|
+
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+ $data = [];
|
|
|
+ $data["user_id"] = $this->auth->id;
|
|
|
+ $data["room_type"] = $room_type;
|
|
|
+ $data["party_id"] = $party_id;
|
|
|
+ $data["party_hot"] = 0;
|
|
|
+ $data["party_name"] = $party_name;
|
|
|
+ $data["party_logo"] = $party_logo;
|
|
|
+ $data["party_type"] = $party_type;
|
|
|
+ $data["party_notice"] = $party_notice;
|
|
|
+ $data["party_notice_detail"] = $party_notice_detail;
|
|
|
+ $data["is_online"] = 1;
|
|
|
+ $data["status"] = 1;
|
|
|
+ $data["is_recommend"] = 0;
|
|
|
+ $data["createtime"] = time();
|
|
|
+ $data["easemob_room_id"] = $easemob_room_id;
|
|
|
+
|
|
|
+ if($room_type == 1){
|
|
|
+ $data["platRate"] = config('site.party_party_platrate');
|
|
|
+ $data["guilderRate"] = config('site.party_party_guilderrate');
|
|
|
+ }else{
|
|
|
+ $data["platRate"] = config('site.party_live_platrate');
|
|
|
+ $data["guilderRate"] = config('site.party_live_guilderrate');
|
|
|
+ }
|
|
|
+
|
|
|
+ $id = $partyModel->insertGetId($data);
|
|
|
+ if(!$id) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error("房间创建失败,请稍后重试!");
|
|
|
+ }
|
|
|
+ $data["id"] = $id;
|
|
|
+
|
|
|
+ if($room_type == 2) {
|
|
|
+ \app\common\model\User::update(["is_live"=>1],["id"=>$user_id]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $partyInfo = $partyModel->where(["id"=>$id])->find();
|
|
|
+ $partyInfo["is_new"] = 1;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if($partyInfo["naming"]) {
|
|
|
+ $userInfo = \app\common\model\User::field("id,nickname,avatar")->where(["id"=>$partyInfo["naming"]])->find();
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+ $partyInfo["avatar"] = \app\common\model\User::where(["id"=>$partyInfo["user_id"]])->value("avatar");
|
|
|
+ }*/
|
|
|
+ $partyInfo["avatar"] = $party_logo;
|
|
|
+
|
|
|
+ $partyTypeName = "普通房";
|
|
|
+ if($partyInfo["party_type"]) {
|
|
|
+ $partyTypeName = \app\common\model\PartyType::where(["id"=>$partyInfo["party_type"]])->value("name");
|
|
|
+ }
|
|
|
+ $partyInfo["naming"] = [];
|
|
|
+ $partyInfo["type_name"] = $partyTypeName;
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->zAdd($this->roomTypeArr[$room_type]."Rank", $partyInfo['party_hot'], $partyInfo["id"]);
|
|
|
+
|
|
|
+ $this->redis->set($this->roomTypeArr[$room_type]."_".$partyInfo["id"],json_encode($partyInfo));
|
|
|
+
|
|
|
+ if($room_type != 2) {
|
|
|
+
|
|
|
+
|
|
|
+ $guildWhere['user_id'] = $user_id;
|
|
|
+ $guildWhere['status'] = 1;
|
|
|
+ $guild = model('Guild')->where($guildWhere)->order('id desc')->find();
|
|
|
+ if (!empty($guild)) {
|
|
|
+ $rs_guild = model('Guild')->where($guildWhere)->update(['party_id'=>$partyInfo['id']]);
|
|
|
+ if($rs_guild === false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('创建房间失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ $partyInfo = $sqlPartyInfo;
|
|
|
+
|
|
|
+
|
|
|
+ if($partyInfo['status'] == 3){
|
|
|
+ $update = [
|
|
|
+ 'status' => 1,
|
|
|
+ 'party_hot' => 0,
|
|
|
+ 'party_logo' => $party_logo,
|
|
|
+ 'party_name' => $party_name,
|
|
|
+ 'seatnum' => $seatnum,
|
|
|
+ 'is_public' => $is_public,
|
|
|
+ 'party_notice' => '请编辑房间公告',
|
|
|
+ 'party_notice_detail' => '请编辑房间公告内容',
|
|
|
+ 'is_recommend' => 0,
|
|
|
+ 'is_close' => 0,
|
|
|
+ 'party_pass' => '',
|
|
|
+ 'is_screen' => 0,
|
|
|
+ 'on_model' => 1,
|
|
|
+ 'background' => '',
|
|
|
+ ];
|
|
|
+ if($room_type == 1){
|
|
|
+ $update["platRate"] = config('site.party_party_platrate');
|
|
|
+ $update["guilderRate"] = config('site.party_party_guilderrate');
|
|
|
+ }else{
|
|
|
+ $update["platRate"] = config('site.party_live_platrate');
|
|
|
+ $update["guilderRate"] = config('site.party_live_guilderrate');
|
|
|
+ }
|
|
|
+
|
|
|
+ $matedata = [
|
|
|
+ 'seatnum'=> $seatnum,
|
|
|
+
|
|
|
+ 'party_name' => $party_name,
|
|
|
+ 'party_logo' => $party_logo,
|
|
|
+ 'is_public' => $is_public,
|
|
|
+ 'room_type' => $room_type,
|
|
|
+ 'online_user_num' => 0,
|
|
|
+
|
|
|
+ 'background' => '',
|
|
|
+ 'party_notice' => $update['party_notice'],
|
|
|
+ 'party_notice_detail' => $update['party_notice_detail'],
|
|
|
+ ];
|
|
|
+ }else{
|
|
|
+ $update = [
|
|
|
+ 'status' => 1,
|
|
|
+ 'party_logo' => $party_logo,
|
|
|
+ 'party_name' => $party_name,
|
|
|
+ 'is_public' => $is_public,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $matedata = [
|
|
|
+ 'party_name' => $party_name,
|
|
|
+ 'party_logo' => $party_logo,
|
|
|
+ 'is_public' => $is_public,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(empty($partyInfo['easemob_room_id'])){
|
|
|
+ $easemob_room_id = $this->easemob_createroom($party_name,$party_logo,$seatnum,$is_public,$room_type);
|
|
|
+
|
|
|
+ $update['easemob_room_id'] = $easemob_room_id;
|
|
|
+
|
|
|
+ }else{
|
|
|
+ $easemob_room_id = $partyInfo['easemob_room_id'];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Db::name('party')->where('id',$partyInfo['id'])->update($update);
|
|
|
+
|
|
|
+ $partyInfo = $partyModel->where(["id"=>$partyInfo['id']])->find();
|
|
|
+ $partyInfo["is_new"] = 0;
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->set($this->roomTypeArr[$room_type]."_".$partyInfo['id'],json_encode($partyInfo));
|
|
|
+
|
|
|
+
|
|
|
+ $easemob = new Easemob();
|
|
|
+ $rs = $easemob->room_setRoomCustomAttributeForced($easemob_room_id,$this->auth->id,$matedata);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $partyInfo['shengwang_token'] = $this->shengwang_token_private($easemob_room_id);
|
|
|
+
|
|
|
+
|
|
|
+ $this->creater_joinParty($partyInfo['id'],$easemob_room_id,$partyInfo['user_id']);
|
|
|
+
|
|
|
+ $this->success("获取成功!",$partyInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private function easemob_createroom($party_name,$party_logo,$seatnum,$is_public,$room_type){
|
|
|
+
|
|
|
+ $easemob = new Easemob();
|
|
|
+ $easemob_room_id = $easemob->room_createRoom($party_name,$party_name,$this->auth->id);
|
|
|
+ if(empty($easemob_room_id)){
|
|
|
+ $this->error('创建房间失败');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $matedata = [
|
|
|
+ 'seatnum'=> $seatnum,
|
|
|
+ 'waitsing_list' => json_encode([]),
|
|
|
+ 'party_name' => $party_name,
|
|
|
+ 'party_logo' => $party_logo,
|
|
|
+ 'is_public' => $is_public,
|
|
|
+ 'room_type' => $room_type,
|
|
|
+ 'online_user_num' => 0,
|
|
|
+ 'wealth_top3_userlist' => json_encode([]),
|
|
|
+ 'background' => '',
|
|
|
+
|
|
|
+
|
|
|
+ ];
|
|
|
+ $rs = $easemob->room_setRoomCustomAttributeForced($easemob_room_id,$this->auth->id,$matedata);
|
|
|
+
|
|
|
+
|
|
|
+ $seatdata = [];
|
|
|
+ for($i=0;$i<$seatnum;$i++){
|
|
|
+ $seat = [
|
|
|
+ 'charm' => 0,
|
|
|
+
|
|
|
+ 'isMaster' => false,
|
|
|
+ 'headUrl' => '',
|
|
|
+ 'userNo' => '',
|
|
|
+ 'rtcUid' => '',
|
|
|
+ 'name' => '',
|
|
|
+ 'seatIndex' => -1,
|
|
|
+ 'chorusSongCode' => '',
|
|
|
+ 'isAudioMuted' => 1,
|
|
|
+ 'isVideoMuted' => 0,
|
|
|
+ 'checked' => false,
|
|
|
+ 'isUsed' => true,
|
|
|
+ 'gender' => 1,
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $seat['isMaster'] = true;
|
|
|
+ $seat['headUrl'] = localpath_to_netpath($this->auth->avatar);
|
|
|
+ $seat['userNo'] = $this->auth->id;
|
|
|
+ $seat['rtcUid'] = $this->auth->id;
|
|
|
+ $seat['name'] = $this->auth->nickname;
|
|
|
+ $seat['seatIndex'] = $i;
|
|
|
+ }*/
|
|
|
+
|
|
|
+ $seatdata['seat'.$i] = json_encode($seat);
|
|
|
+ }
|
|
|
+ $rs = $easemob->room_setRoomCustomAttributeForced($easemob_room_id,$this->auth->id,$seatdata);
|
|
|
+
|
|
|
+ return $easemob_room_id;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function shengwang_token(){
|
|
|
+ $party_id = input('party_id');
|
|
|
+ $partyInfo = \app\common\model\Party::where(["id"=>$party_id])->find();
|
|
|
+ if(!$partyInfo) {
|
|
|
+ $this->error(__('派对不存在!'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $rs = $this->shengwang_token_private($partyInfo['easemob_room_id']);
|
|
|
+ $this->success(1,$rs);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private function shengwang_token_private($easemob_room_id){
|
|
|
+
|
|
|
+ $config = config('shengwang');
|
|
|
+ $appId = $config['app_id'];
|
|
|
+ $appCertificate = $config['app_zhengshu'];;
|
|
|
+ $channelName = $easemob_room_id;
|
|
|
+ $uid = 0;
|
|
|
+ $uidStr = '0';
|
|
|
+ $tokenExpirationInSeconds = 86400;
|
|
|
+ $privilegeExpirationInSeconds = 86400;
|
|
|
+
|
|
|
+
|
|
|
+ $rtc_token = \RtcTokenBuilder2::buildTokenWithUid($appId, $appCertificate, $channelName, $uid, \RtcTokenBuilder2::ROLE_PUBLISHER, $tokenExpirationInSeconds, $privilegeExpirationInSeconds);
|
|
|
+
|
|
|
+
|
|
|
+ $chorus_token = \RtcTokenBuilder2::buildTokenWithUid($appId, $appCertificate, $channelName.'_ex', $uid, \RtcTokenBuilder2::ROLE_PUBLISHER, $tokenExpirationInSeconds, $privilegeExpirationInSeconds);
|
|
|
+
|
|
|
+
|
|
|
+ $user = '0';
|
|
|
+ $expireTimeInSeconds = 86400;
|
|
|
+ $rtm_token = \RtmTokenBuilder2::buildToken($appId, $appCertificate, $user, $expireTimeInSeconds);
|
|
|
+
|
|
|
+ $result = [
|
|
|
+ 'rtc_token' => $rtc_token,
|
|
|
+ 'chorus_token' => $chorus_token,
|
|
|
+ 'rtm_token' => $rtm_token,
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 解散房间
|
|
|
+ */
|
|
|
+ public function closeParty() {
|
|
|
+
|
|
|
+ $party_id = input('party_id');
|
|
|
+ $room_type = input('room_type',1);
|
|
|
+
|
|
|
+ if (!$party_id || !in_array($room_type,[1,2])) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $partyInfo = \app\common\model\Party::where(["id"=>$party_id])->find();
|
|
|
+ if(!$partyInfo) {
|
|
|
+ $this->error(__('派对不存在!'));
|
|
|
+ }
|
|
|
+ $room_type = $partyInfo['room_type'];
|
|
|
+
|
|
|
+ if($partyInfo['user_id'] != $this->auth->id){
|
|
|
+ $this->error('房主才能解散');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $update = [
|
|
|
+ 'status' => 3,
|
|
|
+ ];
|
|
|
+ Db::name('party')->where('id',$party_id)->update($update);
|
|
|
+
|
|
|
+
|
|
|
+ $redispartyInfo = $this->redis->get($this->roomTypeArr[$room_type]."_".$party_id);
|
|
|
+ if($redispartyInfo) {
|
|
|
+ $redispartyInfo = json_decode($redispartyInfo,true);
|
|
|
+ $redispartyInfo = array_replace($redispartyInfo,$update);
|
|
|
+ $this->redis->set($this->roomTypeArr[$room_type]."_".$party_id,json_encode($redispartyInfo));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->zRemRangeByRank("hourCharm_".$party_id, 0,-1);
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->zRemRangeByRank("hourWealth_".$party_id, 0,-1);
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->hSet("user_jewel_top3",$party_id,json_encode([]));
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->hSet("party_lineup",$party_id,serialize([]));
|
|
|
+
|
|
|
+
|
|
|
+ $user_ids = $this->redis->hGetAll("online_".$party_id);
|
|
|
+ if(!empty($user_ids)){
|
|
|
+ foreach($user_ids as $key => $userId){
|
|
|
+ $this->redis->HDel("online_" . $party_id, $userId);
|
|
|
+ $this->redis->zRem("party_user_".$party_id,$userId);
|
|
|
+ $this->redis->hDel("livingUser", $userId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $key = "party_seat_".$party_id;
|
|
|
+ $seats = $this->redis->hGetAll($key);
|
|
|
+ foreach($seats as $seat_num => $seatuserid){
|
|
|
+ $this->redis->HDel($key, $seat_num);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $easemob_room_id = $partyInfo['easemob_room_id'];
|
|
|
+ if(!empty($easemob_room_id)){
|
|
|
+
|
|
|
+
|
|
|
+ $matedata = [
|
|
|
+ 'waitsing_list' => json_encode([]),
|
|
|
+ 'online_user_num' => 0,
|
|
|
+ 'wealth_top3_userlist' => json_encode([]),
|
|
|
+ ];
|
|
|
+
|
|
|
+ $easemob = new Easemob();
|
|
|
+ $easemob->room_setRoomCustomAttributeForced($partyInfo['easemob_room_id'],$partyInfo['user_id'],$matedata);
|
|
|
+
|
|
|
+
|
|
|
+ $seatnum = $partyInfo['seatnum'];
|
|
|
+ $seatdata = [];
|
|
|
+ for($i=0;$i<$seatnum;$i++){
|
|
|
+ $seat = [
|
|
|
+ 'charm' => 0,
|
|
|
+
|
|
|
+ 'isMaster' => false,
|
|
|
+ 'headUrl' => '',
|
|
|
+ 'userNo' => '',
|
|
|
+ 'rtcUid' => '',
|
|
|
+ 'name' => '',
|
|
|
+ 'seatIndex' => -1,
|
|
|
+ 'chorusSongCode' => '',
|
|
|
+ 'isAudioMuted' => 1,
|
|
|
+ 'isVideoMuted' => 0,
|
|
|
+ 'checked' => false,
|
|
|
+ 'isUsed' => true,
|
|
|
+ 'gender' => 1,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $seatdata['seat'.$i] = json_encode($seat);
|
|
|
+ }
|
|
|
+ $easemob->room_setRoomCustomAttributeForced($easemob_room_id,$partyInfo['user_id'],$seatdata);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $usernames = $easemob->room_listRoomMembers($easemob_room_id,0);
|
|
|
+
|
|
|
+ $user_ids = [];
|
|
|
+ if(!empty($usernames)){
|
|
|
+ foreach($usernames as $username){
|
|
|
+ foreach($username as $key => $val)
|
|
|
+ {
|
|
|
+ $user_ids[] = $val;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!empty($user_ids)){
|
|
|
+ $easemob->room_removeRoomMembers($easemob_room_id,$user_ids);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 获取派对列表排序
|
|
|
+ */
|
|
|
+ public function getPartyList() {
|
|
|
+ $order = input('orderby','new');
|
|
|
+
|
|
|
+ $this->reset_all_party();
|
|
|
+
|
|
|
+
|
|
|
+ $orderby = 'party.party_hot desc, party.id desc';
|
|
|
+ $where = [];
|
|
|
+
|
|
|
+ if($order == 'recommend'){
|
|
|
+ $where['party.is_recommend'] = 1;
|
|
|
+ }
|
|
|
+ if($order == 'follow'){
|
|
|
+ $follow_party_ids = Db::name('party_follow')->where('user_id',$this->auth->id)->column('party_id');
|
|
|
+ $where['party.id'] = ['IN',$follow_party_ids];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $where['party.status'] = 1;
|
|
|
+
|
|
|
+ $where['party.is_close'] = 0;
|
|
|
+ $where['party.is_public'] = 1;
|
|
|
+
|
|
|
+ $field = 'party.id,party.user_id,party.room_type,party.party_id,party.party_name,party.party_hot,
|
|
|
+ party.party_logo,party.party_pass,party.party_type,party.easemob_room_id,type.name as type_name';
|
|
|
+ $list = Db::name('party')->alias('party')
|
|
|
+ ->join('party_type type','party.party_type = type.id','LEFT')
|
|
|
+ ->field($field)->where($where)->order($orderby)->autopage()->select();
|
|
|
+ $list = list_domain_image($list,['party_logo']);
|
|
|
+ $resdata = [];
|
|
|
+ if (!empty($list)) {
|
|
|
+
|
|
|
+ $roomService = new RoomService();
|
|
|
+
|
|
|
+ foreach($list as $k => $v) {
|
|
|
+
|
|
|
+ $mod = isset($v["party_type"]) ? intval($v["party_type"])%5 : 1;
|
|
|
+
|
|
|
+
|
|
|
+ $userDataResult = $roomService->getPartyUserList(['party_id'=>$v['id']]);
|
|
|
+ $userDataRes = isset($userDataResult['data']) ? $userDataResult['data'] : [];
|
|
|
+ $partyUserList = [
|
|
|
+ 'user_list' => isset($userDataRes['member_list']) ? $userDataRes['member_list'] : [],
|
|
|
+ 'online_num' => isset($userDataRes['online_num']) ? $userDataRes['online_num'] : 0,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $resdata[] = [
|
|
|
+ "id" => $v["id"],
|
|
|
+ "user_id" => $v["user_id"],
|
|
|
+ "room_type" => $v['room_type'],
|
|
|
+ "party_id" => $v["party_id"],
|
|
|
+ "r_id" => $v["party_id"],
|
|
|
+ "party_name" => $v["party_name"],
|
|
|
+ "party_hot" => $v['party_hot'],
|
|
|
+ "party_logo" => $v["party_logo"],
|
|
|
+ "party_pass" => $v["party_pass"] ? $v["party_pass"]:"",
|
|
|
+ "party_type" => $v['type_name'],
|
|
|
+ "party_type_color" => $mod == 0?5:$mod,
|
|
|
+ "easemob_room_id" => $v['easemob_room_id'],
|
|
|
+ "party_user" => $partyUserList,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success("获取成功!",$resdata);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private function reset_all_party(){
|
|
|
+
|
|
|
+ $redisPartyRankList = $this->redis->zRevRange("partyRank",0,-1,true);
|
|
|
+
|
|
|
+ $redisLiveRankList = $this->redis->zRevRange("liveRank",0,-1,true);
|
|
|
+
|
|
|
+ $roomService = new RoomService();
|
|
|
+ if(!$redisPartyRankList) {
|
|
|
+ $roomParams = ['room_type' => 1];
|
|
|
+ $roomPartyRes = $roomService->roomRedis($roomParams);
|
|
|
+ $redisPartyRankList = $roomPartyRes['data'];
|
|
|
+ }
|
|
|
+ if(!$redisLiveRankList) {
|
|
|
+ $roomParams = ['room_type' => 2];
|
|
|
+ $roomLiveRes = $roomService->roomRedis($roomParams);
|
|
|
+ $redisLiveRankList = $roomLiveRes['data'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取派对用户排序,(日榜,周榜,月榜) X (魅力榜,财富榜)
|
|
|
+ */
|
|
|
+
|
|
|
+ $room_type = input('room_type',1);
|
|
|
+ $party_id = input("party_id");
|
|
|
+ if (!$party_id) $this->error(__('Invalid parameters'));
|
|
|
+
|
|
|
+
|
|
|
+ $res = [];
|
|
|
+
|
|
|
+ $day = date("Ymd");
|
|
|
+
|
|
|
+ $weekday = $this->firstOfWeek(date("Y-m-d H:i:s"));
|
|
|
+
|
|
|
+ $monthday = date("Ym01");
|
|
|
+ $userModel = new \app\common\model\User();
|
|
|
+
|
|
|
+ $num = 50;
|
|
|
+
|
|
|
+
|
|
|
+ $getday = $this->redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_get_".$party_id.":".$day."d",0,$num-1,true);
|
|
|
+ $res['getRankListDay'] = $userModel->rankList($getday);
|
|
|
+
|
|
|
+
|
|
|
+ $today = $this->redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_to_".$party_id.":".$day."d",0,$num-1,true);
|
|
|
+ $res['toRankListDay'] = $userModel->rankList($today);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $getweek = $this->redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_get_".$party_id.":".$weekday."w",0,$num-1,true);
|
|
|
+ $res['getRankListWeek'] = $userModel->rankList($getweek);
|
|
|
+
|
|
|
+
|
|
|
+ $toweek = $this->redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_to_".$party_id.":".$weekday."w",0,$num-1,true);
|
|
|
+ $res['toRankListWeek'] = $userModel->rankList($toweek);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $toweek = $this->redis->zRevRange($this->roomTypeArr[$room_type]."_jewel_get_".$party_id.":".$monthday."m",0,$num-1,true);
|
|
|
+ $res['getRankListMonth'] = $userModel->rankList($toweek);
|
|
|
+
|
|
|
+
|
|
|
+ $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);
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+ public function getPartyUserRank() {
|
|
|
+ $party_id = input("party_id");
|
|
|
+ if (!$party_id) $this->error(__('Invalid parameters'));
|
|
|
+
|
|
|
+ $userModel = new \app\common\model\User();
|
|
|
+
|
|
|
+
|
|
|
+ $getday = $this->redis->zRevRange("hourCharm_".$party_id,0,-1,true);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $res['getRankListDay'] = $userModel->rankList($getday);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $today = $this->redis->zRevRange("hourWealth_".$party_id,0,-1,true);
|
|
|
+ $res['toRankListDay'] = $userModel->rankList($today);
|
|
|
+
|
|
|
+ return $this->success("获取成功!",$res);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 派对热度更新(已废弃)
|
|
|
+ */
|
|
|
+
|
|
|
+ $party_id = input('party_id',0,"intval");
|
|
|
+ $room_type = input('room_type',1);
|
|
|
+ $party_hot = input('party_hot');
|
|
|
+ if (!$party_id || !$party_hot) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->zIncrBy($this->roomTypeArr[$room_type]."Rank", $party_hot, $party_id);
|
|
|
+ return $this->success("更新成功!");
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 更新主持人和麦位前四位至首页房间排行
|
|
|
+ */
|
|
|
+ public function addUserPositionToParty() {
|
|
|
+ $party_id = input('party_id',0,"intval");
|
|
|
+ $user_id = input('user_id',0,"intval");
|
|
|
+ $upOrdown = input('upordown');
|
|
|
+ $room_type = input('room_type',1);
|
|
|
+ $avatar = input('avatar');
|
|
|
+ $position = input('position');
|
|
|
+ if (!$party_id || !$user_id || !in_array($position,[0,1,2,3,4,5,6,7,8]) || !in_array($upOrdown,[1,-1])) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+
|
|
|
+ if($upOrdown == 1) {
|
|
|
+
|
|
|
+ \app\common\model\UserOnsiteTime::update(["status"=>2],["user_id"=>$user_id]);
|
|
|
+
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ $data["user_id"] = $user_id;
|
|
|
+ $data["party_id"] = $party_id;
|
|
|
+ $data["onsite_time"] = time();
|
|
|
+ \app\common\model\UserOnsiteTime::insert($data);
|
|
|
+ }
|
|
|
+ if($upOrdown == -1) {
|
|
|
+
|
|
|
+ $update = [];
|
|
|
+ $update["offsite_time"] = time();
|
|
|
+ $update["status"] = 2;
|
|
|
+ \app\common\model\UserOnsiteTime::update($update,["user_id"=>$user_id,"status"=>1]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(in_array($position,[5,6,7,8])) return $this->success("设置成功!");
|
|
|
+
|
|
|
+
|
|
|
+ $redisData = $this->redis->get($this->roomTypeArr[$room_type]."_".$party_id);
|
|
|
+ if($redisData) {
|
|
|
+ $partyInfo = json_decode($redisData,true);
|
|
|
+ if($upOrdown == 1) {
|
|
|
+
|
|
|
+ $partyuser = isset($partyInfo["party_user"])?$partyInfo["party_user"]:"";
|
|
|
+ if(is_array($partyuser)) foreach($partyuser as $k => $v) if($v === $avatar) unset($partyInfo["party_user"][$k]);
|
|
|
+
|
|
|
+ $partyInfo["party_user"][$position] = $avatar;
|
|
|
+ } else {
|
|
|
+ if(isset($partyInfo["party_user"])) unset($partyInfo["party_user"][$position]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->redis->set($this->roomTypeArr[$room_type]."_".$party_id,json_encode($partyInfo));
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->success("设置成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取派对在线人数列表
|
|
|
+ */
|
|
|
+ public function getOnlieList() {
|
|
|
+ $party_id = input('party_id',0,"intval");
|
|
|
+
|
|
|
+ if (!$party_id) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $res = $this->redis->hGetAll("online_".$party_id);
|
|
|
+ $user_ids = [];$userList = [];
|
|
|
+ if($res) $user_ids = array_values($res);
|
|
|
+
|
|
|
+ if($user_ids){
|
|
|
+ $userList = Db::name('user')->alias('user')->field("user.id,user.avatar,user.nickname,user.level,user.gender,user.charm_level,user.wealth_level,charm.image as charm_image,charm.color as charm_color,wealth.image as wealth_image,wealth.color as wealth_color")
|
|
|
+ ->join('user_config_charm charm','user.charm_level = charm.level','LEFT')
|
|
|
+ ->join('user_config_wealth wealth','user.wealth_level = wealth.level','LEFT')
|
|
|
+ ->where(["user.id"=>["in",$user_ids],'user.is_stealth'=>0])
|
|
|
+ ->autopage()->select();
|
|
|
+ $userList = list_domain_image($userList,['avatar','charm_image','wealth_image']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success("获取成功!",$userList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * @param $user_id
|
|
|
+ * @param $party_id
|
|
|
+ * @return int
|
|
|
+ */
|
|
|
+ private function getUserJoinPartyDays($user_id, $party_id)
|
|
|
+ {
|
|
|
+ $days = 1;
|
|
|
+ $joinPartyDays = $this->redis->hGet("joinParty_days",$user_id."-".$party_id);
|
|
|
+ if ($joinPartyDays){
|
|
|
+ $joinPartyDaysArr = explode('-',$joinPartyDays);
|
|
|
+ $oldTime = (int)$joinPartyDaysArr[0];
|
|
|
+ $todayStartTime = strtotime(date('Y-m-d'));
|
|
|
+ $yesterdayStartTime = strtotime(date("Y-m-d",strtotime("-1 day")));
|
|
|
+ $todayEndTime = $todayStartTime+24 * 60 * 60-1;
|
|
|
+
|
|
|
+
|
|
|
+ if ($yesterdayStartTime <= $oldTime && $oldTime < $todayStartTime){
|
|
|
+ $days = (int)$joinPartyDaysArr[1];
|
|
|
+ $days++;
|
|
|
+ $this->redis->hSet("joinParty_days", $user_id . "-" . $party_id, time().'-'. $days);
|
|
|
+ }elseif($todayStartTime <= $oldTime && $oldTime <= $todayEndTime){
|
|
|
+
|
|
|
+ $days = (int)$joinPartyDaysArr[1];
|
|
|
+ } else {
|
|
|
+ $this->redis->hSet("joinParty_days", $user_id . "-" . $party_id, time().'-1');
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $this->redis->hSet("joinParty_days", $user_id . "-" . $party_id, time().'-1');
|
|
|
+ }
|
|
|
+ return $days;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 加入派对
|
|
|
+ */
|
|
|
+ public function joinParty() {
|
|
|
+ $party_id = input('party_id',0,"intval");
|
|
|
+ $room_type = input("room_type",1);
|
|
|
+ $party_pass = input("party_pass");
|
|
|
+ if (!$party_id || !in_array($room_type,[1,2])) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+ $user_id = $this->auth->id;
|
|
|
+
|
|
|
+
|
|
|
+ $partyInfo = Db::name('party')->where('id',$party_id)->find();
|
|
|
+ if($partyInfo) {
|
|
|
+
|
|
|
+ if($partyInfo["status"] != 1) $this->error("该房间已被解散!");
|
|
|
+
|
|
|
+
|
|
|
+ $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("派对密码不正确!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if ($guildInfo) {
|
|
|
+
|
|
|
+ $guildMemberInfo = \app\common\model\GuildMember::where(["user_id" => $user_id, "guild_id" => $guildInfo['id'], 'status' => 1])->find();
|
|
|
+ if ($guildMemberInfo && $guildMemberInfo['role'] == 0 && $partyInfo['is_online'] == 0) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ $this->error("派对信息获取失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $lsetList = [];
|
|
|
+
|
|
|
+ for($i=1;$i<=4;$i++) {
|
|
|
+ $hgetlist = $this->redis->hGet("party_manage_".$party_id,$user_id."-".$i);
|
|
|
+
|
|
|
+ $hgetlist = unserialize($hgetlist);
|
|
|
+
|
|
|
+ if($hgetlist){
|
|
|
+ $restime = time() - intval($hgetlist["createtime"]);
|
|
|
+ }else{
|
|
|
+ $restime = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if($hgetlist && $i == 1) {
|
|
|
+ $lsetList["manage_restime"] = "";
|
|
|
+
|
|
|
+ $this->setGroupAdmin($partyInfo['easemob_room_id'],$user_id,1);
|
|
|
+ }
|
|
|
+
|
|
|
+ if($hgetlist && $i == 2 && $restime < $hgetlist["time"]) {
|
|
|
+ $lsetList["manage_notalk"] = $restime;
|
|
|
+ }
|
|
|
+
|
|
|
+ if($hgetlist && $i == 3 && $restime < $hgetlist["time"] && $this->auth->is_manager == 0) {
|
|
|
+ $restime = date("Y-m-d H:i:s",($hgetlist["time"]+$hgetlist["createtime"]));
|
|
|
+ $this->error(__('您已被该房间拉黑,解除时间:'.$restime));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if($hgetlist && $i == 4 && $restime < $hgetlist["time"] && $this->auth->is_manager == 0) {
|
|
|
+ $restime = date("Y-m-d H:i:s",($hgetlist["time"]+$hgetlist["createtime"]));
|
|
|
+ $this->error(__('您已被该房间踢出,解除时间:'.$restime));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->zAdd("party_user_".$party_id,$user_id,$user_id);
|
|
|
+ $this->redis->hSet("online_".$party_id,$user_id,$user_id);
|
|
|
+
|
|
|
+
|
|
|
+ $livingUserPartyId = $this->redis->hGet("livingUser", $user_id);
|
|
|
+ if ($livingUserPartyId) {
|
|
|
+ if($livingUserPartyId != $party_id){
|
|
|
+
|
|
|
+ $this->redis->HDel("online_" . $livingUserPartyId, $user_id);
|
|
|
+
|
|
|
+ $this->redis->zRem("party_user_".$livingUserPartyId, $user_id);
|
|
|
+
|
|
|
+ $this->redis->hDel("livingUser", $user_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->hSet("livingUser", $user_id, $party_id);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $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"]) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ $partyInfo["type_name"] = "普通房";
|
|
|
+ }
|
|
|
+ $partyInfo["party_hot"] = changeW($partyInfo["party_hot"]);
|
|
|
+ $partyInfo['is_new'] = $partyInfo["status"] == 0 ? 1 : 0;
|
|
|
+ $partyInfo['join_days'] = $this->getUserJoinPartyDays($user_id,$party_id);
|
|
|
+ $lsetList["partyInfo"] = $partyInfo;
|
|
|
+
|
|
|
+
|
|
|
+ $lsetList['shengwang_token'] = $this->shengwang_token_private($partyInfo['easemob_room_id']);
|
|
|
+
|
|
|
+
|
|
|
+ $easemob = new Easemob();
|
|
|
+ $matedata = [
|
|
|
+ 'online_user_num' => count($this->redis->hGetAll("online_".$party_id)),
|
|
|
+ ];
|
|
|
+
|
|
|
+ $easemob->room_setRoomCustomAttributeForced($partyInfo['easemob_room_id'],$partyInfo['user_id'],$matedata);
|
|
|
+
|
|
|
+ return $this->success("加入成功!",$lsetList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function creater_joinParty($party_id,$easemob_room_id,$party_user_id) {
|
|
|
+
|
|
|
+ $user_id = $this->auth->id;
|
|
|
+
|
|
|
+
|
|
|
+ $lsetList = [];
|
|
|
+
|
|
|
+ for($i=1;$i<=4;$i++) {
|
|
|
+ $hgetlist = $this->redis->hGet("party_manage_".$party_id,$user_id."-".$i);
|
|
|
+
|
|
|
+ $hgetlist = unserialize($hgetlist);
|
|
|
+
|
|
|
+
|
|
|
+ if($hgetlist && $i == 1) {
|
|
|
+ $lsetList["manage_restime"] = "";
|
|
|
+
|
|
|
+ $this->setGroupAdmin($easemob_room_id,$user_id,1);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->zAdd("party_user_".$party_id,$user_id,$user_id);
|
|
|
+ $this->redis->hSet("online_".$party_id,$user_id,$user_id);
|
|
|
+
|
|
|
+
|
|
|
+ $livingUserPartyId = $this->redis->hGet("livingUser", $user_id);
|
|
|
+ if ($livingUserPartyId) {
|
|
|
+ if($livingUserPartyId != $party_id){
|
|
|
+
|
|
|
+ $this->redis->HDel("online_" . $livingUserPartyId, $user_id);
|
|
|
+
|
|
|
+ $this->redis->zRem("party_user_".$livingUserPartyId, $user_id);
|
|
|
+
|
|
|
+ $this->redis->hDel("livingUser", $user_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->hSet("livingUser", $user_id, $party_id);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $easemob = new Easemob();
|
|
|
+ $matedata = [
|
|
|
+ 'online_user_num' => count($this->redis->hGetAll("online_".$party_id)),
|
|
|
+ ];
|
|
|
+
|
|
|
+ $easemob->room_setRoomCustomAttributeForced($easemob_room_id,$party_user_id,$matedata);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 判断是否被禁言
|
|
|
+ */
|
|
|
+ public function isNotalk() {
|
|
|
+ $party_id = input('party_id',0,"intval");
|
|
|
+ $user_id = input('user_id',0,"intval");
|
|
|
+ if (!$user_id || !$party_id) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $lsetList = [];
|
|
|
+ $lsetList["is_notalk"] = 0;
|
|
|
+ $lsetList["notalk_time"] = 0;
|
|
|
+
|
|
|
+ $hgetlist = $this->redis->hGet("party_manage_".$party_id,$user_id."-2");
|
|
|
+ if(!$hgetlist){
|
|
|
+ return $this->success("获取成功!",$lsetList);
|
|
|
+ }
|
|
|
+ $hgetlist = unserialize($hgetlist);
|
|
|
+ $restime = time() - intval($hgetlist["createtime"]);
|
|
|
+
|
|
|
+ if($hgetlist && $restime < $hgetlist["time"]) {
|
|
|
+ $lsetList["is_notalk"] = 1;
|
|
|
+ $lsetList["notalk_time"] = $restime;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->success("获取成功!",$lsetList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 退出派对
|
|
|
+ */
|
|
|
+ public function outParty() {
|
|
|
+ $party_id = input('party_id',0,"intval");
|
|
|
+ $room_type = input("room_type",1);
|
|
|
+ if (!$party_id) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+ $userId = $this->auth->id;
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->zRem("party_user_".$party_id,$userId);
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->HDel("online_" . $party_id, $this->auth->id);
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->hDel("livingUser", $this->auth->id);
|
|
|
+
|
|
|
+
|
|
|
+ $key = "party_seat_".$party_id;
|
|
|
+ $seats = $this->redis->hGetAll($key);
|
|
|
+ foreach($seats as $seat_num => $seatuserid){
|
|
|
+ if($seatuserid == $userId){
|
|
|
+ $this->redis->HDel($key, $seat_num);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $partyInfo = $this->redis->get($this->roomTypeArr[$room_type].'_'.$party_id);
|
|
|
+ if ($partyInfo) {
|
|
|
+ $partyInfo = json_decode($partyInfo, true);
|
|
|
+ $memCount = count($this->redis->hGetAll("online_" . $party_id));
|
|
|
+ if ($memCount <= 0) {
|
|
|
+ $partyInfo["is_online"] = 0;
|
|
|
+ $this->redis->set($this->roomTypeArr[$room_type].'_'.$party_id,json_encode($partyInfo));
|
|
|
+ \app\common\model\Party::update(["is_online" => 0], ["id" => $party_id]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $easemob = new Easemob();
|
|
|
+ $matedata = [
|
|
|
+ 'online_user_num' => count($this->redis->hGetAll("online_".$party_id)),
|
|
|
+ ];
|
|
|
+ $easemob->room_setRoomCustomAttributeForced($partyInfo['easemob_room_id'],$partyInfo['user_id'],$matedata);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $singlist = $easemob->room_getRoomCustomAttribute($easemob_room_id,['waitsing_list']);
|
|
|
+ $singlist = json_decode($singlist['waitsing_list'],true);
|
|
|
+
|
|
|
+ if(!empty($singlist)){
|
|
|
+ foreach($singlist as $key => $sing){
|
|
|
+ if($sing['userNo'] == $userId){
|
|
|
+ unset($singlist[$key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $singlist = $this->waitsing_array_column_sort($singlist);
|
|
|
+
|
|
|
+
|
|
|
+ $matedata = [
|
|
|
+ 'waitsing_list' => json_encode($singlist),
|
|
|
+ ];
|
|
|
+ $easemob->room_setRoomCustomAttributeForced($easemob_room_id,$partyInfo['user_id'],$matedata);
|
|
|
+
|
|
|
+ }*/
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $this->success("退出成功!",[]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 派对内搜索用户
|
|
|
+ */
|
|
|
+ public function searchUserParty() {
|
|
|
+ $u_id = input('u_id',0,"intval");
|
|
|
+ $party_id = input('party_id',0,"intval");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $userModel = new \app\common\model\User();
|
|
|
+ $where = [];
|
|
|
+ $where["u_id"] = $u_id;
|
|
|
+ $userInfo = $userModel->field("id,u_id,avatar,nickname,level,gender")->where($where)->select();
|
|
|
+
|
|
|
+ return $this->success("查询成功!",$userInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 设置冠名
|
|
|
+ */
|
|
|
+ public function setNaming() {
|
|
|
+ $party_id = input('party_id',0,"intval");
|
|
|
+ $user_id = input('user_id',0,"intval");
|
|
|
+ $type = input('type',1);
|
|
|
+ if (!$party_id || !$user_id || ($type != 1 && $type != 0)) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $partyModel = new \app\common\model\Party();
|
|
|
+ $data = [];
|
|
|
+ $where = [];
|
|
|
+ $where["id"] = $party_id;
|
|
|
+ $partyInfo = $partyModel->where(["id"=>$party_id])->find();
|
|
|
+ $getredisPartyInfo = $this->redis->get($this->roomTypeArr[$partyInfo->room_type].'_'.$party_id);
|
|
|
+ $redisPartyInfo = json_decode($getredisPartyInfo,true);
|
|
|
+ if($type == 1) {
|
|
|
+ $data["naming"] = $user_id;
|
|
|
+
|
|
|
+ $userInfo = \app\common\model\User::field("id,nickname,avatar")->where(["id"=>$user_id])->find($user_id);
|
|
|
+ $redisPartyInfo["naming"] = $userInfo;
|
|
|
+ } else {
|
|
|
+ $data["naming"] = 0;
|
|
|
+ $redisPartyInfo["naming"] = [];
|
|
|
+ }
|
|
|
+ $this->redis->set($this->roomTypeArr[$partyInfo->room_type].'_'.$party_id,json_encode($redisPartyInfo));
|
|
|
+ $res = $partyModel->update($data,$where);
|
|
|
+ if($res !== false) {
|
|
|
+ $this->success("操作成功!");
|
|
|
+ } else {
|
|
|
+ $this->error("网络错误,请稍后重试!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 派对关注
|
|
|
+ */
|
|
|
+ public function followparty() {
|
|
|
+ $party_id = input('party_id',0,"intval");
|
|
|
+ if (!$party_id) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+ $user_id = $this->auth->id;
|
|
|
+
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ $data["user_id"] = $user_id;
|
|
|
+ $data["party_id"] = $party_id;
|
|
|
+ if(Db::name('party_follow')->where($data)->find()) {
|
|
|
+ $res = Db::name('party_follow')->where($data)->delete();
|
|
|
+
|
|
|
+ $this->success("已取消关注");
|
|
|
+ }
|
|
|
+ $data["createtime"] = time();
|
|
|
+ $res = Db::name('party_follow')->insert($data);
|
|
|
+
|
|
|
+ $this->success("已关注");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 获取派对信息
|
|
|
+ */
|
|
|
+ public function getPartyInfo() {
|
|
|
+ $party_id = input('party_id',0,"intval");
|
|
|
+ if (!$party_id) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+ $user_id = $this->auth->id;
|
|
|
+ $partyModel = new \app\common\model\Party();
|
|
|
+ $userModel = new \app\common\model\User();
|
|
|
+
|
|
|
+ $where = [];
|
|
|
+ $where["a.id"] = $party_id;
|
|
|
+ $partyInfo = $partyModel->alias("a")
|
|
|
+ ->field("a.id,a.user_id,a.party_id,a.party_name,a.party_hot,a.party_logo,a.party_notice,a.party_notice_detail,a.on_model,a.background,a.is_public,
|
|
|
+ rt.id as party_type,rt.name as type_name")
|
|
|
+ ->join("hx_party_type rt","rt.id = a.party_type", "left")
|
|
|
+ ->where($where)
|
|
|
+ ->find();
|
|
|
+
|
|
|
+ if($partyInfo) {
|
|
|
+ $mod = isset($partyInfo["party_type"])?intval($partyInfo["party_type"])%5:1;
|
|
|
+ $partyInfo["party_type_color"] = $mod == 0?5:$mod;
|
|
|
+
|
|
|
+ if(isset($partyInfo["type_name"]) && $partyInfo["type_name"]) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ $partyInfo["type_name"] = "普通房";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $partyInfo["is_follow"] = 0;
|
|
|
+ $where = [];
|
|
|
+ $where["user_id"] = $user_id;
|
|
|
+ $where["party_id"] = $party_id;
|
|
|
+ if(Db::name('party_follow')->where($where)->find()) {
|
|
|
+ $partyInfo["is_follow"] = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $where = [];
|
|
|
+ $where["id"] = $partyInfo["user_id"];
|
|
|
+ $userInfo = $userModel->field("avatar,nickname")->where($where)->find();
|
|
|
+
|
|
|
+
|
|
|
+ $partyInfo["userInfo"] = $userInfo;
|
|
|
+ $partyInfo["party_hot"] = changeW($partyInfo["party_hot"]);
|
|
|
+ }
|
|
|
+ $this->success("获取成功!",$partyInfo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 派对设置
|
|
|
+ */
|
|
|
+ public function setParty() {
|
|
|
+ $party_id = input('party_id',0,"intval");
|
|
|
+ $room_type = input('room_type',1);
|
|
|
+
|
|
|
+ if (!$party_id || !$room_type) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $field_array = ['party_name','party_logo','party_pass','is_screen','on_model','background','is_public','party_notice','party_notice_detail'];
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ foreach($field_array as $key => $field){
|
|
|
+
|
|
|
+
|
|
|
+ if(!request()->has($field,'post')){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ continue;
|
|
|
+ }*/
|
|
|
+
|
|
|
+ $newone = input($field);
|
|
|
+ $data[$field] = $newone;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isset($data['party_pass'])){
|
|
|
+ if(empty($data['party_pass'])){
|
|
|
+ $data['party_pass'] = '';
|
|
|
+ }
|
|
|
+ if(!empty($data['party_pass']) && strlen($data['party_pass']) != 4) {
|
|
|
+ $this->error("房间密码必须为四位!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $partyModel = new \app\common\model\Party();
|
|
|
+ $where = [];
|
|
|
+ $where["id"] = $party_id;
|
|
|
+ $res = $partyModel->update($data,$where);
|
|
|
+ if($res) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $partyInfo = $this->redis->get($this->roomTypeArr[$room_type]."_".$party_id);
|
|
|
+ if($partyInfo) {
|
|
|
+ $partyInfo = json_decode($partyInfo,true);
|
|
|
+ $partyInfo = array_replace($partyInfo,$data);
|
|
|
+ $this->redis->set($this->roomTypeArr[$room_type]."_".$party_id,json_encode($partyInfo));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $matedata = [];
|
|
|
+ if(isset($data['party_name'])){
|
|
|
+ $matedata['party_name'] = $data['party_name'];
|
|
|
+ }
|
|
|
+ if(isset($data['party_logo'])){
|
|
|
+ $matedata['party_logo'] = $data['party_logo'];
|
|
|
+ }
|
|
|
+ if(isset($data['is_public'])){
|
|
|
+ $matedata['is_public'] = $data['is_public'];
|
|
|
+ }
|
|
|
+ if(isset($data['background'])){
|
|
|
+ $matedata['background'] = $data['background'];
|
|
|
+ }
|
|
|
+ if(isset($data['party_notice'])){
|
|
|
+ $matedata['party_notice'] = $data['party_notice'];
|
|
|
+ }
|
|
|
+ if(isset($data['party_notice_detail'])){
|
|
|
+ $matedata['party_notice_detail'] = $data['party_notice_detail'];
|
|
|
+ }
|
|
|
+ if(!empty($matedata)){
|
|
|
+ $easemob = new Easemob();
|
|
|
+ $rs = $easemob->room_setRoomCustomAttributeForced($partyInfo['easemob_room_id'],$partyInfo['user_id'],$matedata);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success("房间设置成功!",$data);
|
|
|
+ } else {
|
|
|
+ $this->error("网络错误,请稍后重试!");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取派对背景
|
|
|
+ */
|
|
|
+ public function getDefaultBackground() {
|
|
|
+ $room_type = input('room_type',1);
|
|
|
+ if (!in_array($room_type,[1,2])) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success("获取成功!",\app\common\model\PartyBackground::where(["room_type"=>$room_type])->select());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private function setGroupAdmin($easemob_room_id,$user_id,$type = 1)
|
|
|
+ {
|
|
|
+ $easemob = new Easemob();
|
|
|
+
|
|
|
+ if($type == 1){
|
|
|
+ $easemob->room_promoteRoomAdmin($easemob_room_id,$user_id);
|
|
|
+ }else{
|
|
|
+ $easemob->room_demoteRoomAdmin($easemob_room_id,$user_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 派对管理设置
|
|
|
+ */
|
|
|
+ public function partyManageSet() {
|
|
|
+ $party_id = input('party_id',0,"intval");
|
|
|
+ $user_id = input('user_id',0,"intval");
|
|
|
+ $item = input('item');
|
|
|
+ $time = input('time');
|
|
|
+ if (!$party_id || !$user_id || !in_array($item,[1,2,3,4])) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if($item>1 && $time<=0) {
|
|
|
+ $this->error(__('时间设置有误'));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $partyinfo = \app\common\model\Party::where('id', $party_id)->field('user_id,easemob_room_id')->find();
|
|
|
+ if ($partyinfo['user_id'] == $user_id && in_array($item, [2, 3, 4])) {
|
|
|
+ $this->error("您当前无权限操作!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if($item == 1 && $this->auth->id != $partyinfo['user_id']){
|
|
|
+ $this->error('只有房主才能设置管理员');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $userInfo = \app\common\model\User::field("avatar,nickname,gender")->where(["id"=>$user_id])->find();
|
|
|
+ if(!$userInfo) $this->error("用户信息获取失败!");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ $data["user_id"] = $user_id;
|
|
|
+ $data["avatar"] = $userInfo->avatar;
|
|
|
+ $data["nickname"] = $userInfo->nickname;
|
|
|
+ $data["gender"] = $userInfo->gender;
|
|
|
+ $data["item"] = $item;
|
|
|
+ $data["time"] = $time;
|
|
|
+ $data["createtime"] = time();
|
|
|
+
|
|
|
+ $res = $this->redis->hSet("party_manage_".$party_id,$user_id."-".$item,serialize($data));
|
|
|
+
|
|
|
+ if ($item==1) {
|
|
|
+ $this->setGroupAdmin($partyinfo['easemob_room_id'],$user_id,1);
|
|
|
+ }
|
|
|
+
|
|
|
+ if($res !== false) {
|
|
|
+ $this->success("设置成功!",$data);
|
|
|
+ } else {
|
|
|
+ $this->error("网络错误,请稍后重试!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 派对管理设置列表
|
|
|
+ * 仅用来给前端展示,禁言的鉴权在isNotalk接口,拉黑与提出的鉴权在joinparty接口
|
|
|
+ */
|
|
|
+ public function partyManageSetList() {
|
|
|
+ $party_id = input('party_id',0,"intval");
|
|
|
+ $item = input('item',1,"intval");
|
|
|
+ if (!$party_id || !in_array($item,[1,2,3,4])) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+ $time = time();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $hget=$this->redis->hGetAll("party_manage_".$party_id);
|
|
|
+ $list=array();
|
|
|
+ foreach($hget as $key=>$val) {
|
|
|
+ if(substr($key,-2) == "-".$item){
|
|
|
+ array_push($list,unserialize($val));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($list) {
|
|
|
+ foreach($list as $k => $v) if(bcadd($v["createtime"],$v["time"]) <= $time && $v["item"] > 1) unset($list[$k]);
|
|
|
+ if($list) $list = array_values($list);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success("获取成功!",$list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 派对管理设置移除
|
|
|
+ */
|
|
|
+ public function partyManageSetDel() {
|
|
|
+ $id = input('user_id',0,"intval");
|
|
|
+ $party_id = input('party_id',0,"intval");
|
|
|
+ $item = input('item',1,"intval");
|
|
|
+ if (!$id || !in_array($item,[1,2,3,4])) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $partyinfo = \app\common\model\Party::where('id', $party_id)->field('user_id,easemob_room_id')->find();
|
|
|
+
|
|
|
+
|
|
|
+ if($item == 1 && $this->auth->id != $partyinfo['user_id']){
|
|
|
+ $this->error('只有房主才能免除管理员');
|
|
|
+ }
|
|
|
+
|
|
|
+ $res = $this->redis->hDel("party_manage_".$party_id,$id."-".$item);
|
|
|
+
|
|
|
+ if ($item==1) {
|
|
|
+ $this->setGroupAdmin($partyinfo['easemob_room_id'],$id,0);
|
|
|
+ }
|
|
|
+
|
|
|
+ if($res !== false) {
|
|
|
+ $this->success("移除成功!",$res);
|
|
|
+ } else {
|
|
|
+ $this->error("网络错误,请稍后重试!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 更新派对公告
|
|
|
+ */
|
|
|
+ public function savePartyNotice() {
|
|
|
+ $party_id = input('party_id',0,"intval");
|
|
|
+ $room_type = input('room_type',1);
|
|
|
+ $party_notice = input('party_notice');
|
|
|
+ $party_notice_detail = input('party_notice_detail');
|
|
|
+ if (!$party_id || !$party_notice || !$party_notice_detail) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+ $partyModel = new \app\common\model\Party();
|
|
|
+ $where = [];
|
|
|
+ $where["id"] = $party_id;
|
|
|
+ $data = [];
|
|
|
+ $data["party_notice"] = $party_notice;
|
|
|
+ $data["party_notice_detail"] = $party_notice_detail;
|
|
|
+ $res = $partyModel->update($data,$where);
|
|
|
+ if($res) {
|
|
|
+
|
|
|
+
|
|
|
+ $partyInfo = $this->redis->get($this->roomTypeArr[$room_type]."_".$party_id);
|
|
|
+ if($partyInfo) {
|
|
|
+ $partyInfo = json_decode($partyInfo,true);
|
|
|
+ $partyInfo = array_replace($partyInfo,$data);
|
|
|
+ $this->redis->set($this->roomTypeArr[$room_type]."_".$party_id,json_encode($partyInfo));
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success("更新成功!",$res);
|
|
|
+ } else {
|
|
|
+ $this->error("网络错误,请稍后重试!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 开始排麦
|
|
|
+ */
|
|
|
+ public function addLineUp() {
|
|
|
+ $party_id = input('party_id',0,"intval");
|
|
|
+ $mai_id = input('mai_id',"1");
|
|
|
+ if (!$party_id) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+ $userInfo = $this->auth->getUserinfo();
|
|
|
+ $userid = $userInfo['id'];
|
|
|
+
|
|
|
+ $partyUser = \app\common\model\Party::where(['id'=>$party_id])->value("user_id");
|
|
|
+ if(!$partyUser) $this->error(__('房间信息未找到!'));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $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;
|
|
|
+ $data[$userid]["nickname"] = $userInfo['nickname'];
|
|
|
+
|
|
|
+
|
|
|
+ $data[$userid]["gender"] = $userInfo['gender'];
|
|
|
+
|
|
|
+ $res = false;
|
|
|
+ $data && $res = $this->redis->hSet("party_lineup",$party_id,serialize($data));
|
|
|
+
|
|
|
+ $data = array_values($data);
|
|
|
+ if($res !== false) {
|
|
|
+ $this->success("设置成功!",$data);
|
|
|
+ } else {
|
|
|
+ $this->error("网络错误,请稍后重试!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 取消排麦
|
|
|
+ */
|
|
|
+ public function cancelLineUp() {
|
|
|
+ $party_id = input('party_id',0,"intval");
|
|
|
+ $user_id = input('user_id',0);
|
|
|
+ $is_empty = input('is_empty',0,"intval");
|
|
|
+ $is_baomai = input('is_baomai',0,'intval');
|
|
|
+
|
|
|
+ if (!$party_id) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $data=unserialize($this->redis->hGet("party_lineup",$party_id));
|
|
|
+
|
|
|
+ $baomai_user = [];
|
|
|
+ if($data && $is_empty != 1) {
|
|
|
+ foreach($data as $k => $v) {
|
|
|
+ if($v["user_id"] == $user_id) {
|
|
|
+ $baomai_user = $v;
|
|
|
+ unset($data[$k]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($is_empty == 1) $data = [];
|
|
|
+ $this->redis->hSet("party_lineup",$party_id,serialize($data));
|
|
|
+
|
|
|
+
|
|
|
+ if($is_empty != 1 && $is_baomai == 1 && !empty($baomai_user)){
|
|
|
+ $this->baomai($party_id,$user_id,$baomai_user);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $datas = [];
|
|
|
+ is_array($data) && $datas=array_values($data);
|
|
|
+ if($datas) {
|
|
|
+ $this->success("移除成功!",$datas);
|
|
|
+ } else {
|
|
|
+ $this->success("移除成功!",[]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private function baomai($party_id,$user_id,$baomai_user){
|
|
|
+
|
|
|
+ $partyinfo = \app\common\model\Party::where('id', $party_id)->field('user_id,easemob_room_id')->find();
|
|
|
+ if(empty($partyinfo)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $easemob = new Easemob();
|
|
|
+ $seatlist = $easemob->room_getRoomCustomAttribute($partyinfo['easemob_room_id'],['seat0','seat1','seat2','seat3','seat4','seat5','seat6','seat7']);
|
|
|
+
|
|
|
+ $newseat = [
|
|
|
+ 'charm' => 0,
|
|
|
+
|
|
|
+ 'isMaster' => false,
|
|
|
+ 'headUrl' => $baomai_user['avatar'],
|
|
|
+ 'userNo' => $baomai_user['user_id'],
|
|
|
+ 'rtcUid' => $baomai_user['user_id'],
|
|
|
+ 'name' => $baomai_user['nickname'],
|
|
|
+ 'seatIndex' => -1,
|
|
|
+ 'chorusSongCode' => '',
|
|
|
+ 'isAudioMuted' => 1,
|
|
|
+ 'isVideoMuted' => 0,
|
|
|
+ 'checked' => false,
|
|
|
+ 'isUsed' => true,
|
|
|
+ 'gender' => $baomai_user['gender'],
|
|
|
+ ];
|
|
|
+
|
|
|
+ if(empty($seatlist)){
|
|
|
+ $newseat['seatIndex'] = 0;
|
|
|
+ $matedata['seat0'] = $newseat;
|
|
|
+ }else{
|
|
|
+
|
|
|
+ foreach($seatlist as $k => $seat){
|
|
|
+ $seat = json_decode($seat,true);
|
|
|
+
|
|
|
+
|
|
|
+ if(isset($seat['rtcUid']) && !empty($seat['rtcUid']) && $seat['rtcUid'] == $user_id){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $matedata = [];
|
|
|
+ foreach($seatlist as $k => $seat){
|
|
|
+ $seat = json_decode($seat,true);
|
|
|
+
|
|
|
+
|
|
|
+ if(isset($seat['rtcUid']) && empty($seat['rtcUid'])){
|
|
|
+
|
|
|
+ $newseat['seatIndex'] = substr($k,-1);
|
|
|
+
|
|
|
+
|
|
|
+ $matedata = [
|
|
|
+ $k => json_encode($newseat),
|
|
|
+ ];
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(!empty($matedata)){
|
|
|
+ $easemob->room_setRoomCustomAttributeForced($partyinfo['easemob_room_id'],$partyinfo['user_id'],$matedata);
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 排麦列表
|
|
|
+ */
|
|
|
+ public function lineUpList() {
|
|
|
+ $party_id = input('party_id',0,"intval");
|
|
|
+ if (!$party_id) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = $this->redis->hGet("party_lineup",$party_id);
|
|
|
+ $dataArr = unserialize($data);
|
|
|
+ $datas = [];
|
|
|
+ is_array($dataArr) && $datas=array_values($dataArr);
|
|
|
+ if($datas) {
|
|
|
+ $this->success("获取成功!",$datas);
|
|
|
+ } else {
|
|
|
+ $this->success("获取成功!",[]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取派对类型
|
|
|
+ */
|
|
|
+ public function getPatyType() {
|
|
|
+ $room_type = input("room_type",1);
|
|
|
+ if (!in_array($room_type,[1,2])) $this->error(__('Invalid parameters'));
|
|
|
+ $partytypeModel = new \app\common\model\PartyType();
|
|
|
+ $partytypeList = $partytypeModel->where(["room_type"=>$room_type])->select();
|
|
|
+ $this->success("获取成功!",$partytypeList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 判断派对是否设置过密码
|
|
|
+ */
|
|
|
+ public function getPatyIspass() {
|
|
|
+ $party_id = input("party_id");
|
|
|
+ $room_type = input("room_type",1);
|
|
|
+ $is_miniprogram = input("is_miniprogram",0);
|
|
|
+ if (!$party_id) $this->error(__('Invalid parameters'));
|
|
|
+
|
|
|
+ $user_id = $this->auth->id;
|
|
|
+
|
|
|
+
|
|
|
+ $partyInfo = $this->redis->get($this->roomTypeArr[$room_type]."_".$party_id);
|
|
|
+ if($partyInfo) {
|
|
|
+ $partyInfo = json_decode($partyInfo,true);
|
|
|
+ } else {
|
|
|
+ $partyModel = new \app\common\model\Party();
|
|
|
+ $partyInfo = $partyModel->field("id,user_id,party_pass")->where(["id"=>$party_id])->find();
|
|
|
+ if(!$partyInfo) {
|
|
|
+ $this->error(__('房间信息获取失败!'));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ $data["status"] = 0;
|
|
|
+ $data["is_pass"] = $partyInfo["party_pass"]?1:0;
|
|
|
+ $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) {
|
|
|
+
|
|
|
+ $lsetList = [];
|
|
|
+ for($i=1;$i<=4;$i++) {
|
|
|
+ $hgetlist = $this->redis->hGet("party_manage_".$party_id,$user_id."-".$i);
|
|
|
+
|
|
|
+ $hgetlist = unserialize($hgetlist);
|
|
|
+ $restime = time() - intval($hgetlist["createtime"]);
|
|
|
+
|
|
|
+
|
|
|
+ if($hgetlist && $i == 1) $lsetList["manage_restime"] = "";
|
|
|
+
|
|
|
+ if($hgetlist && $i == 2 && $restime < $hgetlist["time"]) $lsetList["manage_notalk"] = $restime;
|
|
|
+
|
|
|
+ if($hgetlist && $i == 3 && $restime < $hgetlist["time"]) {
|
|
|
+ $restime = date("Y-m-d H:i:s",($hgetlist["time"]+$hgetlist["createtime"]));
|
|
|
+ $lsetList["manage_black"] = $restime;
|
|
|
+ $lsetList["tips"] = '您已被该房间拉黑,解除时间:'.$restime;
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if($hgetlist && $i == 4 && $restime < $hgetlist["time"]) {
|
|
|
+ $restime = date("Y-m-d H:i:s",($hgetlist["time"]+$hgetlist["createtime"]));
|
|
|
+ $lsetList["manage_takeout"] = $restime;
|
|
|
+ $lsetList["tips"] = '您已被该房间踢出,解除时间:'.$restime;
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if($lsetList) {
|
|
|
+ $data["status"] = 1;
|
|
|
+ $data["hgetlist"] = $lsetList;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success("获取成功!",$data);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取房间gif表情分类
|
|
|
+ */
|
|
|
+ public function getPartyGifType()
|
|
|
+ {
|
|
|
+ $list = \app\common\model\PartyGifType::field("id,name,image")->order("weigh", "asc")->select();
|
|
|
+ $this->success("获取成功!", $list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取房间gif表情列表
|
|
|
+ */
|
|
|
+ public function getPartGifList() {
|
|
|
+ $this->success("获取成功!",\app\common\model\PartyGif::field("id,gif_image")->order("weight","asc")->select());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取房间头像gif表情列表
|
|
|
+ */
|
|
|
+ public function getPartHeadgifList() {
|
|
|
+ $this->success("获取成功!",\app\common\model\PartyHeadgif::field("id,name,gif_image")->order("weight","asc")->select());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 全麦/单独赠送礼物
|
|
|
+ */
|
|
|
+ public function giveGiftToYou() {
|
|
|
+
|
|
|
+ $is_back = input("is_back",0);
|
|
|
+
|
|
|
+
|
|
|
+ if($is_back){
|
|
|
+ if (!$this->apiLimit(50, 1000)) {
|
|
|
+
|
|
|
+ $this->error('休息一下吧');
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if (!$this->apiLimit(10, 1000)) {
|
|
|
+
|
|
|
+ $this->error('休息一下吧');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $this->error('您已被限制:赠送礼物,请联系管理员');
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+ $user_ids = input("user_id");
|
|
|
+ $seat_ids = input("seat_id");
|
|
|
+ $gift_id = input("gift_id",0,'intval');
|
|
|
+ $party_id = input("party_id",0,'intval');
|
|
|
+ $room_type = input('room_type',1,'intval');
|
|
|
+ $number = input("number",1,'intval');
|
|
|
+
|
|
|
+ if (!$user_ids || $seat_ids == '' || !in_array($is_back,[0,1]) || !$gift_id || !$number || !in_array($room_type,[1,2]))
|
|
|
+ {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+ if(!$party_id){
|
|
|
+ $this->error('只有房间内能送礼物');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $user_id_arr = explode(",",$user_ids);
|
|
|
+ $seat_id_arr = explode(",",$seat_ids);
|
|
|
+ $userCount = count($user_id_arr);
|
|
|
+ $seatCount = count($seat_id_arr);
|
|
|
+ if($userCount != $seatCount){
|
|
|
+ $this->error();
|
|
|
+ }
|
|
|
+
|
|
|
+ $userauthid = $this->auth->id;
|
|
|
+ $money_to_jewel = config('site.money_to_jewel') ?: 10000;
|
|
|
+
|
|
|
+
|
|
|
+ if(in_array($userauthid,$user_id_arr)) $this->error("不可以赠送给自己!");
|
|
|
+
|
|
|
+ $backGiftId = 0;
|
|
|
+ $boxgiftInfo = [];
|
|
|
+
|
|
|
+
|
|
|
+ $giftValue = 0;
|
|
|
+
|
|
|
+ $getValue = 0;
|
|
|
+
|
|
|
+ $hotValue = 0;
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+
|
|
|
+ if($is_back == 1) {
|
|
|
+
|
|
|
+ $giftbackInfo = Db::name('gift_back')->field('gift_id')->where('id',$gift_id)->find();
|
|
|
+ if(!$giftbackInfo){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error("背包礼物获取失败");
|
|
|
+ }
|
|
|
+ $backGiftId = $giftbackInfo['gift_id'];
|
|
|
+
|
|
|
+
|
|
|
+ $allCount = $number*$userCount;
|
|
|
+ $giftbackList = Db::name('gift_back')->field('id,value,name,image,gif_image,number')->where(["gift_id"=>$backGiftId,"user_id"=>$userauthid,'is_use'=>0])->limit($allCount)->order('id asc')->lock(true)->select();
|
|
|
+
|
|
|
+ if(count($giftbackList) < $allCount)
|
|
|
+ {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error("背包数量不足");
|
|
|
+ }
|
|
|
+
|
|
|
+ $giftInfo = isset($giftbackList[0]) ? $giftbackList[0] : [];
|
|
|
+ $giftInfo['is_baobi'] = 0;
|
|
|
+
|
|
|
+ $giftValue = $giftInfo["value"] * $number;
|
|
|
+
|
|
|
+ $giftCountValue = $giftValue * $userCount;
|
|
|
+ } else {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $giftInfo = Db::name('gift')->field('id,value,name,image,special as gif_image,is_baobi')->where('id',$gift_id)->find();
|
|
|
+ if (!$giftInfo) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error("请选择礼物!");
|
|
|
+ }
|
|
|
+
|
|
|
+ $giftValue = $giftInfo["value"] * $number;
|
|
|
+
|
|
|
+
|
|
|
+ $giftCountValue = $giftValue * $userCount;
|
|
|
+ $user_jewel = model('wallet')->getWallet($this->auth->id,'jewel');
|
|
|
+ if($user_jewel < $giftCountValue){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error("您的金币余额不足!");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $partyInfo = null;
|
|
|
+
|
|
|
+ $partyInfo = \app\common\model\Party::field("id,room_type,party_name,party_hot,user_id,platRate,guilderRate,easemob_room_id")->where(["id"=>$party_id])->find();
|
|
|
+ if(empty($partyInfo)){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error("不存在的派对!");
|
|
|
+ }
|
|
|
+
|
|
|
+ $platRate = $partyInfo->platRate;
|
|
|
+ $guilderRate = $partyInfo->guilderRate;
|
|
|
+
|
|
|
+
|
|
|
+ if($is_back != 1){
|
|
|
+ if(isset($giftInfo['is_baobi']) && $giftInfo['is_baobi'] == 1){
|
|
|
+ $platRate = config('site.baobi_gift_platrate');
|
|
|
+ $guilderRate = config('site.baobi_gift_guilderrate');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $returnData = [];
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $i = 0;
|
|
|
+
|
|
|
+
|
|
|
+ foreach($user_id_arr as $user_id_key => $user_id) {
|
|
|
+
|
|
|
+ if($is_back == 1) {
|
|
|
+ $giftback_ids = array_column($giftbackList,'id');
|
|
|
+
|
|
|
+ if($user_id_key == 0){
|
|
|
+
|
|
|
+ $res1 = Db::name('gift_back')->where('id','IN',$giftback_ids)->delete();
|
|
|
+ if(!$res1){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('背包送礼物失败');
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+
|
|
|
+ $res1 = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ $res1 = true;
|
|
|
+
|
|
|
+
|
|
|
+ $rs_wallet = model('wallet')->lockChangeAccountRemain($userauthid, $giftValue, '-', 0, "赠送礼物:'" . $giftInfo["name"] . "',扣除" . $giftValue . "金币!", 3,'jewel');
|
|
|
+ if($rs_wallet['status'] == false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($rs_wallet['msg']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ $data["user_id"] = $userauthid;
|
|
|
+ $data["user_to_id"] = $user_id;
|
|
|
+ $data["seat_num"] = $seat_id_arr[$user_id_key];
|
|
|
+ $data["party_id"] = $party_id;
|
|
|
+
|
|
|
+
|
|
|
+ $data["gift_id"] = $backGiftId > 0 ? $backGiftId : $gift_id;
|
|
|
+ $data["gift_give_type"] = $is_back ? 1 : 2;
|
|
|
+ $data["gift_name"] = $giftInfo["name"];
|
|
|
+ $data["gift_gif_image"] = $giftInfo["image"];
|
|
|
+ $data["number"] = $number;
|
|
|
+ $data["price"] = $giftInfo["value"];
|
|
|
+ $data["value"] = $giftValue;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $data['platvalue'] = bcmul($platRate/100 ,$data["value"],2);
|
|
|
+ $data['guildervalue'] = bcmul($guilderRate/100 ,$data["value"],2);
|
|
|
+ $data['guildermoney'] = bcdiv($data['guildervalue'],$money_to_jewel,2);
|
|
|
+ $data['getvalue'] = bcsub(bcsub($data["value"] ,$data['platvalue'],2),$data['guildervalue'],2);
|
|
|
+
|
|
|
+ $data['task_status'] = 0;
|
|
|
+ $data['new_task_status'] = 0;
|
|
|
+ $data["createtime"] = time();
|
|
|
+ $res5 = Db::name('gift_user_party')->insertGetId($data);
|
|
|
+ if(!$res5){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('送礼物失败');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $getMoney = bcdiv($data['getvalue'],$money_to_jewel,2);
|
|
|
+ if($getMoney > 0){
|
|
|
+ $rs_wallet = model('wallet')->lockChangeAccountRemain($user_id,$getMoney,'+',0,"{$this->auth->nickname}送你{$giftInfo['name']}x{$number}",101,'money');
|
|
|
+ if($rs_wallet['status'] == false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($rs_wallet['msg']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $guilderMoney = $data['guildermoney'];
|
|
|
+ if($guilderMoney > 0){
|
|
|
+ $touserInfo = Db::name('user')->field('nickname')->where('id',$user_id)->find();
|
|
|
+ $rs_wallet = model('wallet')->lockChangeAccountRemain($partyInfo->user_id,$guilderMoney,'+',0,"{$this->auth->nickname}送礼物{$giftInfo['name']}x{$number}给{$touserInfo['nickname']},房间礼物抽成",102,'money');
|
|
|
+ if($rs_wallet['status'] == false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($rs_wallet['msg']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+ if ($res1 && $res5) {
|
|
|
+ $i++;
|
|
|
+ if($party_id > 0) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->zIncrBy("hourCharm_".$party_id, $giftValue, $user_id);
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->zIncrBy("hourWealth_".$party_id, $giftValue, $userauthid);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $res_charm = \app\common\model\User::add_charm_level($user_id,$giftValue);
|
|
|
+ */
|
|
|
+
|
|
|
+ \app\common\model\Message::addMessage($user_id,"礼物通知","收到 ".$this->auth->nickname." 赠送的".$giftInfo["name"]." x".$number." 价值 ".$giftValue ." 金币");
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if($is_back != 1){
|
|
|
+ if(isset($giftInfo['is_baobi']) && $giftInfo['is_baobi'] == 1){
|
|
|
+
|
|
|
+ $res_baobi = $this->baobi($this->auth->id,$data["gift_id"],$giftCountValue,$giftInfo["value"]);
|
|
|
+ if($res_baobi === false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('爆币失败');
|
|
|
+ }elseif($res_baobi === true){
|
|
|
+ $returnData['baobi_total'] = 0;
|
|
|
+ $returnData['baobi_beilv'] = 0;
|
|
|
+ }else{
|
|
|
+
|
|
|
+ $returnData['baobi_total'] = $res_baobi['baobi_total'];
|
|
|
+ $returnData['baobi_beilv'] = $res_baobi['baobi_beilv'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $res_wealth = \app\common\model\User::add_wealth_level($this->auth->id,$giftCountValue);
|
|
|
+
|
|
|
+
|
|
|
+ $this->getPartyUserTop($partyInfo, $room_type);
|
|
|
+
|
|
|
+ if($i == $userCount) {
|
|
|
+
|
|
|
+ $returnData["image"] = $giftInfo["image"];
|
|
|
+ $returnData["gif_image"] = $giftInfo["gif_image"];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ $this->success("赠送成功!",$returnData);
|
|
|
+ } else {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error("赠送失败!");
|
|
|
+ }
|
|
|
+ } catch (ValidateException $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ } catch (PDOException $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ } catch (Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function baobi($user_id,$gift_id,$pay_total,$giftInfo_value){
|
|
|
+
|
|
|
+
|
|
|
+ $conf_arr = Db::name('gift_baobi_config')->where('gift_id',$gift_id)->select();
|
|
|
+ if(empty($conf_arr)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $today_start = strtotime(date('Y-m-d')) - (86400 * 3);
|
|
|
+ $today_end = time();
|
|
|
+ $map = [
|
|
|
+
|
|
|
+ 'createtime' => ['BETWEEN',[$today_start,$today_end]],
|
|
|
+ 'gift_id' => $gift_id,
|
|
|
+ ];
|
|
|
+ $today_data = Db::name('gift_baobi_log')->field('IFNULL(sum(pay_total),0) as today_pay_total,IFNULL(sum(baobi_total),0) as today_baobi_total')->where($map)->find();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $baobi_zhisun_bili = Db::name('gift')->where('id',$gift_id)->value('baobi_zhisun_bili');
|
|
|
+ if($today_data['today_baobi_total'] >= bcdiv(bcmul($today_data['today_pay_total'],$baobi_zhisun_bili,2),100,2)){
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ $data['user_id'] = $user_id;
|
|
|
+ $data['gift_id'] = $gift_id;
|
|
|
+ $data['baobi_id'] = 0;
|
|
|
+ $data['beilv'] = 0;
|
|
|
+ $data['rate'] = 0;
|
|
|
+ $data['pay_total'] = $pay_total;
|
|
|
+ $data['baobi_total'] = 0;
|
|
|
+ $data['createtime'] = time();
|
|
|
+
|
|
|
+ $log_id = Db::name('gift_baobi_log')->insertGetId($data);
|
|
|
+ if(!$log_id){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $gailv = [];
|
|
|
+ $bei = 100;
|
|
|
+ foreach ($conf_arr as $key=>$value)
|
|
|
+ {
|
|
|
+ $gailv[$value['id']] = $value['rate']*$bei;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $conf_column = [];
|
|
|
+ foreach ($conf_arr as $key=>$value)
|
|
|
+ {
|
|
|
+ $conf_column[$value['id']] = $value;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $rid = $this->getRand($gailv);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $result = $conf_column[$rid];
|
|
|
+
|
|
|
+
|
|
|
+ $baobi_total = bcmul($giftInfo_value,$result['beilv'],0);
|
|
|
+
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ $data['user_id'] = $user_id;
|
|
|
+ $data['gift_id'] = $gift_id;
|
|
|
+ $data['baobi_id'] = $result['id'];
|
|
|
+ $data['beilv'] = $result['beilv'];
|
|
|
+ $data['rate'] = $result['rate'];
|
|
|
+ $data['pay_total'] = $pay_total;
|
|
|
+ $data['baobi_total'] = $baobi_total;
|
|
|
+ $data['createtime'] = time();
|
|
|
+
|
|
|
+ $log_id = Db::name('gift_baobi_log')->insertGetId($data);
|
|
|
+ if(!$log_id){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if($baobi_total > 0){
|
|
|
+ $rs_wallet = model('wallet')->lockChangeAccountRemain($user_id,$baobi_total,'+',0,'送礼物爆币'.$result['beilv'].'倍',21,'jewel');
|
|
|
+ if($rs_wallet['status'] === false){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'baobi_total' => $baobi_total,
|
|
|
+ 'baobi_beilv' => $result['beilv'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private function getRand($proArr) {
|
|
|
+
|
|
|
+ $proSum = array_sum($proArr);
|
|
|
+
|
|
|
+ $key = rand(1, $proSum);
|
|
|
+
|
|
|
+ $result = 0;
|
|
|
+ $now = 0;
|
|
|
+ foreach ($proArr as $k=>$v)
|
|
|
+ {
|
|
|
+ $now = $now + $v;
|
|
|
+ if($key<=$now)
|
|
|
+ {
|
|
|
+ $result = $k;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ unset ($proArr);
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public function getPartyGiftLog(){
|
|
|
+ $party_id = input('party_id',0);
|
|
|
+ $list = Db::name('gift_user_party')->alias('log')
|
|
|
+ ->field('log.gift_name,log.gift_gif_image,log.number,log.value,log.guildermoney,log.createtime,user.nickname as give_nickname,b.nickname as get_nickname')
|
|
|
+ ->join('user','log.user_id = user.id','LEFT')
|
|
|
+ ->join('user b','log.user_to_id = b.id','LEFT')
|
|
|
+ ->where('log.party_id',$party_id)->order('log.id desc')->autopage()->select();
|
|
|
+ $list = list_domain_image($list,['gift_gif_image']);
|
|
|
+ foreach($list as $key => &$val){
|
|
|
+ $val['createtime'] = get_last_time($val['createtime']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('success',$list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 更新派对信息(热度等)
|
|
|
+ */
|
|
|
+ private function updatePartyHot($partyInfo,$giftValue,$room_type) {
|
|
|
+
|
|
|
+ if(!$partyInfo) return $giftValue;
|
|
|
+
|
|
|
+ $party_hot = $partyInfo->party_hot > 0 ? $partyInfo->party_hot:0;
|
|
|
+ $party_hot_value = $party_hot + $giftValue;
|
|
|
+ $party_hot_value = $party_hot_value > 0 ? $party_hot_value : 0;
|
|
|
+ if($party_hot_value != $party_hot) {
|
|
|
+
|
|
|
+ $partyInfo->party_hot = $party_hot_value;
|
|
|
+ $partyInfo->save();
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->zAdd($this->roomTypeArr[$room_type]."Rank", $partyInfo['party_hot'], $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;
|
|
|
+ $this->redis->set($this->roomTypeArr[$room_type]."_".$partyInfo["id"],json_encode($redPartyInfo));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return $party_hot_value;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 用户赠送礼物后房间内用户排行,财富榜前三名
|
|
|
+ */
|
|
|
+ private function getPartyUserTop($party_info,$room_type) {
|
|
|
+
|
|
|
+
|
|
|
+ $userModel = new \app\common\model\User();
|
|
|
+
|
|
|
+ $num = 3;
|
|
|
+
|
|
|
+ $getweek = $this->redis->zRevRange("hourWealth_".$party_info['id'],0,$num-1,true);
|
|
|
+ $userList = $userModel->rankList($getweek);
|
|
|
+ $avatarArr = [];
|
|
|
+ if($userList) {
|
|
|
+ foreach($userList as $k => $v) {
|
|
|
+ $v["jewel"] > 0 && $avatarArr[] = $v;
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->redis->hSet("user_jewel_top3",$party_info['id'],json_encode($avatarArr));
|
|
|
+
|
|
|
+ }
|
|
|
+ return $avatarArr;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 单个房间魅力值清零
|
|
|
+ */
|
|
|
+ public function partyClearCharm() {
|
|
|
+ $party_id = input("party_id");
|
|
|
+ $userId = input("user_id", 0);
|
|
|
+ if($party_id <= 0) {
|
|
|
+ $this->error("请输入派对ID");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if ($userId) {
|
|
|
+ $this->redis->zRem("hourCharm_" . $party_id, $userId);
|
|
|
+ } else {
|
|
|
+ $this->redis->del("hourCharm_" . $party_id);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success("操作成功!");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public function getPartyUserCharm(){
|
|
|
+ $party_id = input("party_id");
|
|
|
+ $userId = input("user_id", 0);
|
|
|
+ $seat_num = input('seat_num',0);
|
|
|
+
|
|
|
+ $key = "party_seat_".$party_id;
|
|
|
+ $seat_userid = $this->redis->hGet($key,$seat_num);
|
|
|
+ if($seat_userid){
|
|
|
+ $this->error('麦上有人了');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $key = "party_seat_".$party_id;
|
|
|
+ $seats = $this->redis->hGetAll($key);
|
|
|
+ foreach($seats as $seatnum => $seatuserid){
|
|
|
+ if($seatuserid == $userId){
|
|
|
+ $this->redis->HDel($key, $seatnum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->hSet($key,$seat_num,$userId);
|
|
|
+
|
|
|
+
|
|
|
+ $users = $this->redis->zRevRange("hourCharm_".$party_id,0,-1,true);
|
|
|
+
|
|
|
+ $charm = 0;
|
|
|
+ if($users) {
|
|
|
+ foreach($users as $k => $v){
|
|
|
+ if($userId == $k){
|
|
|
+ $charm = changeW($v);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $this->success(1,$charm);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function seat_down(){
|
|
|
+ $party_id = input("party_id");
|
|
|
+ $userId = input("user_id", 0);
|
|
|
+
|
|
|
+
|
|
|
+ $key = "party_seat_".$party_id;
|
|
|
+ $this->redis->HDel($key, $seat_num);*/
|
|
|
+
|
|
|
+
|
|
|
+ $key = "party_seat_".$party_id;
|
|
|
+ $seats = $this->redis->hGetAll($key);
|
|
|
+ foreach($seats as $seat_num => $seatuserid){
|
|
|
+ if($seatuserid == $userId){
|
|
|
+ $this->redis->HDel($key, $seat_num);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success(1);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取音乐列表
|
|
|
+ */
|
|
|
+ public function getMusicList() {
|
|
|
+ $this->success("获取成功!",\app\common\model\Music::select());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function report_party() {
|
|
|
+ $type = input('type');
|
|
|
+ $content = input('content');
|
|
|
+ $images = input('images');
|
|
|
+ $party_id = input('party_id');
|
|
|
+ if (!$type || !$content || !$images || !$party_id) {
|
|
|
+ $this->error("请完成举报内容!");
|
|
|
+ }
|
|
|
+ $data = [];
|
|
|
+ $data["user_id"] = $this->auth->id;
|
|
|
+ $data["party_id"] = $party_id;
|
|
|
+ $data["type"] = $type;
|
|
|
+ $data["content"] = $content;
|
|
|
+ $data["images"] = $images;
|
|
|
+ $data["createtime"] = time();
|
|
|
+ $res = Db::name('party_report')->insertGetId($data);
|
|
|
+ if ($res) {
|
|
|
+ $this->success("举报内容提交成功!");
|
|
|
+ } else {
|
|
|
+ $this->error("网络错误,请稍后重试!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public function waitsing_list(){
|
|
|
+ $party_id = input('party_id');
|
|
|
+
|
|
|
+ $party_info = Db::name('party')->where('id',$party_id)->find();
|
|
|
+ if(empty($party_info)){
|
|
|
+ $this->error();
|
|
|
+ }
|
|
|
+ $easemob_room_id = $party_info['easemob_room_id'];
|
|
|
+ $easemob = new Easemob();
|
|
|
+
|
|
|
+ $singlist = $easemob->room_getRoomCustomAttribute($easemob_room_id,['waitsing_list']);
|
|
|
+ if(empty($singlist)){
|
|
|
+
|
|
|
+ $singlist['waitsing_list'] = '[]';
|
|
|
+ }
|
|
|
+
|
|
|
+ $singlist = json_decode($singlist['waitsing_list'],true);
|
|
|
+
|
|
|
+
|
|
|
+ $singlist = $this->waitsing_array_column_sort($singlist);
|
|
|
+
|
|
|
+ $this->success(1,$singlist);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function waitsing_add(){
|
|
|
+
|
|
|
+ $party_id = input('party_id');
|
|
|
+
|
|
|
+ $party_info = Db::name('party')->where('id',$party_id)->find();
|
|
|
+ if(empty($party_info)){
|
|
|
+ $this->error();
|
|
|
+ }
|
|
|
+ $easemob_room_id = $party_info['easemob_room_id'];
|
|
|
+
|
|
|
+
|
|
|
+ $sing_json = input('sing_json','','htmlspecialchars_decode');
|
|
|
+ $sing_json = json_decode($sing_json,true);
|
|
|
+
|
|
|
+ $sing_json['sing_no'] = createUniqueNo('s');
|
|
|
+ $sing_json['sort'] = time();
|
|
|
+
|
|
|
+
|
|
|
+ $easemob = new Easemob();
|
|
|
+ $singlist = $easemob->room_getRoomCustomAttribute($easemob_room_id,['waitsing_list']);
|
|
|
+ if(empty($singlist)){
|
|
|
+
|
|
|
+ $singlist['waitsing_list'] = '[]';
|
|
|
+ }
|
|
|
+ $singlist = json_decode($singlist['waitsing_list'],true);
|
|
|
+
|
|
|
+
|
|
|
+ $singlist[] = $sing_json;
|
|
|
+
|
|
|
+
|
|
|
+ $singlist = $this->waitsing_array_column_sort($singlist);
|
|
|
+
|
|
|
+
|
|
|
+ $matedata = [
|
|
|
+ 'waitsing_list' => json_encode($singlist),
|
|
|
+ ];
|
|
|
+ $easemob->room_setRoomCustomAttributeForced($easemob_room_id,$party_info['user_id'],$matedata);
|
|
|
+
|
|
|
+
|
|
|
+ $this->success(1,$singlist);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private function waitsing_array_column_sort($data){
|
|
|
+ if(empty($data)){
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ $sort = array_column($data,'sort');
|
|
|
+ $sing_no = array_column($data,'sing_no');
|
|
|
+ $a = array_multisort($sort,SORT_ASC,$sing_no,$data);
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function waitsing_delete(){
|
|
|
+
|
|
|
+ $party_id = input('party_id');
|
|
|
+
|
|
|
+ $party_info = Db::name('party')->where('id',$party_id)->find();
|
|
|
+ if(empty($party_info)){
|
|
|
+ $this->error();
|
|
|
+ }
|
|
|
+ $easemob_room_id = $party_info['easemob_room_id'];
|
|
|
+
|
|
|
+
|
|
|
+ $sing_no = input('sing_no','');
|
|
|
+
|
|
|
+
|
|
|
+ $easemob = new Easemob();
|
|
|
+ $singlist = $easemob->room_getRoomCustomAttribute($easemob_room_id,['waitsing_list']);
|
|
|
+ if(empty($singlist)){
|
|
|
+
|
|
|
+ $singlist['waitsing_list'] = '[]';
|
|
|
+ }
|
|
|
+ $singlist = json_decode($singlist['waitsing_list'],true);
|
|
|
+
|
|
|
+
|
|
|
+ foreach($singlist as $key => $sing){
|
|
|
+ if($sing['sing_no'] == $sing_no){
|
|
|
+ unset($singlist[$key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $singlist = $this->waitsing_array_column_sort($singlist);
|
|
|
+
|
|
|
+
|
|
|
+ $matedata = [
|
|
|
+ 'waitsing_list' => json_encode($singlist),
|
|
|
+ ];
|
|
|
+ $easemob->room_setRoomCustomAttributeForced($easemob_room_id,$party_info['user_id'],$matedata);
|
|
|
+
|
|
|
+
|
|
|
+ $this->success(1,$singlist);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function waitsing_top(){
|
|
|
+
|
|
|
+ $party_id = input('party_id');
|
|
|
+
|
|
|
+ $party_info = Db::name('party')->where('id',$party_id)->find();
|
|
|
+ if(empty($party_info)){
|
|
|
+ $this->error();
|
|
|
+ }
|
|
|
+ $easemob_room_id = $party_info['easemob_room_id'];
|
|
|
+
|
|
|
+
|
|
|
+ $sing_no = input('sing_no','');
|
|
|
+
|
|
|
+
|
|
|
+ $easemob = new Easemob();
|
|
|
+ $singlist = $easemob->room_getRoomCustomAttribute($easemob_room_id,['waitsing_list']);
|
|
|
+ if(empty($singlist)){
|
|
|
+
|
|
|
+ $singlist['waitsing_list'] = '[]';
|
|
|
+ }
|
|
|
+ $singlist = json_decode($singlist['waitsing_list'],true);
|
|
|
+
|
|
|
+
|
|
|
+ if(!empty($singlist)){
|
|
|
+
|
|
|
+ $sort = array_column($singlist,'sort');
|
|
|
+ ksort($sort);
|
|
|
+
|
|
|
+ foreach($singlist as $key => &$sing){
|
|
|
+ if($sing['sing_no'] == $sing_no){
|
|
|
+ $sing['sort'] = $sort[0] - 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $singlist = $this->waitsing_array_column_sort($singlist);
|
|
|
+
|
|
|
+
|
|
|
+ $matedata = [
|
|
|
+ 'waitsing_list' => json_encode($singlist),
|
|
|
+ ];
|
|
|
+ $easemob->room_setRoomCustomAttributeForced($easemob_room_id,$party_info['user_id'],$matedata);
|
|
|
+
|
|
|
+
|
|
|
+ $this->success(1,$singlist);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public function room_task(){
|
|
|
+
|
|
|
+ $ids = Db::name('party')->select();
|
|
|
+
|
|
|
+ $easemob = new Easemob();
|
|
|
+ foreach($ids as $key => $party){
|
|
|
+
|
|
|
+
|
|
|
+ $matedata = [
|
|
|
+ 'seatnum'=> $party['seatnum'],
|
|
|
+ 'waitsing_list' => json_encode([]),
|
|
|
+ 'party_name' => $party['party_name'],
|
|
|
+ 'party_logo' => localpath_to_netpath($party['party_logo']),
|
|
|
+ 'is_public' => $party['is_public'],
|
|
|
+ 'room_type' => $party['room_type'],
|
|
|
+ 'online_user_num' => 0,
|
|
|
+ 'wealth_top3_userlist' => json_encode([]),
|
|
|
+ 'background' => '',
|
|
|
+ ];
|
|
|
+ $rs = $easemob->room_setRoomCustomAttributeForced($party['easemob_room_id'],$party['user_id'],$matedata);
|
|
|
+
|
|
|
+
|
|
|
+ $seatdata = [];
|
|
|
+ for($i=0;$i<$party['seatnum'];$i++){
|
|
|
+ $seat = [
|
|
|
+ 'charm' => 0,
|
|
|
+
|
|
|
+ 'isMaster' => false,
|
|
|
+ 'headUrl' => '',
|
|
|
+ 'userNo' => '',
|
|
|
+ 'rtcUid' => '',
|
|
|
+ 'name' => '',
|
|
|
+ 'seatIndex' => -1,
|
|
|
+ 'chorusSongCode' => '',
|
|
|
+ 'isAudioMuted' => 1,
|
|
|
+ 'isVideoMuted' => 0,
|
|
|
+ 'checked' => false,
|
|
|
+ 'isUsed' => true,
|
|
|
+ 'gender' => 1,
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
+ $owner = Db::name('user')->where('id',$party['user_id'])->find();
|
|
|
+ if($i == 0){
|
|
|
+ $seat['isMaster'] = true;
|
|
|
+ $seat['headUrl'] = localpath_to_netpath($owner['avatar']);
|
|
|
+ $seat['userNo'] = $owner['id'];
|
|
|
+ $seat['rtcUid'] = $owner['id'];
|
|
|
+ $seat['name'] = $owner['nickname'];
|
|
|
+ $seat['seatIndex']= $i;
|
|
|
+ }
|
|
|
+
|
|
|
+ $seatdata['seat'.$i] = json_encode($seat);
|
|
|
+ }
|
|
|
+ $rs = $easemob->room_setRoomCustomAttributeForced($party['easemob_room_id'],$party['user_id'],$seatdata);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function test_party_attr(){
|
|
|
+ $party_id = input('party_id',0);
|
|
|
+ $party_info = Db::name('party')->where('id',$party_id)->find();
|
|
|
+
|
|
|
+ $easemob = new Easemob();
|
|
|
+
|
|
|
+ $field = [
|
|
|
+ 'seatnum',
|
|
|
+ 'waitsing_list',
|
|
|
+ 'party_name',
|
|
|
+ 'party_logo',
|
|
|
+ 'is_public',
|
|
|
+ 'room_type',
|
|
|
+ 'online_user_num',
|
|
|
+ 'wealth_top3_userlist',
|
|
|
+ 'background',
|
|
|
+ 'party_notice',
|
|
|
+ 'party_notice_detail',
|
|
|
+ ];
|
|
|
+ for($i=0;$i<$party_info['seatnum'];$i++){
|
|
|
+ $field[] = 'seat'.$i;
|
|
|
+ }
|
|
|
+ $all_attr = $easemob->room_getRoomCustomAttribute($party_info['easemob_room_id'],$field);
|
|
|
+ dump($all_attr);
|
|
|
+ echo '<hr>';
|
|
|
+ foreach($all_attr as $key => $val){
|
|
|
+ echo $key;
|
|
|
+ echo '<br>';
|
|
|
+ $val = json_decode($val,true);
|
|
|
+ dump($val);
|
|
|
+ echo '<hr>';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 'background' => '1.jpg',
|
|
|
+ ];
|
|
|
+ $rs = $easemob->room_setRoomCustomAttributeForced($party_info['easemob_room_id'],$party_info['user_id'],$matedata);
|
|
|
+ dump($rs);*/
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * redis清理排行榜 并数据库备份
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+ $yestaday = date("Ymd",bcsub(time(),86400));
|
|
|
+
|
|
|
+ $preweek = $this->firstOfWeek(date("Y-m-d H:i:s",bcsub(time(),604800)));
|
|
|
+
|
|
|
+ $monty = bcsub(date("m"),1);
|
|
|
+ if($monty < 10) $monty = "0".$monty;
|
|
|
+ $premonth = date("Y").$monty."01";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $party_ids = \app\common\model\Party::where(["status"=>1])->column("id");
|
|
|
+
|
|
|
+ $time = time();
|
|
|
+ if($party_ids) foreach($party_ids as $k => $v) {
|
|
|
+ $keys = [
|
|
|
+ "party_jewel_get_".$v.":".$yestaday."d",
|
|
|
+ "party_jewel_to_".$v.":".$yestaday."d",
|
|
|
+ "party_jewel_get_".$v.":".$preweek."w",
|
|
|
+ "party_jewel_to_".$v.":".$preweek."w",
|
|
|
+ "party_jewel_get_".$v.":".$premonth."m",
|
|
|
+ "party_jewel_to_".$v.":".$premonth."m",
|
|
|
+ ];
|
|
|
+ foreach($keys as $key) {
|
|
|
+
|
|
|
+ $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 && $this->redis->zRemRangeByRank($key,0,-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+ public function handleParty() {
|
|
|
+ return false;
|
|
|
+ $partyList = \app\common\model\Party::where('is_online',1)->select();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ foreach ($partyList as $party){
|
|
|
+
|
|
|
+
|
|
|
+ $userId = $party['user_id'];
|
|
|
+ $roomId = $party['id'];
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->HDel("online_" . $roomId, $userId);
|
|
|
+ $this->redis->zRem("party_user_".$roomId, $userId);
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis->hDel("livingUser",$userId);
|
|
|
+
|
|
|
+
|
|
|
+ $partyInfo = $this->redis->get("party_" . $roomId);
|
|
|
+ if ($partyInfo) {
|
|
|
+ $partyInfo = json_decode($partyInfo, true);
|
|
|
+ $memCount = count($this->redis->hGetAll("online_" . $roomId));
|
|
|
+ if ($memCount <= 0) {
|
|
|
+ dump($roomId.'--1---');
|
|
|
+ $partyInfo["is_online"] = 0;
|
|
|
+ $this->redis->set("party_" . $roomId, json_encode($partyInfo));
|
|
|
+ \app\common\model\Party::update(["is_online" => 0], ["id" => $roomId]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $liveInfo = $this->redis->get("live_" . $roomId);
|
|
|
+ if ($liveInfo) {
|
|
|
+ $liveInfo = json_decode($liveInfo, true);
|
|
|
+ $memCount = count($this->redis->hGetAll("online_" . $roomId));
|
|
|
+ if ($memCount <= 0) {
|
|
|
+ dump($roomId.'---2--');
|
|
|
+ $liveInfo["is_online"] = 0;
|
|
|
+ $this->redis->set("live_" . $roomId, json_encode($liveInfo));
|
|
|
+ \app\common\model\Party::update(["is_online" => 0], ["id" => $roomId]);
|
|
|
+ }else{
|
|
|
+ dump($roomId.'---3--');
|
|
|
+ $this->redis->del("online_" . $roomId);
|
|
|
+ $liveInfo["is_online"] = 0;
|
|
|
+ $this->redis->set("live_" . $roomId, json_encode($liveInfo));
|
|
|
+ \app\common\model\Party::update(["is_online" => 0], ["id" => $roomId]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $this->success("获取成功!");
|
|
|
+ }
|
|
|
+}
|