feat(core): harden sessions settlement and credit activity
This commit is contained in:
@@ -2,24 +2,26 @@
|
||||
|
||||
use App\Models\Draw;
|
||||
use App\Models\Player;
|
||||
use App\Models\AdminUser;
|
||||
use App\Models\TicketItem;
|
||||
use App\Lottery\DrawStatus;
|
||||
use App\Models\JackpotPool;
|
||||
use App\Models\TicketOrder;
|
||||
use App\Models\PlayerWallet;
|
||||
use App\Models\DrawResultItem;
|
||||
use App\Models\DrawResultBatch;
|
||||
use App\Models\TicketOrder;
|
||||
use App\Models\AdminUser;
|
||||
use App\Models\SettlementBatch;
|
||||
use App\Services\Draw\DrawPrizeLayout;
|
||||
use App\Services\Settlement\SettlementOrchestrator;
|
||||
use App\Services\Settlement\SettlementBatchWorkflowService;
|
||||
use App\Models\TicketCombination;
|
||||
use Database\Seeders\CurrencySeeder;
|
||||
use Database\Seeders\PlayTypeSeeder;
|
||||
use App\Lottery\DrawResultBatchStatus;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Lottery\DrawResultBatchStatus;
|
||||
use App\Services\Draw\DrawPrizeLayout;
|
||||
use Database\Seeders\LotterySettingsSeeder;
|
||||
use Database\Seeders\OperationalConfigV1Seeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use App\Services\Settlement\SettlementOrchestrator;
|
||||
use App\Services\Settlement\SettlementBatchWorkflowService;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
@@ -171,6 +173,12 @@ test('ticket items index returns placed ticket for player', function (): void {
|
||||
->assertJsonPath('data.ticket_no', $ticketNo)
|
||||
->assertJsonPath('data.combinations.0.number_4d', '1234');
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
||||
->getJson('/api/v1/ticket/items?ticket_no='.urlencode($ticketNo))
|
||||
->assertOk()
|
||||
->assertJsonPath('data.total', 1)
|
||||
->assertJsonPath('data.items.0.ticket_no', $ticketNo);
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
||||
->getJson('/api/v1/ticket/items?draw_no='.urlencode('20260511-777'))
|
||||
->assertOk()
|
||||
@@ -313,7 +321,7 @@ test('ticket item show returns match result and timeline', function (): void {
|
||||
|
||||
ticketItemsPublishAndSettle($draw, '1234');
|
||||
|
||||
$ticketNo = \App\Models\TicketItem::query()->where('draw_id', $draw->id)->value('ticket_no');
|
||||
$ticketNo = TicketItem::query()->where('draw_id', $draw->id)->value('ticket_no');
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
||||
->getJson('/api/v1/ticket/items/'.$ticketNo)
|
||||
@@ -348,9 +356,9 @@ test('my-match returns hit numbers when draw settled with winning ticket', funct
|
||||
]);
|
||||
|
||||
$draw = Draw::query()->create([
|
||||
'draw_no' => '20260511-778',
|
||||
'draw_no' => '20260511-1778',
|
||||
'business_date' => '2026-05-11',
|
||||
'sequence_no' => 778,
|
||||
'sequence_no' => 1778,
|
||||
'status' => DrawStatus::Open->value,
|
||||
'start_time' => now()->subMinutes(2),
|
||||
'close_time' => now()->addMinutes(5),
|
||||
@@ -364,7 +372,7 @@ test('my-match returns hit numbers when draw settled with winning ticket', funct
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
||||
->postJson('/api/v1/ticket/place', [
|
||||
'draw_id' => '20260511-778',
|
||||
'draw_id' => '20260511-1778',
|
||||
'currency_code' => 'NPR',
|
||||
'client_trace_id' => 'match-trace-1',
|
||||
'lines' => [
|
||||
@@ -376,7 +384,7 @@ test('my-match returns hit numbers when draw settled with winning ticket', funct
|
||||
ticketItemsPublishAndSettle($draw, '1234');
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
||||
->getJson('/api/v1/ticket/draws/20260511-778/my-match')
|
||||
->getJson('/api/v1/ticket/draws/20260511-1778/my-match')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.has_bets', true)
|
||||
->assertJsonPath('data.winning_ticket_count', 1)
|
||||
@@ -441,7 +449,7 @@ test('my-match only highlights settled winning tickets', function (): void {
|
||||
'client_trace_id' => 'pending-match',
|
||||
]);
|
||||
|
||||
$item = \App\Models\TicketItem::query()->create([
|
||||
$item = TicketItem::query()->create([
|
||||
'ticket_no' => 'TKPENDINGMATCH',
|
||||
'order_id' => $order->id,
|
||||
'player_id' => $player->id,
|
||||
@@ -467,7 +475,7 @@ test('my-match only highlights settled winning tickets', function (): void {
|
||||
'jackpot_win_amount' => 0,
|
||||
]);
|
||||
|
||||
\App\Models\TicketCombination::query()->create([
|
||||
TicketCombination::query()->create([
|
||||
'ticket_item_id' => $item->id,
|
||||
'combination_no' => 0,
|
||||
'number_4d' => '1234',
|
||||
|
||||
Reference in New Issue
Block a user