feat: 支持开奖重开与风险池原子扣减,完善投注部分成功流程

This commit is contained in:
2026-05-18 11:28:11 +08:00
parent 4f143c7cb1
commit 9157dcb6a1
14 changed files with 526 additions and 103 deletions

View File

@@ -471,7 +471,7 @@ test('§14.5 jackpot contributes on place and stays in pool when no first-prize
expect((int) $item->jackpot_win_amount)->toBe(0);
});
test('§14.5 placement rollback returns stake when mid-order risk acquire fails (退本)', function (): void {
test('§14.5 placement partial failure only deducts successful lines when mid-order risk acquire fails', function (): void {
$player = p145_player(500_000);
$drawNo = p145_next_draw_no();
$draw = p145_draw($drawNo, random_int(1, 99_999));
@@ -495,14 +495,24 @@ test('§14.5 placement rollback returns stake when mid-order risk acquire fails
['number' => '1234', 'play_code' => 'big', 'amount' => 120],
],
])
->assertStatus(400)
->assertJsonPath('code', ErrorCode::RiskPoolSoldOut->value);
->assertOk()
->assertJsonPath('data.summary.success_count', 1)
->assertJsonPath('data.summary.failure_count', 1)
->assertJsonPath('data.items.1.fail_reason_code', (string) ErrorCode::RiskPoolSoldOut->value);
expect(TicketOrder::query()->count())->toBe(0);
expect(WalletTxn::query()->where('biz_type', 'bet_deduct')->count())->toBe(0);
expect(TicketOrder::query()->count())->toBe(1);
expect(TicketOrder::query()->firstOrFail()->status)->toBe('partial_failed');
expect(WalletTxn::query()->where('biz_type', 'bet_deduct')->count())->toBe(1);
$wallet = PlayerWallet::query()->where('player_id', $player->id)->firstOrFail();
expect((int) $wallet->balance)->toBe(500_000);
expect((int) $wallet->balance)->toBe(500_000 - 120);
$pool = RiskPool::query()
->where('draw_id', $draw->id)
->where('normalized_number', '1234')
->firstOrFail();
expect((int) $pool->remaining_amount)->toBe(2000);
expect((int) $pool->locked_amount)->toBe(3000);
});
/**