2025-08-07 20:21:47 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
|
|
|
|
|
|
use app\common\controller\BaseCom;
|
|
|
|
|
|
use think\Db;
|
|
|
|
|
|
|
|
|
|
|
|
class RoomPit extends BaseCom
|
|
|
|
|
|
{
|
2026-01-05 15:16:42 +08:00
|
|
|
|
|
2025-08-07 20:21:47 +08:00
|
|
|
|
//申请上麦
|
|
|
|
|
|
public function apply_pit()
|
|
|
|
|
|
{
|
|
|
|
|
|
$room_id = input('room_id', 0);
|
|
|
|
|
|
if($room_id == 0){
|
|
|
|
|
|
return V(0, '房间ID不能为空', null);
|
|
|
|
|
|
}
|
2026-01-05 15:16:42 +08:00
|
|
|
|
$pit_number = input('pit_number', 0);
|
|
|
|
|
|
|
|
|
|
|
|
$key_name = "api:room:apply_pit:" . $this->uid;
|
|
|
|
|
|
redis_lock_exits($key_name);
|
|
|
|
|
|
|
|
|
|
|
|
$room_type = model('Room')->get_room_type($room_id);
|
|
|
|
|
|
if($room_type == 0){
|
2025-08-07 20:21:47 +08:00
|
|
|
|
return V(0, '房间不存在', null);
|
|
|
|
|
|
}
|
2026-01-06 19:37:41 +08:00
|
|
|
|
$gift_id = input('gift_id', 0);//酒吧房上其他麦需要带礼物
|
2026-01-05 15:16:42 +08:00
|
|
|
|
if($room_type == 2){
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$reslut = model('RoomSong')->apply_kpit($this->uid, $room_id,$pit_number);
|
2026-01-05 15:16:42 +08:00
|
|
|
|
}elseif($room_type == 11){
|
2026-01-06 19:37:41 +08:00
|
|
|
|
//9麦位,10麦位 不做$gift_id校验
|
|
|
|
|
|
if($pit_number != 9 && $pit_number != 10){
|
2026-01-08 17:06:55 +08:00
|
|
|
|
//有麦位就是换麦
|
|
|
|
|
|
$pit_infos = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $this->uid])->value('pit_number')??0;
|
2026-01-08 17:52:28 +08:00
|
|
|
|
if($pit_infos == 10){
|
|
|
|
|
|
return V(0, '此房间不允许嘉宾直接换麦', null);
|
|
|
|
|
|
}
|
|
|
|
|
|
if($gift_id == 0){
|
2026-01-06 19:37:41 +08:00
|
|
|
|
return V(0, '请选择礼物', null);
|
|
|
|
|
|
}
|
2026-01-05 15:16:42 +08:00
|
|
|
|
}
|
2026-01-07 16:37:26 +08:00
|
|
|
|
$reslut = model('RoomPit')->apply_pit($this->uid, $room_id, $gift_id, $pit_number);
|
2025-08-07 20:21:47 +08:00
|
|
|
|
}else{
|
2026-01-05 15:16:42 +08:00
|
|
|
|
$reslut = model('RoomPit')->apply_pit($this->uid, $room_id,$pit_number);
|
2025-08-07 20:21:47 +08:00
|
|
|
|
}
|
2025-10-20 09:59:39 +08:00
|
|
|
|
redis_unlocks($key_name);
|
2026-01-05 15:16:42 +08:00
|
|
|
|
|
|
|
|
|
|
//用户操作记录
|
2025-08-07 20:21:47 +08:00
|
|
|
|
//1-禁麦位,2-清空消息,3-清空魅力值,4-加入黑名单,5-踢出房间,6-关闭麦克风,7-申请上麦,8-同意上麦,9-拒绝上麦,10-点歌,11-开启PK',
|
|
|
|
|
|
model('Room')->room_operation_record($this->uid,$room_id,7,0,$pit_number);
|
|
|
|
|
|
|
|
|
|
|
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//申请上麦列表
|
|
|
|
|
|
public function apply_pit_list()
|
|
|
|
|
|
{
|
|
|
|
|
|
$room_id = input('room_id', 0);
|
2026-01-05 15:16:42 +08:00
|
|
|
|
if($room_id == 0){
|
|
|
|
|
|
return V(0, '房间ID不能为空', null);
|
|
|
|
|
|
}
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$reslut = model('RoomPit')->apply_pit_list($this->uid, $room_id);
|
|
|
|
|
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//上麦助力
|
|
|
|
|
|
public function help_apply_pit()
|
|
|
|
|
|
{
|
|
|
|
|
|
$room_id = input('room_id', 0);
|
2026-01-05 15:16:42 +08:00
|
|
|
|
if($room_id == 0){
|
|
|
|
|
|
return V(0, '房间ID不能为空', null);
|
|
|
|
|
|
}
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$user_id = input('user_id', 0);
|
2026-01-05 15:16:42 +08:00
|
|
|
|
if($user_id == 0){
|
|
|
|
|
|
return V(0, '请选择助力用户', null);
|
|
|
|
|
|
}
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$reslut = model('RoomPit')->help_apply_pit($this->uid, $room_id, $user_id);
|
|
|
|
|
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//同意上麦
|
|
|
|
|
|
public function agree_pit()
|
|
|
|
|
|
{
|
|
|
|
|
|
$room_id = input('room_id', 0);
|
2026-01-05 15:16:42 +08:00
|
|
|
|
if($room_id == 0){
|
|
|
|
|
|
return V(0, '房间ID不能为空', null);
|
|
|
|
|
|
}
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$user_id = input('user_id', 0);//逗号分割
|
2026-01-05 15:16:42 +08:00
|
|
|
|
if($user_id == 0){
|
|
|
|
|
|
return V(0, '请选择同意用户', null);
|
|
|
|
|
|
}
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$reslut = model('RoomPit')->agree_pit($this->uid, $room_id, $user_id);
|
|
|
|
|
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//拒绝上麦
|
|
|
|
|
|
public function refuse_pit()
|
|
|
|
|
|
{
|
|
|
|
|
|
$room_id = input('room_id', 0);
|
2026-01-05 15:16:42 +08:00
|
|
|
|
if($room_id == 0){
|
|
|
|
|
|
return V(0, '房间ID不能为空', null);
|
|
|
|
|
|
}
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$user_id = input('user_id', 0);//逗号分割
|
|
|
|
|
|
$reslut = model('RoomPit')->clear_apply_pit_list($this->uid, $room_id, $user_id);
|
|
|
|
|
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//清空上麦申请列表
|
|
|
|
|
|
public function clear_apply_pit_list()
|
|
|
|
|
|
{
|
|
|
|
|
|
$room_id = input('room_id', 0);
|
2026-01-05 15:16:42 +08:00
|
|
|
|
if($room_id == 0){
|
|
|
|
|
|
return V(0, '房间ID不能为空', null);
|
|
|
|
|
|
}
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$reslut = model('RoomPit')->clear_apply_pit_list($this->uid, $room_id);
|
|
|
|
|
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//设置房间插麦礼物
|
|
|
|
|
|
public function set_room_pit_apply_help_gift()
|
|
|
|
|
|
{
|
|
|
|
|
|
$room_id = input('room_id', 0);
|
2026-01-05 15:16:42 +08:00
|
|
|
|
if($room_id == 0){
|
|
|
|
|
|
return V(0, '房间ID不能为空', null);
|
|
|
|
|
|
}
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$gift_id = input('gift_id', 0);
|
2026-01-05 15:16:42 +08:00
|
|
|
|
if($gift_id == 0){
|
|
|
|
|
|
return V(0, '请选择礼物', null);
|
|
|
|
|
|
}
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$gift_price = input('gift_price', 0);
|
2025-12-22 16:58:31 +08:00
|
|
|
|
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
|
|
|
|
|
|
if($gift_id == $pool_gift_id){
|
|
|
|
|
|
return V(0, '此礼物不能进行此操作');
|
|
|
|
|
|
}
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$reslut = model('RoomPit')->set_room_pit_apply_help_gift($this->uid, $room_id, $gift_id, $gift_price);
|
|
|
|
|
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//下麦
|
|
|
|
|
|
public function down_pit()
|
|
|
|
|
|
{
|
|
|
|
|
|
$room_id = input('room_id', 0);
|
|
|
|
|
|
if($room_id == 0){
|
|
|
|
|
|
return V(0, '房间ID不能为空', null);
|
|
|
|
|
|
}
|
2026-01-05 15:16:42 +08:00
|
|
|
|
$pit_number = input('pit_number', 0);
|
|
|
|
|
|
|
|
|
|
|
|
$room_type = model('Room')->get_room_type($room_id);
|
|
|
|
|
|
if($room_type == 0){
|
2025-08-07 20:21:47 +08:00
|
|
|
|
return V(0, '房间不存在', null);
|
|
|
|
|
|
}
|
2026-01-05 15:16:42 +08:00
|
|
|
|
|
2025-11-28 16:02:52 +08:00
|
|
|
|
if($room_type == 10){
|
|
|
|
|
|
$upit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $this->uid])->value('pit_number');
|
|
|
|
|
|
if($upit == 2){
|
|
|
|
|
|
return V(0, '师父麦,不能操作', null);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-01-05 15:16:42 +08:00
|
|
|
|
|
|
|
|
|
|
if($room_type == 2){
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$reslut = model('RoomSong')->down_kpit($this->uid, $room_id);
|
2026-01-05 15:16:42 +08:00
|
|
|
|
}else{
|
|
|
|
|
|
$reslut = model('RoomPit')->DownPit($this->uid, $room_id,$pit_number);
|
2025-08-07 20:21:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//修改房间上麦模式
|
|
|
|
|
|
public function change_room_up_pit_type()
|
|
|
|
|
|
{
|
|
|
|
|
|
$key_name = "api:room:change_room_up_pit_type:" . $this->uid;
|
|
|
|
|
|
redis_lock_exit($key_name);
|
|
|
|
|
|
$room_id = input('room_id', 0);
|
2026-01-05 15:16:42 +08:00
|
|
|
|
if($room_id == 0){
|
|
|
|
|
|
return V(0, '房间ID不能为空', null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$reslut = model('RoomPit')->change_room_up_pit_type($this->uid, $room_id);
|
|
|
|
|
|
redis_unlock($key_name);
|
|
|
|
|
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//抱麦/踢麦
|
|
|
|
|
|
public function host_user_pit()
|
|
|
|
|
|
{
|
|
|
|
|
|
$room_id = input('room_id', 0);
|
2026-01-05 15:16:42 +08:00
|
|
|
|
if($room_id == 0){
|
|
|
|
|
|
return V(0, '房间ID不能为空', null);
|
|
|
|
|
|
}
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$pit_number = input('pit_number', 0);
|
2026-01-05 15:16:42 +08:00
|
|
|
|
$user_id = input('user_id', 0);
|
|
|
|
|
|
if($user_id == 0){
|
|
|
|
|
|
return V(0, '请选择用户', null);
|
|
|
|
|
|
}
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$type = input('type', 0);//1-抱麦 2-踢下去
|
|
|
|
|
|
$reslut = model('RoomPit')->host_user_pit($this->uid, $room_id,$pit_number,$user_id,$type);
|
|
|
|
|
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
|
|
|
|
|
}
|
2025-12-08 16:56:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//签约房间主持邀请上签约麦用户拒绝
|
|
|
|
|
|
public function refuse_sign_room_host_invite()
|
|
|
|
|
|
{
|
|
|
|
|
|
$room_id = input('room_id', 0);
|
2026-01-05 15:16:42 +08:00
|
|
|
|
if($room_id == 0){
|
|
|
|
|
|
return V(0, '房间ID不能为空', null);
|
|
|
|
|
|
}
|
2025-12-08 16:56:31 +08:00
|
|
|
|
$reslut = model('RoomPit')->refuse_sign_room_host_invite($this->uid, $room_id);
|
|
|
|
|
|
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
|
|
|
|
|
}
|
2025-08-07 20:21:47 +08:00
|
|
|
|
}
|