From 469063984ea528b23a8093b181086d385a76e59d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Mon, 29 Sep 2025 14:26:04 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=88=BF=E9=97=B4=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E6=A6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/RoomHourRanking.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/application/api/controller/RoomHourRanking.php b/application/api/controller/RoomHourRanking.php index 859e461..244ab62 100644 --- a/application/api/controller/RoomHourRanking.php +++ b/application/api/controller/RoomHourRanking.php @@ -42,9 +42,8 @@ class RoomHourRanking ->select(); if($profit){ foreach ($profit as $v) { - $xlh_status = model('BlindBoxTurntableGift')->get_user_xlh_info($v['room_id']); + $xlh_status = model('BlindBoxTurntableGift')->get_user_xlh_info(); $v['xlh_status'] = $xlh_status['xlh_status']; -// $v['xlh_status'] = 1; } } return V(1, '获取成功', $profit); From 550058ec453fe5fa93ac56412cec8a4a277c5527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Mon, 29 Sep 2025 14:29:08 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=88=BF=E9=97=B4=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E6=A6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/RoomHourRanking.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/application/api/controller/RoomHourRanking.php b/application/api/controller/RoomHourRanking.php index 244ab62..1b8bef8 100644 --- a/application/api/controller/RoomHourRanking.php +++ b/application/api/controller/RoomHourRanking.php @@ -42,8 +42,13 @@ class RoomHourRanking ->select(); if($profit){ foreach ($profit as $v) { - $xlh_status = model('BlindBoxTurntableGift')->get_user_xlh_info(); - $v['xlh_status'] = $xlh_status['xlh_status']; + 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; + } + } } return V(1, '获取成功', $profit); From 6e3eabbc8fa5b543c6e81d7df5f2c251001ebe13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Mon, 29 Sep 2025 14:30:15 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=88=BF=E9=97=B4=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E6=A6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/RoomHourRanking.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/api/controller/RoomHourRanking.php b/application/api/controller/RoomHourRanking.php index 1b8bef8..8674538 100644 --- a/application/api/controller/RoomHourRanking.php +++ b/application/api/controller/RoomHourRanking.php @@ -41,7 +41,7 @@ class RoomHourRanking // ->limit(20) ->select(); if($profit){ - foreach ($profit as $v) { + foreach ($profit as &$v) { if($v['room_id'] > 0){ $xlh_status = model('BlindBoxTurntableGift')->get_user_xlh_info($v['room_id']); $v['xlh_status'] = $xlh_status['xlh_status']; From 5ac02eabb6f827ad444a3068fd3a4b6518d9e993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Mon, 29 Sep 2025 14:33:56 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=88=BF=E9=97=B4=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E6=A6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/RoomHourRanking.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/application/api/controller/RoomHourRanking.php b/application/api/controller/RoomHourRanking.php index 8674538..2e72f19 100644 --- a/application/api/controller/RoomHourRanking.php +++ b/application/api/controller/RoomHourRanking.php @@ -23,6 +23,8 @@ class RoomHourRanking //房间小时榜 public function room_hour_ranking() { + $page = input('page', 1); + $page_limit = input('page_limit', 20); //判断是否开启 $open_time = db::name('vs_hour_ranking_config')->order('id', 'desc')->value('open_time'); if ($open_time = 0) { @@ -38,7 +40,7 @@ class RoomHourRanking ->where('b.from',2) ->where('b.createtime', 'between', [$start_time, time()]) ->order('total_price', 'desc') -// ->limit(20) + ->page($page, $page_limit) ->select(); if($profit){ foreach ($profit as &$v) { @@ -48,7 +50,6 @@ class RoomHourRanking }else{ $v['xlh_status'] = 0; } - } } return V(1, '获取成功', $profit); From 80a6cc44592794bf4996922be717ef8af98d5022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Mon, 29 Sep 2025 14:57:41 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=88=BF=E9=97=B4=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E6=A6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/RoomHourRanking.php | 75 ++++++++++++++++++- 1 file changed, 72 insertions(+), 3 deletions(-) diff --git a/application/api/controller/RoomHourRanking.php b/application/api/controller/RoomHourRanking.php index 2e72f19..96bf3c0 100644 --- a/application/api/controller/RoomHourRanking.php +++ b/application/api/controller/RoomHourRanking.php @@ -2,9 +2,10 @@ namespace app\api\controller; +use app\common\controller\BaseCom; use think\Db; -class RoomHourRanking +class RoomHourRanking extends BaseCom { //房间小时榜是否开启 public function room_hour_ranking_is_open() @@ -33,15 +34,20 @@ class RoomHourRanking //当前小时开始时间 $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) + ->field('a.id as room_id,a.room_name,a.label_id,a.room_cover,IFNULL(sum(b.total_price), 0) as total_price,c.label_icon') + ->where('a.room_status', 1) // 只统计正常状态的房间 + ->where('a.apply_status', 2) // 只统计审核通过的房间 + ->where('b.from', 2) ->where('b.createtime', 'between', [$start_time, time()]) + ->group('a.id') ->order('total_price', 'desc') ->page($page, $page_limit) ->select(); + if($profit){ foreach ($profit as &$v) { if($v['room_id'] > 0){ @@ -54,4 +60,67 @@ class RoomHourRanking } return V(1, '获取成功', $profit); } + + //房间小时榜 + public function room_hour_rankings() + { + $page = input('page', 1); + $page_limit = input('page_limit', 20); + //判断是否开启 + $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')); + + // 先查询所有符合条件的房间 + $rooms = db::name('vs_room')->alias('a') + ->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,0 as total_price,c.label_icon') + ->where('a.room_status', 1) + ->where('a.apply_status', 2) + ->page($page, $page_limit) + ->select(); + + if ($rooms) { + // 获取房间ID列表 + $room_ids = array_column($rooms, 'room_id'); + + // 查询这些房间在当前小时的礼物总额 + $gift_data = db::name('vs_give_gift') + ->field('from_id as room_id, sum(total_price) as total_price') + ->where('from', 2) + ->where('from_id', 'in', $room_ids) + ->where('createtime', 'between', [$start_time, time()]) + ->group('from_id') + ->select(); + + // 将礼物数据合并到房间数据中 + $gift_map = []; + foreach ($gift_data as $gift) { + $gift_map[$gift['room_id']] = $gift['total_price'] * get_system_config_value('coin_charm_exp');; + } + + // 更新房间数据 + foreach ($rooms as &$room) { + $room['total_price'] = isset($gift_map[$room['room_id']]) ? $gift_map[$room['room_id']] : 0; + + if($room['room_id'] > 0){ + $xlh_status = model('BlindBoxTurntableGift')->get_user_xlh_info($room['room_id']); + $room['xlh_status'] = $xlh_status['xlh_status']; + }else{ + $room['xlh_status'] = 0; + } + } + + // 按礼物总额排序 + usort($rooms, function($a, $b) { + return $b['total_price'] <=> $a['total_price']; + }); + } + + return V(1, '获取成功', $rooms); + } } \ No newline at end of file From 8fca63d9102c5d30c628a4f529ad776541b09282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Mon, 29 Sep 2025 15:14:00 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=88=BF=E9=97=B4=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E6=A6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/RoomHourRanking.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/application/api/controller/RoomHourRanking.php b/application/api/controller/RoomHourRanking.php index 96bf3c0..b6b1089 100644 --- a/application/api/controller/RoomHourRanking.php +++ b/application/api/controller/RoomHourRanking.php @@ -120,7 +120,9 @@ class RoomHourRanking extends BaseCom return $b['total_price'] <=> $a['total_price']; }); } + //当前小时开始时间 和结束时间 00:00-00:59 这样的格式 + $time_range = date('H:') . '00-' . date('H:'). '59'; - return V(1, '获取成功', $rooms); + return V(1, '获取成功', ['time_range' => $time_range, 'lists' =>$rooms]); } } \ No newline at end of file