feat(chat): 完善后台彩票游戏的历史总览、期号列表及单期购买明细页面

This commit is contained in:
2026-03-12 08:48:30 +08:00
parent 246d89fef6
commit 9e1e5fb7db
5 changed files with 326 additions and 9 deletions
@@ -19,6 +19,8 @@ use App\Models\BaccaratRound;
use App\Models\FortuneLog;
use App\Models\HorseBet;
use App\Models\HorseRace;
use App\Models\LotteryIssue;
use App\Models\LotteryTicket;
use App\Models\MysteryBox;
use App\Models\SlotMachineLog;
use Illuminate\Http\JsonResponse;
@@ -73,12 +75,21 @@ class GameHistoryController extends Controller
'today_times' => FortuneLog::query()->whereDate('created_at', today())->count(),
];
// 彩票
$lottery = [
'total_issues' => LotteryIssue::query()->count(),
'total_bets' => LotteryTicket::query()->count(),
'total_pool' => LotteryIssue::query()->where('status', 'drawn')->sum('prize_pool'),
'today_issues' => LotteryIssue::query()->whereDate('created_at', today())->count(),
];
return response()->json([
'baccarat' => $baccarat,
'slot' => $slot,
'horse' => $horse,
'mystery_box' => $mysteryBox,
'fortune' => $fortune,
'lottery' => $lottery,
]);
}
@@ -241,4 +252,33 @@ class GameHistoryController extends Controller
return view('admin.game-history.fortune', compact('logs', 'summary'));
}
/**
* 双色球彩票历史记录页面(期号列表,支持分页)。
*/
public function lottery(Request $request): View
{
$summary = [
'total_issues' => LotteryIssue::query()->count(),
'total_tickets' => LotteryTicket::query()->count(),
'total_pool' => (int) LotteryIssue::query()->sum('prize_pool'),
'drawn_count' => LotteryIssue::query()->where('status', 'drawn')->count(),
];
$issues = LotteryIssue::query()
->latest()
->paginate(20);
return view('admin.game-history.lottery', compact('issues', 'summary'));
}
/**
* 双色球单期购买明细与中奖详情。
*/
public function lotteryIssue(LotteryIssue $issue): View
{
$tickets = $issue->tickets()->with('user')->latest()->paginate(30);
return view('admin.game-history.lottery-issue', compact('issue', 'tickets'));
}
}
@@ -64,6 +64,7 @@
'mystery_box' => 'admin.game-history.mystery-box',
'horse_racing' => 'admin.game-history.horse',
'fortune_telling' => 'admin.game-history.fortune',
'lottery' => 'admin.game-history.lottery',
default => null,
};
@endphp
@@ -477,16 +478,34 @@
value: data.fortune.total_times.toLocaleString() + ' 次'
},
{
label: '上上签',
value: data.fortune.jackpot_count.toLocaleString()
label: '吉签/凶签',
value: data.fortune.jackpot_count + ' / ' + data.fortune.curse_count
},
{
label: '今日次数',
label: '今日占卜',
value: data.fortune.today_times.toLocaleString()
},
],
color: 'border-indigo-200 bg-indigo-50',
color: 'border-fuchsia-200 bg-fuchsia-50',
},
{
icon: '🎟️',
title: '双色球彩票',
items: [{
label: '总期数',
value: data.lottery.total_issues.toLocaleString() + ' 期'
},
{
label: '历史彩票',
value: data.lottery.total_bets.toLocaleString() + ' 张'
},
{
label: '累计奖池',
value: data.lottery.total_pool.toLocaleString() + ' 金'
},
],
color: 'border-rose-200 bg-rose-50',
}
];
grid.innerHTML = cards.map(card => `
@@ -497,11 +516,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,133 @@
@extends('admin.layouts.app')
@section('title', "双色球第 {$issue->issue_number} 期购买明细")
@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">🎟️ 双色球 {{ $issue->issue_number }} 期购买明细</h2>
<p class="text-xs text-gray-500 mt-1">
开奖时间:{{ $issue->draw_time?->format('Y-m-d H:i:s') ?? '未开奖' }}
@if ($issue->status === 'drawn')
&nbsp;·&nbsp;开奖号码:
<span class="font-bold text-indigo-600">
@php
$balls = is_string($issue->winning_balls)
? json_decode($issue->winning_balls, true)
: $issue->winning_balls;
$reds = $balls['red'] ?? [];
$blue = $balls['blue'] ?? null;
@endphp
@foreach ($reds as $r)
<span class="bg-red-100 text-red-600 px-1 rounded">{{ $r }}</span>
@endforeach
@if ($blue)
<span class="bg-blue-100 text-blue-600 px-1 rounded">{{ $blue }}</span>
@endif
</span>
@endif
&nbsp;·&nbsp;奖池:<span class="font-bold text-amber-600">{{ number_format($issue->prize_pool ?? 0) }}
金币</span>
</p>
</div>
<a href="{{ route('admin.game-history.lottery') }}"
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="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">玩家</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-right text-xs font-bold text-gray-500 uppercase">花费</th>
<th class="px-4 py-3 text-right 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-right text-xs font-bold text-gray-500 uppercase">下注时间</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-50">
@forelse ($tickets as $ticket)
@php
$won = ($ticket->prize_amount ?? 0) > 0;
// 拆分红蓝球显示
$selectedBalls = is_string($ticket->selected_balls)
? json_decode($ticket->selected_balls, true)
: $ticket->selected_balls;
$selReds = $selectedBalls['red'] ?? [];
$selBlue = $selectedBalls['blue'] ?? null;
@endphp
<tr class="hover:bg-gray-50 transition {{ $won ? 'bg-amber-50/50' : '' }}">
<td class="px-4 py-3 font-medium text-gray-800">
{{ $ticket->user?->username ?? '已注销' }}
</td>
<td class="px-4 py-3 text-center font-mono">
<div class="flex items-center justify-center gap-1 flex-wrap">
@foreach ($selReds as $r)
<span
class="text-xs bg-red-50 text-red-500 px-1 rounded shadow-sm border border-red-100">{{ $r }}</span>
@endforeach
@if ($selBlue)
<span
class="text-xs bg-blue-50 text-blue-500 px-1 rounded shadow-sm border border-blue-100">{{ $selBlue }}</span>
@endif
</div>
</td>
<td class="px-4 py-3 text-center">
@if ($ticket->is_quick_pick)
<span
class="px-2 py-0.5 rounded-full text-xs font-bold bg-purple-100 text-purple-700">随机机选</span>
@else
<span
class="px-2 py-0.5 rounded-full text-xs font-bold bg-blue-100 text-blue-700">自选号码</span>
@endif
</td>
<td class="px-4 py-3 text-right font-mono text-sm text-gray-700">
{{ number_format($ticket->cost_amount) }}
</td>
<td
class="px-4 py-3 text-right font-mono text-sm {{ $won ? 'text-emerald-600 font-bold' : 'text-gray-400' }}">
{{ $won ? '+' . number_format($ticket->prize_amount) : '0' }}
</td>
<td class="px-4 py-3 text-center">
@if ($issue->status === 'drawn')
@if ($won)
<span
class="px-2 py-0.5 rounded-full text-xs font-bold bg-amber-100 text-amber-700">
🎉 {{ $ticket->prize_level }}等奖
</span>
@else
<span
class="px-2 py-0.5 rounded-full text-xs font-bold bg-gray-100 text-gray-500">未中奖</span>
@endif
@else
<span class="text-xs text-gray-400">等待开奖</span>
@endif
</td>
<td class="px-4 py-3 text-right text-xs text-gray-400">
{{ $ticket->created_at->format('H:i:s') }}
</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 ($tickets->hasPages())
<div class="px-4 py-3 border-t border-gray-100">
{{ $tickets->links() }}
</div>
@endif
</div>
</div>
@endsection
@@ -0,0 +1,122 @@
@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">查询各期双色球的开奖结果及购买明细。</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_issues']) }}</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['drawn_count']) }}</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['total_tickets']) }}</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-rose-600">{{ number_format($summary['total_pool']) }}</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">期号</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-right text-xs font-bold text-gray-500 uppercase">售出票数</th>
<th class="px-4 py-3 text-right text-xs font-bold text-gray-500 uppercase">期奖池</th>
<th class="px-4 py-3 text-right text-xs font-bold text-gray-500 uppercase">操作</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-50">
@forelse ($issues as $issue)
<tr class="hover:bg-gray-50 transition">
<td class="px-4 py-3 text-gray-600 text-xs font-mono font-bold"> {{ $issue->issue_number }}
</td>
<td class="px-4 py-3 text-xs text-gray-600">
{{ $issue->draw_time ? $issue->draw_time->format('m-d H:i') : '—' }}
</td>
<td class="px-4 py-3 text-center">
@if ($issue->status === 'drawn')
<span
class="px-2 py-0.5 rounded-full text-xs font-bold bg-emerald-100 text-emerald-700">已开奖</span>
@else
<span
class="px-2 py-0.5 rounded-full text-xs font-bold bg-amber-100 text-amber-700">销售中</span>
@endif
</td>
<td class="px-4 py-3 text-center font-mono">
@if ($issue->winning_balls)
@php
$balls = is_string($issue->winning_balls)
? json_decode($issue->winning_balls, true)
: $issue->winning_balls;
$reds = $balls['red'] ?? [];
$blue = $balls['blue'] ?? null;
@endphp
<div class="flex items-center justify-center gap-1">
@foreach ($reds as $r)
<span
class="text-xs bg-red-100 text-red-600 px-1 rounded">{{ $r }}</span>
@endforeach
@if ($blue)
<span
class="text-xs bg-blue-100 text-blue-600 px-1 rounded">{{ $blue }}</span>
@endif
</div>
@else
<span class="text-xs text-gray-400">等待开奖</span>
@endif
</td>
<td class="px-4 py-3 text-right font-mono text-xs text-indigo-600 font-bold">
{{ number_format($issue->tickets_count) }}
</td>
<td class="px-4 py-3 text-right font-mono text-xs text-amber-600 font-bold">
{{ number_format($issue->prize_pool) }}
</td>
<td class="px-4 py-3 text-right">
<a href="{{ route('admin.game-history.lottery.issue', $issue->id) }}"
class="px-3 py-1 bg-indigo-50 text-indigo-700 rounded text-xs font-bold hover:bg-indigo-100 transition">
购买明细
</a>
</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 ($issues->hasPages())
<div class="px-4 py-3 border-t border-gray-100">
{{ $issues->links() }}
</div>
@endif
</div>
</div>
@endsection
+3
View File
@@ -458,6 +458,9 @@ Route::middleware(['chat.auth', 'chat.has_position'])->prefix('admin')->name('ad
Route::get('/mystery-box', [\App\Http\Controllers\Admin\GameHistoryController::class, 'mysteryBox'])->name('mystery-box');
// 神秘占卜历史
Route::get('/fortune', [\App\Http\Controllers\Admin\GameHistoryController::class, 'fortune'])->name('fortune');
// 彩票场次历史
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');
});
// 📦 神秘箱子:管理员手动投放