Files
midi-php/application/api/controller/RoomHourRanking.php

57 lines
1.9 KiB
PHP
Raw Normal View History

2025-09-29 14:12:04 +08:00
<?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()
{
2025-09-29 14:33:56 +08:00
$page = input('page', 1);
$page_limit = input('page_limit', 20);
2025-09-29 14:12:04 +08:00
//判断是否开启
$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')
2025-09-29 14:14:20 +08:00
->join('vs_give_gift b', 'a.id = b.from_id','left')
2025-09-29 14:12:04 +08:00
->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')
2025-09-29 14:33:56 +08:00
->page($page, $page_limit)
2025-09-29 14:12:04 +08:00
->select();
if($profit){
2025-09-29 14:30:15 +08:00
foreach ($profit as &$v) {
2025-09-29 14:29:08 +08:00
if($v['room_id'] > 0){
$xlh_status = model('BlindBoxTurntableGift')->get_user_xlh_info($v['room_id']);
$v['xlh_status'] = $xlh_status['xlh_status'];
}else{
$v['xlh_status'] = 0;
}
2025-09-29 14:12:04 +08:00
}
}
return V(1, '获取成功', $profit);
}
}