|
|
|
|
@ -12,7 +12,6 @@ use App\Models\TicketGrabEvent;
|
|
|
|
|
use App\Models\Venue;
|
|
|
|
|
use App\Support\ActivityH5View;
|
|
|
|
|
use App\Support\CalendarDateFormat;
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
|
|
|
|
|
|
class H5HomeController extends Controller
|
|
|
|
|
@ -170,39 +169,45 @@ class H5HomeController extends Controller
|
|
|
|
|
];
|
|
|
|
|
});
|
|
|
|
|
$controller = $this;
|
|
|
|
|
$today = Carbon::now((string) config('app.timezone'))->toDateString();
|
|
|
|
|
$hotActivities = $actRows->merge($tgRows)->sort(function (array $x, array $y) use ($today, $controller) {
|
|
|
|
|
$hx = (($x['list_kind'] ?? 'activity') === 'activity' && ! empty($x['is_hot'])) ? 0 : 1;
|
|
|
|
|
$hy = (($y['list_kind'] ?? 'activity') === 'activity' && ! empty($y['is_hot'])) ? 0 : 1;
|
|
|
|
|
if ($hx !== $hy) {
|
|
|
|
|
return $hx <=> $hy;
|
|
|
|
|
}
|
|
|
|
|
$sx = $controller->homeScheduleRank($x['start_at'] ?? null, $x['end_at'] ?? null, $today);
|
|
|
|
|
$sy = $controller->homeScheduleRank($y['start_at'] ?? null, $y['end_at'] ?? null, $today);
|
|
|
|
|
if ($sx !== $sy) {
|
|
|
|
|
return $sx <=> $sy;
|
|
|
|
|
}
|
|
|
|
|
$a = $x['start_at'] ?? '';
|
|
|
|
|
$b = $y['start_at'] ?? '';
|
|
|
|
|
if ($a !== $b) {
|
|
|
|
|
if ($a === '') {
|
|
|
|
|
return 1;
|
|
|
|
|
$hotActivities = $actRows
|
|
|
|
|
->merge($tgRows)
|
|
|
|
|
->filter(fn (array $row) => ($row['schedule_status'] ?? '') !== 'ended')
|
|
|
|
|
->values()
|
|
|
|
|
->sort(function (array $x, array $y) use ($controller) {
|
|
|
|
|
$hx = (($x['list_kind'] ?? 'activity') === 'activity' && ! empty($x['is_hot'])) ? 0 : 1;
|
|
|
|
|
$hy = (($y['list_kind'] ?? 'activity') === 'activity' && ! empty($y['is_hot'])) ? 0 : 1;
|
|
|
|
|
if ($hx !== $hy) {
|
|
|
|
|
return $hx <=> $hy;
|
|
|
|
|
}
|
|
|
|
|
if ($b === '') {
|
|
|
|
|
return -1;
|
|
|
|
|
$sx = $controller->homeScheduleRankFromStatus($x['schedule_status'] ?? null);
|
|
|
|
|
$sy = $controller->homeScheduleRankFromStatus($y['schedule_status'] ?? null);
|
|
|
|
|
if ($sx !== $sy) {
|
|
|
|
|
return $sx <=> $sy;
|
|
|
|
|
}
|
|
|
|
|
$a = $x['start_at'] ?? '';
|
|
|
|
|
$b = $y['start_at'] ?? '';
|
|
|
|
|
if ($a !== $b) {
|
|
|
|
|
if ($a === '') {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
if ($b === '') {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return strcmp((string) $a, (string) $b);
|
|
|
|
|
}
|
|
|
|
|
return strcmp((string) $a, (string) $b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$tx = $this->homeActivityTicketPaidRank($x);
|
|
|
|
|
$ty = $this->homeActivityTicketPaidRank($y);
|
|
|
|
|
if ($tx !== $ty) {
|
|
|
|
|
return $tx <=> $ty;
|
|
|
|
|
}
|
|
|
|
|
$tx = $this->homeActivityTicketPaidRank($x);
|
|
|
|
|
$ty = $this->homeActivityTicketPaidRank($y);
|
|
|
|
|
if ($tx !== $ty) {
|
|
|
|
|
return $tx <=> $ty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (int) $y['id'] <=> (int) $x['id'];
|
|
|
|
|
})->values()->take(5)->values();
|
|
|
|
|
return (int) $y['id'] <=> (int) $x['id'];
|
|
|
|
|
})
|
|
|
|
|
->values()
|
|
|
|
|
->take(5)
|
|
|
|
|
->values();
|
|
|
|
|
|
|
|
|
|
$rankings = $hotActivities->take(2)->values();
|
|
|
|
|
|
|
|
|
|
@ -281,22 +286,15 @@ class H5HomeController extends Controller
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 与活动列表 H5 混合排序:0 进行中/未结束, 1 未开始, 2 已结束。
|
|
|
|
|
* 0=进行中 1=未开始 2=已结束,与 {@see Activity::computeScheduleStatusForDisplay} 口径一致。
|
|
|
|
|
* (热门区已过滤 ended,此处仅用于未开始/进行中 的先后。)
|
|
|
|
|
*/
|
|
|
|
|
private function homeScheduleRank(?string $startIso, ?string $endIso, string $today): int
|
|
|
|
|
private function homeScheduleRankFromStatus(?string $scheduleStatus): int
|
|
|
|
|
{
|
|
|
|
|
$s = $startIso ? Carbon::parse($startIso)->toDateString() : null;
|
|
|
|
|
$e = $endIso ? Carbon::parse($endIso)->toDateString() : null;
|
|
|
|
|
if (! $e && ! $s) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
if ($e && $e < $today) {
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
if ($s && $s > $today) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
return match ($scheduleStatus) {
|
|
|
|
|
'not_started' => 1,
|
|
|
|
|
'ended' => 2,
|
|
|
|
|
default => 0,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|