198 lines
6.4 KiB
PHP
198 lines
6.4 KiB
PHP
<?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()
|
||
{
|
||
$page = input('page', 1);
|
||
$page_limit = input('page_limit', 30);
|
||
$room_id = input('room_id', 0);
|
||
//用户ID
|
||
$user_id = input('user_id', 0);
|
||
//以上两个参数二选一
|
||
if (!$room_id && !$user_id) {
|
||
return V(0, '请选择房间或歌手');
|
||
}
|
||
|
||
$reslut = model('SingerSong')->getSong($this->uid, $user_id, $room_id, $page, $page_limit);
|
||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||
}
|
||
|
||
|
||
//点歌
|
||
public function singerSong()
|
||
{
|
||
$song_id = input('song_id', 0);
|
||
if (!$song_id) {
|
||
return V(0, '请选择歌曲');
|
||
}
|
||
$room_id = input('room_id', 0);
|
||
if (!$room_id) {
|
||
return V(0, '请选择房间');
|
||
}
|
||
$reslut = model('SingerSong')->singerSong($this->uid, $song_id ,$room_id);
|
||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||
}
|
||
|
||
|
||
//点歌列表
|
||
public function singerSongList()
|
||
{
|
||
$page = input('page', 1);
|
||
$page_limit = input('page_limit', 30);
|
||
$room_id = input('room_id', 0);
|
||
if (!$room_id) {
|
||
return V(0, '请选择房间');
|
||
}
|
||
$type = input('type', 1);//1:已点列表,2:今日列表,3:昨日列表,4:本周列表,5:本月列表
|
||
$reslut = model('SingerSong')->singerSongList($room_id,$type,$page,$page_limit);
|
||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||
}
|
||
|
||
|
||
//点歌各类型各个总数
|
||
public function singerSongCount()
|
||
{
|
||
$room_id = input('room_id', 0);
|
||
if (!$room_id) {
|
||
return V(0, '请选择房间');
|
||
}
|
||
$reslut = model('SingerSong')->singerSongCount($room_id);
|
||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||
}
|
||
|
||
|
||
//歌曲置顶
|
||
public function singerSongTop()
|
||
{
|
||
$id = input('id', 0);
|
||
if (!$id) {
|
||
return V(0, '请选择歌曲');
|
||
}
|
||
$reslut = db::name('vs_song_log')->where(['id' => $id])->update(['sort' => time()]);
|
||
if ($reslut) {
|
||
//给前端推送下首歌曲信息
|
||
$next_song_info = db::name('vs_song_log')->where(['id' => $id])->find();
|
||
$next_song_info['boss_id'] = $next_song_info['user_id'];
|
||
$next_song_info['boss_nickname'] = db::name('user')->where(['id' => $next_song_info['user_id']])->value('nickname');
|
||
$next_song_info['boss_avatar'] = db::name('user')->where(['id' => $next_song_info['user_id']])->value('avatar');
|
||
$next_song_info['boss_dress'] = model('api/Decorate')->user_decorate_detail($next_song_info['user_id'], 1);
|
||
$next_song_info['boss_mic_cycle'] = model('api/Decorate')->user_decorate_detail($next_song_info['user_id'],3);
|
||
$singer_song = db::name('vs_singer_song')->where(['id' => $next_song_info['singer_song_id']])->find();
|
||
$next_song_info['singer_id'] = $singer_song['user_id'];
|
||
$next_song_info['singer_nickname'] = db::name('user')->where(['id' => $singer_song['user_id']])->value('nickname');
|
||
$next_song_info['singer_avatar'] = db::name('user')->where(['id' => $singer_song['user_id']])->value('avatar');
|
||
$next_song_info['singer_dress'] = model('api/Decorate')->user_decorate_detail($singer_song['user_id'], 1);
|
||
$next_song_info['singer_mic_cycle'] = model('api/Decorate')->user_decorate_detail($singer_song['user_id'],3);
|
||
$next_song_info['song_name'] = $singer_song['song_name'];
|
||
|
||
$data = [
|
||
'text' => '房间下一首演唱歌曲变化',
|
||
'next_song_info' => $next_song_info
|
||
];
|
||
model('Chat')->sendMsg(1071,$next_song_info['room_id'],$data);
|
||
|
||
return V(1, '置顶成功');
|
||
} else {
|
||
return V(0, '置顶失败');
|
||
}
|
||
}
|
||
|
||
|
||
//切歌
|
||
public function singerSongCut()
|
||
{
|
||
$id = input('id', 0);//点歌列表的ID
|
||
if (!$id) {
|
||
return V(0, '请选择要切的歌曲列表ID');
|
||
}
|
||
|
||
$reslut = model('SingerSong')->singerSongCut($this->uid, $id);
|
||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||
}
|
||
|
||
|
||
} |