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
|
|
|
|
|
|
{
|
|
|
|
|
|
//申请上麦
|
|
|
|
|
|
public function apply_pit()
|
|
|
|
|
|
{
|
2025-10-20 09:59:39 +08:00
|
|
|
|
$key_name = "api:room:apply_pit:" . $this->uid;
|
|
|
|
|
|
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$room_id = input('room_id', 0);
|
|
|
|
|
|
$pit_number = input('pit_number', 0);
|
|
|
|
|
|
if($room_id == 0){
|
|
|
|
|
|
return V(0, '房间ID不能为空', null);
|
|
|
|
|
|
}
|
|
|
|
|
|
$res = model('Room')->get_room_label($room_id);
|
|
|
|
|
|
if($res['code'] != 1){
|
|
|
|
|
|
return V(0, '房间不存在', null);
|
|
|
|
|
|
}
|
2025-10-20 09:59:39 +08:00
|
|
|
|
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$room_label = $res['data']['label_id'];
|
|
|
|
|
|
$room_type = $res['data']['type_id'];
|
2025-10-20 09:59:39 +08:00
|
|
|
|
redis_lock_exits($key_name);
|
|
|
|
|
|
if(($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8))|| $room_type == 2 || $room_type == 7){
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$reslut = model('RoomPit')->apply_pit($this->uid, $room_id,$pit_number);
|
2025-10-20 09:59:39 +08:00
|
|
|
|
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)){
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$reslut = model('RoomSong')->apply_kpit($this->uid, $room_id,$pit_number);
|
|
|
|
|
|
}else{
|
2025-10-20 09:59:39 +08:00
|
|
|
|
redis_unlocks($key_name);
|
2025-08-07 20:21:47 +08:00
|
|
|
|
return V(0, '房间不存在', null);
|
|
|
|
|
|
}
|
2025-10-20 09:59:39 +08:00
|
|
|
|
redis_unlocks($key_name);
|
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);
|
|
|
|
|
|
$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);
|
|
|
|
|
|
$user_id = input('user_id', 0);
|
|
|
|
|
|
$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);
|
|
|
|
|
|
$user_id = input('user_id', 0);//逗号分割
|
|
|
|
|
|
$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);
|
|
|
|
|
|
$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);
|
|
|
|
|
|
$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);
|
|
|
|
|
|
$gift_id = input('gift_id', 0);
|
|
|
|
|
|
$gift_price = input('gift_price', 0);
|
|
|
|
|
|
$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);
|
|
|
|
|
|
$pit_number = input('pit_number', 0);
|
|
|
|
|
|
if($room_id == 0){
|
|
|
|
|
|
return V(0, '房间ID不能为空', null);
|
|
|
|
|
|
}
|
|
|
|
|
|
$res = model('Room')->get_room_label($room_id);
|
|
|
|
|
|
if($res['code'] != 1){
|
|
|
|
|
|
return V(0, '房间不存在', null);
|
|
|
|
|
|
}
|
|
|
|
|
|
$room_label = $res['data']['label_id'];
|
|
|
|
|
|
$room_type = $res['data']['type_id'];
|
2025-10-20 09:59:39 +08:00
|
|
|
|
if(($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)) || $room_type == 2 || $room_type == 7){
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$reslut = model('RoomPit')->DownPit($this->uid, $room_id,$pit_number);
|
2025-10-20 09:59:39 +08:00
|
|
|
|
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)){
|
2025-08-07 20:21:47 +08:00
|
|
|
|
$reslut = model('RoomSong')->down_kpit($this->uid, $room_id);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
// $user_id = input('user_id', 0);
|
|
|
|
|
|
$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);
|
|
|
|
|
|
$pit_number = input('pit_number', 0);
|
|
|
|
|
|
$user_id = input('user_id', 0);//
|
|
|
|
|
|
$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']);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|