- 拆分 HomeController → TransactionController, ReportWebController, FollowPlanController - 新增 Service 层: TransactionService, ReportService, FollowPlanService - pk10.php JS 抽离为 4 个独立文件 (sound/race/bet/poll) - 前台新增报表查询页面 (/report) + 跟单计划页面 (/follow-plan) - 后台新增跟单计划管理 + 用户输赢明细统计 - 封盘状态显示倒计时 (x:xx) - 音效仅在开奖弹窗打开时播放 - 路由按模块分组整理 - autoload 支持 App\Services 命名空间
91 lines
3.7 KiB
PHP
91 lines
3.7 KiB
PHP
<?php
|
|
namespace App\Controllers\Admin;
|
|
|
|
use App\Core\AdminBaseController;
|
|
use Db\Database;
|
|
|
|
class WaterController extends AdminBaseController {
|
|
private $db;
|
|
public function __construct(Database $db) { $this->db = $db; }
|
|
|
|
public function index() {
|
|
$this->checkLogin(); $this->checkAdmin();
|
|
$gameId = $this->getGameId();
|
|
$configs = $this->db->select('water_control', '*', ['game_id' => $gameId]);
|
|
$limits = $this->db->select('bet_limits', '*', ['game_id' => $gameId]);
|
|
$targetProfitRate = \App\Core\SettingsHelper::get('target_profit_rate');
|
|
$this->render('Admin/water_control.php', compact('configs', 'limits', 'gameId', 'targetProfitRate'));
|
|
}
|
|
|
|
public function updateWater() {
|
|
$this->checkLogin(); $this->checkAdmin();
|
|
$data = json_decode(file_get_contents('php://input'), true);
|
|
foreach ($data['items'] ?? [] as $item) {
|
|
$existing = $this->db->get('water_control', 'id', [
|
|
'game_id' => (int)$item['game_id'], 'bet_type' => $item['bet_type']
|
|
]);
|
|
$fields = [
|
|
'win_rate_pct' => floatval($item['win_rate_pct']),
|
|
'enabled' => (int)($item['enabled'] ?? 0),
|
|
];
|
|
if ($existing) {
|
|
$this->db->update('water_control', $fields, ['id' => $existing]);
|
|
} else {
|
|
$fields['game_id'] = (int)$item['game_id'];
|
|
$fields['bet_type'] = $item['bet_type'];
|
|
$this->db->insert('water_control', $fields);
|
|
}
|
|
}
|
|
$this->json(['status' => 'success']);
|
|
}
|
|
|
|
public function updateLimits() {
|
|
$this->checkLogin(); $this->checkAdmin();
|
|
$data = json_decode(file_get_contents('php://input'), true);
|
|
foreach ($data['items'] ?? [] as $item) {
|
|
$existing = $this->db->get('bet_limits', 'id', [
|
|
'game_id' => (int)$item['game_id'], 'bet_type' => $item['bet_type']
|
|
]);
|
|
$fields = [
|
|
'min_amount' => floatval($item['min_amount']),
|
|
'max_amount' => floatval($item['max_amount']),
|
|
'max_per_period' => floatval($item['max_per_period'] ?? 500000),
|
|
];
|
|
if ($existing) {
|
|
$this->db->update('bet_limits', $fields, ['id' => $existing]);
|
|
} else {
|
|
$fields['game_id'] = (int)$item['game_id'];
|
|
$fields['bet_type'] = $item['bet_type'];
|
|
$this->db->insert('bet_limits', $fields);
|
|
}
|
|
}
|
|
$this->json(['status' => 'success']);
|
|
}
|
|
|
|
public function updateProfitRate() {
|
|
$this->checkLogin(); $this->checkAdmin();
|
|
$data = json_decode(file_get_contents('php://input'), true);
|
|
$rate = isset($data['target_profit_rate']) ? floatval($data['target_profit_rate']) : 15;
|
|
if ($rate < 0 || $rate > 100) {
|
|
$this->json(['status' => 'error', 'message' => '盈利率必须在0-100之间']);
|
|
return;
|
|
}
|
|
|
|
$db = $this->db;
|
|
$existing = $db->get('system_settings', 'id', ['setting_key' => 'target_profit_rate']);
|
|
if ($existing) {
|
|
$db->update('system_settings', ['setting_value' => (string)$rate], ['id' => $existing]);
|
|
} else {
|
|
$db->insert('system_settings', ['setting_key' => 'target_profit_rate', 'setting_value' => (string)$rate]);
|
|
}
|
|
\App\Core\SettingsHelper::clearCache();
|
|
$this->json(['status' => 'success']);
|
|
}
|
|
|
|
private function getGameId(): int {
|
|
if (!empty($_GET['game_id'])) return (int)$_GET['game_id'];
|
|
return (int)($this->db->get('games', 'id', ['code' => 'pk10']) ?: 0);
|
|
}
|
|
private function json($d) { header('Content-Type: application/json'); echo json_encode($d); }
|
|
}
|