1.优化game_config

2.备份MySQL数据库
This commit is contained in:
2026-04-28 15:50:16 +08:00
parent 9bc439ea5e
commit a033bf47b6
9 changed files with 1324 additions and 1 deletions

View File

@@ -60,7 +60,8 @@ class Game extends MobileBase
'bet_config' => [ 'bet_config' => [
'pick_max_number_count' => $this->getPickMaxNumberCount(), 'pick_max_number_count' => $this->getPickMaxNumberCount(),
'chips' => ['1.00', '5.00', '10.00', '25.00', '50.00', '100.00'], 'chips' => ['1.00', '5.00', '10.00', '25.00', '50.00', '100.00'],
'single_number_max_bet' => $this->getConfigValue('single_number_max_bet', '500.00'), 'min_bet_per_number' => $this->getConfigValue('min_bet_per_number', '0.0100'),
'max_bet_per_number' => $this->getConfigValue('max_bet_per_number', '10000.0000'),
], ],
'dictionary' => $items, 'dictionary' => $items,
'user_snapshot' => [ 'user_snapshot' => [
@@ -154,6 +155,17 @@ class Game extends MobileBase
return $this->mobileError(1003, 'Invalid parameter value'); return $this->mobileError(1003, 'Invalid parameter value');
} }
$singleAmount = bcadd($singleBetAmount, '0', 2); $singleAmount = bcadd($singleBetAmount, '0', 2);
$minPer = trim((string) $this->getConfigValue('min_bet_per_number', '0.0100'));
$maxPer = trim((string) $this->getConfigValue('max_bet_per_number', '10000.0000'));
if (!is_numeric($minPer) || bccomp($minPer, '0', 4) <= 0) {
$minPer = '0.0100';
}
if (!is_numeric($maxPer) || bccomp($maxPer, $minPer, 4) < 0) {
$maxPer = '10000.0000';
}
if (bccomp($singleAmount, $minPer, 4) < 0 || bccomp($singleAmount, $maxPer, 4) > 0) {
return $this->mobileError(1003, 'Bet amount out of range');
}
$numberCount = (string) count($numbers); $numberCount = (string) count($numbers);
$totalAmount = bcmul($singleAmount, $numberCount, 2); $totalAmount = bcmul($singleAmount, $numberCount, 2);

View File

@@ -25,6 +25,15 @@ final class GameHotDataRedis
private const KEY_USER = 'dfw:v1:user:'; private const KEY_USER = 'dfw:v1:user:';
/**
* 进程内实例化缓存(避免同一请求/进程内重复打 Redis/DB
* - key => null表示已确认不存在负缓存
* - key => array表示已加载行数据
*
* @var array<string, array<string, mixed>|null>
*/
private static array $gcLocal = [];
public static function enabled(): bool public static function enabled(): bool
{ {
return config('game_hot_cache.enabled', true) === true; return config('game_hot_cache.enabled', true) === true;
@@ -38,23 +47,30 @@ final class GameHotDataRedis
if ($configKey === '') { if ($configKey === '') {
return null; return null;
} }
if (array_key_exists($configKey, self::$gcLocal)) {
$cachedLocal = self::$gcLocal[$configKey];
return is_array($cachedLocal) ? $cachedLocal : null;
}
if (self::enabled()) { if (self::enabled()) {
$cached = self::redisGet(self::KEY_GC . $configKey); $cached = self::redisGet(self::KEY_GC . $configKey);
if ($cached !== null && $cached !== '') { if ($cached !== null && $cached !== '') {
$decoded = json_decode($cached, true); $decoded = json_decode($cached, true);
if (is_array($decoded)) { if (is_array($decoded)) {
self::$gcLocal[$configKey] = $decoded;
return $decoded; return $decoded;
} }
} }
} }
$row = Db::name('game_config')->where('config_key', $configKey)->find(); $row = Db::name('game_config')->where('config_key', $configKey)->find();
if (!$row) { if (!$row) {
self::$gcLocal[$configKey] = null;
return null; return null;
} }
if (self::enabled()) { if (self::enabled()) {
$ttl = self::intConfig('ttl_game_config', 86400); $ttl = self::intConfig('ttl_game_config', 86400);
self::redisSetEx(self::KEY_GC . $configKey, $ttl, json_encode($row, JSON_UNESCAPED_UNICODE)); self::redisSetEx(self::KEY_GC . $configKey, $ttl, json_encode($row, JSON_UNESCAPED_UNICODE));
} }
self::$gcLocal[$configKey] = $row;
return $row; return $row;
} }
@@ -64,6 +80,7 @@ final class GameHotDataRedis
return; return;
} }
self::redisDel(self::KEY_GC . $configKey); self::redisDel(self::KEY_GC . $configKey);
unset(self::$gcLocal[$configKey]);
} }
/** /**
@@ -81,6 +98,7 @@ final class GameHotDataRedis
} }
$ttl = self::intConfig('ttl_game_config', 86400); $ttl = self::intConfig('ttl_game_config', 86400);
self::redisSetEx(self::KEY_GC . $configKey, $ttl, json_encode($row, JSON_UNESCAPED_UNICODE)); self::redisSetEx(self::KEY_GC . $configKey, $ttl, json_encode($row, JSON_UNESCAPED_UNICODE));
self::$gcLocal[$configKey] = $row;
} }
/** /**

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,20 @@
-- 已上线环境:移除后台「会员管理」目录及子菜单、相关安全配置项(与代码移除配套执行)
-- 执行前请备份数据库
DELETE FROM admin_rule WHERE `name` = 'user' OR `name` LIKE 'user/%';
DELETE FROM security_sensitive_data WHERE `id` = 2;
DELETE FROM security_data_recycle WHERE `id` = 5;
-- ---------------------------------------------------------------------------
-- 以下可选:物理删除会员业务表(执行后 /api/user、/api/account 等会员接口将不可用)
-- 若仍使用前台会员中心,请勿执行 DROP并保留 user、user_group、user_rule 等表
-- ---------------------------------------------------------------------------
-- SET FOREIGN_KEY_CHECKS = 0;
-- DROP TABLE IF EXISTS `user_money_log`;
-- DROP TABLE IF EXISTS `user_score_log`;
-- DROP TABLE IF EXISTS `user`;
-- DROP TABLE IF EXISTS `user_group`;
-- SET FOREIGN_KEY_CHECKS = 1;
-- 说明:`user_rule` 仍用于前台会员菜单与权限,若整体下线会员功能再单独处理