feat: 更新玩法配置管理,简化字段并增强功能
- 将玩法相关的显示名称字段统一为 `display_name`,移除多语言字段。 - 在 `PlayTypePatchController` 中新增即时切换玩法开关的功能,并推送大厅更新。 - 优化多个控制器和服务中的权限检查与数据处理逻辑,提升代码可读性与维护性。
This commit is contained in:
105
tests/Feature/AdminDashboardAnalyticsApiTest.php
Normal file
105
tests/Feature/AdminDashboardAnalyticsApiTest.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Draw;
|
||||
use App\Models\Player;
|
||||
use App\Models\AdminUser;
|
||||
use App\Models\TicketItem;
|
||||
use App\Models\TicketOrder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
test('dashboard analytics returns summary trend and play breakdown for period', function (): void {
|
||||
$this->artisan('lottery:admin-auth-sync')->assertExitCode(0);
|
||||
$player = Player::query()->create([
|
||||
'site_code' => 'main',
|
||||
'site_player_id' => 'da-p1',
|
||||
'username' => 'da_u1',
|
||||
'nickname' => null,
|
||||
'default_currency' => 'NPR',
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
$draw = Draw::query()->create([
|
||||
'draw_no' => '20260510-001',
|
||||
'business_date' => '2026-05-10',
|
||||
'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,
|
||||
]);
|
||||
|
||||
$order = TicketOrder::query()->create([
|
||||
'order_no' => 'ORD-DA-1',
|
||||
'player_id' => $player->id,
|
||||
'draw_id' => $draw->id,
|
||||
'currency_code' => 'NPR',
|
||||
'total_bet_amount' => 8_000,
|
||||
'total_rebate_amount' => 0,
|
||||
'total_actual_deduct' => 8_000,
|
||||
'total_estimated_payout' => 0,
|
||||
'status' => 'settled',
|
||||
'submit_source' => 'h5',
|
||||
'client_trace_id' => null,
|
||||
]);
|
||||
|
||||
TicketItem::query()->create([
|
||||
'ticket_no' => 'TK-DA-1',
|
||||
'order_id' => $order->id,
|
||||
'player_id' => $player->id,
|
||||
'draw_id' => $draw->id,
|
||||
'original_number' => '1234',
|
||||
'normalized_number' => '1234',
|
||||
'play_code' => 'big',
|
||||
'dimension' => 4,
|
||||
'digit_slot' => null,
|
||||
'bet_mode' => null,
|
||||
'unit_bet_amount' => 8_000,
|
||||
'total_bet_amount' => 8_000,
|
||||
'rebate_rate_snapshot' => 0,
|
||||
'commission_rate_snapshot' => 0,
|
||||
'actual_deduct_amount' => 8_000,
|
||||
'odds_snapshot_json' => null,
|
||||
'rule_snapshot_json' => null,
|
||||
'combination_count' => 1,
|
||||
'estimated_max_payout' => 0,
|
||||
'risk_locked_amount' => 0,
|
||||
'status' => 'won',
|
||||
'fail_reason_code' => null,
|
||||
'fail_reason_text' => null,
|
||||
'win_amount' => 2_000,
|
||||
'jackpot_win_amount' => 0,
|
||||
'settled_at' => now(),
|
||||
]);
|
||||
|
||||
$admin = AdminUser::query()->create([
|
||||
'username' => 'dash_analytics_admin',
|
||||
'name' => 'Dash Analytics QA',
|
||||
'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=last_30_days&metric=overview')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.summary.total_bet_minor', 8_000)
|
||||
->assertJsonPath('data.summary.total_payout_minor', 2_000)
|
||||
->assertJsonPath('data.summary.approx_house_gross_minor', 6_000)
|
||||
->assertJsonStructure([
|
||||
'data' => [
|
||||
'daily_series',
|
||||
'play_breakdown',
|
||||
'chart_meta' => ['truncated', 'span_days'],
|
||||
],
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user