点唱房
This commit is contained in:
@@ -266,7 +266,7 @@ class Room extends BaseCom
|
||||
public function change_room_type()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$type = input('type', 1);//1-点唱,2-拍卖,3-男神,4-女神,7-交友
|
||||
$type = input('type', 1);//1-聊天,2-拍卖,7-互娱,8-交友,9-点唱
|
||||
$reslut = model('Room')->change_room_type($this->uid, $room_id, $type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
99
application/api/controller/SingerSong.php
Normal file
99
application/api/controller/SingerSong.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Db;
|
||||
|
||||
class SingerSong extends BaseCom
|
||||
{
|
||||
|
||||
//歌手认证
|
||||
public function singerAuth()
|
||||
{
|
||||
//试音地址
|
||||
$song = input('song', 0);
|
||||
if (!$song) {
|
||||
return V(0, '请上传试音地址');
|
||||
}
|
||||
|
||||
$reslut = model('SingerSong')->singerAuth($this->uid, $song);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//歌手添加歌曲
|
||||
public function singerAddSong()
|
||||
{
|
||||
$song_name = input('song_name', 0);
|
||||
if (!$song_name) {
|
||||
return V(0, '请输入歌曲名称');
|
||||
}
|
||||
$gift_id = input('gift_id', 0);
|
||||
if (!$gift_id) {
|
||||
return V(0, '请选择礼物');
|
||||
}
|
||||
$gift_num = input('gift_num', 1);
|
||||
$reslut = model('SingerSong')->singerAddSong($this->uid, $song_name, $gift_id, $gift_num);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//歌手删除 歌曲
|
||||
public function singerDelSong()
|
||||
{
|
||||
$id = input('id', 0);
|
||||
if (!$id) {
|
||||
return V(0, '请选择歌曲');
|
||||
}
|
||||
$reslut = db::name('vs_singer_song')->where(['id' => $id])->update(['deletetime' => time()]);
|
||||
if ($reslut) {
|
||||
return V(1, '删除成功');
|
||||
} else {
|
||||
return V(0, '删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//歌手修改歌曲
|
||||
public function singerEditSong()
|
||||
{
|
||||
$id = input('id', 0);
|
||||
if (!$id) {
|
||||
return V(0, '请选择歌曲');
|
||||
}
|
||||
$song_name = input('song_name', 0);
|
||||
if (!$song_name) {
|
||||
return V(0, '请输入歌曲名称');
|
||||
}
|
||||
$gift_id = input('gift_id', 0);
|
||||
if (!$gift_id) {
|
||||
return V(0, '请选择礼物');
|
||||
}
|
||||
$gift_num = input('gift_num', 1);
|
||||
$reslut = db::name('vs_singer_song')->where(['id' => $id])->update([
|
||||
'song_name' => $song_name,
|
||||
'gift_id' => $gift_id,
|
||||
'gift_num' => $gift_num,
|
||||
]);
|
||||
if ($reslut) {
|
||||
return V(1, '修改成功');
|
||||
} else {
|
||||
return V(0, '修改失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//获取房间内麦位上歌手歌曲
|
||||
public function getSong()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if (!$room_id) {
|
||||
return V(0, '请选择房间');
|
||||
}
|
||||
//用户ID
|
||||
$reslut = model('SingerSong')->getSong($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1729,6 +1729,7 @@ class Room extends Model
|
||||
|
||||
|
||||
//修改房间类型
|
||||
// $type 1-聊天,2-拍卖,7-互娱,8-交友,9-点唱
|
||||
public function change_room_type($uid,$room_id,$type)
|
||||
{
|
||||
if(!$uid || !$room_id || !$type){
|
||||
@@ -1759,7 +1760,7 @@ class Room extends Model
|
||||
//开启事务
|
||||
db::startTrans();
|
||||
$data = [];
|
||||
if($type == 1 || $type == 3 || $type == 4 || $type == 8){
|
||||
if($type == 1 || $type == 3 || $type == 4 || $type == 8 || $type == 9){
|
||||
$data = [
|
||||
'label_id' => 1,
|
||||
'type_id' => $type,
|
||||
@@ -1809,7 +1810,7 @@ class Room extends Model
|
||||
//申请上麦的全部下麦
|
||||
model('RoomPit')->clear_apply_pit_list($uid, $room_id);
|
||||
|
||||
if($type == 1 || $type == 3 || $type == 4 || $type == 7 || $type == 8){
|
||||
if($type == 1 || $type == 3 || $type == 4 || $type == 7 || $type == 8 || $type == 9){
|
||||
//查询拍卖房的状态
|
||||
$room_auction = db::name('vs_room_auction')->where(['room_id' => $room_id,'status' => 2])->select();
|
||||
if($room_auction){
|
||||
@@ -1847,7 +1848,7 @@ class Room extends Model
|
||||
if($room_user){
|
||||
foreach ($room_user as $v){
|
||||
if(Db::name('user')->where('id', $v['user_id'])->value('is_online') == 0){
|
||||
model('Room')->quit_room($v['user_id'], $room_id,$v['user_id'],2);
|
||||
// model('Room')->quit_room($v['user_id'], $room_id,$v['user_id'],2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ class RoomPit extends Model
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
//查询房间状态
|
||||
$room_info = db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->field('id,room_status,room_up_pit_type,label_id,step')->find();
|
||||
$room_info = db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->field('id,room_status,room_up_pit_type,type_id,label_id,step')->find();
|
||||
if(!$room_info){
|
||||
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
|
||||
}
|
||||
@@ -224,6 +224,11 @@ class RoomPit extends Model
|
||||
return ['code' => 0, 'msg' => '房间违规或关闭', 'data' => null];
|
||||
}
|
||||
|
||||
$user_singer = db::name('vs_singer')->where(['user_id' => $user_id, 'status' => 1])->find();
|
||||
if($room_info['type_id'] == 9 && !$user_singer && $pit_number < 9){
|
||||
return ['code' => 0, 'msg' => '不是歌手不能上麦', 'data' => null];
|
||||
}
|
||||
|
||||
if($pit_number == 9){
|
||||
//检查用户是否是房主或主持
|
||||
$is_room_owner =db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
|
||||
105
application/api/model/SingerSong.php
Normal file
105
application/api/model/SingerSong.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class SingerSong extends Model
|
||||
{
|
||||
/*
|
||||
* 歌手认证 状态及等级
|
||||
*/
|
||||
public function singerAuthStatus($user_id)
|
||||
{
|
||||
$res = db::name('vs_singer')->where(['user_id' => $user_id])->find();
|
||||
if ($res) {
|
||||
$data = [
|
||||
'status' => $res['status'],
|
||||
'level' => $res['level'],
|
||||
];
|
||||
} else {
|
||||
$data = [
|
||||
'status' => -1,
|
||||
'level' => 0,
|
||||
];
|
||||
}
|
||||
return $data ;
|
||||
}
|
||||
|
||||
/*
|
||||
* 歌手认证
|
||||
*/
|
||||
public function singerAuth($user_id, $song)
|
||||
{
|
||||
//查询是否提交过认证
|
||||
$res = db::name('vs_singer')->where(['user_id' => $user_id])->find();
|
||||
if ($res) {
|
||||
$data = [
|
||||
'song' => $song,
|
||||
'status' => 0,
|
||||
'updatetime' => time()
|
||||
];
|
||||
$result = db::name('vs_singer')->where(['id' => $res['id']])->update($data);
|
||||
}else{
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'song' => $song,
|
||||
'status' => 0,
|
||||
'createtime' => time()
|
||||
];
|
||||
$result = db::name('vs_singer')->insert($data);
|
||||
}
|
||||
if ($result) {
|
||||
return ['code' => 1, 'msg' => '提交成功'];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => '提交失败'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 歌手添加歌曲
|
||||
* @param song_name 歌曲名称
|
||||
* @param gift_id 礼物id
|
||||
* @param gift_num 礼物数量
|
||||
*/
|
||||
public function singerAddSong($user_id, $song_name, $gift_id, $gift_num)
|
||||
{
|
||||
//查询是否提交过歌曲
|
||||
$res = db::name('vs_singer_song')->where(['user_id' => $user_id, 'song_name' => $song_name])->find();
|
||||
if ($res) {
|
||||
return ['code' => 0, 'msg' => '请勿重复提交歌曲'];
|
||||
}
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'song_name' => $song_name,
|
||||
'gift_id' => $gift_id,
|
||||
'gift_num' => $gift_num,
|
||||
'createtime' => time()
|
||||
];
|
||||
$result = db::name('vs_singer_song')->insert($data);
|
||||
if ($result) {
|
||||
return ['code' => 1, 'msg' => '提交成功'];
|
||||
} else {
|
||||
return ['code' => 0, 'msg' => '提交失败'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 获取房间内麦位上歌手歌曲
|
||||
* @param room_id 房间id
|
||||
* @param user_id 用户id
|
||||
*/
|
||||
public function getSong($user_id, $room_id)
|
||||
{
|
||||
//查询当前房间内麦位上的歌手
|
||||
$room_singer = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',9]])->column('user_id');
|
||||
if ($room_singer) {
|
||||
foreach ($room_singer as $v){
|
||||
$res = db::name('vs_singer_song')->where(['user_id' => $v])->find();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -173,6 +173,10 @@ class User extends Model
|
||||
}
|
||||
$user_info['is_hide'] = $is_hide;//是否可以设置隐藏
|
||||
$user_info['hide_status'] = db::name('user')->where('id',$uid)->value('hide_status');//0-取消隐身,1-隐身进入
|
||||
//歌手认证
|
||||
$singer = model('api/SingerSong')->singerAuthStatus($uid);
|
||||
$user_info['singer_status'] = $singer['status'];//歌手认证状态0-待审核,1-通过,2-拒绝 -1-未认证
|
||||
$user_info['singer_level'] = $singer['level'];
|
||||
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => $user_info];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user