refactor: 迁移彩票设置至 LotterySettings 服务
- 更新多个控制器和服务,使用 LotterySettings 服务获取彩票相关配置,如默认币种、开奖间隔、下注窗口等,提升代码一致性与可维护性。 - 移除 .env.example 中不再使用的配置项,建议通过后台管理进行设置。
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Lottery\ErrorCode;
|
||||
use App\Support\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Services\LotterySettings;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
final class AdminCurrencyDestroyController extends Controller
|
||||
@@ -15,7 +16,7 @@ final class AdminCurrencyDestroyController extends Controller
|
||||
{
|
||||
$code = strtoupper((string) $currency->code);
|
||||
|
||||
if ($code === strtoupper((string) config('lottery.default_currency', 'NPR'))) {
|
||||
if ($code === LotterySettings::defaultCurrency()) {
|
||||
return ApiResponse::error(
|
||||
'默认币种不可删除',
|
||||
ErrorCode::ValidationFailed->value,
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Models\TicketItem;
|
||||
use App\Models\TicketOrder;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Support\AdminApiList;
|
||||
use App\Services\LotterySettings;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
@@ -38,10 +39,10 @@ final class AdminDrawIndexController extends Controller
|
||||
|
||||
return AdminApiList::jsonWith($paginator, fn (Draw $row) => $this->row($row), [
|
||||
'schedule' => [
|
||||
'timezone' => (string) config('lottery.draw.timezone', 'UTC'),
|
||||
'interval_minutes' => (int) config('lottery.draw.interval_minutes', 5),
|
||||
'betting_window_seconds' => (int) config('lottery.draw.betting_window_seconds', 270),
|
||||
'close_before_draw_seconds' => (int) config('lottery.draw.close_before_draw_seconds', 30),
|
||||
'timezone' => LotterySettings::drawTimezone(),
|
||||
'interval_minutes' => LotterySettings::drawIntervalMinutes(),
|
||||
'betting_window_seconds' => LotterySettings::drawBettingWindowSeconds(),
|
||||
'close_before_draw_seconds' => LotterySettings::drawCloseBeforeDrawSeconds(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api\V1;
|
||||
use App\Support\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\LotterySettings;
|
||||
|
||||
final class HealthController extends Controller
|
||||
{
|
||||
@@ -17,7 +18,7 @@ final class HealthController extends Controller
|
||||
{
|
||||
$payload = [
|
||||
'app' => config('app.name'),
|
||||
'default_currency' => config('lottery.default_currency'),
|
||||
'default_currency' => LotterySettings::defaultCurrency(),
|
||||
];
|
||||
|
||||
if (config('app.debug')) {
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Support\ApiResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\LotterySettings;
|
||||
use App\Services\Jackpot\JackpotSummaryService;
|
||||
|
||||
/**
|
||||
@@ -21,7 +22,7 @@ final class JackpotSummaryController extends Controller
|
||||
{
|
||||
$currencyCode = strtoupper(trim((string) $request->query(
|
||||
'currency_code',
|
||||
(string) config('lottery.default_currency', 'NPR'),
|
||||
LotterySettings::defaultCurrency(),
|
||||
)));
|
||||
|
||||
return ApiResponse::success($this->summary->summary($currencyCode));
|
||||
|
||||
Reference in New Issue
Block a user