feat(core): harden sessions settlement and credit activity
Some checks failed
lotterLaravel CI / test (push) Has been cancelled
lotterLaravel E2E / e2e-api (push) Has been cancelled

This commit is contained in:
wchino
2026-07-22 20:53:43 +08:00
parent 35f6e46958
commit 15bd997c4e
48 changed files with 1920 additions and 93 deletions

View File

@@ -2,6 +2,7 @@
use App\Models\Draw;
use App\Models\Player;
use App\Models\AuditLog;
use App\Models\AdminRole;
use App\Models\AdminUser;
use App\Models\TicketItem;
@@ -444,9 +445,24 @@ test('settlement tick finalizer keeps approved batch retryable when payout throw
expect($result['payout_failed'])->toBe(1)
->and($batch->fresh()->status)->toBe(SettlementBatchStatus::Approved->value)
->and($batch->fresh()->review_remark)->toContain('auto_payout_failed');
->and($batch->fresh()->review_remark)->toContain('auto_payout_failed')
->and((int) $batch->fresh()->auto_payout_attempts)->toBe(1)
->and(AuditLog::query()
->where('action_code', 'auto_payout_failed')
->where('target_id', (string) $batch->id)
->count())->toBe(1);
$immediateRetry = app(SettlementTickFinalizer::class)->finalizePendingBatches();
expect($immediateRetry)->toMatchArray(['approved' => 0, 'paid' => 0, 'payout_failed' => 0])
->and((int) $batch->fresh()->auto_payout_attempts)->toBe(1)
->and(AuditLog::query()
->where('action_code', 'auto_payout_failed')
->where('target_id', (string) $batch->id)
->count())->toBe(1);
DB::table('ticket_items')->where('id', $orphanItemId)->delete();
$this->travel((int) config('lottery.auto_payout_retry_base_seconds'))->seconds();
$retry = app(SettlementTickFinalizer::class)->finalizePendingBatches();
expect($retry)->toMatchArray(['approved' => 0, 'paid' => 1, 'payout_failed' => 0])