Files
midi-php/application/api/controller/RoomHourRanking.php
2025-09-29 14:14:20 +08:00

51 lines
1.7 KiB
PHP

<?php
namespace app\api\controller;
use think\Db;
class RoomHourRanking
{
//房间小时榜是否开启
public function room_hour_ranking_is_open()
{
$open_time = db::name('vs_hour_ranking_config')->order('id', 'desc')->value('open_time');
return V(1, '获取成功', ['open_time' => $open_time]);
}
//房间小时榜玩法
public function room_hour_ranking_play()
{
$introd = db::name('vs_hour_ranking_config')->order('id', 'desc')->value('introd');
return V(1, '获取成功', ['introd' => $introd]);
}
//房间小时榜
public function room_hour_ranking()
{
//判断是否开启
$open_time = db::name('vs_hour_ranking_config')->order('id', 'desc')->value('open_time');
if ($open_time = 0) {
return V(0, '排行榜暂未开启');
}
//当前小时开始时间
$start_time = strtotime(date('Y-m-d H:00:00'));
$profit = db::name('vs_room')->alias('a')
->join('vs_give_gift b', 'a.id = b.from_id','left')
->join('vs_room_label c', 'a.label_id = c.id','left')
->field('a.id as room_id,a.room_name,a.label_id,a.room_cover,sum(b.total_price) as total_price,c.label_icon')
->where('b.from',2)
->where('b.createtime', 'between', [$start_time, time()])
->order('total_price', 'desc')
->limit(20)
->select();
if($profit){
foreach ($profit as $k => $v) {
$xlh_status = model('BlindBoxTurntableGift')->get_user_xlh_info($v['room_id']);
$profit[$k]['xlh_status'] = $xlh_status['xlh_status'];
}
}
return V(1, '获取成功', $profit);
}
}