fix: 兼容钱包日志投注与派奖业务类型映射

This commit is contained in:
2026-05-15 16:36:47 +08:00
parent c0cd8be0fb
commit 87637f2e4a
2 changed files with 61 additions and 18 deletions

View File

@@ -44,39 +44,80 @@ test('wallet logs returns transfer rows and pagination', function () {
expect(WalletTxn::query()->where('player_id', $player->id)->count())->toBe(1);
});
test('wallet logs filters by type refund', function () {
test('wallet logs filters bet_deduct as public bet type', function () {
$player = Player::query()->create([
'site_code' => 'main',
'site_player_id' => 'wl2',
'site_player_id' => 'wl3',
'default_currency' => 'NPR',
'status' => 0,
]);
PlayerWallet::query()->create([
$wallet = PlayerWallet::query()->create([
'player_id' => $player->id,
'wallet_type' => 'lottery',
'currency_code' => 'NPR',
'balance' => 500,
'balance' => 1000,
'frozen_balance' => 0,
'status' => 0,
'version' => 0,
]);
config(['lottery.main_site.wallet_api_url' => 'http://failure.test']);
Http::fake([
'failure.test/*' => Http::response(['success' => false, 'message' => 'no'], 200),
WalletTxn::query()->create([
'txn_no' => 'WX_bet_deduct_1',
'player_id' => $player->id,
'wallet_id' => $wallet->id,
'biz_type' => 'bet_deduct',
'biz_no' => 'TO_test_bet',
'direction' => 2,
'amount' => 28900,
'balance_before' => 100000,
'balance_after' => 71100,
'status' => 'posted',
]);
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
->postJson('/api/v1/wallet/transfer-out', [
'amount' => 200,
'idempotent_key' => 'out-fail',
])
->assertStatus(400);
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
->getJson('/api/v1/wallet/logs?type=refund')
->getJson('/api/v1/wallet/logs?type=bet')
->assertOk()
->assertJsonPath('data.total', 1)
->assertJsonPath('data.items.0.type', 'refund');
->assertJsonPath('data.items.0.type', 'bet')
->assertJsonPath('data.items.0.biz_type', 'bet_deduct');
});
test('wallet logs filters settle_payout as public prize type', function () {
$player = Player::query()->create([
'site_code' => 'main',
'site_player_id' => 'wl4',
'default_currency' => 'NPR',
'status' => 0,
]);
$wallet = PlayerWallet::query()->create([
'player_id' => $player->id,
'wallet_type' => 'lottery',
'currency_code' => 'NPR',
'balance' => 1000,
'frozen_balance' => 0,
'status' => 0,
'version' => 0,
]);
WalletTxn::query()->create([
'txn_no' => 'WX_settle_payout_1',
'player_id' => $player->id,
'wallet_id' => $wallet->id,
'biz_type' => 'settle_payout',
'biz_no' => 'SB_test_prize',
'direction' => 1,
'amount' => 50000,
'balance_before' => 100000,
'balance_after' => 150000,
'status' => 'posted',
]);
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
->getJson('/api/v1/wallet/logs?type=prize')
->assertOk()
->assertJsonPath('data.total', 1)
->assertJsonPath('data.items.0.type', 'prize')
->assertJsonPath('data.items.0.biz_type', 'settle_payout');
});