- 在多个控制器中更新权限检查逻辑,确保管理员能够更灵活地管理代理和玩家。 - 在 AdminPlayerStoreController 中引入对玩家创建能力的验证,确保只有具备相应权限的管理员能够创建玩家。 - 更新请求验证逻辑,新增 credit_limit、rebate_rate 和 extra_rebate_rate 字段,以支持更细粒度的玩家管理。 - 在 AgentNodeProfileController 中添加对父代理能力授予的验证,确保子代理的权限在父代理范围内。 - 引入 AgentProfileFieldRules 以简化代理资料更新请求的规则定义,提升代码复用性。
85 lines
2.8 KiB
PHP
85 lines
2.8 KiB
PHP
<?php
|
|
|
|
use App\Models\AdminUser;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
test('settlement payments and adjustments index return items', function (): void {
|
|
$siteId = (int) DB::table('admin_sites')->where('is_default', true)->value('id');
|
|
$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(),
|
|
]);
|
|
|
|
$billId = (int) DB::table('settlement_bills')->insertGetId([
|
|
'settlement_period_id' => $periodId,
|
|
'bill_type' => 'player',
|
|
'owner_type' => 'player',
|
|
'owner_id' => 1,
|
|
'counterparty_type' => 'agent',
|
|
'counterparty_id' => 1,
|
|
'net_amount' => 1000,
|
|
'unpaid_amount' => 0,
|
|
'paid_amount' => 1000,
|
|
'status' => 'settled',
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]);
|
|
|
|
DB::table('payment_records')->insert([
|
|
'settlement_bill_id' => $billId,
|
|
'payer_type' => 'player',
|
|
'payer_id' => 1,
|
|
'payee_type' => 'agent',
|
|
'payee_id' => 1,
|
|
'amount' => 1000,
|
|
'method' => 'cash',
|
|
'status' => 'confirmed',
|
|
'confirmed_at' => now(),
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]);
|
|
|
|
DB::table('settlement_adjustments')->insert([
|
|
'settlement_period_id' => $periodId,
|
|
'original_bill_id' => $billId,
|
|
'adjustment_type' => 'adjustment',
|
|
'amount' => 100,
|
|
'reason' => 'test',
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]);
|
|
|
|
$admin = AdminUser::query()->create([
|
|
'username' => 'lists_super',
|
|
'name' => 'Lists',
|
|
'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/settlement-payments?admin_site_id='.$siteId)
|
|
->assertOk()
|
|
->assertJsonPath('data.items.0.settlement_bill_id', $billId);
|
|
|
|
$this->withHeader('Authorization', 'Bearer '.$token)
|
|
->getJson('/api/v1/admin/settlement-adjustments?admin_site_id='.$siteId)
|
|
->assertOk()
|
|
->assertJsonPath('data.items.0.original_bill_id', $billId);
|
|
|
|
$this->withHeader('Authorization', 'Bearer '.$token)
|
|
->getJson('/api/v1/admin/settlement-bills?admin_site_id='.$siteId.'&bill_type=player')
|
|
->assertOk()
|
|
->assertJsonPath('data.items.0.bill_type', 'player');
|
|
});
|