点唱后端数据操作 api 添加分页
This commit is contained in:
208
application/adminapi/controller/SingerSong.php
Normal file
208
application/adminapi/controller/SingerSong.php
Normal file
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\controller;
|
||||
|
||||
use app\common\controller\adminApi;
|
||||
use think\Db;
|
||||
|
||||
class SingerSong extends adminApi
|
||||
{
|
||||
|
||||
//歌手认证列表
|
||||
public function singerList()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$search = input('search', '');
|
||||
$status = input('status', '');
|
||||
$where=[];
|
||||
//搜索信息有值且是纯数字
|
||||
if(isset($search) && is_numeric($search)){
|
||||
$where['ss.user_id'] = $search;
|
||||
}
|
||||
if(isset($search) && !is_numeric($search)){
|
||||
$where['u.nickname'] = ['like', '%'.$search.'%'];;
|
||||
}
|
||||
if(isset($start_time) && isset($end_time)){
|
||||
$where['ss.create_time'] = ['between', [strtotime($start_time), strtotime($end_time)]];
|
||||
}
|
||||
if(isset($status)){
|
||||
$where['ss.status'] = $status;
|
||||
}else{
|
||||
$where['ss.status'] = 0;
|
||||
}
|
||||
|
||||
$count = db::name('vs_singer')->where($where)->count();
|
||||
$list = db::name('vs_singer')
|
||||
->alias('ss')
|
||||
->join('user u', 'ss.user_id=s.id')
|
||||
->field('ss.*,u.nickname,u.avatar,u.user_code,u.mobile,u.sex')
|
||||
->where($where)
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//歌手认证编辑
|
||||
public function singerEdit()
|
||||
{
|
||||
$id = input('id', '');
|
||||
if(empty($id)){
|
||||
return V(0, '参数错误');
|
||||
}
|
||||
$data = [
|
||||
'status' => input('status', ''),
|
||||
'remark' => input('remark', ''),
|
||||
];
|
||||
$res = db::name('vs_singer')->where('id', $id)->update($data);
|
||||
if($res){
|
||||
return V(1, '操作成功');
|
||||
}else{
|
||||
return V(0, '操作失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//认证歌手歌曲列表
|
||||
public function singerSongList()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$user_id = input('user_id', '');
|
||||
$where=[];
|
||||
if(isset($user_id)){
|
||||
$where['user_id'] = $user_id;
|
||||
}else{
|
||||
return V(0, '请填写用户ID');
|
||||
}
|
||||
$count = db::name('vs_singer_song')->where($where)->count();
|
||||
$list = db::name('vs_singer_song')
|
||||
->alias('o')
|
||||
->join('user u', 'o.user_id=u.id')
|
||||
->join('vs_gift g', 'o.gift_id=g.gid')
|
||||
->field('o.*,u.nickname,u.user_code,g.gift_name,g.gift_price')
|
||||
->where($where)
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
//歌手等级列表
|
||||
public function singerLevelList()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$where=[];
|
||||
$count = db::name('vs_singer_level')->where($where)->count();
|
||||
$list = db::name('vs_singer_level')
|
||||
->where($where)
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
|
||||
//编辑歌手等级
|
||||
public function singerLevelEdit()
|
||||
{
|
||||
$id = input('id', '');
|
||||
//没有 id就是新增
|
||||
if(empty($id)){
|
||||
$data = [
|
||||
'level' => input('level', ''),
|
||||
'name' => input('name', ''),
|
||||
'image' => input('image', ''),
|
||||
'change_value' => input('change_value', ''),
|
||||
'rights_icon' => input('rights_icon', ''),
|
||||
'createtime' => time(),
|
||||
];
|
||||
$res = db::name('vs_singer_level')->insert($data);
|
||||
if($res){
|
||||
return V(1, '操作成功');
|
||||
}else{
|
||||
return V(0, '操作失败');
|
||||
}
|
||||
}else{
|
||||
$data = [
|
||||
'level' => input('level', ''),
|
||||
'name' => input('name', ''),
|
||||
'image' => input('image', ''),
|
||||
'change_value' => input('change_value', ''),
|
||||
'rights_icon' => input('rights_icon', ''),
|
||||
];
|
||||
$res = db::name('vs_singer_level')->where('id', $id)->update($data);
|
||||
if($res){
|
||||
return V(1, '操作成功');
|
||||
}else{
|
||||
return V(0, '操作失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//点歌信息列表
|
||||
public function songList()
|
||||
{
|
||||
$page = input('page', 1);
|
||||
$page_limit = input('page_limit', 30);
|
||||
$type = input('type', 3);//1-今天,2-本周,3-本月,4-昨天
|
||||
$room_id = input('room_id', '');
|
||||
|
||||
$where=[];
|
||||
if(isset($room_id)){
|
||||
$where['room_id'] = $room_id;
|
||||
}else{
|
||||
return V(0, '请填写房间ID');
|
||||
}
|
||||
if($type==1){
|
||||
$where['create_time'] = ['between', [strtotime(date('Y-m-d')), strtotime(date('Y-m-d', strtotime('+1 day')))]];
|
||||
}elseif($type==2){
|
||||
$where['create_time'] = ['between', [strtotime(date('Y-m-d', strtotime('-7 day'))), strtotime(date('Y-m-d'))]];
|
||||
}elseif($type==3){
|
||||
$where['create_time'] = ['between', [strtotime(date('Y-m-01')), strtotime(date('Y-m-t', strtotime(date('Y-m-01'))))]];
|
||||
}elseif($type==4){
|
||||
$where['create_time'] = ['between', [strtotime(date('Y-m-d', strtotime('-1 day'))), strtotime(date('Y-m-d'))]];
|
||||
}
|
||||
$count = db::name('vs_song_log')->where($where)->count();
|
||||
$list = db::name('vs_song_log')
|
||||
->alias('o')
|
||||
->join('user u', 'o.user_id=u.id')
|
||||
->join('vs_singer_song r', 'o.singer_song_id=r.id')
|
||||
->join('user uu', 'r.user_id=u.id')
|
||||
->join('vs_gift g', 'r.gift_id=g.gid')
|
||||
->field('o.*,u.nickname boss_nickname,u.user_code boss_user_code,r.song_name,r.gift_num,uu.nickname singer_nickname,uu.user_code singer_user_code,g.gift_name,g.gift_price')
|
||||
->where($where)
|
||||
->page($page, $page_limit)
|
||||
->select();
|
||||
$return_data = [
|
||||
'page' =>$page,
|
||||
'page_limit' => $page_limit,
|
||||
'count' => $count,
|
||||
'lists' => $list
|
||||
];
|
||||
return V(1,"成功", $return_data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user