Initial commit: 投注游戏平台初始化
This commit is contained in:
Executable
+71
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Core\AdminBaseController;
|
||||
use Db\Database;
|
||||
use App\Core\PluginManager;
|
||||
|
||||
class HomeController extends AdminBaseController {
|
||||
protected $pluginManager;
|
||||
protected $db;
|
||||
|
||||
public function __construct() {
|
||||
global $pluginManager;
|
||||
$this->pluginManager = $pluginManager;
|
||||
$this->checkLogin();
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$plugins = $this->pluginManager->getPluginStatusList();
|
||||
$stats = $this->calculateDashboardStats();
|
||||
|
||||
$this->render('Admin/dashboard.php', [
|
||||
'plugins' => $plugins,
|
||||
'stats' => $stats,
|
||||
'title' => '控制台'
|
||||
]);
|
||||
}
|
||||
|
||||
private function calculateDashboardStats() {
|
||||
$db = new Database();
|
||||
$todayStart = date('Y-m-d 00:00:00');
|
||||
|
||||
try {
|
||||
// 1. 今日投注总额
|
||||
$todayBetAmount = $db->sum('bets', 'amount', [
|
||||
'created_at[>=]' => $todayStart
|
||||
]) ?: 0;
|
||||
|
||||
// 2. 今日已派彩金额 (已结算且中奖的)
|
||||
$todayPayoutAmount = $db->sum('bets', 'win_amount', [
|
||||
'settled_at[>=]' => $todayStart,
|
||||
'status' => 'win'
|
||||
]) ?: 0;
|
||||
|
||||
// 3. 待处理开奖 (已封盘 waiting for draw, 或 已开奖 waiting for settle)
|
||||
// status: pending -> locked -> drawn -> settled
|
||||
$pendingDrawCount = $db->count('periods', [
|
||||
'status' => ['locked', 'drawn']
|
||||
]);
|
||||
|
||||
// 4. 待处理提现 (目前没有提现申请表,暂定为0)
|
||||
// 如果后续有 withdrawals 表或 transactions status 字段,需在此修改
|
||||
$pendingWithdrawCount = 0;
|
||||
|
||||
return [
|
||||
'today_bet_amount' => $todayBetAmount,
|
||||
'today_payout_amount' => $todayPayoutAmount,
|
||||
'pending_draw_count' => $pendingDrawCount,
|
||||
'pending_withdraw_count' => $pendingWithdrawCount
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
return [
|
||||
'today_bet_amount' => 0,
|
||||
'today_payout_amount' => 0,
|
||||
'pending_draw_count' => 0,
|
||||
'pending_withdraw_count' => 0
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user