refactor: 迁移彩票设置至 LotterySettings 服务
- 更新多个控制器和服务,使用 LotterySettings 服务获取彩票相关配置,如默认币种、开奖间隔、下注窗口等,提升代码一致性与可维护性。 - 移除 .env.example 中不再使用的配置项,建议通过后台管理进行设置。
This commit is contained in:
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use App\Services\LotterySettings;
|
||||
|
||||
/**
|
||||
* 将「最小货币单位」整数格式化为展示用字符串(不改变业务数字,仅格式化)。
|
||||
*
|
||||
@@ -22,9 +24,9 @@ final class CurrencyFormatter
|
||||
|
||||
private static function formatMinorInt(int $minorUnits): string
|
||||
{
|
||||
$decimals = max(0, min(12, (int) config('lottery.ui.format.currency.decimals', 2)));
|
||||
$decSep = (string) config('lottery.ui.format.currency.decimal_separator', '.');
|
||||
$thousandsSep = (string) config('lottery.ui.format.currency.thousands_separator', ',');
|
||||
$decimals = LotterySettings::currencyDisplayDecimals();
|
||||
$decSep = LotterySettings::currencyDecimalSeparator();
|
||||
$thousandsSep = LotterySettings::currencyThousandsSeparator();
|
||||
|
||||
$divisor = (int) max(1, 10 ** $decimals);
|
||||
$negative = $minorUnits < 0;
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Support;
|
||||
use App\Models\Player;
|
||||
use App\Models\Currency;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Services\LotterySettings;
|
||||
|
||||
/**
|
||||
* 币种码解析工具。
|
||||
@@ -36,7 +37,7 @@ final class CurrencyResolver
|
||||
} else {
|
||||
$fallback = $default
|
||||
?? $player?->default_currency
|
||||
?? config('lottery.default_currency', 'NPR');
|
||||
?? LotterySettings::defaultCurrency();
|
||||
$code = strtoupper(substr(trim((string) $fallback), 0, 16));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Support;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Services\LotterySettings;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
/**
|
||||
@@ -40,7 +41,7 @@ trait TicketItemListFilters
|
||||
|
||||
private function scheduleTimezone(): string
|
||||
{
|
||||
return (string) config('lottery.draw.timezone', 'UTC');
|
||||
return LotterySettings::drawTimezone();
|
||||
}
|
||||
|
||||
private function scheduleDateStartUtc(string $ymd): Carbon
|
||||
|
||||
Reference in New Issue
Block a user