no message

This commit is contained in:
hajimi
2026-06-11 12:15:29 +08:00
parent 10ebe39c30
commit 96efa1d905
5859 changed files with 815501 additions and 5 deletions
@@ -0,0 +1,101 @@
<?php
namespace app\adminapi\lists\match;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\league\League;
class LeagueLists extends BaseAdminDataLists implements ListsSearchInterface
{
public function setSearch(): array
{
return [
'%like%' => ['label'],
'=' => ['type', 'is_show'],
];
}
public function lists(): array
{
$lists = League::where($this->searchWhere)
->whereIn('type', ['sport', 'league'])
->order('sort', 'desc')
->order('id', 'desc')
->select()
->toArray();
// 按 type 分组
$sports = [];
$leagues = [];
foreach ($lists as $item) {
if ($item['type'] === 'sport') {
$sports[] = $item;
} else {
$leagues[] = $item;
}
}
// 按 sport_type 将联赛挂到对应体育类型下
$leagueMap = [];
foreach ($leagues as $lg) {
$st = $lg['sport_type'];
if (!isset($leagueMap[$st])) {
$leagueMap[$st] = [];
}
$leagueMap[$st][] = $lg;
}
// 构建树形:sport 为父节点,league 为子节点
$tree = [];
foreach ($sports as $sport) {
$st = $sport['sport_type'];
$children = $leagueMap[$st] ?? [];
$tree[] = [
'id' => $sport['id'],
'label' => $sport['label'],
'type' => 'sport',
'sport_type' => $st,
'icon' => $sport['icon'] ?? '',
'sort' => $sport['sort'],
'is_show' => $sport['is_show'],
'is_group' => true,
'children' => $children,
];
}
// 未归属任何 sport 的联赛(孤儿数据)
$assignedIds = [];
foreach ($leagueMap as $group) {
foreach ($group as $lg) {
$assignedIds[] = $lg['id'];
}
}
$orphans = [];
foreach ($leagues as $lg) {
if (!in_array($lg['id'], $assignedIds)) {
$orphans[] = $lg;
}
}
if (!empty($orphans)) {
$tree[] = [
'id' => 'type_orphan',
'label' => '未分类',
'type' => 'league',
'sport_type' => -1,
'icon' => '',
'sort' => '',
'is_show' => '',
'is_group' => true,
'children' => $orphans,
];
}
return $tree;
}
public function count(): int
{
return League::where($this->searchWhere)->whereIn('type', ['sport', 'league'])->count();
}
}
@@ -0,0 +1,38 @@
<?php
namespace app\adminapi\lists\match;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\match\MatchEvent;
class MatchLists extends BaseAdminDataLists implements ListsSearchInterface
{
public function setSearch(): array
{
return [
'=' => ['sport_type', 'status', 'is_hot', 'is_show'],
'%like%' => ['home_team', 'away_team', 'league_name'],
];
}
public function lists(): array
{
$lists = MatchEvent::where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)
->order('match_time', 'desc')
->select()
->toArray();
foreach ($lists as &$item) {
$item['match_time_str'] = date('Y-m-d H:i', $item['match_time']);
}
return $lists;
}
public function count(): int
{
return MatchEvent::where($this->searchWhere)->count();
}
}