feat: 更新玩法配置管理,简化字段并增强功能

- 将玩法相关的显示名称字段统一为 `display_name`,移除多语言字段。
- 在 `PlayTypePatchController` 中新增即时切换玩法开关的功能,并推送大厅更新。
- 优化多个控制器和服务中的权限检查与数据处理逻辑,提升代码可读性与维护性。
This commit is contained in:
2026-05-25 14:34:24 +08:00
parent 270d2e9af1
commit e27a00f260
74 changed files with 4469 additions and 280 deletions

View File

@@ -16,6 +16,7 @@ use App\Lottery\DrawResultBatchStatus;
use App\Services\Draw\DrawTickService;
use App\Events\DrawStatusChangeBroadcast;
use App\Services\Draw\DrawPlannerService;
use App\Services\Draw\DrawHallSnapshotBuilder;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
@@ -747,9 +748,70 @@ test('lottery hall-countdown dispatches draw.countdown when using reverb connect
'broadcasting.connections.reverb.driver' => 'reverb',
]);
Draw::query()->create([
'draw_no' => '20260509-001',
'business_date' => '2026-05-09',
'sequence_no' => 1,
'status' => DrawStatus::Open->value,
'start_time' => now()->subMinutes(5),
'close_time' => now()->addMinutes(20),
'draw_time' => now()->addMinutes(25),
'cooling_end_time' => null,
'result_source' => null,
'current_result_version' => 0,
'settle_version' => 0,
'is_reopened' => false,
]);
$this->artisan('lottery:hall-countdown')->assertSuccessful();
Event::assertDispatched(DrawCountdownBroadcast::class);
Event::assertDispatched(
DrawCountdownBroadcast::class,
fn (DrawCountdownBroadcast $event): bool => is_array($event->data) && isset($event->data['draw_no']),
);
});
test('hall snapshot switches to next bettable draw when cooldown ended', function (): void {
Carbon::setTestNow(Carbon::parse('2026-05-10 12:00:00', 'UTC'));
Draw::query()->create([
'draw_no' => '20260510-001',
'business_date' => '2026-05-10',
'sequence_no' => 1,
'status' => DrawStatus::Cooldown->value,
'start_time' => now()->subHours(3),
'close_time' => now()->subHours(2),
'draw_time' => now()->subHours(2),
'cooling_end_time' => now()->subMinutes(5),
'result_source' => 'rng',
'current_result_version' => 1,
'settle_version' => 0,
'is_reopened' => false,
]);
$next = Draw::query()->create([
'draw_no' => '20260510-002',
'business_date' => '2026-05-10',
'sequence_no' => 2,
'status' => DrawStatus::Pending->value,
'start_time' => now()->subMinutes(1),
'close_time' => now()->addMinutes(20),
'draw_time' => now()->addMinutes(25),
'cooling_end_time' => null,
'result_source' => null,
'current_result_version' => 0,
'settle_version' => 0,
'is_reopened' => false,
]);
$target = app(DrawHallSnapshotBuilder::class)->resolveHallTarget(now()->utc());
expect($target)->not->toBeNull()
->and($target->draw_no)->toBe('20260510-002');
$payload = app(DrawHallSnapshotBuilder::class)->build(now()->utc());
expect($payload['status'] ?? null)->toBe('open');
Carbon::setTestNow();
});
test('draw tick dispatches draw.status_change when hall draw_no or status changes', function (): void {