feat: 增强开奖与设置控制器的币种支持功能

引入 CurrencyResolver,用于在 DrawCurrentController、DrawResultShowController 与 DrawResultsIndexController 中统一处理币种代码解析。
更新 DrawHallSnapshotBuilder 与 DrawResultViewService 的构建方法,新增币种代码参数支持,确保开奖相关功能中的币种处理一致性。
增强 SettingIndexController:新增允许访问的 KV 配置分组校验。
在 OddsStreamService、PlayConfigStreamService 与 RiskCapStreamService 中新增广播功能,用于在玩法目录变更时推送更新通知。
新增测试用例,验证风险限额发布的广播行为。
This commit is contained in:
2026-05-27 09:57:39 +08:00
parent 618201f980
commit a9d0f39a9c
13 changed files with 237 additions and 21 deletions

View File

@@ -1,8 +1,10 @@
<?php
use App\Events\BalanceUpdateBroadcast;
use App\Events\PlayCatalogUpdatedBroadcast;
use App\Events\RiskSoldOutBroadcast;
use App\Events\RiskWarningBroadcast;
use App\Services\Config\RiskCapStreamService;
use App\Models\Draw;
use App\Models\Player;
use App\Models\PlayerWallet;
@@ -101,6 +103,31 @@ test('risk pool acquire dispatches warning and sold out broadcasts', function ()
);
});
test('risk cap publish dispatches play catalog updated broadcast', function (): void {
Event::fake([PlayCatalogUpdatedBroadcast::class]);
$admin = \App\Models\AdminUser::query()->create([
'username' => 'risk_cap_admin',
'name' => 'Risk Cap QA',
'email' => null,
'password' => \Illuminate\Support\Facades\Hash::make('secret-strong'),
'status' => 0,
]);
grantSuperAdminRole($admin);
$draft = app(RiskCapStreamService::class)->createDraft($admin, 'test', null);
app(RiskCapStreamService::class)->replaceItems($draft, [
[
'normalized_number' => '1234',
'cap_amount' => 1_000_000,
'cap_type' => 'default',
],
], $admin);
app(RiskCapStreamService::class)->publish($draft, $admin);
Event::assertDispatched(PlayCatalogUpdatedBroadcast::class);
});
test('transfer in dispatches balance update after success', function (): void {
Event::fake([BalanceUpdateBroadcast::class]);

View File

@@ -0,0 +1,37 @@
<?php
use App\Lottery\ErrorCode;
use Database\Seeders\CurrencySeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
beforeEach(function (): void {
$this->seed(CurrencySeeder::class);
});
test('public settings requires allowed group', function (): void {
$this->getJson('/api/v1/settings')
->assertStatus(400)
->assertJsonPath('code', ErrorCode::ClientHttpError->value);
$this->getJson('/api/v1/settings?group=wallet')
->assertStatus(400)
->assertJsonPath('code', ErrorCode::ClientHttpError->value);
});
test('public settings returns frontend group only', function (): void {
\App\Models\LotterySetting::query()->updateOrCreate(
['setting_key' => 'frontend.play_rules_html_zh'],
[
'group_name' => 'frontend',
'value_json' => '<p>rules</p>',
'description_zh' => '规则',
],
);
$this->getJson('/api/v1/settings?group=frontend')
->assertOk()
->assertJsonPath('code', ErrorCode::Success->value)
->assertJsonFragment(['key' => 'frontend.play_rules_html_zh']);
});