refactor: 迁移彩票设置至 LotterySettings 服务

- 更新多个控制器和服务,使用 LotterySettings 服务获取彩票相关配置,如默认币种、开奖间隔、下注窗口等,提升代码一致性与可维护性。
- 移除 .env.example 中不再使用的配置项,建议通过后台管理进行设置。
This commit is contained in:
2026-05-28 14:50:25 +08:00
parent 5e73dc6ec1
commit 8ccf39dff5
20 changed files with 131 additions and 44 deletions

View File

@@ -10,6 +10,7 @@ use App\Models\DrawResultItem;
use App\Models\DrawResultBatch;
use App\Lottery\DrawResultBatchStatus;
use App\Services\Jackpot\JackpotSummaryService;
use App\Services\LotterySettings;
/**
* `GET draw/current` 与大厅 WS 快照共用数据结构。
@@ -237,7 +238,7 @@ final class DrawHallSnapshotBuilder
$effectiveStatus = $this->effectiveHallDisplayStatus($target, $nowUtc);
$scheduleTz = (string) config('lottery.draw.timezone', 'UTC');
$scheduleTz = LotterySettings::drawTimezone();
$payload = [
'schedule_timezone' => $scheduleTz,
@@ -324,6 +325,6 @@ final class DrawHallSnapshotBuilder
return $code;
}
return strtoupper(substr(trim((string) config('lottery.default_currency', 'NPR')), 0, 16));
return LotterySettings::defaultCurrency();
}
}

View File

@@ -4,6 +4,7 @@ namespace App\Services\Draw;
use Carbon\Carbon;
use App\Models\Draw;
use App\Services\LotterySettings;
use Illuminate\Support\Facades\DB;
/**
@@ -27,7 +28,7 @@ final class DrawManualCreateService
*/
public function create(array $input, ?Carbon $now = null): Draw
{
$tz = (string) config('lottery.draw.timezone', 'UTC');
$tz = LotterySettings::drawTimezone();
$nowUtc = ($now ?? Carbon::now())->utc();
$drawLocal = $this->parseInTimezone((string) $input['draw_time'], $tz);

View File

@@ -6,6 +6,7 @@ use Carbon\Carbon;
use App\Models\Draw;
use App\Models\TicketOrder;
use App\Lottery\DrawStatus;
use App\Services\LotterySettings;
use Illuminate\Support\Facades\DB;
/**
@@ -29,7 +30,7 @@ final class DrawManualUpdateService
*/
public function update(Draw $draw, array $input, ?Carbon $now = null): Draw
{
$tz = (string) config('lottery.draw.timezone', 'UTC');
$tz = LotterySettings::drawTimezone();
$nowUtc = ($now ?? Carbon::now())->utc();
return DB::transaction(function () use ($draw, $input, $tz, $nowUtc): Draw {

View File

@@ -5,6 +5,7 @@ namespace App\Services\Draw;
use Carbon\Carbon;
use App\Models\Draw;
use App\Lottery\DrawStatus;
use App\Services\LotterySettings;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\QueryException;
@@ -21,9 +22,9 @@ final class DrawPlannerService
public function ensureBuffer(?Carbon $now = null): array
{
$nowUtc = ($now ?? Carbon::now())->utc();
$tz = (string) config('lottery.draw.timezone', 'UTC');
$interval = (int) config('lottery.draw.interval_minutes', 5);
$buffer = (int) config('lottery.draw.buffer_draws_ahead', 8);
$tz = LotterySettings::drawTimezone();
$interval = LotterySettings::drawIntervalMinutes();
$buffer = LotterySettings::drawBufferDrawsAhead();
$maxSeq = intdiv(24 * 60, $interval);
$upcoming = Draw::query()

View File

@@ -79,10 +79,7 @@ final class DrawPublishService
private function applyPublishedToDraw(Draw $draw, DrawResultBatch $batch): Draw
{
$cooldownMinutes = max(0, (int) LotterySettings::get(
'draw.cooldown_minutes',
(int) config('lottery.draw.cooldown_minutes', 15),
));
$cooldownMinutes = LotterySettings::drawCooldownMinutes();
if ($cooldownMinutes > 0) {
$draw->forceFill([
'status' => DrawStatus::Cooldown->value,

View File

@@ -9,6 +9,7 @@ use App\Models\DrawResultBatch;
use Illuminate\Support\Collection;
use App\Lottery\DrawResultBatchStatus;
use App\Services\Jackpot\JackpotSummaryService;
use App\Services\LotterySettings;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
/**
@@ -194,6 +195,6 @@ final class DrawResultViewService
return $code;
}
return strtoupper(substr(trim((string) config('lottery.default_currency', 'NPR')), 0, 16));
return LotterySettings::defaultCurrency();
}
}

View File

@@ -28,10 +28,7 @@ final class DrawRngRunner
'status' => DrawStatus::Drawing->value,
])->save();
$manualReview = (bool) LotterySettings::get(
'draw.require_manual_review',
(bool) config('lottery.draw.require_manual_review', false),
);
$manualReview = LotterySettings::drawRequireManualReview();
$seedHex = DrawRngSeedDerivation::generateSeedHex();
$rngSeedHash = DrawRngSeedDerivation::hashSeedHex($seedHex);
$rawSeedEncrypted = DrawRngSeedDerivation::encryptSeedHex($seedHex);

View File

@@ -4,6 +4,7 @@ namespace App\Services\Draw;
use Carbon\Carbon;
use App\Lottery\DrawStatus;
use App\Services\LotterySettings;
/**
* 由开奖时刻推导下注窗口、封盘时刻与期号初始状态。
@@ -12,12 +13,12 @@ final class DrawTimelineBuilder
{
public function closeBeforeDrawSeconds(): int
{
return (int) config('lottery.draw.close_before_draw_seconds', 30);
return LotterySettings::drawCloseBeforeDrawSeconds();
}
public function bettingWindowSeconds(): int
{
return (int) config('lottery.draw.betting_window_seconds', 270);
return LotterySettings::drawBettingWindowSeconds();
}
/**