feat: 增强奖池与钱包管理功能

更新 AdminJackpotPoolUpdateController 校验规则,禁止传入 current_amount。
优化 AdminRiskPoolManualStatusController:更新奖池状态后同步 Redis 状态。
在 TransferOrderReconcileController 中新增 completeCredit 方法,用于处理卡住的转账订单对账。
调整 TransferOrderListController:优化转账订单处理条件。
在 TicketItemsIndexController 中实现支持时区的日期筛选,提升日期处理准确性。
扩展 JackpotPool 模型,新增 adjustments 关联关系。
改进票据与钱包相关服务中的错误处理和事务管理。
This commit is contained in:
2026-05-26 14:58:41 +08:00
parent 48349e3302
commit c8c90e3e94
45 changed files with 1877 additions and 104 deletions

View File

@@ -122,6 +122,48 @@ test('transfer out debits lottery and matches stub credit', function () {
expect((int) PlayerWallet::query()->where('player_id', $player->id)->first()?->balance)->toBe(600);
});
test('transfer out respects frozen balance when checking available funds', function () {
$player = Player::query()->create([
'site_code' => 'main',
'site_player_id' => 'u-frozen',
'username' => null,
'nickname' => null,
'default_currency' => 'NPR',
'status' => 0,
]);
PlayerWallet::query()->create([
'player_id' => $player->id,
'wallet_type' => 'lottery',
'currency_code' => 'NPR',
'balance' => 10_000,
'frozen_balance' => 9_500,
'status' => 0,
'version' => 0,
]);
$code = ErrorCode::WalletInsufficientBalance->value;
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
->postJson('/api/v1/wallet/transfer-out', [
'amount' => 1_000,
'idempotent_key' => 'idem-out-frozen-too-much',
])
->assertStatus(400)
->assertJsonPath('code', $code);
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
->postJson('/api/v1/wallet/transfer-out', [
'amount' => 400,
'idempotent_key' => 'idem-out-frozen-ok',
])
->assertOk()
->assertJsonPath('data.lottery_balance_after', 9_600);
expect((int) PlayerWallet::query()->where('player_id', $player->id)->value('balance'))->toBe(9_600)
->and((int) PlayerWallet::query()->where('player_id', $player->id)->value('frozen_balance'))->toBe(9_500);
});
test('transfer out insufficient balance fails with 1001', function () {
$player = Player::query()->create([
'site_code' => 'main',