feat(wallet): 增强资金流水和信用账本的公共类型过滤,支持游戏结算和账单结算
This commit is contained in:
@@ -106,7 +106,7 @@ test('credit player wallet logs distinguish win credit from bill settlement', fu
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonPath('data.total', 2)
|
||||
->assertJsonPath('data.items.0.type', 'win_credit')
|
||||
->assertJsonPath('data.items.0.type', 'game_settlement')
|
||||
->assertJsonPath('data.items.0.biz_type', 'game_settlement_win')
|
||||
->assertJsonPath('data.items.0.affects_available_credit', true)
|
||||
->assertJsonPath('data.items.1.type', 'bill_settlement')
|
||||
@@ -126,13 +126,105 @@ test('credit player wallet logs distinguish win credit from bill settlement', fu
|
||||
->getJson('/api/v1/wallet/logs?type=win_credit')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.total', 1)
|
||||
->assertJsonPath('data.items.0.type', 'win_credit');
|
||||
->assertJsonPath('data.items.0.type', 'game_settlement');
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
||||
->getJson('/api/v1/wallet/logs?type=credit_release')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.total', 1)
|
||||
->assertJsonPath('data.items.0.type', 'win_credit');
|
||||
->assertJsonPath('data.items.0.type', 'game_settlement');
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
||||
->getJson('/api/v1/wallet/logs?type=game_settlement')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.total', 1)
|
||||
->assertJsonPath('data.items.0.type', 'game_settlement');
|
||||
});
|
||||
|
||||
test('credit player wallet logs include period rebate records without affecting available credit', function (): void {
|
||||
$player = Player::query()->create([
|
||||
'site_code' => 'default_site',
|
||||
'site_player_id' => 'native:logs-rebate',
|
||||
'auth_source' => PlayerAuthSource::LOTTERY_NATIVE,
|
||||
'funding_mode' => PlayerFundingMode::CREDIT,
|
||||
'username' => 'credit_logs_rebate',
|
||||
'default_currency' => 'NPR',
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
DB::table('player_credit_accounts')->insert([
|
||||
'player_id' => $player->id,
|
||||
'credit_limit' => 500,
|
||||
'used_credit' => 0,
|
||||
'frozen_credit' => 0,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$drawId = (int) DB::table('draws')->insertGetId([
|
||||
'draw_no' => 'RB-LOG-001',
|
||||
'business_date' => now()->toDateString(),
|
||||
'sequence_no' => 1,
|
||||
'status' => 'settled',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
$orderId = (int) DB::table('ticket_orders')->insertGetId([
|
||||
'order_no' => 'RB-LOG-ORDER-001',
|
||||
'player_id' => $player->id,
|
||||
'draw_id' => $drawId,
|
||||
'currency_code' => 'NPR',
|
||||
'status' => 'settled',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
$ticketItemId = (int) DB::table('ticket_items')->insertGetId([
|
||||
'ticket_no' => 'RB-LOG-TICKET-001',
|
||||
'order_id' => $orderId,
|
||||
'player_id' => $player->id,
|
||||
'draw_id' => $drawId,
|
||||
'normalized_number' => '1234',
|
||||
'play_code' => '4d',
|
||||
'total_bet_amount' => 10000,
|
||||
'status' => 'settled',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
DB::table('rebate_records')->insert([
|
||||
'player_id' => $player->id,
|
||||
'ticket_item_id' => $ticketItemId,
|
||||
'game_type' => '*',
|
||||
'valid_bet_amount' => 10000,
|
||||
'rebate_rate' => 0.01,
|
||||
'rebate_amount' => 100,
|
||||
'rebate_type' => 'basic',
|
||||
'owner_agent_id' => null,
|
||||
'status' => 'accrued',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
||||
->getJson('/api/v1/wallet/logs?page=1&size=10')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.total', 1)
|
||||
->assertJsonPath('data.items.0.type', 'rebate')
|
||||
->assertJsonPath('data.items.0.biz_type', 'rebate_accrued')
|
||||
->assertJsonPath('data.items.0.ledger_source', 'rebate_record')
|
||||
->assertJsonPath('data.items.0.affects_available_credit', false)
|
||||
->assertJsonPath('data.items.0.balance_after', null);
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
||||
->getJson('/api/v1/wallet/logs?type=rebate')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.total', 1)
|
||||
->assertJsonPath('data.items.0.type', 'rebate');
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
||||
->getJson('/api/v1/wallet/logs?type=bet')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.total', 0);
|
||||
});
|
||||
|
||||
test('credit wallet logs page 2 balance_after continues from page 1 baseline', function (): void {
|
||||
|
||||
Reference in New Issue
Block a user