From d3de53715d55ddcad7206ddf0129efef901d4e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Mon, 8 Dec 2025 16:04:30 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=88=BF=E9=97=B4=E6=8E=92?= =?UTF-8?q?=E8=A1=8C=E5=92=8C=E9=BB=98=E8=AE=A4=E9=80=89=E6=8B=A9=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Index.php | 37 +++++++++++++++-- application/api/model/Chat.php | 2 + application/api/model/Room.php | 26 ++++++------ application/api/model/RoomPit.php | 61 ++++++++++++++++++++++++---- 4 files changed, 99 insertions(+), 27 deletions(-) diff --git a/application/api/controller/Index.php b/application/api/controller/Index.php index 1256a754..5205e89b 100644 --- a/application/api/controller/Index.php +++ b/application/api/controller/Index.php @@ -18,7 +18,7 @@ class Index extends BaseCom public function room_list() { $is_top = input('is_top', 0); //1非置顶2置顶 - $label_id = input('label_id', 0); + $label_id = input('label_id'); $page = input('page', 1); $page_limit = input('page_limit', 20); @@ -29,10 +29,39 @@ class Index extends BaseCom //房间类型列表 public function room_type_list() { - $list = db::name('vs_room_type')->where(['status' => 1, 'deletetime' => 0])->field('id,type_name as label_name')->order('sort asc')->select(); + $list = db::name('vs_room_label') + ->where(['status' => 1]) + ->field('id,label_name,default_index')->order('sort asc')->select(); + if($list){ + $default_index = 0; + $label_name = ''; + $sort = 99; + foreach ($list as $k => $v) { + if($v['id'] == 3 || $v['id'] == 4){ + $label_name = '亲密/真爱拍'; + if($v['default_index'] == 1){ + $default_index = 1; + } + $sort = min($sort, $v['sort']); + unset($list[$k]); + } + } + if($label_name){ + //添加到列表后面 + $list[] = [ + 'id' => 0, + 'label_name' => $label_name, + 'default_index' => $default_index, + 'sort' => $sort + ]; + } + //数据重组避免乱序 再根据sort 排序 越小的越靠前 + $list = array_values($list); + usort($list, function ($a, $b) { + return $a['sort'] - $b['sort']; + }); + } - //给前面面添加一组数据 - array_unshift($list, ['id' => -2, 'label_name' => '练歌房']); //给前面添加一组数据 array_unshift($list, ['id' => -1, 'label_name' => '热门']); return V(1, '获取成功', $list); diff --git a/application/api/model/Chat.php b/application/api/model/Chat.php index 00622466..35496411 100644 --- a/application/api/model/Chat.php +++ b/application/api/model/Chat.php @@ -145,6 +145,8 @@ class Chat extends Model // SignRoomEnd = 1092, //签约延时 // SignRoomDelay = 1093, + //签约房 邀请用户上签约麦位 + // SignRoomInviteUser = 1094, diff --git a/application/api/model/Room.php b/application/api/model/Room.php index 9da45f4d..d9efd2d4 100644 --- a/application/api/model/Room.php +++ b/application/api/model/Room.php @@ -190,22 +190,20 @@ class Room extends Model // $map['is_show_room'] = 1;//是否显示房间 1是2否 $map['apply_status'] = 2;//1待审核 2审核通过 3审核失败 - if(!empty($label_id) && $label_id > 0){ - $map['type_id'] = $label_id; - if($label_id == 1){ - $map['label_id'] = 1; - } - } - if(!empty($label_id) && $label_id == -1){ - $map['is_hot'] = 2; - } - - if(!empty($label_id) && $label_id == -2){ - $map['label_id'] = 2; - } - if($is_top == 2){ $map['is_top'] = $is_top; + }else{ + if($label_id == -1){ + $map['is_hot'] = 2; + } + if($label_id == 0){ + $map['type_id'] = 2; + //label_id == 3 或 label_id == 4 + $map['label_id'] = ['in', [3, 4]]; + } + if($label_id >= 1){ + $map['label_id'] = $label_id; + } } $list = db::name('vs_room') diff --git a/application/api/model/RoomPit.php b/application/api/model/RoomPit.php index be23df98..ebe9dae4 100644 --- a/application/api/model/RoomPit.php +++ b/application/api/model/RoomPit.php @@ -320,6 +320,20 @@ class RoomPit extends Model if($room_info['label_id'] == 5 && $room_info['step'] != 1 && $pit_number < 9){ return ['code' => 0, 'msg' => '互娱房 此阶段不可此操作', 'data' => null]; } + //签约房间 主持邀请上麦 用户同意邀请后自己上1号麦 + if($room_info['type_id'] == 10 && $pit_number == 1){ + $is_user = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 1])->value('user_id'); + if($is_user){ + return ['code' => 0, 'msg' => '签约买上已经有用户,请申请上麦', 'data' => null]; + } + $ompit = $this->OnPit($user_id,$room_id,$pit_number);//用户上了这个房间的几号麦位 + if($ompit['code'] != 1){ + return ['code' => 0, 'msg' => '上麦失败', 'data' => null]; + } + //删除主持邀请记录 + db::name('vs_room_sign_invite')->where(['room_id' => $room_id, 'user_id' => $user_id])->delete(); + return ['code' => 1, 'msg' => '上麦成功', 'data' => null]; + } //自由麦 if($room_info['room_up_pit_type'] == 2){ @@ -359,7 +373,7 @@ class RoomPit extends Model if(isset($pit_infos) && $pit_infos['pit_number'] > 0){ //9号麦位不允许换 if($pit_infos['pit_number'] == 9){ - return ['code' => 0, 'msg' => 'PK中 主持不允许换麦', 'data' => null]; + return ['code' => 0, 'msg' => '主持不允许换麦', 'data' => null]; } $exchange1 = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_infos['pit_number']])->update([ 'user_id' => 0]); $exchange = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_number])->update([ 'user_id' => $user_id]); @@ -1058,9 +1072,38 @@ class RoomPit extends Model return ['code' => 0, 'msg' => '互娱房 不能上7、8号麦位', 'data' => null]; } if($room_type == 10){ - //$pit_number 只能是1、3、4、5 + if($pit_number == 1){ + //查询主持邀请列表是否是有数据 + $is_invite = db::name('vs_room_sign_invite')->where(['room_id' => $room_id,'createtime' => ['<',time() - 5]])->find(); + if($is_invite){ + return ['code' => 0, 'msg' => '5秒内已经有人邀请了,请勿重复邀请', 'data' => null]; + } + $is_user = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 1])->value('user_id'); + if($is_user){ + return ['code' => 0, 'msg' => '签约买上已经有用户', 'data' => null]; + } + //添加到主持邀请列表 + $data = [ + 'user_id' => $accept_user_id, + 'room_id' => $room_id, + 'createtime' => time(), + ]; + $reslut = db::name('vs_room_sign_invite')->insert($data); + if(!$reslut){ + return ['code' => 0, 'msg' => '操作失败', 'data' => null]; + } + $text['user_id'] = $accept_user_id; + $text['text'] = '主持正在抱您上签约麦呢,您是否同意?'; + //聊天室推送系统消息 + model('Chat')->sendMsg(1094,$room_id,$text); + return ['code' => 1, 'msg' => '操作成功', 'data' => null]; + } + //$pit_number没有值 只能是抱老板位、3、4、5 if(!$pit_number){ - $pit_number = $this->getRoomNullPitWithout($room_id, [2,6,7,8,9,10]); + $pit_number = $this->getRoomNullPitWithout($room_id, [1,2,6,7,8,9,10]); + if(!$pit_number){ + return ['code' => 0, 'msg' => '没有空位了', 'data' => null]; + } } //麦位上否有人 $on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_number])->value('user_id'); @@ -1237,12 +1280,12 @@ class RoomPit extends Model } } //获取被踢用户的爵位信息 -// $user_jue_info = model('api/Nobility')->getUserNobilityInfo($accept_user_id); -// foreach ($user_jue_info['power_list'] as $key => $value){ -// if($value['id'] == 7){ -// return ['code' => 0, 'msg' => '该用户已是'.$user_jue_info['nobility_name'].'爵位,不能踢', 'data' => null]; -// } -// } + $user_jue_info = model('api/Nobility')->getUserNobilityInfo($accept_user_id); + foreach ($user_jue_info['power_list'] as $key => $value){ + if($value['id'] == 7){ + return ['code' => 0, 'msg' => '该用户已是'.$user_jue_info['nobility_name'].'爵位,不能踢', 'data' => null]; + } + } if(!$pit_number || $pit_number == 888){ $roomInfo = db::name('vs_room')->where('id',$room_id)->field('label_id,type_id')->find();