|
@@ -2147,12 +2147,142 @@ class Party extends Common
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- ////////////////////待唱歌曲操作
|
|
|
|
|
|
+ //=============待唱歌曲操作=================
|
|
|
|
|
|
//待唱,列表
|
|
//待唱,列表
|
|
|
|
+ public function waitsing_list(){
|
|
|
|
+ $easemob_room_id = input('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(){
|
|
|
|
+ //查找派对
|
|
|
|
+ $easemob_room_id = input('easemob_room_id');
|
|
|
|
+
|
|
|
|
+ $party_info = Db::name('party')->where('easemob_room_id',$easemob_room_id)->find();
|
|
|
|
+ if(empty($party_info)){
|
|
|
|
+ $this->error();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //接收新歌
|
|
|
|
+ $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']);
|
|
|
|
+
|
|
|
|
+ //加入新歌
|
|
|
|
+ $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);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //根据歌曲sort字段,正序排列
|
|
|
|
+ private function waitsing_array_column_sort($data){
|
|
|
|
+ if(empty($data)){
|
|
|
|
+ return $data;
|
|
|
|
+ }
|
|
|
|
+ //dump($data);
|
|
|
|
+ $sort = array_column($data,'sort');
|
|
|
|
+ $sing_no = array_column($data,'sing_no');
|
|
|
|
+ $a = array_multisort($sort,SORT_ASC,$sing_no,$data);
|
|
|
|
+ //dump($data);exit;
|
|
|
|
+ return $data;
|
|
|
|
+ }
|
|
|
|
+
|
|
//待唱,删除
|
|
//待唱,删除
|
|
|
|
+ public function waitsing_delete(){
|
|
|
|
+
|
|
|
|
+ }
|
|
//待唱,置顶
|
|
//待唱,置顶
|
|
|
|
+ public function waitsing_top(){
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //轮询所有房间,挨个赋值新的初始化自定义属性
|
|
|
|
+ public function room_task(){
|
|
|
|
+ exit;
|
|
|
|
+ $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']),//logo
|
|
|
|
+ 'is_public' => $party['is_public'],//是否公开
|
|
|
|
+ 'room_type' => $party['room_type'],//房间类型
|
|
|
|
+ ];
|
|
|
|
+ $rs = $easemob->room_setRoomCustomAttributeForced($party['easemob_room_id'],$party['user_id'],$matedata);
|
|
|
|
+
|
|
|
|
+ //[环信]初始化N个麦位
|
|
|
|
+ $seatdata = [];
|
|
|
|
+ for($i=1;$i<=$party['seatnum'];$i++){
|
|
|
|
+ $seat = [
|
|
|
|
+ 'charm' => 0, //红心,魅力值
|
|
|
|
+
|
|
|
|
+ 'isMaster' => false, // 是否是房主
|
|
|
|
+ 'headUrl' => '', // 头像
|
|
|
|
+ 'userNo' => '', // 座位上用户no
|
|
|
|
+ 'rtcUid' => '', // 座位上用户id,与rtc的userId一致
|
|
|
|
+ 'name' => '', // 座位上用户昵称
|
|
|
|
+ 'seatIndex' => $i, // 座位编号
|
|
|
|
+ 'chorusSongCode' => '', // 是否合唱
|
|
|
|
+ 'isAudioMuted' => 1, // 是否静音
|
|
|
|
+ 'isVideoMuted' => 0, // 是否开启视频
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ //创建完房间就进入,所以房主直接在麦位1
|
|
|
|
+ $owner = Db::name('user')->where('id',$party['user_id'])->find();
|
|
|
|
+ if($i == 1){
|
|
|
|
+ $seat['isMaster'] = true;
|
|
|
|
+ $seat['headUrl'] = localpath_to_netpath($owner['avatar']);
|
|
|
|
+ $seat['userNo'] = $owner['id'];
|
|
|
|
+ $seat['rtcUid'] = $owner['id'];
|
|
|
|
+ $seat['name'] = $owner['nickname'];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $seatdata['seat'.$i] = json_encode($seat);
|
|
|
|
+ }
|
|
|
|
+ $rs = $easemob->room_setRoomCustomAttributeForced($party['easemob_room_id'],$party['user_id'],$seatdata);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
//============================定时任务==========================//
|
|
//============================定时任务==========================//
|