feat(core): harden sessions settlement and credit activity
This commit is contained in:
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user