feat(agent-profile): 限制代理及玩家返点和分成范围,增强权限校验
- 添加ensureSuperAdmin方法,限制管理员设置操作权限 - 在AdminSettingController接口中新增权限检查,防止非超级管理员操作 - AdminPlayerIndexController新增direct agent筛选支持 - AdminPlayerUpdateController新增对信用玩家默认币别变更的拒绝逻辑 - 新增WalletSettlementBillsController,实现玩家信用盘账期账单摘要接口 - AgentProfileService调整,新增返点限额和分享比例自动下调机制,保持子代理及玩家配置不超父级 - AgentProfileService增加can_grant_extra_rebate权限继承限制,阻止无权限代理开启 - AgentSettlementPeriodCloseService增加玩家账单回水信用释放逻辑,确保信用额度同步 - PlayerCreditService新增释放账单回水对应信用逻辑,维护账期信用一致性 - TicketPlacementService和TicketPreviewService新增信用玩家投注币别匹配校验,防止币别不符 - PlayerLedgerLogsService优化信用额度计算,增加可用额度上下限限制,防止负值和超限 - 调整后台管理导航,仅超管可见设置入口,强化权限隔离 - 路由新增玩家信用账单查询接口 - 补充多项AgentProfile相关单元测试覆盖额度限制、返点继承、返点下调场景及权限限制 - 增加站点管理员登录测试,验证系统设置菜单不可见,提升用户权限体验
This commit is contained in:
@@ -297,6 +297,61 @@ test('child agent profile update rejects credit above parent available', functio
|
||||
->assertJsonPath('code', ErrorCode::ValidationFailed->value);
|
||||
});
|
||||
|
||||
test('agent profile update rejects credit below already allocated amount', function (): void {
|
||||
$siteId = (int) DB::table('admin_sites')->where('is_default', true)->value('id');
|
||||
$rootId = (int) DB::table('agent_nodes')->where('admin_site_id', $siteId)->where('depth', 0)->value('id');
|
||||
$service = app(\App\Services\Agent\AgentNodeService::class);
|
||||
|
||||
\App\Models\AgentProfile::query()->updateOrCreate(
|
||||
['agent_node_id' => $rootId],
|
||||
[
|
||||
'total_share_rate' => 100,
|
||||
'credit_limit' => 10000,
|
||||
'allocated_credit' => 0,
|
||||
'used_credit' => 0,
|
||||
'rebate_limit' => 1,
|
||||
'default_player_rebate' => 0,
|
||||
],
|
||||
);
|
||||
|
||||
$super = AdminUser::query()->create([
|
||||
'username' => 'below_allocated_super',
|
||||
'name' => 'Below Allocated Super',
|
||||
'email' => null,
|
||||
'password' => Hash::make('secret-strong'),
|
||||
'status' => 0,
|
||||
]);
|
||||
grantSuperAdminRole($super);
|
||||
|
||||
$agent = $service->createChild($super, agentChildPayload([
|
||||
'parent_id' => $rootId,
|
||||
'code' => 'below-allocated-agent',
|
||||
'name' => 'Below Allocated Agent',
|
||||
'username' => 'below_allocated_agent',
|
||||
'credit_limit' => 5000,
|
||||
]));
|
||||
$service->createChild($super, agentChildPayload([
|
||||
'parent_id' => $agent->id,
|
||||
'code' => 'below-allocated-child',
|
||||
'name' => 'Below Allocated Child',
|
||||
'username' => 'below_allocated_child',
|
||||
'credit_limit' => 3000,
|
||||
]));
|
||||
|
||||
$token = $super->createToken('test', ['*'], now()->addDay())->plainTextToken;
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer '.$token)
|
||||
->putJson('/api/v1/admin/agent-nodes/'.$agent->id.'/profile', [
|
||||
'credit_limit' => 2000,
|
||||
])
|
||||
->assertStatus(422)
|
||||
->assertJsonPath('code', ErrorCode::ValidationFailed->value);
|
||||
|
||||
$profile = DB::table('agent_profiles')->where('agent_node_id', $agent->id)->first();
|
||||
expect((int) $profile->credit_limit)->toBe(5000)
|
||||
->and((int) $profile->allocated_credit)->toBe(3000);
|
||||
});
|
||||
|
||||
test('child agent profile update rejects rebate above parent', function (): void {
|
||||
$siteId = (int) DB::table('admin_sites')->where('is_default', true)->value('id');
|
||||
$rootId = (int) DB::table('agent_nodes')->where('admin_site_id', $siteId)->where('depth', 0)->value('id');
|
||||
@@ -385,6 +440,266 @@ test('agent profile update rejects default rebate above limit', function (): voi
|
||||
->assertJsonPath('code', ErrorCode::ValidationFailed->value);
|
||||
});
|
||||
|
||||
test('lowering agent rebate limit clamps descendant agent and player rebate profiles', function (): void {
|
||||
$siteId = (int) DB::table('admin_sites')->where('is_default', true)->value('id');
|
||||
$siteCode = (string) DB::table('admin_sites')->where('id', $siteId)->value('code');
|
||||
$rootId = (int) DB::table('agent_nodes')->where('admin_site_id', $siteId)->where('depth', 0)->value('id');
|
||||
$service = app(\App\Services\Agent\AgentNodeService::class);
|
||||
|
||||
\App\Models\AgentProfile::query()->updateOrCreate(
|
||||
['agent_node_id' => $rootId],
|
||||
[
|
||||
'total_share_rate' => 100,
|
||||
'credit_limit' => 10000,
|
||||
'allocated_credit' => 0,
|
||||
'used_credit' => 0,
|
||||
'rebate_limit' => 1,
|
||||
'default_player_rebate' => 0,
|
||||
'can_grant_extra_rebate' => true,
|
||||
],
|
||||
);
|
||||
|
||||
$super = AdminUser::query()->create([
|
||||
'username' => 'clamp_rebate_super',
|
||||
'name' => 'Clamp Rebate Super',
|
||||
'email' => null,
|
||||
'password' => Hash::make('secret-strong'),
|
||||
'status' => 0,
|
||||
]);
|
||||
grantSuperAdminRole($super);
|
||||
|
||||
$agent = $service->createChild($super, agentChildPayload([
|
||||
'parent_id' => $rootId,
|
||||
'code' => 'clamp-rebate-agent',
|
||||
'name' => 'Clamp Rebate Agent',
|
||||
'username' => 'clamp_rebate_agent',
|
||||
'rebate_limit' => 10,
|
||||
'default_player_rebate' => 6,
|
||||
'can_grant_extra_rebate' => true,
|
||||
]));
|
||||
$childAgent = $service->createChild($super, agentChildPayload([
|
||||
'parent_id' => $agent->id,
|
||||
'code' => 'clamp-rebate-child',
|
||||
'name' => 'Clamp Rebate Child',
|
||||
'username' => 'clamp_rebate_child',
|
||||
'rebate_limit' => 8,
|
||||
'default_player_rebate' => 6,
|
||||
'can_grant_extra_rebate' => true,
|
||||
]));
|
||||
$grandchildAgent = $service->createChild($super, agentChildPayload([
|
||||
'parent_id' => $childAgent->id,
|
||||
'code' => 'clamp-rebate-grandchild',
|
||||
'name' => 'Clamp Rebate Grandchild',
|
||||
'username' => 'clamp_rebate_grandchild',
|
||||
'rebate_limit' => 7,
|
||||
'default_player_rebate' => 5,
|
||||
'can_grant_extra_rebate' => true,
|
||||
]));
|
||||
|
||||
$directPlayer = \App\Models\Player::query()->create([
|
||||
'site_code' => $siteCode,
|
||||
'agent_node_id' => $agent->id,
|
||||
'site_player_id' => 'clamp-direct-player',
|
||||
'username' => 'clamp_direct_player',
|
||||
'default_currency' => 'NPR',
|
||||
'status' => 0,
|
||||
]);
|
||||
$downlinePlayer = \App\Models\Player::query()->create([
|
||||
'site_code' => $siteCode,
|
||||
'agent_node_id' => $childAgent->id,
|
||||
'site_player_id' => 'clamp-downline-player',
|
||||
'username' => 'clamp_downline_player',
|
||||
'default_currency' => 'NPR',
|
||||
'status' => 0,
|
||||
]);
|
||||
$grandchildPlayer = \App\Models\Player::query()->create([
|
||||
'site_code' => $siteCode,
|
||||
'agent_node_id' => $grandchildAgent->id,
|
||||
'site_player_id' => 'clamp-grandchild-player',
|
||||
'username' => 'clamp_grandchild_player',
|
||||
'default_currency' => 'NPR',
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
DB::table('player_rebate_profiles')->insert([
|
||||
[
|
||||
'player_id' => $directPlayer->id,
|
||||
'game_type' => '*',
|
||||
'inherit_from_agent' => false,
|
||||
'rebate_rate' => 0.10,
|
||||
'extra_rebate_rate' => 0.03,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
[
|
||||
'player_id' => $downlinePlayer->id,
|
||||
'game_type' => '*',
|
||||
'inherit_from_agent' => false,
|
||||
'rebate_rate' => 0.10,
|
||||
'extra_rebate_rate' => 0.03,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
[
|
||||
'player_id' => $grandchildPlayer->id,
|
||||
'game_type' => '*',
|
||||
'inherit_from_agent' => false,
|
||||
'rebate_rate' => 0.07,
|
||||
'extra_rebate_rate' => 0.01,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
]);
|
||||
|
||||
$token = $super->createToken('test', ['*'], now()->addDay())->plainTextToken;
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer '.$token)
|
||||
->putJson('/api/v1/admin/agent-nodes/'.$agent->id.'/profile', [
|
||||
'rebate_limit' => 2,
|
||||
'default_player_rebate' => 0,
|
||||
'can_grant_extra_rebate' => false,
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('data.rebate_limit', 2);
|
||||
|
||||
$directProfile = DB::table('player_rebate_profiles')->where('player_id', $directPlayer->id)->first();
|
||||
expect(round((float) $directProfile->rebate_rate, 4))->toBe(0.02)
|
||||
->and(round((float) $directProfile->extra_rebate_rate, 4))->toBe(0.0);
|
||||
|
||||
$childProfile = DB::table('agent_profiles')->where('agent_node_id', $childAgent->id)->first();
|
||||
expect(round((float) $childProfile->rebate_limit, 4))->toBe(0.02)
|
||||
->and(round((float) $childProfile->default_player_rebate, 4))->toBe(0.02)
|
||||
->and((bool) $childProfile->can_grant_extra_rebate)->toBeFalse();
|
||||
|
||||
$downlineProfile = DB::table('player_rebate_profiles')->where('player_id', $downlinePlayer->id)->first();
|
||||
expect(round((float) $downlineProfile->rebate_rate, 4))->toBe(0.02)
|
||||
->and(round((float) $downlineProfile->extra_rebate_rate, 4))->toBe(0.0);
|
||||
|
||||
$grandchildProfile = DB::table('agent_profiles')->where('agent_node_id', $grandchildAgent->id)->first();
|
||||
expect(round((float) $grandchildProfile->rebate_limit, 4))->toBe(0.02)
|
||||
->and(round((float) $grandchildProfile->default_player_rebate, 4))->toBe(0.02)
|
||||
->and((bool) $grandchildProfile->can_grant_extra_rebate)->toBeFalse();
|
||||
|
||||
$grandchildPlayerProfile = DB::table('player_rebate_profiles')->where('player_id', $grandchildPlayer->id)->first();
|
||||
expect(round((float) $grandchildPlayerProfile->rebate_rate, 4))->toBe(0.02)
|
||||
->and(round((float) $grandchildPlayerProfile->extra_rebate_rate, 4))->toBe(0.0);
|
||||
});
|
||||
|
||||
test('agent profile update rejects enabling extra rebate when parent disallows it', function (): void {
|
||||
$siteId = (int) DB::table('admin_sites')->where('is_default', true)->value('id');
|
||||
$rootId = (int) DB::table('agent_nodes')->where('admin_site_id', $siteId)->where('depth', 0)->value('id');
|
||||
$service = app(\App\Services\Agent\AgentNodeService::class);
|
||||
|
||||
\App\Models\AgentProfile::query()->updateOrCreate(
|
||||
['agent_node_id' => $rootId],
|
||||
[
|
||||
'total_share_rate' => 100,
|
||||
'credit_limit' => 10000,
|
||||
'allocated_credit' => 0,
|
||||
'used_credit' => 0,
|
||||
'rebate_limit' => 1,
|
||||
'default_player_rebate' => 0,
|
||||
'can_grant_extra_rebate' => true,
|
||||
],
|
||||
);
|
||||
|
||||
$super = AdminUser::query()->create([
|
||||
'username' => 'extra_rebate_super',
|
||||
'name' => 'Extra Rebate Super',
|
||||
'email' => null,
|
||||
'password' => Hash::make('secret-strong'),
|
||||
'status' => 0,
|
||||
]);
|
||||
grantSuperAdminRole($super);
|
||||
|
||||
$parent = $service->createChild($super, agentChildPayload([
|
||||
'parent_id' => $rootId,
|
||||
'code' => 'extra-rebate-parent',
|
||||
'name' => 'Extra Rebate Parent',
|
||||
'username' => 'extra_rebate_parent',
|
||||
'rebate_limit' => 10,
|
||||
'can_grant_extra_rebate' => false,
|
||||
]));
|
||||
$child = $service->createChild($super, agentChildPayload([
|
||||
'parent_id' => $parent->id,
|
||||
'code' => 'extra-rebate-child',
|
||||
'name' => 'Extra Rebate Child',
|
||||
'username' => 'extra_rebate_child',
|
||||
'rebate_limit' => 2,
|
||||
]));
|
||||
|
||||
$token = $super->createToken('test', ['*'], now()->addDay())->plainTextToken;
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer '.$token)
|
||||
->putJson('/api/v1/admin/agent-nodes/'.$child->id.'/profile', [
|
||||
'can_grant_extra_rebate' => true,
|
||||
])
|
||||
->assertStatus(422)
|
||||
->assertJsonPath('code', ErrorCode::ValidationFailed->value);
|
||||
});
|
||||
|
||||
test('lowering agent share rate clamps descendant agent share rates', function (): void {
|
||||
$siteId = (int) DB::table('admin_sites')->where('is_default', true)->value('id');
|
||||
$rootId = (int) DB::table('agent_nodes')->where('admin_site_id', $siteId)->where('depth', 0)->value('id');
|
||||
$service = app(\App\Services\Agent\AgentNodeService::class);
|
||||
|
||||
$super = AdminUser::query()->create([
|
||||
'username' => 'clamp_share_super',
|
||||
'name' => 'Clamp Share Super',
|
||||
'email' => null,
|
||||
'password' => Hash::make('secret-strong'),
|
||||
'status' => 0,
|
||||
]);
|
||||
grantSuperAdminRole($super);
|
||||
|
||||
$agent = $service->createChild($super, agentChildPayload([
|
||||
'parent_id' => $rootId,
|
||||
'code' => 'clamp-share-agent',
|
||||
'name' => 'Clamp Share Agent',
|
||||
'username' => 'clamp_share_agent',
|
||||
'total_share_rate' => 60,
|
||||
]));
|
||||
$childAgent = $service->createChild($super, agentChildPayload([
|
||||
'parent_id' => $agent->id,
|
||||
'code' => 'clamp-share-child',
|
||||
'name' => 'Clamp Share Child',
|
||||
'username' => 'clamp_share_child',
|
||||
'total_share_rate' => 40,
|
||||
]));
|
||||
$grandchildAgent = $service->createChild($super, agentChildPayload([
|
||||
'parent_id' => $childAgent->id,
|
||||
'code' => 'clamp-share-grandchild',
|
||||
'name' => 'Clamp Share Grandchild',
|
||||
'username' => 'clamp_share_grandchild',
|
||||
'total_share_rate' => 25,
|
||||
]));
|
||||
$lowShareGrandchild = $service->createChild($super, agentChildPayload([
|
||||
'parent_id' => $childAgent->id,
|
||||
'code' => 'clamp-share-low',
|
||||
'name' => 'Clamp Share Low',
|
||||
'username' => 'clamp_share_low',
|
||||
'total_share_rate' => 15,
|
||||
]));
|
||||
|
||||
$token = $super->createToken('test', ['*'], now()->addDay())->plainTextToken;
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer '.$token)
|
||||
->putJson('/api/v1/admin/agent-nodes/'.$agent->id.'/profile', [
|
||||
'total_share_rate' => 20,
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('data.total_share_rate', 20);
|
||||
|
||||
$childProfile = DB::table('agent_profiles')->where('agent_node_id', $childAgent->id)->first();
|
||||
expect(round((float) $childProfile->total_share_rate, 4))->toBe(20.0);
|
||||
|
||||
$grandchildProfile = DB::table('agent_profiles')->where('agent_node_id', $grandchildAgent->id)->first();
|
||||
expect(round((float) $grandchildProfile->total_share_rate, 4))->toBe(20.0);
|
||||
|
||||
$lowShareGrandchildProfile = DB::table('agent_profiles')->where('agent_node_id', $lowShareGrandchild->id)->first();
|
||||
expect(round((float) $lowShareGrandchildProfile->total_share_rate, 4))->toBe(15.0);
|
||||
});
|
||||
|
||||
test('partial agent profile update preserves unchanged share rate', function (): void {
|
||||
$siteId = (int) DB::table('admin_sites')->where('is_default', true)->value('id');
|
||||
$rootId = (int) DB::table('agent_nodes')->where('admin_site_id', $siteId)->where('depth', 0)->value('id');
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use App\Models\AdminUser;
|
||||
use App\Lottery\ErrorCode;
|
||||
use App\Support\SitePlatformRole;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
@@ -152,6 +153,36 @@ test('agent operator auth me omits platform-only navigation', function (): void
|
||||
->and($keys)->not->toContain('admin_users', 'admin_roles', 'settings', 'integration', 'rules_plays');
|
||||
});
|
||||
|
||||
test('site admin auth me omits system settings navigation', function (): void {
|
||||
$this->artisan('lottery:admin-auth-sync')->assertExitCode(0);
|
||||
|
||||
$admin = AdminUser::query()->create([
|
||||
'username' => 'site_admin_nav',
|
||||
'name' => 'Site Admin Nav',
|
||||
'email' => null,
|
||||
'password' => 'secret-strong',
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
$admin->roles()->sync([
|
||||
SitePlatformRole::id() => [
|
||||
'site_id' => AdminUser::defaultAdminSiteId(),
|
||||
'granted_at' => now(),
|
||||
],
|
||||
]);
|
||||
|
||||
$token = $admin->createToken('test', ['*'], now()->addDay())->plainTextToken;
|
||||
|
||||
$segments = $this->withHeader('Authorization', 'Bearer '.$token)
|
||||
->getJson('/api/v1/admin/auth/me')
|
||||
->assertOk()
|
||||
->json('data.admin.navigation');
|
||||
|
||||
$keys = array_column($segments, 'segment');
|
||||
expect($keys)->toContain('dashboard', 'agents', 'players', 'wallet')
|
||||
->and($keys)->not->toContain('settings', 'admin_users', 'admin_roles', 'integration', 'rules_plays');
|
||||
});
|
||||
|
||||
test('admin captcha exposes key and image base64', function () {
|
||||
$resp = $this->getJson('/api/v1/admin/auth/captcha');
|
||||
|
||||
|
||||
@@ -237,6 +237,60 @@ test('player manage permission gates write and freeze APIs separately from view
|
||||
->assertOk();
|
||||
});
|
||||
|
||||
test('agent players list can filter direct players without including downline players', function (): void {
|
||||
$siteId = (int) DB::table('admin_sites')->where('is_default', true)->value('id');
|
||||
$siteCode = (string) DB::table('admin_sites')->where('id', $siteId)->value('code');
|
||||
$rootId = (int) DB::table('agent_nodes')->where('admin_site_id', $siteId)->where('depth', 0)->value('id');
|
||||
|
||||
$super = AdminUser::query()->create([
|
||||
'username' => 'direct_player_super',
|
||||
'name' => 'Direct Player Super',
|
||||
'email' => null,
|
||||
'password' => Hash::make('secret-strong'),
|
||||
'status' => 0,
|
||||
]);
|
||||
grantSuperAdminRole($super);
|
||||
|
||||
$child = app(\App\Services\Agent\AgentNodeService::class)->createChild($super, [
|
||||
'parent_id' => $rootId,
|
||||
'code' => 'direct-child',
|
||||
'name' => 'Direct Child',
|
||||
]);
|
||||
|
||||
$rootPlayer = Player::query()->create([
|
||||
'site_code' => $siteCode,
|
||||
'agent_node_id' => $rootId,
|
||||
'site_player_id' => 'direct-root-player',
|
||||
'username' => 'direct_root_player',
|
||||
'default_currency' => 'NPR',
|
||||
'status' => 0,
|
||||
]);
|
||||
$childPlayer = Player::query()->create([
|
||||
'site_code' => $siteCode,
|
||||
'agent_node_id' => $child->id,
|
||||
'site_player_id' => 'direct-child-player',
|
||||
'username' => 'direct_child_player',
|
||||
'default_currency' => 'NPR',
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
$token = playerManageAdminToken();
|
||||
|
||||
$rootResponse = $this->withHeader('Authorization', 'Bearer '.$token)
|
||||
->getJson('/api/v1/admin/players?site_code='.$siteCode.'&agent_node_id='.$rootId.'&agent_scope=direct');
|
||||
|
||||
$rootResponse->assertOk()->assertJsonPath('data.meta.total', 1);
|
||||
$rootIds = collect($rootResponse->json('data.items'))->pluck('id')->map(static fn ($id): int => (int) $id);
|
||||
expect($rootIds)->toContain($rootPlayer->id)->not->toContain($childPlayer->id);
|
||||
|
||||
$childResponse = $this->withHeader('Authorization', 'Bearer '.$token)
|
||||
->getJson('/api/v1/admin/players?site_code='.$siteCode.'&agent_node_id='.$child->id.'&agent_scope=direct');
|
||||
|
||||
$childResponse->assertOk()->assertJsonPath('data.meta.total', 1);
|
||||
$childIds = collect($childResponse->json('data.items'))->pluck('id')->map(static fn ($id): int => (int) $id);
|
||||
expect($childIds)->toContain($childPlayer->id)->not->toContain($rootPlayer->id);
|
||||
});
|
||||
|
||||
test('admin can update player default currency and validation rejects unknown code', function (): void {
|
||||
$player = Player::query()->create([
|
||||
'site_code' => 'main',
|
||||
@@ -244,6 +298,7 @@ test('admin can update player default currency and validation rejects unknown co
|
||||
'username' => 'currency_user',
|
||||
'nickname' => 'Currency',
|
||||
'default_currency' => 'NPR',
|
||||
'funding_mode' => PlayerFundingMode::WALLET,
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
@@ -268,6 +323,46 @@ test('admin can update player default currency and validation rejects unknown co
|
||||
->assertStatus(422);
|
||||
});
|
||||
|
||||
test('admin cannot change credit player default currency', function (): void {
|
||||
$siteCode = DB::table('admin_sites')->where('is_default', true)->value('code');
|
||||
$siteCode = is_string($siteCode) && $siteCode !== '' ? $siteCode : 'default_site';
|
||||
$rootId = (int) DB::table('agent_nodes')->where('depth', 0)->value('id');
|
||||
|
||||
$player = Player::query()->create([
|
||||
'site_code' => $siteCode,
|
||||
'agent_node_id' => $rootId,
|
||||
'site_player_id' => 'credit-currency-locked-1',
|
||||
'auth_source' => PlayerAuthSource::LOTTERY_NATIVE,
|
||||
'funding_mode' => PlayerFundingMode::CREDIT,
|
||||
'username' => 'credit_currency_locked',
|
||||
'default_currency' => 'NPR',
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
DB::table('player_credit_accounts')->insert([
|
||||
'player_id' => $player->id,
|
||||
'credit_limit' => 500,
|
||||
'used_credit' => 120,
|
||||
'frozen_credit' => 0,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$token = playerManageAdminToken();
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer '.$token)
|
||||
->putJson('/api/v1/admin/players/'.$player->id, [
|
||||
'default_currency' => 'USD',
|
||||
])
|
||||
->assertStatus(422)
|
||||
->assertJsonPath('code', \App\Lottery\ErrorCode::ValidationFailed->value);
|
||||
|
||||
$this->assertDatabaseHas('players', [
|
||||
'id' => $player->id,
|
||||
'default_currency' => 'NPR',
|
||||
]);
|
||||
});
|
||||
|
||||
test('admin can set player credit limit without clobbering used credit', function (): void {
|
||||
$siteCode = DB::table('admin_sites')->where('is_default', true)->value('code');
|
||||
$siteCode = is_string($siteCode) && $siteCode !== '' ? $siteCode : 'default_site';
|
||||
|
||||
@@ -4,6 +4,7 @@ use App\Models\AdminRole;
|
||||
use App\Models\AdminUser;
|
||||
use App\Models\LotterySetting;
|
||||
use App\Services\LotterySettings;
|
||||
use App\Support\SitePlatformRole;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
@@ -22,24 +23,7 @@ function settingsAdminToken(): string
|
||||
'password' => Hash::make('secret-strong'),
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
$role = AdminRole::query()->create([
|
||||
'slug' => 'settings_role',
|
||||
'name' => 'Settings Role',
|
||||
]);
|
||||
$role->syncLegacyPermissionSlugs([
|
||||
'prd.payout.manage',
|
||||
'prd.draw_result.manage',
|
||||
'prd.wallet_reconcile.manage',
|
||||
'prd.rebate.manage',
|
||||
]);
|
||||
|
||||
$admin->roles()->sync([
|
||||
(int) $role->id => [
|
||||
'site_id' => AdminUser::defaultAdminSiteId(),
|
||||
'granted_at' => now(),
|
||||
],
|
||||
]);
|
||||
grantSuperAdminRole($admin);
|
||||
|
||||
return $admin->createToken('test', ['*'], now()->addDay())->plainTextToken;
|
||||
}
|
||||
@@ -70,6 +54,26 @@ function settingsReadOnlyToken(): string
|
||||
return $admin->createToken('test', ['*'], now()->addDay())->plainTextToken;
|
||||
}
|
||||
|
||||
function settingsSiteAdminToken(): string
|
||||
{
|
||||
$admin = AdminUser::query()->create([
|
||||
'username' => 'settings_site_admin',
|
||||
'name' => 'Settings Site Admin',
|
||||
'email' => null,
|
||||
'password' => Hash::make('secret-strong'),
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
$admin->roles()->sync([
|
||||
SitePlatformRole::id() => [
|
||||
'site_id' => AdminUser::defaultAdminSiteId(),
|
||||
'granted_at' => now(),
|
||||
],
|
||||
]);
|
||||
|
||||
return $admin->createToken('test', ['*'], now()->addDay())->plainTextToken;
|
||||
}
|
||||
|
||||
test('admin can batch update settings in one request', function (): void {
|
||||
LotterySettings::put('draw.cooldown_minutes', 15, 'draw');
|
||||
LotterySettings::put('draw.require_manual_review', true, 'draw');
|
||||
@@ -124,6 +128,35 @@ test('admin settings deployment returns read only snapshot', function (): void {
|
||||
->assertJsonFragment(['key' => 'draw.interval_minutes', 'value' => 7]);
|
||||
});
|
||||
|
||||
test('site admin cannot access system settings endpoints', function (): void {
|
||||
LotterySettings::put('frontend.play_rules_html_zh', '<div>old</div>', 'frontend');
|
||||
$token = settingsSiteAdminToken();
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer '.$token)
|
||||
->getJson('/api/v1/admin/settings')
|
||||
->assertForbidden();
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer '.$token)
|
||||
->getJson('/api/v1/admin/settings/deployment')
|
||||
->assertForbidden();
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer '.$token)
|
||||
->putJson('/api/v1/admin/settings/frontend.play_rules_html_zh', [
|
||||
'value' => '<div>new</div>',
|
||||
])
|
||||
->assertForbidden();
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer '.$token)
|
||||
->putJson('/api/v1/admin/settings/batch', [
|
||||
'items' => [
|
||||
['key' => 'frontend.play_rules_html_zh', 'value' => '<div>new</div>'],
|
||||
],
|
||||
])
|
||||
->assertForbidden();
|
||||
|
||||
expect(LotterySetting::query()->where('setting_key', 'frontend.play_rules_html_zh')->value('value_json'))->toBe('<div>old</div>');
|
||||
});
|
||||
|
||||
test('admin settings batch update rejects empty items', function (): void {
|
||||
$token = settingsAdminToken();
|
||||
|
||||
@@ -232,7 +265,7 @@ test('wallet max limit cannot be less than current min limit', function (): void
|
||||
expect(LotterySetting::query()->where('setting_key', 'wallet.transfer_in_max_minor')->value('value_json'))->toBe(10_000);
|
||||
});
|
||||
|
||||
test('settings updates require permission for their setting group', function (): void {
|
||||
test('non super admin cannot update settings even with setting related permissions', function (): void {
|
||||
LotterySettings::put('draw.cooldown_minutes', 15, 'draw');
|
||||
LotterySettings::put('frontend.play_rules_html_zh', '<div>old</div>', 'frontend');
|
||||
|
||||
@@ -248,8 +281,8 @@ test('settings updates require permission for their setting group', function ():
|
||||
->putJson('/api/v1/admin/settings/frontend.play_rules_html_zh', [
|
||||
'value' => '<div>new</div>',
|
||||
])
|
||||
->assertOk();
|
||||
->assertForbidden();
|
||||
|
||||
expect(LotterySetting::query()->where('setting_key', 'draw.cooldown_minutes')->value('value_json'))->toBe(15)
|
||||
->and(LotterySetting::query()->where('setting_key', 'frontend.play_rules_html_zh')->value('value_json'))->toBe('<div>new</div>');
|
||||
->and(LotterySetting::query()->where('setting_key', 'frontend.play_rules_html_zh')->value('value_json'))->toBe('<div>old</div>');
|
||||
});
|
||||
|
||||
@@ -138,6 +138,9 @@ test('period close aggregates share ledger written by game settlement recorder',
|
||||
expect($recorder->shouldRecord($item))->toBeTrue();
|
||||
|
||||
$recorder->recordForTicketItem($item, 0, 'settled_lose');
|
||||
DB::table('player_credit_accounts')
|
||||
->where('player_id', $player->id)
|
||||
->update(['used_credit' => \App\Support\CreditAmountScale::minorToMajor($betMinor, 'NPR')]);
|
||||
|
||||
$item->refresh();
|
||||
expect($item->agent_settled_at)->not->toBeNull()
|
||||
@@ -168,9 +171,26 @@ test('period close aggregates share ledger written by game settlement recorder',
|
||||
->where('owner_id', $player->id)
|
||||
->first();
|
||||
|
||||
$usedAfterClose = (int) DB::table('player_credit_accounts')
|
||||
->where('player_id', $player->id)
|
||||
->value('used_credit');
|
||||
$rebateCreditLedger = DB::table('credit_ledger')
|
||||
->where('owner_type', 'player')
|
||||
->where('owner_id', $player->id)
|
||||
->where('reason', 'rebate_in_bill')
|
||||
->where('ref_type', 'settlement_bill')
|
||||
->where('ref_id', $playerBill->id ?? 0)
|
||||
->first();
|
||||
|
||||
expect($playerBill)->not->toBeNull()
|
||||
->and((int) $playerBill->gross_win_loss)->toBe($betMinor)
|
||||
->and((int) $playerBill->rebate_amount)->toBeGreaterThan(0);
|
||||
->and((int) $playerBill->rebate_amount)->toBeGreaterThan(0)
|
||||
->and($rebateCreditLedger)->not->toBeNull()
|
||||
->and((int) $rebateCreditLedger->amount)->toBe((int) $playerBill->rebate_amount)
|
||||
->and($usedAfterClose)->toBe(
|
||||
\App\Support\CreditAmountScale::minorToMajor($betMinor, 'NPR')
|
||||
- \App\Support\CreditAmountScale::minorToMajor((int) $playerBill->rebate_amount, 'NPR'),
|
||||
);
|
||||
});
|
||||
|
||||
test('credit settlement records base rebate plus add-on rebate and keeps extra rebate separate', function (): void {
|
||||
|
||||
@@ -141,6 +141,72 @@ test('credit player wallet logs distinguish win credit from bill settlement', fu
|
||||
->assertJsonPath('data.items.0.type', 'game_settlement');
|
||||
});
|
||||
|
||||
test('credit wallet logs cap available credit after win above credit limit', function (): void {
|
||||
$player = Player::query()->create([
|
||||
'site_code' => 'default_site',
|
||||
'site_player_id' => 'native:logs-win-cap',
|
||||
'auth_source' => PlayerAuthSource::LOTTERY_NATIVE,
|
||||
'funding_mode' => PlayerFundingMode::CREDIT,
|
||||
'username' => 'credit_logs_win_cap',
|
||||
'default_currency' => 'NPR',
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
DB::table('player_credit_accounts')->insert([
|
||||
'player_id' => $player->id,
|
||||
'credit_limit' => 200,
|
||||
'used_credit' => 0,
|
||||
'frozen_credit' => 0,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
DB::table('credit_ledger')->insert([
|
||||
[
|
||||
'owner_type' => 'player',
|
||||
'owner_id' => $player->id,
|
||||
'amount' => -5000,
|
||||
'reason' => 'bet_hold',
|
||||
'ref_type' => 'bet',
|
||||
'ref_id' => 1,
|
||||
'created_at' => now()->subMinutes(2),
|
||||
'updated_at' => now()->subMinutes(2),
|
||||
],
|
||||
[
|
||||
'owner_type' => 'player',
|
||||
'owner_id' => $player->id,
|
||||
'amount' => 5000,
|
||||
'reason' => 'bet_hold_release',
|
||||
'ref_type' => 'ticket_item',
|
||||
'ref_id' => 1,
|
||||
'created_at' => now()->subMinute(),
|
||||
'updated_at' => now()->subMinute(),
|
||||
],
|
||||
[
|
||||
'owner_type' => 'player',
|
||||
'owner_id' => $player->id,
|
||||
'amount' => 50000,
|
||||
'reason' => 'game_settlement_win',
|
||||
'ref_type' => 'ticket_item',
|
||||
'ref_id' => 1,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
]);
|
||||
|
||||
$data = $this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
||||
->getJson('/api/v1/wallet/logs?page=1&size=10')
|
||||
->assertOk()
|
||||
->json('data');
|
||||
|
||||
expect($data['items'][0]['biz_type'])->toBe('game_settlement_win')
|
||||
->and($data['items'][0]['balance_after'])->toBe(20000)
|
||||
->and($data['items'][1]['biz_type'])->toBe('bet_hold_release')
|
||||
->and($data['items'][1]['balance_after'])->toBe(0)
|
||||
->and($data['items'][2]['biz_type'])->toBe('bet_hold')
|
||||
->and($data['items'][2]['balance_after'])->toBe(0);
|
||||
});
|
||||
|
||||
test('credit player wallet logs include period rebate records without affecting available credit', function (): void {
|
||||
$player = Player::query()->create([
|
||||
'site_code' => 'default_site',
|
||||
@@ -276,6 +342,6 @@ test('credit wallet logs page 2 balance_after continues from page 1 baseline', f
|
||||
$page1LastBalanceAfter = $page1['items'][9]['balance_after'];
|
||||
$page2FirstBalanceAfter = $page2['items'][0]['balance_after'];
|
||||
|
||||
// Page 2 must continue the running balance from page 1, not restart at current available.
|
||||
expect($page2FirstBalanceAfter)->toBe($page1LastBalanceAfter + 1000);
|
||||
// Page 2 must continue the running balance from page 1, capped by credit limit.
|
||||
expect($page2FirstBalanceAfter)->toBe(min($page1LastBalanceAfter + 1000, 50000));
|
||||
});
|
||||
|
||||
@@ -124,6 +124,26 @@ test('partial payments accumulate settlement_confirm ledger and release used cre
|
||||
expect((string) DB::table('settlement_bills')->where('id', $billId)->value('status'))->toBe('settled');
|
||||
});
|
||||
|
||||
test('rebate in player bill plus net payment releases full loss credit', function (): void {
|
||||
$fixture = partialPaymentCreditFixture(900, 10);
|
||||
$player = $fixture['player'];
|
||||
$billId = $fixture['billId'];
|
||||
$adminId = (int) $fixture['admin']->id;
|
||||
|
||||
app(\App\Services\Player\PlayerCreditService::class)->releaseRebateInBill($player, 100, $billId);
|
||||
|
||||
expect((int) DB::table('player_credit_accounts')->where('player_id', $player->id)->value('used_credit'))
|
||||
->toBe(9);
|
||||
|
||||
app(SettlementPaymentService::class)->recordPayment($billId, 900, $adminId);
|
||||
|
||||
expect((int) DB::table('player_credit_accounts')->where('player_id', $player->id)->value('used_credit'))
|
||||
->toBe(0);
|
||||
expect(settlementBillLedgerRows($player, $billId, 'rebate_in_bill'))->toHaveCount(1)
|
||||
->and((int) settlementBillLedgerRows($player, $billId, 'rebate_in_bill')[0]->amount)->toBe(100)
|
||||
->and((int) settlementBillLedgerRows($player, $billId, 'settlement_confirm')[0]->amount)->toBe(900);
|
||||
});
|
||||
|
||||
test('partial payments accumulate settlement_payout ledger for player win bill', function (): void {
|
||||
$fixture = partialPaymentCreditFixture(-800);
|
||||
$player = $fixture['player'];
|
||||
|
||||
@@ -1033,6 +1033,61 @@ test('credit player ticket preview shows period rebate estimate without instant
|
||||
->assertJsonPath('data.lines.0.actual_deduct_amount', 10_000);
|
||||
});
|
||||
|
||||
test('credit player preview and place reject non default currency', function (): void {
|
||||
$site = DB::table('admin_sites')->where('is_default', true)->first();
|
||||
$rootId = (int) DB::table('agent_nodes')->where('depth', 0)->value('id');
|
||||
|
||||
$player = Player::query()->create([
|
||||
'site_code' => (string) $site->code,
|
||||
'agent_node_id' => $rootId,
|
||||
'site_player_id' => 'native:credit-currency-mismatch',
|
||||
'auth_source' => 'lottery_native',
|
||||
'funding_mode' => 'credit',
|
||||
'username' => 'credit_currency_user',
|
||||
'password_hash' => bcrypt('secret-pass'),
|
||||
'nickname' => null,
|
||||
'default_currency' => 'NPR',
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
DB::table('player_credit_accounts')->insert([
|
||||
'player_id' => $player->id,
|
||||
'credit_limit' => 500_000,
|
||||
'used_credit' => 0,
|
||||
'frozen_credit' => 0,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
ticketOpenDraw('20260511-credit-currency');
|
||||
|
||||
$payload = [
|
||||
'draw_id' => '20260511-credit-currency',
|
||||
'currency_code' => 'USD',
|
||||
'client_trace_id' => 'trace-credit-currency-mismatch',
|
||||
'lines' => [
|
||||
['number' => '12', 'play_code' => 'pos_2a', 'amount' => 10_000],
|
||||
],
|
||||
];
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
||||
->postJson('/api/v1/ticket/preview', $payload)
|
||||
->assertStatus(400)
|
||||
->assertJsonPath('code', ErrorCode::ConfigCurrencyInvalid->value)
|
||||
->assertJsonPath('data.currency_code', 'USD')
|
||||
->assertJsonPath('data.expected_currency', 'NPR');
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
||||
->postJson('/api/v1/ticket/place', $payload)
|
||||
->assertStatus(400)
|
||||
->assertJsonPath('code', ErrorCode::ConfigCurrencyInvalid->value)
|
||||
->assertJsonPath('data.currency_code', 'USD')
|
||||
->assertJsonPath('data.expected_currency', 'NPR');
|
||||
|
||||
expect(TicketOrder::query()->where('player_id', $player->id)->exists())->toBeFalse()
|
||||
->and(DB::table('credit_ledger')->where('owner_id', $player->id)->exists())->toBeFalse();
|
||||
});
|
||||
|
||||
test('ticket pending confirmation reconcile releases risk when wallet deduction is missing', function (): void {
|
||||
$draw = ticketOpenDraw();
|
||||
$player = ticketPlayerWithWallet();
|
||||
|
||||
160
tests/Feature/WalletSettlementBillsTest.php
Normal file
160
tests/Feature/WalletSettlementBillsTest.php
Normal file
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Player;
|
||||
use App\Support\PlayerAuthSource;
|
||||
use App\Support\PlayerFundingMode;
|
||||
use Database\Seeders\CurrencySeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
beforeEach(function (): void {
|
||||
$this->seed(CurrencySeeder::class);
|
||||
});
|
||||
|
||||
test('credit player can view own pending settlement bills summary', function (): void {
|
||||
$siteId = (int) DB::table('admin_sites')->where('is_default', true)->value('id');
|
||||
$player = Player::query()->create([
|
||||
'site_code' => 'default_site',
|
||||
'site_player_id' => 'native:settlement-bills',
|
||||
'auth_source' => PlayerAuthSource::LOTTERY_NATIVE,
|
||||
'funding_mode' => PlayerFundingMode::CREDIT,
|
||||
'username' => 'settlement_bills_player',
|
||||
'default_currency' => 'NPR',
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
$periodId = (int) DB::table('settlement_periods')->insertGetId([
|
||||
'admin_site_id' => $siteId,
|
||||
'period_start' => now()->subWeek(),
|
||||
'period_end' => now(),
|
||||
'status' => 'closed',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
DB::table('settlement_bills')->insert([
|
||||
[
|
||||
'settlement_period_id' => $periodId,
|
||||
'bill_type' => 'player',
|
||||
'owner_type' => 'player',
|
||||
'owner_id' => $player->id,
|
||||
'counterparty_type' => 'agent',
|
||||
'counterparty_id' => 1,
|
||||
'gross_win_loss' => -50000,
|
||||
'rebate_amount' => 0,
|
||||
'adjustment_amount' => 0,
|
||||
'net_amount' => -50000,
|
||||
'paid_amount' => 10000,
|
||||
'unpaid_amount' => 40000,
|
||||
'status' => 'partial_paid',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
[
|
||||
'settlement_period_id' => $periodId,
|
||||
'bill_type' => 'player',
|
||||
'owner_type' => 'player',
|
||||
'owner_id' => $player->id,
|
||||
'counterparty_type' => 'agent',
|
||||
'counterparty_id' => 1,
|
||||
'gross_win_loss' => 12000,
|
||||
'rebate_amount' => 0,
|
||||
'adjustment_amount' => 0,
|
||||
'net_amount' => 12000,
|
||||
'paid_amount' => 0,
|
||||
'unpaid_amount' => 12000,
|
||||
'status' => 'confirmed',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
]);
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
||||
->getJson('/api/v1/wallet/settlement-bills')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.summary.pending_receivable', 40000)
|
||||
->assertJsonPath('data.summary.pending_payable', 12000)
|
||||
->assertJsonPath('data.summary.net_pending', 28000)
|
||||
->assertJsonPath('data.summary.pending_count', 2)
|
||||
->assertJsonPath('data.items.0.direction', 'payable')
|
||||
->assertJsonPath('data.items.1.direction', 'receivable');
|
||||
});
|
||||
|
||||
test('credit player win above credit limit is shown as agent payable to player', function (): void {
|
||||
$siteId = (int) DB::table('admin_sites')->where('is_default', true)->value('id');
|
||||
$player = Player::query()->create([
|
||||
'site_code' => 'default_site',
|
||||
'site_player_id' => 'native:settlement-win-above-limit',
|
||||
'auth_source' => PlayerAuthSource::LOTTERY_NATIVE,
|
||||
'funding_mode' => PlayerFundingMode::CREDIT,
|
||||
'username' => 'settlement_win_above_limit',
|
||||
'default_currency' => 'NPR',
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
DB::table('player_credit_accounts')->insert([
|
||||
'player_id' => $player->id,
|
||||
'credit_limit' => 200,
|
||||
'used_credit' => 0,
|
||||
'frozen_credit' => 0,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$periodId = (int) DB::table('settlement_periods')->insertGetId([
|
||||
'admin_site_id' => $siteId,
|
||||
'period_start' => now()->subWeek(),
|
||||
'period_end' => now(),
|
||||
'status' => 'closed',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
DB::table('settlement_bills')->insert([
|
||||
'settlement_period_id' => $periodId,
|
||||
'bill_type' => 'player',
|
||||
'owner_type' => 'player',
|
||||
'owner_id' => $player->id,
|
||||
'counterparty_type' => 'agent',
|
||||
'counterparty_id' => 1,
|
||||
'gross_win_loss' => -25000,
|
||||
'rebate_amount' => 0,
|
||||
'adjustment_amount' => 0,
|
||||
'net_amount' => -25000,
|
||||
'paid_amount' => 0,
|
||||
'unpaid_amount' => 25000,
|
||||
'status' => 'confirmed',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
||||
->getJson('/api/v1/wallet/settlement-bills')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.summary.pending_receivable', 25000)
|
||||
->assertJsonPath('data.summary.pending_payable', 0)
|
||||
->assertJsonPath('data.summary.net_pending', 25000)
|
||||
->assertJsonPath('data.items.0.direction', 'receivable')
|
||||
->assertJsonPath('data.items.0.unpaid_amount', 25000)
|
||||
->assertJsonPath('data.items.0.net_amount', -25000);
|
||||
});
|
||||
|
||||
test('wallet player settlement bills response is empty', function (): void {
|
||||
$player = Player::query()->create([
|
||||
'site_code' => 'default_site',
|
||||
'site_player_id' => 'wallet:settlement-bills',
|
||||
'auth_source' => PlayerAuthSource::MAIN_SITE_SSO,
|
||||
'funding_mode' => PlayerFundingMode::WALLET,
|
||||
'username' => 'wallet_settlement_bills',
|
||||
'default_currency' => 'NPR',
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
||||
->getJson('/api/v1/wallet/settlement-bills')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.summary.pending_count', 0)
|
||||
->assertJsonCount(0, 'data.items');
|
||||
});
|
||||
Reference in New Issue
Block a user