You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.8 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace app\mall\logic;
use app\mall\model\MallSpikeTime;
class Spike extends Base
{
/**
* 获取场次列表
* @date 2022-08-26
*/
public function listScene()
{
$time_model = new MallSpikeTime();
// 获取每天的时间场次列表
$where = [
['uid', '=', $this->mid]
];
$time_list = $time_model->getAllData($where, 'start_time,end_time', 'start_time asc')->toArray();
// 定义显示场次列表
$today_spike_time = [];
$tomorrow_spike_time = [];
foreach ($time_list as $k => $v) {
// 今日场次 未过结束时间
if (strtotime(date('Y-m-d ' . $v['end_time'])) > time()) {
$today_spike_time[] = [
// 显示开始时间H:i
'start_time' => $v['start_time'],
// 显示结束时间H:i
'end_time' => $v['end_time'],
// 开始时间时间戳
's_time' => strtotime(date('Y-m-d ' . $v['start_time'])),
// 结束时间时间戳
'e_time' => strtotime(date('Y-m-d ' . $v['end_time'])),
// 显示文案
'brief' => strtotime(date('Y-m-d ' . $v['start_time'])) > time() ? '即将开场' : '已开抢',
// 状态 1--已开抢 2--即将开场 3--明日开场
'status' => strtotime(date('Y-m-d ' . $v['start_time'])) > time() ? 2 : 1,
// 间隔时间,距离开始/结束还剩多长时间,单位秒
'space_time' => strtotime(date('Y-m-d ' . $v['start_time'])) > time() ? strtotime(date('Y-m-d ' . $v['start_time'])) - time() : strtotime(date('Y-m-d ' . $v['end_time'])) - time()
];
}
// 明日场次 开始时间小于1天后的现在
if (strtotime(date('Y-m-d ' . $v['start_time'])) <= time()) {
$tomorrow_spike_time[] = [
'start_time' => $v['start_time'],
'end_time' => $v['end_time'],
's_time' => strtotime(date('Y-m-d ' . $v['start_time'])) + 86400,
'e_time' => strtotime(date('Y-m-d ' . $v['end_time'])) + 86400,
'brief' => '明日开场',
'status' => strtotime(date('Y-m-d ' . $v['start_time'])) + 86400 > time() ? 2 : 1,
'space_time' => strtotime(date('Y-m-d ' . $v['start_time'])) + 86400 > time() ? strtotime(date('Y-m-d ' . $v['start_time'])) + 86400 - time() : strtotime(date('Y-m-d ' . $v['end_time'])) + 86400 - time()
];
}
}
$spike_time = array_merge($today_spike_time, $tomorrow_spike_time);
return $spike_time;
}
}