|
@@ -1404,16 +1404,19 @@ class Party extends Api
|
|
|
$party_id = input('party_id',0,"intval"); // 直播间ID
|
|
|
$user_id = input('user_id',0); // 直播间ID
|
|
|
$is_empty = input('is_empty',0,"intval"); // 是否清空排麦列表 1=清空,0=不清空
|
|
|
+ $is_baomai = input('is_baomai',0,'intval'); //是否抱麦
|
|
|
+
|
|
|
if (!$party_id) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
- $userid = $this->auth->id;
|
|
|
|
|
|
$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;
|
|
|
}
|
|
@@ -1423,7 +1426,12 @@ class Party extends Api
|
|
|
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) {
|
|
@@ -1433,6 +1441,61 @@ class Party extends Api
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取所有麦位,假设8个
|
|
|
+ $easemob = new Easemob();
|
|
|
+ $seatlist = $easemob->room_getRoomCustomAttribute($partyinfo['easemob_room_id'],['seat1','seat2','seat3','seat4','seat5','seat6','seat7','seat8']);
|
|
|
+
|
|
|
+ $newseat = [
|
|
|
+ 'charm' => 0, //红心,魅力值
|
|
|
+
|
|
|
+ 'isMaster' => false, // 是否是房主
|
|
|
+ 'headUrl' => $baomai_user['avatar'], // 头像
|
|
|
+ 'userNo' => $baomai_user['user_id'], // 座位上用户no
|
|
|
+ 'rtcUid' => $baomai_user['user_id'], // 座位上用户id,与rtc的userId一致
|
|
|
+ 'name' => $baomai_user['nickname'], // 座位上用户昵称
|
|
|
+ 'seatIndex' => 1, // 座位编号
|
|
|
+ 'chorusSongCode' => '', // 是否合唱
|
|
|
+ 'isAudioMuted' => 1, // 是否静音
|
|
|
+ 'isVideoMuted' => 0, // 是否开启视频
|
|
|
+ ];
|
|
|
+
|
|
|
+ if(empty($seatlist)){
|
|
|
+ $matedata['seat1'] = $newseat;
|
|
|
+ }else{
|
|
|
+ $matedata = [];
|
|
|
+ foreach($seatlist as $k => $seat){
|
|
|
+ $seat = json_decode($seat,true);
|
|
|
+
|
|
|
+ //找到当前用户所在的麦位
|
|
|
+ if(isset($seat['rtcUid']) && empty($seat['rtcUid'])){
|
|
|
+ //dump(substr($k,-1));
|
|
|
+ $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;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 排麦列表
|
|
|
*/
|