进入房间
This commit is contained in:
@@ -8,7 +8,7 @@ use think\Model;
|
||||
class RoomHourRanking extends Model
|
||||
{
|
||||
//房间小时榜
|
||||
public function room_hour_ranking($page, $page_limit,$start_time = null, $end_time = null)
|
||||
public function room_hour_rankings($page, $page_limit,$start_time = null, $end_time = null)
|
||||
{
|
||||
//当前小时开始时间
|
||||
if($start_time == null){
|
||||
@@ -70,4 +70,81 @@ class RoomHourRanking extends Model
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => ['time_range' => $time_range, 'lists' =>$profit]];
|
||||
}
|
||||
|
||||
|
||||
//房间小时榜(更正版)
|
||||
public function room_hour_ranking($page, $page_limit,$start_time = null, $end_time = null)
|
||||
{
|
||||
//当前小时开始时间
|
||||
if($start_time == null){
|
||||
$start_time = strtotime(date('Y-m-d H:00:00'));
|
||||
}
|
||||
|
||||
//结束时间
|
||||
if($end_time == null){
|
||||
$end_time = strtotime(date('Y-m-d H:59:59'));
|
||||
}
|
||||
|
||||
//判断是否开启
|
||||
$open_time = db::name('vs_hour_ranking_config')->where('id', 1)->value('open_time');
|
||||
if ($open_time == 0) {
|
||||
return ['code' => 0, 'msg' => '排行榜暂未开启', 'data' => null];
|
||||
}
|
||||
|
||||
//是否开启巡乐会
|
||||
$is_open_xlh = db::name('vs_hour_ranking_config')->where('id', 1)->value('is_open_xlh');
|
||||
// 查询这个时间段内收礼的房间ID集合,并实现分页
|
||||
$room_query = Db::name('vs_give_gift')
|
||||
->where('from', 2)
|
||||
->whereBetween('createtime', [$start_time, $end_time])
|
||||
->group('from_id')
|
||||
->field('from_id, SUM(total_price) as total_price');
|
||||
|
||||
// 应用分页限制
|
||||
$room_ids_with_price = $room_query
|
||||
->order('total_price', 'desc')
|
||||
->limit(($page - 1) * $page_limit, $page_limit)
|
||||
->select();
|
||||
|
||||
$profit = [];
|
||||
if($room_ids_with_price){
|
||||
foreach ($room_ids_with_price as $k => $item){
|
||||
$room_id = $item['from_id'];
|
||||
$profit[$k] = 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('a.type_id', '<>', 6)
|
||||
->where('a.id', $room_id)
|
||||
->find();
|
||||
|
||||
if($profit[$k]) {
|
||||
$profit[$k]['total_price'] = $profit[$k]['total_price'] * get_system_config_value('coin_charm_exp');
|
||||
if($room_id > 0 && $is_open_xlh == 1){
|
||||
$xlh_status = model('BlindBoxTurntableGift')->get_user_xlh_info($room_id);
|
||||
$profit[$k]['xlh_status'] = $xlh_status['xlh_status'];
|
||||
}else{
|
||||
$profit[$k]['xlh_status'] = 0;
|
||||
}
|
||||
//查询房间是否有红包
|
||||
if($room_id){
|
||||
$red_pack_status = Db::name('redpacket')->where(['room_id' => $room_id, 'status' => ['<=',1]])->count();
|
||||
$profit[$k]['redpacket_status'] = $red_pack_status;
|
||||
}else{
|
||||
$profit[$k]['redpacket_status'] = 0;
|
||||
}
|
||||
} else {
|
||||
unset($profit[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 过滤掉空值并重新索引数组
|
||||
if($profit){
|
||||
$profit = array_values(array_filter($profit));
|
||||
}
|
||||
|
||||
//当前小时开始时间 和结束时间 00:00-00:59 这样的格式
|
||||
$time_range = date('H:') . '00-' . date('H:'). '59';
|
||||
return ['code' => 1, 'msg' => '获取成功', 'data' => ['time_range' => $time_range, 'lists' =>$profit]];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user