feat: 更新玩法配置管理,简化字段并增强功能
- 将玩法相关的显示名称字段统一为 `display_name`,移除多语言字段。 - 在 `PlayTypePatchController` 中新增即时切换玩法开关的功能,并推送大厅更新。 - 优化多个控制器和服务中的权限检查与数据处理逻辑,提升代码可读性与维护性。
This commit is contained in:
103
tests/Feature/AdminDashboardAnalyticsLifetimeTest.php
Normal file
103
tests/Feature/AdminDashboardAnalyticsLifetimeTest.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Draw;
|
||||
use App\Models\Player;
|
||||
use App\Models\AdminUser;
|
||||
use App\Models\TicketOrder;
|
||||
use App\Services\Admin\AdminReportQueryService;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
test('resolve dashboard period lifetime returns associative bounds without error', function (): void {
|
||||
$service = app(AdminReportQueryService::class);
|
||||
|
||||
$empty = $service->resolveDashboardPeriod('lifetime', null, null);
|
||||
expect($empty)->toHaveKeys(['date_from', 'date_to'])
|
||||
->and($empty['date_from'])->toBeString()
|
||||
->and($empty['date_to'])->toBeString();
|
||||
|
||||
$player = Player::query()->create([
|
||||
'site_code' => 'main',
|
||||
'site_player_id' => 'lt-p1',
|
||||
'username' => 'lt_u1',
|
||||
'nickname' => null,
|
||||
'default_currency' => 'NPR',
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
Draw::query()->create([
|
||||
'draw_no' => '20260101-001',
|
||||
'business_date' => '2026-01-01',
|
||||
'sequence_no' => 1,
|
||||
'status' => 'settled',
|
||||
'start_time' => now()->subMonths(2),
|
||||
'close_time' => now()->subMonths(2),
|
||||
'draw_time' => now()->subMonths(2),
|
||||
'cooling_end_time' => null,
|
||||
'result_source' => null,
|
||||
'current_result_version' => 1,
|
||||
'settle_version' => 1,
|
||||
'is_reopened' => false,
|
||||
]);
|
||||
|
||||
$drawLate = Draw::query()->create([
|
||||
'draw_no' => '20260520-001',
|
||||
'business_date' => '2026-05-20',
|
||||
'sequence_no' => 1,
|
||||
'status' => 'settled',
|
||||
'start_time' => now()->subDay(),
|
||||
'close_time' => now()->subDay(),
|
||||
'draw_time' => now()->subDay(),
|
||||
'cooling_end_time' => null,
|
||||
'result_source' => null,
|
||||
'current_result_version' => 1,
|
||||
'settle_version' => 1,
|
||||
'is_reopened' => false,
|
||||
]);
|
||||
|
||||
TicketOrder::query()->create([
|
||||
'order_no' => 'ORD-LT-1',
|
||||
'player_id' => $player->id,
|
||||
'draw_id' => $drawLate->id,
|
||||
'currency_code' => 'NPR',
|
||||
'total_bet_amount' => 1_000,
|
||||
'total_rebate_amount' => 0,
|
||||
'total_actual_deduct' => 1_000,
|
||||
'total_estimated_payout' => 0,
|
||||
'status' => 'settled',
|
||||
'submit_source' => 'h5',
|
||||
'client_trace_id' => null,
|
||||
]);
|
||||
|
||||
$range = $service->resolveDashboardPeriod('lifetime', null, null);
|
||||
expect($range['date_from'])->toBe('2026-05-20')
|
||||
->and($range['date_to'])->toBe('2026-05-20');
|
||||
});
|
||||
|
||||
test('dashboard analytics lifetime period returns ok via http', function (): void {
|
||||
$this->artisan('lottery:admin-auth-sync')->assertExitCode(0);
|
||||
|
||||
$admin = AdminUser::query()->create([
|
||||
'username' => 'lt_dash_admin',
|
||||
'name' => 'LT Dash',
|
||||
'email' => null,
|
||||
'password' => Hash::make('secret-strong'),
|
||||
'status' => 0,
|
||||
]);
|
||||
grantSuperAdminRole($admin);
|
||||
$token = $admin->createToken('test', ['*'], now()->addDay())->plainTextToken;
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer '.$token)
|
||||
->getJson('/api/v1/admin/dashboard/analytics?period=lifetime&metric=overview')
|
||||
->assertOk()
|
||||
->assertJsonStructure([
|
||||
'data' => [
|
||||
'date_from',
|
||||
'date_to',
|
||||
'summary',
|
||||
'daily_series',
|
||||
],
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user