- 在多个控制器中更新权限检查逻辑,确保管理员能够更灵活地管理代理和玩家。 - 在 AdminPlayerStoreController 中引入对玩家创建能力的验证,确保只有具备相应权限的管理员能够创建玩家。 - 更新请求验证逻辑,新增 credit_limit、rebate_rate 和 extra_rebate_rate 字段,以支持更细粒度的玩家管理。 - 在 AgentNodeProfileController 中添加对父代理能力授予的验证,确保子代理的权限在父代理范围内。 - 引入 AgentProfileFieldRules 以简化代理资料更新请求的规则定义,提升代码复用性。
47 lines
1.5 KiB
PHP
47 lines
1.5 KiB
PHP
<?php
|
|
|
|
use App\Models\Player;
|
|
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 wallet balance returns minor units matching admin credit limit', function (): void {
|
|
$site = DB::table('admin_sites')->where('is_default', true)->first();
|
|
|
|
$player = Player::query()->create([
|
|
'site_code' => (string) $site->code,
|
|
'agent_node_id' => (int) DB::table('agent_nodes')->where('depth', 0)->value('id'),
|
|
'site_player_id' => 'credit-bal-1',
|
|
'auth_source' => 'lottery_native',
|
|
'funding_mode' => PlayerFundingMode::CREDIT,
|
|
'username' => 'creditbal',
|
|
'nickname' => null,
|
|
'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(),
|
|
]);
|
|
|
|
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
|
->getJson('/api/v1/wallet/balance?currency=NPR')
|
|
->assertOk()
|
|
->assertJsonPath('data.credit_line_mode', true)
|
|
->assertJsonPath('data.available_balance', 20000)
|
|
->assertJsonPath('data.credit_limit', 20000)
|
|
->assertJsonPath('data.available_balance_formatted', '200.00');
|
|
});
|