feat(chat): 增加五子棋的后台历史记录查阅面板与统计展示
This commit is contained in:
@@ -17,6 +17,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Models\BaccaratBet;
|
||||
use App\Models\BaccaratRound;
|
||||
use App\Models\FortuneLog;
|
||||
use App\Models\GomokuGame;
|
||||
use App\Models\HorseBet;
|
||||
use App\Models\HorseRace;
|
||||
use App\Models\LotteryIssue;
|
||||
@@ -83,6 +84,14 @@ class GameHistoryController extends Controller
|
||||
'today_issues' => LotteryIssue::query()->whereDate('created_at', today())->count(),
|
||||
];
|
||||
|
||||
// 五子棋
|
||||
$gomoku = [
|
||||
'total_games' => GomokuGame::query()->count(),
|
||||
'pvp_count' => GomokuGame::query()->where('is_pvp', true)->count(),
|
||||
'pve_count' => GomokuGame::query()->where('is_pvp', false)->count(),
|
||||
'today_games' => GomokuGame::query()->whereDate('created_at', today())->count(),
|
||||
];
|
||||
|
||||
return response()->json([
|
||||
'baccarat' => $baccarat,
|
||||
'slot' => $slot,
|
||||
@@ -90,6 +99,7 @@ class GameHistoryController extends Controller
|
||||
'mystery_box' => $mysteryBox,
|
||||
'fortune' => $fortune,
|
||||
'lottery' => $lottery,
|
||||
'gomoku' => $gomoku,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -281,4 +291,25 @@ class GameHistoryController extends Controller
|
||||
|
||||
return view('admin.game-history.lottery-issue', compact('issue', 'tickets'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 五子棋历史记录页面。
|
||||
*/
|
||||
public function gomoku(Request $request): View
|
||||
{
|
||||
$summary = [
|
||||
'total_games' => GomokuGame::query()->count(),
|
||||
'pvp_count' => GomokuGame::query()->where('is_pvp', true)->count(),
|
||||
'pve_count' => GomokuGame::query()->where('is_pvp', false)->count(),
|
||||
'completed' => GomokuGame::query()->where('status', 'finished')->count(),
|
||||
'today_games' => GomokuGame::query()->whereDate('created_at', today())->count(),
|
||||
];
|
||||
|
||||
$games = GomokuGame::query()
|
||||
->with(['playerBlack', 'playerWhite'])
|
||||
->latest()
|
||||
->paginate(30);
|
||||
|
||||
return view('admin.game-history.gomoku', compact('games', 'summary'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
'horse_racing' => 'admin.game-history.horse',
|
||||
'fortune_telling' => 'admin.game-history.fortune',
|
||||
'lottery' => 'admin.game-history.lottery',
|
||||
'gomoku' => 'admin.game-history.gomoku',
|
||||
default => null,
|
||||
};
|
||||
@endphp
|
||||
@@ -505,6 +506,24 @@
|
||||
},
|
||||
],
|
||||
color: 'border-rose-200 bg-rose-50',
|
||||
},
|
||||
{
|
||||
icon: '♟️',
|
||||
title: '五子棋',
|
||||
items: [{
|
||||
label: '总对局',
|
||||
value: data.gomoku.total_games.toLocaleString() + ' 局'
|
||||
},
|
||||
{
|
||||
label: '人机/对战',
|
||||
value: data.gomoku.pve_count + ' / ' + data.gomoku.pvp_count
|
||||
},
|
||||
{
|
||||
label: '今日对局',
|
||||
value: data.gomoku.today_games.toLocaleString()
|
||||
},
|
||||
],
|
||||
color: 'border-blue-200 bg-blue-50',
|
||||
}
|
||||
];
|
||||
|
||||
@@ -516,11 +535,11 @@
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
${card.items.map(item => `
|
||||
<div class="flex justify-between text-xs">
|
||||
<span class="text-gray-500">${item.label}</span>
|
||||
<span class="font-bold text-gray-700">${item.value}</span>
|
||||
</div>
|
||||
`).join('')}
|
||||
<div class="flex justify-between text-xs">
|
||||
<span class="text-gray-500">${item.label}</span>
|
||||
<span class="font-bold text-gray-700">${item.value}</span>
|
||||
</div>
|
||||
`).join('')}
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('title', '五子棋对局记录')
|
||||
|
||||
@section('content')
|
||||
<div class="space-y-6">
|
||||
|
||||
{{-- 页头 --}}
|
||||
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6 flex justify-between items-center">
|
||||
<div>
|
||||
<h2 class="text-lg font-bold text-gray-800">♟️ 五子棋历史记录</h2>
|
||||
<p class="text-xs text-gray-500 mt-1">查询全站所有的五子棋人机及 PvP 对局。</p>
|
||||
</div>
|
||||
<a href="{{ route('admin.game-configs.index') }}"
|
||||
class="px-4 py-2 bg-gray-100 text-gray-700 rounded-lg text-sm font-bold hover:bg-gray-200 transition">
|
||||
⚙️ 游戏配置
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{{-- 统计卡片 --}}
|
||||
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-5">
|
||||
<div class="text-2xl font-bold text-indigo-600">{{ number_format($summary['total_games']) }}</div>
|
||||
<div class="text-xs text-gray-500 mt-1">历史对局数</div>
|
||||
</div>
|
||||
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-5">
|
||||
<div class="text-2xl font-bold text-emerald-600">{{ number_format($summary['completed']) }}</div>
|
||||
<div class="text-xs text-gray-500 mt-1">正常完赛</div>
|
||||
</div>
|
||||
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-5">
|
||||
<div class="text-2xl font-bold text-amber-600">{{ number_format($summary['pvp_count']) }}</div>
|
||||
<div class="text-xs text-gray-500 mt-1">PvP 人人对战数</div>
|
||||
</div>
|
||||
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-5">
|
||||
<div class="text-2xl font-bold text-rose-600">{{ number_format($summary['today_games']) }}</div>
|
||||
<div class="text-xs text-gray-500 mt-1">今日新建对局</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- 期数列表 --}}
|
||||
<div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
|
||||
<table class="w-full text-sm">
|
||||
<thead class="bg-gray-50 border-b border-gray-100">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-left text-xs font-bold text-gray-500 uppercase">赛事ID</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-bold text-gray-500 uppercase">创建时间</th>
|
||||
<th class="px-4 py-3 text-center text-xs font-bold text-gray-500 uppercase">模式</th>
|
||||
<th class="px-4 py-3 text-center text-xs font-bold text-gray-500 uppercase">黑方 (发起)</th>
|
||||
<th class="px-4 py-3 text-center text-xs font-bold text-gray-500 uppercase">白方 (迎战)</th>
|
||||
<th class="px-4 py-3 text-center text-xs font-bold text-gray-500 uppercase">状态</th>
|
||||
<th class="px-4 py-3 text-center text-xs font-bold text-gray-500 uppercase">胜负</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-50">
|
||||
@forelse ($games as $game)
|
||||
<tr class="hover:bg-gray-50 transition">
|
||||
<td class="px-4 py-3 text-gray-600 text-xs font-mono font-bold">#{{ $game->id }}</td>
|
||||
<td class="px-4 py-3 text-xs text-gray-600">
|
||||
{{ $game->created_at ? $game->created_at->format('m-d H:i') : '—' }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-center">
|
||||
@if ($game->mode === 'pve')
|
||||
<span
|
||||
class="px-2 py-0.5 rounded-full text-xs font-bold bg-purple-100 text-purple-700">单机
|
||||
PvE(L{{ $game->ai_level }})</span>
|
||||
@else
|
||||
<span class="px-2 py-0.5 rounded-full text-xs font-bold bg-blue-100 text-blue-700">在线
|
||||
PvP</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-4 py-3 text-center font-bold">
|
||||
{{ $game->playerBlack?->username ?? '已注销/未知' }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-center font-bold">
|
||||
@if ($game->mode === 'pve')
|
||||
<span class="text-xs text-gray-400">AI 机器人</span>
|
||||
@else
|
||||
{{ $game->playerWhite?->username ?? '已注销/未加入' }}
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-4 py-3 text-center">
|
||||
@php
|
||||
$s = match ($game->status) {
|
||||
'waiting' => ['label' => '等待中', 'bg' => 'bg-amber-100 text-amber-600'],
|
||||
'playing' => ['label' => '对弈中', 'bg' => 'bg-blue-100 text-blue-600'],
|
||||
'finished' => ['label' => '已结束', 'bg' => 'bg-emerald-100 text-emerald-700'],
|
||||
default => ['label' => $game->status, 'bg' => 'bg-gray-100 text-gray-600'],
|
||||
};
|
||||
@endphp
|
||||
<span
|
||||
class="px-2 py-0.5 rounded-full text-xs font-bold {{ $s['bg'] }}">{{ $s['label'] }}</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-center">
|
||||
@if ($game->status !== 'finished')
|
||||
<span class="text-xs text-gray-400">-</span>
|
||||
@else
|
||||
@if ($game->winner === 1)
|
||||
<span class="text-xs font-bold text-gray-800 bg-gray-200 px-2 py-1 rounded">⚫
|
||||
黑胜</span>
|
||||
@elseif($game->winner === 2)
|
||||
<span class="text-xs font-bold bg-white border border-gray-300 px-2 py-1 rounded">⚪
|
||||
白胜</span>
|
||||
@else
|
||||
<span
|
||||
class="text-xs font-bold text-gray-500 bg-gray-100 px-2 py-1 rounded">平局撤销</span>
|
||||
@endif
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="7" class="px-4 py-10 text-center text-gray-400 text-sm">暂无记录</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@if ($games->hasPages())
|
||||
<div class="px-4 py-3 border-t border-gray-100">
|
||||
{{ $games->links() }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -461,6 +461,8 @@ Route::middleware(['chat.auth', 'chat.has_position'])->prefix('admin')->name('ad
|
||||
// 彩票场次历史
|
||||
Route::get('/lottery', [\App\Http\Controllers\Admin\GameHistoryController::class, 'lottery'])->name('lottery');
|
||||
Route::get('/lottery/{issue}', [\App\Http\Controllers\Admin\GameHistoryController::class, 'lotteryIssue'])->name('lottery.issue');
|
||||
// 五子棋历史
|
||||
Route::get('/gomoku', [\App\Http\Controllers\Admin\GameHistoryController::class, 'gomoku'])->name('gomoku');
|
||||
});
|
||||
|
||||
// 📦 神秘箱子:管理员手动投放
|
||||
|
||||
Reference in New Issue
Block a user