Files
pk10/App/Views/Admin/bets.php
T

215 lines
14 KiB
PHP
Executable File

<h1 class="text-2xl font-bold text-gray-800 mb-6 flex items-center">
<i class="fas fa-list-alt text-primary mr-3"></i>
投注记录
</h1>
<!-- 筛选工具栏 -->
<div class="bg-white rounded-xl shadow-md p-6 mb-8">
<form class="flex flex-col md:flex-row gap-4" method="GET" action="/admin/bets">
<div class="flex-1">
<label class="block text-sm font-medium text-gray-700 mb-1">用户ID</label>
<input type="text" name="user_id" value="<?= htmlspecialchars($_GET['user_id'] ?? '') ?>" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary/50 focus:border-primary text-sm" placeholder="输入用户ID">
</div>
<div class="flex-1">
<label class="block text-sm font-medium text-gray-700 mb-1">期号</label>
<input type="text" name="period_number" value="<?= htmlspecialchars($_GET['period_number'] ?? '') ?>" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary/50 focus:border-primary text-sm" placeholder="输入期号">
</div>
<div class="flex-1">
<label class="block text-sm font-medium text-gray-700 mb-1">状态</label>
<select name="status" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary/50 focus:border-primary text-sm">
<option value="">全部状态</option>
<option value="pending" <?= ($_GET['status'] ?? '') === 'pending' ? 'selected' : '' ?>>待结算</option>
<option value="win" <?= ($_GET['status'] ?? '') === 'win' ? 'selected' : '' ?>>已中奖</option>
<option value="lose" <?= ($_GET['status'] ?? '') === 'lose' ? 'selected' : '' ?>>未中奖</option>
<option value="settled" <?= ($_GET['status'] ?? '') === 'settled' ? 'selected' : '' ?>>已结算</option>
</select>
</div>
<div class="flex items-end">
<button type="submit" class="bg-primary hover:bg-primary/90 text-white px-6 py-2 rounded-lg text-sm transition-colors h-[38px]">
<i class="fas fa-search mr-2"></i>查询
</button>
<a href="/admin/bets" class="ml-2 bg-gray-100 hover:bg-gray-200 text-gray-700 px-4 py-2 rounded-lg text-sm transition-colors h-[38px] flex items-center">
重置
</a>
</div>
</form>
</div>
<!-- 数据列表 -->
<div class="bg-white rounded-xl shadow-md p-6 mb-8">
<div class="overflow-x-auto">
<table class="w-full bg-white rounded-xl overflow-hidden">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">用户</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">游戏房</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">期号</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">下注内容</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">金额</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">状态</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">中奖/盈利</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider hidden md:table-cell">下注时间</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
<?php if (!empty($bets) && is_array($bets)): ?>
<?php foreach ($bets as $bet): ?>
<tr class="hover:bg-gray-50 transition-colors">
<td class="px-4 py-4 text-sm text-gray-500">
#<?= $bet['id'] ?>
</td>
<td class="px-4 py-4">
<div class="text-sm font-medium text-gray-900"><?= htmlspecialchars($bet['username'] ?? '未知用户') ?></div>
<div class="text-xs text-gray-500">ID: <?= $bet['user_id'] ?></div>
<div class="text-xs text-gray-500">余额: <?= number_format($bet['balance'] ?? 0) ?></div>
</td>
<td class="px-4 py-4 text-sm text-gray-700">
<?= htmlspecialchars($bet['game_name'] ?? '未关联') ?>
</td>
<td class="px-4 py-4 text-sm text-gray-700">
<?= htmlspecialchars($bet['period_number']) ?>
</td>
<td class="px-4 py-4">
<?php
// ========== 投注类型中文映射(完整版)==========
$bt = $bet['bet_type'];
$bv = $bet['bet_value'];
$displayType = '';
$displayValue = '';
// PK10 名次投注: rank + rank1_5
if ($bt === 'rank' && preg_match('/^rank(\d+)_(\d+)$/', $bv, $m)) {
$rn = (int)$m[1];
$displayType = $rn === 1 ? '冠军' : ($rn === 2 ? '亚军' : '第'.$rn.'名');
$displayValue = $m[2] . '号车';
}
// PK10 大小: bs + rank1_big
elseif ($bt === 'bs' && preg_match('/^rank(\d+)_(big|small)$/', $bv, $m)) {
$rn = (int)$m[1];
$displayType = ($rn === 1 ? '冠军' : ($rn === 2 ? '亚军' : '第'.$rn.'名')) . ' 大小';
$displayValue = $m[2] === 'big' ? '大' : '小';
}
// PK10 单双: oe + rank1_odd
elseif ($bt === 'oe' && preg_match('/^rank(\d+)_(odd|even)$/', $bv, $m)) {
$rn = (int)$m[1];
$displayType = ($rn === 1 ? '冠军' : ($rn === 2 ? '亚军' : '第'.$rn.'名')) . ' 单双';
$displayValue = $m[2] === 'odd' ? '单' : '双';
}
// PK10 龙虎: dt + dt1_dragon
elseif ($bt === 'dt' && preg_match('/^dt(\d+)_(dragon|tiger)$/', $bv, $m)) {
$pairs = [1=>[1,10],2=>[2,9],3=>[3,8],4=>[4,7],5=>[5,6]];
$p = $pairs[(int)$m[1]] ?? [(int)$m[1], 11-(int)$m[1]];
$displayType = '龙虎 '.$p[0].'vs'.$p[1];
$displayValue = $m[2] === 'dragon' ? '龙' : '虎';
}
// PK10 冠亚和值: sum + sum_11
elseif ($bt === 'sum' && preg_match('/^sum_(\d+)$/', $bv, $m)) {
$displayType = '冠亚和';
$displayValue = $m[1];
}
// PK10 冠亚和大小: sum_bs + sum_big
elseif ($bt === 'sum_bs') {
$displayType = '冠亚和';
$sbMap = ['sum_big'=>'大','sum_small'=>'小','sum_odd'=>'单','sum_even'=>'双'];
$displayValue = $sbMap[$bv] ?? $bv;
}
// 骰子 大小/单双/点数/单骰/豹子
else {
$typeMap = [
'xiu' => '小', 'tai' => '大', 'chan' => '双', 'le' => '单',
'number' => '点数', 'dice' => '单骰', 'combo' => '豹子',
'big_small' => '大小', 'odd_even' => '单双',
];
$displayType = $typeMap[$bt] ?? $bt;
$valueMap = ['big'=>'大','small'=>'小','odd'=>'单','even'=>'双',
'4red'=>'4红','4white'=>'4白','3red1white'=>'3红1白','1red3white'=>'1红3白'];
$displayValue = $valueMap[$bv] ?? $bv;
}
?>
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
<?= htmlspecialchars($displayType) ?>
</span>
<span class="text-sm font-bold ml-1 text-gray-700">
<?= htmlspecialchars($displayValue) ?>
</span>
<div class="text-xs text-gray-500 mt-0.5">赔率: <?= $bet['odds'] ?></div>
</td>
<td class="px-4 py-4 text-sm font-bold text-gray-900">
<?= number_format($bet['amount']) ?>
</td>
<td class="px-4 py-4">
<?php
$status = $bet['status'];
$statusClassMap = [
'pending' => 'bg-yellow-100 text-yellow-800',
'win' => 'bg-green-100 text-green-800',
'lose' => 'bg-gray-100 text-gray-800',
'settled' => 'bg-blue-100 text-blue-800'
];
$statusClass = $statusClassMap[$status] ?? 'bg-gray-100 text-gray-800';
$statusTextMap = [
'pending' => '待结算',
'win' => '已中奖',
'lose' => '未中奖',
'settled' => '已结算'
];
$statusText = $statusTextMap[$status] ?? $status;
?>
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full <?= $statusClass ?>">
<?= $statusText ?>
</span>
</td>
<td class="px-4 py-4">
<?php if ($status === 'win'): ?>
<div class="text-sm font-bold text-green-600">+<?= number_format($bet['win_amount']) ?></div>
<div class="text-xs text-gray-500">盈利: <?= number_format($bet['win_amount'] - $bet['amount']) ?></div>
<?php elseif ($status === 'lose'): ?>
<div class="text-sm font-bold text-red-500">-<?= number_format($bet['amount']) ?></div>
<?php else: ?>
<span class="text-gray-400">-</span>
<?php endif; ?>
</td>
<td class="px-4 py-4 text-sm text-gray-500 hidden md:table-cell">
<?= $bet['created_at'] ?>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="8" class="px-6 py-12 text-center text-gray-500">
暂无投注记录
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
<!-- 分页 -->
<?php if ($totalPages > 1): ?>
<div class="mt-4 flex justify-between items-center">
<div class="text-sm text-gray-500">
共 <?= $totalPages ?> 页
</div>
<div class="flex gap-2">
<?php if ($currentPage > 1): ?>
<a href="?page=<?= $currentPage - 1 ?><?= http_build_query(array_diff_key($_GET, ['page' => ''])) ? '&' . http_build_query(array_diff_key($_GET, ['page' => ''])) : '' ?>" class="px-3 py-1 border rounded hover:bg-gray-50">上一页</a>
<?php endif; ?>
<?php for ($i = max(1, $currentPage - 2); $i <= min($totalPages, $currentPage + 2); $i++): ?>
<a href="?page=<?= $i ?><?= http_build_query(array_diff_key($_GET, ['page' => ''])) ? '&' . http_build_query(array_diff_key($_GET, ['page' => ''])) : '' ?>" class="px-3 py-1 border rounded <?= $i == $currentPage ? 'bg-primary text-white border-primary' : 'hover:bg-gray-50' ?>">
<?= $i ?>
</a>
<?php endfor; ?>
<?php if ($currentPage < $totalPages): ?>
<a href="?page=<?= $currentPage + 1 ?><?= http_build_query(array_diff_key($_GET, ['page' => ''])) ? '&' . http_build_query(array_diff_key($_GET, ['page' => ''])) : '' ?>" class="px-3 py-1 border rounded hover:bg-gray-50">下一页</a>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
</div>