refactor: 迁移彩票设置至 LotterySettings 服务
- 更新多个控制器和服务,使用 LotterySettings 服务获取彩票相关配置,如默认币种、开奖间隔、下注窗口等,提升代码一致性与可维护性。 - 移除 .env.example 中不再使用的配置项,建议通过后台管理进行设置。
This commit is contained in:
@@ -13,6 +13,84 @@ use Illuminate\Support\Facades\Cache;
|
||||
*/
|
||||
final class LotterySettings
|
||||
{
|
||||
public static function defaultCurrency(): string
|
||||
{
|
||||
$fallback = (string) config('lottery.default_currency', 'NPR');
|
||||
$value = self::get('currency.default_code', $fallback);
|
||||
|
||||
return strtoupper(substr(trim((string) $value), 0, 16));
|
||||
}
|
||||
|
||||
public static function drawTimezone(): string
|
||||
{
|
||||
return (string) self::get('draw.timezone', (string) config('lottery.draw.timezone', 'UTC'));
|
||||
}
|
||||
|
||||
public static function drawIntervalMinutes(): int
|
||||
{
|
||||
$fallback = (int) config('lottery.draw.interval_minutes', 5);
|
||||
|
||||
return max(1, min(1440, (int) self::get('draw.interval_minutes', $fallback)));
|
||||
}
|
||||
|
||||
public static function drawBufferDrawsAhead(): int
|
||||
{
|
||||
$fallback = (int) config('lottery.draw.buffer_draws_ahead', 8);
|
||||
|
||||
return max(1, (int) self::get('draw.buffer_draws_ahead', $fallback));
|
||||
}
|
||||
|
||||
public static function drawBettingWindowSeconds(): int
|
||||
{
|
||||
$fallback = (int) config('lottery.draw.betting_window_seconds', 270);
|
||||
|
||||
return max(10, (int) self::get('draw.betting_window_seconds', $fallback));
|
||||
}
|
||||
|
||||
public static function drawCloseBeforeDrawSeconds(): int
|
||||
{
|
||||
$fallback = (int) config('lottery.draw.close_before_draw_seconds', 30);
|
||||
|
||||
return max(5, (int) self::get('draw.close_before_draw_seconds', $fallback));
|
||||
}
|
||||
|
||||
public static function drawRequireManualReview(): bool
|
||||
{
|
||||
$fallback = (bool) config('lottery.draw.require_manual_review', true);
|
||||
|
||||
return (bool) self::get('draw.require_manual_review', $fallback);
|
||||
}
|
||||
|
||||
public static function drawCooldownMinutes(): int
|
||||
{
|
||||
$fallback = (int) config('lottery.draw.cooldown_minutes', 15);
|
||||
|
||||
return max(0, (int) self::get('draw.cooldown_minutes', $fallback));
|
||||
}
|
||||
|
||||
public static function currencyDisplayDecimals(): int
|
||||
{
|
||||
$fallback = (int) config('lottery.ui.format.currency.decimals', 2);
|
||||
|
||||
return max(0, min(12, (int) self::get('currency.display_decimals', $fallback)));
|
||||
}
|
||||
|
||||
public static function currencyDecimalSeparator(): string
|
||||
{
|
||||
return (string) self::get(
|
||||
'currency.decimal_separator',
|
||||
(string) config('lottery.ui.format.currency.decimal_separator', '.')
|
||||
);
|
||||
}
|
||||
|
||||
public static function currencyThousandsSeparator(): string
|
||||
{
|
||||
return (string) self::get(
|
||||
'currency.thousands_separator',
|
||||
(string) config('lottery.ui.format.currency.thousands_separator', ',')
|
||||
);
|
||||
}
|
||||
|
||||
public static function cacheTtlSeconds(): int
|
||||
{
|
||||
return max(5, (int) config('lottery.settings.cache_ttl_seconds', 60));
|
||||
|
||||
Reference in New Issue
Block a user