diff --git a/application/api/controller/SingerSong.php b/application/api/controller/SingerSong.php index 71067bb..58fcf79 100644 --- a/application/api/controller/SingerSong.php +++ b/application/api/controller/SingerSong.php @@ -133,6 +133,18 @@ class SingerSong extends BaseCom } + //点歌各类型各个总数 + 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() { diff --git a/application/api/model/SingerSong.php b/application/api/model/SingerSong.php index fdf780d..c84aaba 100644 --- a/application/api/model/SingerSong.php +++ b/application/api/model/SingerSong.php @@ -231,6 +231,27 @@ class SingerSong extends Model } + /* + * 点歌各类型各个总数 + * @param type 类型 1:已点列表,2:今日列表,3:昨日列表,4:本周列表,5:本月列表 + * @param room_id 房间id + */ + public function singerSongCount($room_id) + { + $where = [ + 'room_id' => $room_id + ]; + $res = [ + 'total' => db::name('vs_song_log')->where($where)->count(), + 'today' => db::name('vs_song_log')->where($where)->where('createtime', 'between time', [strtotime(date('Y-m-d')), time()])->count(), + 'yesterday' => db::name('vs_song_log')->where($where)->where('createtime', 'between time', [strtotime(date('Y-m-d', strtotime("-1 day"))), strtotime(date('Y-m-d'))])->count(), + 'week' => db::name('vs_song_log')->where($where)->where('createtime', 'between time', [strtotime(date('Y-m-d', strtotime("-1 week"))), time()])->count(), + 'month' => db::name('vs_song_log')->where($where)->where('createtime', 'between time', [strtotime(date('Y-m-01')), strtotime(date('Y-m-t'))])->count() + ]; + return $res; + } + + /* * 歌手等级收礼升级 * @param user_id 用户id