- 拆分 HomeController → TransactionController, ReportWebController, FollowPlanController - 新增 Service 层: TransactionService, ReportService, FollowPlanService - pk10.php JS 抽离为 4 个独立文件 (sound/race/bet/poll) - 前台新增报表查询页面 (/report) + 跟单计划页面 (/follow-plan) - 后台新增跟单计划管理 + 用户输赢明细统计 - 封盘状态显示倒计时 (x:xx) - 音效仅在开奖弹窗打开时播放 - 路由按模块分组整理 - autoload 支持 App\Services 命名空间
82 lines
2.3 KiB
PHP
Executable File
82 lines
2.3 KiB
PHP
Executable File
<?php
|
|
namespace App\Core;
|
|
|
|
use Db\Database;
|
|
|
|
class SettingsHelper {
|
|
private static $settings = null;
|
|
|
|
/**
|
|
* 获取所有系统设置
|
|
*/
|
|
public static function getAll() {
|
|
if (self::$settings !== null) {
|
|
return self::$settings;
|
|
}
|
|
|
|
try {
|
|
$db = new Database();
|
|
|
|
// 尝试查询设置(如果表不存在会抛出异常,被catch捕获)
|
|
try {
|
|
$settings = $db->select('system_settings', ['setting_key', 'setting_value']);
|
|
} catch (\Exception $e) {
|
|
// 表不存在或其他错误,返回默认值
|
|
self::$settings = self::getDefaults();
|
|
return self::$settings;
|
|
}
|
|
$result = [];
|
|
|
|
foreach ($settings as $setting) {
|
|
$result[$setting['setting_key']] = $setting['setting_value'];
|
|
}
|
|
|
|
// 合并默认值
|
|
$defaults = self::getDefaults();
|
|
foreach ($defaults as $key => $value) {
|
|
if (!isset($result[$key])) {
|
|
$result[$key] = $value;
|
|
}
|
|
}
|
|
|
|
self::$settings = $result;
|
|
return $result;
|
|
} catch (\Exception $e) {
|
|
// 出错时返回默认值
|
|
return self::getDefaults();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取单个设置值
|
|
*/
|
|
public static function get($key, $default = '') {
|
|
$settings = self::getAll();
|
|
return isset($settings[$key]) ? $settings[$key] : $default;
|
|
}
|
|
|
|
/**
|
|
* 获取默认设置值
|
|
*/
|
|
private static function getDefaults() {
|
|
return [
|
|
'site_title' => 'F1 Racing',
|
|
'site_description' => 'F1 Racing - Online Betting Platform',
|
|
'site_keywords' => 'f1, racing, betting, online game',
|
|
'site_logo' => '/Static/images/logo.png',
|
|
'site_favicon' => '/Static/css/favicon.ico',
|
|
'site_copyright' => '© 2025 F1 Racing. All rights reserved.',
|
|
'target_profit_rate' => '15', // 目标盈利率,百分比,如15表示15%
|
|
'customer_service_url' => '', // 客服链接(充值时跳转)
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 清除缓存(当设置更新后调用)
|
|
*/
|
|
public static function clearCache() {
|
|
self::$settings = null;
|
|
}
|
|
}
|
|
|