feat: 支持开奖重开与风险池原子扣减,完善投注部分成功流程
This commit is contained in:
@@ -23,7 +23,10 @@ final class DrawRngRunController extends Controller
|
||||
$batch = DB::transaction(function () use ($draw) {
|
||||
/** @var Draw $locked */
|
||||
$locked = Draw::query()->whereKey($draw->id)->lockForUpdate()->firstOrFail();
|
||||
if ($locked->status !== DrawStatus::Closed->value || $locked->resultBatches()->exists()) {
|
||||
if ($locked->status !== DrawStatus::Closed->value || (int) $locked->settle_version > 0) {
|
||||
throw new \RuntimeException('draw_not_runnable');
|
||||
}
|
||||
if (! (bool) $locked->is_reopened && $locked->resultBatches()->exists()) {
|
||||
throw new \RuntimeException('draw_not_runnable');
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ final class TicketDrawMyMatchController extends Controller
|
||||
'hit_numbers_4d' => [],
|
||||
'total_win_minor' => 0,
|
||||
'total_jackpot_win_minor' => 0,
|
||||
'winning_ticket_count' => 0,
|
||||
'has_bets' => false,
|
||||
]);
|
||||
}
|
||||
@@ -45,6 +46,7 @@ final class TicketDrawMyMatchController extends Controller
|
||||
'hit_numbers_4d' => [],
|
||||
'total_win_minor' => 0,
|
||||
'total_jackpot_win_minor' => 0,
|
||||
'winning_ticket_count' => 0,
|
||||
'has_bets' => false,
|
||||
]);
|
||||
}
|
||||
@@ -63,11 +65,20 @@ final class TicketDrawMyMatchController extends Controller
|
||||
->pluck('id');
|
||||
|
||||
$hasBets = $itemIds->isNotEmpty();
|
||||
$winningItemIds = TicketItem::query()
|
||||
->where('draw_id', $draw->id)
|
||||
->where('player_id', $player->id)
|
||||
->where('status', 'settled_win')
|
||||
->where(function ($q): void {
|
||||
$q->where('win_amount', '>', 0)
|
||||
->orWhere('jackpot_win_amount', '>', 0);
|
||||
})
|
||||
->pluck('id');
|
||||
|
||||
$hits = [];
|
||||
if ($hasBets) {
|
||||
if ($winningItemIds->isNotEmpty()) {
|
||||
$hits = TicketCombination::query()
|
||||
->whereIn('ticket_item_id', $itemIds)
|
||||
->whereIn('ticket_item_id', $winningItemIds)
|
||||
->pluck('number_4d')
|
||||
->map(fn ($n) => self::norm4d((string) $n))
|
||||
->filter(fn (string $n) => isset($board[$n]))
|
||||
@@ -88,6 +99,7 @@ final class TicketDrawMyMatchController extends Controller
|
||||
'hit_numbers_4d' => $hits,
|
||||
'total_win_minor' => (int) ($sums->sum_win ?? 0),
|
||||
'total_jackpot_win_minor' => (int) ($sums->sum_jackpot ?? 0),
|
||||
'winning_ticket_count' => $winningItemIds->count(),
|
||||
'has_bets' => $hasBets,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@ final class TicketItemsIndexController extends Controller
|
||||
$page = $this->page($request);
|
||||
$drawNo = $request->query('draw_no');
|
||||
$statusInput = $request->query('status', []);
|
||||
if (is_string($statusInput)) {
|
||||
$statusInput = [$statusInput];
|
||||
}
|
||||
$statusValues = is_array($statusInput) ? array_values(array_filter(array_map(
|
||||
fn ($status) => is_string($status) ? trim($status) : '',
|
||||
$statusInput,
|
||||
|
||||
@@ -88,7 +88,11 @@ final class DrawRngRunner
|
||||
->where('status', DrawStatus::Closed->value)
|
||||
->whereNotNull('draw_time')
|
||||
->where('draw_time', '<=', $nowUtc)
|
||||
->whereDoesntHave('resultBatches')
|
||||
->where('settle_version', 0)
|
||||
->where(function ($q): void {
|
||||
$q->where('is_reopened', true)
|
||||
->orWhereDoesntHave('resultBatches');
|
||||
})
|
||||
->orderBy('draw_time')
|
||||
->pluck('id');
|
||||
|
||||
@@ -100,7 +104,10 @@ final class DrawRngRunner
|
||||
if ($locked === null || $locked->status !== DrawStatus::Closed->value) {
|
||||
return;
|
||||
}
|
||||
if ($locked->resultBatches()->exists()) {
|
||||
if ((int) $locked->settle_version > 0) {
|
||||
return;
|
||||
}
|
||||
if (! (bool) $locked->is_reopened && $locked->resultBatches()->exists()) {
|
||||
return;
|
||||
}
|
||||
$this->executeLocked($locked);
|
||||
|
||||
@@ -6,6 +6,8 @@ use App\Models\RiskPool;
|
||||
use App\Lottery\ErrorCode;
|
||||
use App\Models\TicketItem;
|
||||
use App\Models\RiskPoolLockLog;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
use App\Exceptions\TicketOperationException;
|
||||
|
||||
final class RiskPoolService
|
||||
@@ -47,46 +49,106 @@ final class RiskPoolService
|
||||
*/
|
||||
public function acquire(int $drawId, ?TicketItem $ticketItem, array $locks): int
|
||||
{
|
||||
$total = 0;
|
||||
foreach ($locks as $lock) {
|
||||
$pool = RiskPool::query()
|
||||
->where('draw_id', $drawId)
|
||||
->where('normalized_number', $lock['number_4d'])
|
||||
->lockForUpdate()
|
||||
->first();
|
||||
if ($this->shouldUseRedisAtomicLocks()) {
|
||||
return $this->acquireWithRedisLua($drawId, $ticketItem, $locks);
|
||||
}
|
||||
|
||||
if ($pool === null) {
|
||||
$pool = $this->createPool($drawId, $lock['number_4d']);
|
||||
return $this->acquireWithDatabaseLocks($drawId, $ticketItem, $locks);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array{number_4d:string, amount:int}> $locks
|
||||
*/
|
||||
private function acquireWithDatabaseLocks(int $drawId, ?TicketItem $ticketItem, array $locks): int
|
||||
{
|
||||
$acquired = [];
|
||||
$total = 0;
|
||||
|
||||
try {
|
||||
foreach ($locks as $lock) {
|
||||
$pool = RiskPool::query()
|
||||
->where('draw_id', $drawId)
|
||||
->where('normalized_number', $lock['number_4d'])
|
||||
->lockForUpdate()
|
||||
->firstOrFail();
|
||||
->first();
|
||||
|
||||
if ($pool === null) {
|
||||
$pool = $this->createPool($drawId, $lock['number_4d']);
|
||||
$pool = RiskPool::query()
|
||||
->where('draw_id', $drawId)
|
||||
->where('normalized_number', $lock['number_4d'])
|
||||
->lockForUpdate()
|
||||
->firstOrFail();
|
||||
}
|
||||
|
||||
$amount = (int) $lock['amount'];
|
||||
if ((int) $pool->remaining_amount < $amount) {
|
||||
throw new TicketOperationException('risk_sold_out', ErrorCode::RiskPoolSoldOut->value);
|
||||
}
|
||||
|
||||
$pool->forceFill([
|
||||
'locked_amount' => (int) $pool->locked_amount + $amount,
|
||||
'remaining_amount' => (int) $pool->remaining_amount - $amount,
|
||||
'sold_out_status' => ((int) $pool->remaining_amount - $amount) <= 0 ? 1 : 0,
|
||||
'version' => (int) $pool->version + 1,
|
||||
])->save();
|
||||
|
||||
RiskPoolLockLog::query()->create([
|
||||
'draw_id' => $drawId,
|
||||
'normalized_number' => $lock['number_4d'],
|
||||
'ticket_item_id' => $ticketItem?->id,
|
||||
'action_type' => 'lock',
|
||||
'amount' => $amount,
|
||||
'source_reason' => 'ticket_place',
|
||||
'created_at' => now(),
|
||||
]);
|
||||
|
||||
$acquired[] = ['number_4d' => $lock['number_4d'], 'amount' => $amount];
|
||||
$total += $amount;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$this->releaseDatabaseLocks($drawId, $ticketItem, $acquired, 'ticket_failed_line');
|
||||
|
||||
$amount = (int) $lock['amount'];
|
||||
if ((int) $pool->remaining_amount < $amount) {
|
||||
throw new TicketOperationException('risk_sold_out', ErrorCode::RiskPoolSoldOut->value);
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Redis Lua 负责额度判断与扣减的原子性;数据库事实表随后同步,失败时释放 Redis 占用。
|
||||
*
|
||||
* @param list<array{number_4d:string, amount:int}> $locks
|
||||
*/
|
||||
private function acquireWithRedisLua(int $drawId, ?TicketItem $ticketItem, array $locks): int
|
||||
{
|
||||
$acquired = [];
|
||||
$total = 0;
|
||||
|
||||
try {
|
||||
foreach ($locks as $lock) {
|
||||
$number4d = $lock['number_4d'];
|
||||
$amount = (int) $lock['amount'];
|
||||
$pool = $this->firstOrMakePool($drawId, $number4d);
|
||||
$key = $this->redisPoolKey($drawId, $number4d);
|
||||
|
||||
Redis::eval($this->initLua(), 1, $key, (int) $pool->total_cap_amount, (int) $pool->locked_amount);
|
||||
|
||||
$result = (int) Redis::eval($this->acquireLua(), 1, $key, $amount);
|
||||
if ($result !== 1) {
|
||||
throw new TicketOperationException('risk_sold_out', ErrorCode::RiskPoolSoldOut->value);
|
||||
}
|
||||
|
||||
$acquired[] = ['number_4d' => $number4d, 'amount' => $amount];
|
||||
$total += $amount;
|
||||
|
||||
$this->syncDatabaseAfterRedisAcquire($drawId, $ticketItem, $number4d, $amount);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$this->releaseRedisLocks($drawId, $acquired);
|
||||
$this->releaseDatabaseLocks($drawId, $ticketItem, $acquired, 'ticket_failed_line');
|
||||
|
||||
$pool->forceFill([
|
||||
'locked_amount' => (int) $pool->locked_amount + $amount,
|
||||
'remaining_amount' => (int) $pool->remaining_amount - $amount,
|
||||
'sold_out_status' => ((int) $pool->remaining_amount - $amount) <= 0 ? 1 : 0,
|
||||
'version' => (int) $pool->version + 1,
|
||||
])->save();
|
||||
|
||||
RiskPoolLockLog::query()->create([
|
||||
'draw_id' => $drawId,
|
||||
'normalized_number' => $lock['number_4d'],
|
||||
'ticket_item_id' => $ticketItem?->id,
|
||||
'action_type' => 'lock',
|
||||
'amount' => $amount,
|
||||
'source_reason' => 'ticket_place',
|
||||
'created_at' => now(),
|
||||
]);
|
||||
|
||||
$total += $amount;
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $total;
|
||||
@@ -96,6 +158,109 @@ final class RiskPoolService
|
||||
* @param list<array{number_4d:string, amount:int}> $locks
|
||||
*/
|
||||
public function release(int $drawId, ?TicketItem $ticketItem, array $locks): void
|
||||
{
|
||||
if ($this->shouldUseRedisAtomicLocks()) {
|
||||
$this->releaseRedisLocks($drawId, $locks);
|
||||
}
|
||||
|
||||
foreach ($locks as $lock) {
|
||||
$this->releaseDatabaseLocks($drawId, $ticketItem, [$lock], 'ticket_rollback');
|
||||
}
|
||||
}
|
||||
|
||||
private function shouldUseRedisAtomicLocks(): bool
|
||||
{
|
||||
if (App::environment('testing')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) config('lottery.risk_pool.use_redis_lua', true);
|
||||
}
|
||||
|
||||
private function redisPoolKey(int $drawId, string $number4d): string
|
||||
{
|
||||
return "risk_pool:draw:{$drawId}:number:{$number4d}";
|
||||
}
|
||||
|
||||
private function initLua(): string
|
||||
{
|
||||
return <<<'LUA'
|
||||
if redis.call('EXISTS', KEYS[1]) == 0 then
|
||||
redis.call('HMSET', KEYS[1], 'total', ARGV[1], 'locked', ARGV[2], 'remaining', ARGV[1] - ARGV[2])
|
||||
end
|
||||
return 1
|
||||
LUA;
|
||||
}
|
||||
|
||||
private function acquireLua(): string
|
||||
{
|
||||
return <<<'LUA'
|
||||
local amount = tonumber(ARGV[1])
|
||||
local remaining = tonumber(redis.call('HGET', KEYS[1], 'remaining') or '0')
|
||||
if remaining < amount then
|
||||
return 0
|
||||
end
|
||||
redis.call('HINCRBY', KEYS[1], 'locked', amount)
|
||||
redis.call('HINCRBY', KEYS[1], 'remaining', -amount)
|
||||
return 1
|
||||
LUA;
|
||||
}
|
||||
|
||||
private function releaseLua(): string
|
||||
{
|
||||
return <<<'LUA'
|
||||
local amount = tonumber(ARGV[1])
|
||||
local locked = tonumber(redis.call('HGET', KEYS[1], 'locked') or '0')
|
||||
local releaseAmount = amount
|
||||
if locked < releaseAmount then
|
||||
releaseAmount = locked
|
||||
end
|
||||
redis.call('HINCRBY', KEYS[1], 'locked', -releaseAmount)
|
||||
redis.call('HINCRBY', KEYS[1], 'remaining', releaseAmount)
|
||||
return releaseAmount
|
||||
LUA;
|
||||
}
|
||||
|
||||
private function syncDatabaseAfterRedisAcquire(int $drawId, ?TicketItem $ticketItem, string $number4d, int $amount): void
|
||||
{
|
||||
$pool = RiskPool::query()
|
||||
->where('draw_id', $drawId)
|
||||
->where('normalized_number', $number4d)
|
||||
->lockForUpdate()
|
||||
->firstOrFail();
|
||||
|
||||
$pool->forceFill([
|
||||
'locked_amount' => (int) $pool->locked_amount + $amount,
|
||||
'remaining_amount' => (int) $pool->remaining_amount - $amount,
|
||||
'sold_out_status' => ((int) $pool->remaining_amount - $amount) <= 0 ? 1 : 0,
|
||||
'version' => (int) $pool->version + 1,
|
||||
])->save();
|
||||
|
||||
RiskPoolLockLog::query()->create([
|
||||
'draw_id' => $drawId,
|
||||
'normalized_number' => $number4d,
|
||||
'ticket_item_id' => $ticketItem?->id,
|
||||
'action_type' => 'lock',
|
||||
'amount' => $amount,
|
||||
'source_reason' => 'ticket_place',
|
||||
'created_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array{number_4d:string, amount:int}> $locks
|
||||
*/
|
||||
private function releaseRedisLocks(int $drawId, array $locks): void
|
||||
{
|
||||
foreach ($locks as $lock) {
|
||||
Redis::eval($this->releaseLua(), 1, $this->redisPoolKey($drawId, $lock['number_4d']), (int) $lock['amount']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array{number_4d:string, amount:int}> $locks
|
||||
*/
|
||||
private function releaseDatabaseLocks(int $drawId, ?TicketItem $ticketItem, array $locks, string $sourceReason): void
|
||||
{
|
||||
foreach ($locks as $lock) {
|
||||
$pool = RiskPool::query()
|
||||
@@ -122,7 +287,7 @@ final class RiskPoolService
|
||||
'ticket_item_id' => $ticketItem?->id,
|
||||
'action_type' => 'release',
|
||||
'amount' => $amount,
|
||||
'source_reason' => 'ticket_rollback',
|
||||
'source_reason' => $sourceReason,
|
||||
'created_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ final class TicketPlacementService
|
||||
if ($draw === null) {
|
||||
throw new TicketOperationException('draw_not_found', ErrorCode::BetInvalidDraw->value);
|
||||
}
|
||||
if ($draw->status !== DrawStatus::Open->value) {
|
||||
if ($draw->status !== DrawStatus::Open->value || ($draw->close_time !== null && now()->greaterThanOrEqualTo($draw->close_time))) {
|
||||
throw new TicketOperationException('draw_closed', ErrorCode::DrawClosed->value);
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ final class TicketPlacementService
|
||||
'client_line_no' => $index + 1,
|
||||
'play_code' => (string) ($line['play_code'] ?? ''),
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -91,7 +92,7 @@ final class TicketPlacementService
|
||||
'number_4d' => $combo['number_4d'],
|
||||
'amount' => $combo['estimated_payout'],
|
||||
], $evaluated['combinations']);
|
||||
$this->riskPoolService->preview((int) $draw->id, $locks);
|
||||
// place 阶段以 acquire 的原子扣减结果为准,允许单行售罄后形成混合成功/失败结果。
|
||||
|
||||
$evaluatedLines[] = $evaluated;
|
||||
$rebateAmount = (int) $evaluated['total_bet_amount'] - (int) $evaluated['actual_deduct_amount'];
|
||||
@@ -127,8 +128,14 @@ final class TicketPlacementService
|
||||
'client_trace_id' => $payload['client_trace_id'] ?? null,
|
||||
]);
|
||||
|
||||
$balanceAfter = $this->ticketWalletService->deduct($player, $currencyCode, $totalActualDeduct, $order);
|
||||
|
||||
$successfulItems = [];
|
||||
$failedItems = [];
|
||||
$successfulEvaluatedLines = [];
|
||||
$successTotalBet = 0;
|
||||
$successTotalRebate = 0;
|
||||
$successTotalActualDeduct = 0;
|
||||
$successTotalEstimatedPayout = 0;
|
||||
$firstFailure = null;
|
||||
foreach ($evaluatedLines as $evaluated) {
|
||||
$item = TicketItem::query()->create([
|
||||
'ticket_no' => $this->newTicketNo(),
|
||||
@@ -145,13 +152,13 @@ final class TicketPlacementService
|
||||
'total_bet_amount' => $evaluated['total_bet_amount'],
|
||||
'rebate_rate_snapshot' => $evaluated['rebate_rate_snapshot'],
|
||||
'commission_rate_snapshot' => $evaluated['commission_rate_snapshot'],
|
||||
'actual_deduct_amount' => $evaluated['actual_deduct_amount'],
|
||||
'actual_deduct_amount' => 0,
|
||||
'odds_snapshot_json' => $evaluated['odds_snapshot_json'],
|
||||
'rule_snapshot_json' => $evaluated['rule_snapshot_json'],
|
||||
'combination_count' => $evaluated['combination_count'],
|
||||
'estimated_max_payout' => $evaluated['estimated_max_payout'],
|
||||
'risk_locked_amount' => 0,
|
||||
'status' => 'success',
|
||||
'status' => 'pending',
|
||||
'fail_reason_code' => null,
|
||||
'fail_reason_text' => null,
|
||||
'win_amount' => 0,
|
||||
@@ -175,10 +182,67 @@ final class TicketPlacementService
|
||||
];
|
||||
}
|
||||
|
||||
$lockedAmount = $this->riskPoolService->acquire((int) $draw->id, $item, $locks);
|
||||
$item->forceFill(['risk_locked_amount' => $lockedAmount])->save();
|
||||
try {
|
||||
$lockedAmount = $this->riskPoolService->acquire((int) $draw->id, $item, $locks);
|
||||
} catch (TicketOperationException $e) {
|
||||
if ($e->lotteryCode !== ErrorCode::RiskPoolSoldOut->value) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$this->jackpotContribution->recordFromPlacedTicketItem($item, $draw, $currencyCode);
|
||||
$firstFailure ??= $e;
|
||||
$item->forceFill([
|
||||
'status' => 'failed',
|
||||
'fail_reason_code' => (string) $e->lotteryCode,
|
||||
'fail_reason_text' => 'risk_sold_out',
|
||||
])->save();
|
||||
$failedItems[] = $item;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$rebateAmount = (int) $evaluated['total_bet_amount'] - (int) $evaluated['actual_deduct_amount'];
|
||||
$item->forceFill([
|
||||
'actual_deduct_amount' => (int) $evaluated['actual_deduct_amount'],
|
||||
'risk_locked_amount' => $lockedAmount,
|
||||
'status' => 'success',
|
||||
])->save();
|
||||
|
||||
$successfulItems[] = $item;
|
||||
$successfulEvaluatedLines[] = ['item' => $item, 'evaluated' => $evaluated];
|
||||
$successTotalBet += (int) $evaluated['total_bet_amount'];
|
||||
$successTotalRebate += $rebateAmount;
|
||||
$successTotalActualDeduct += (int) $evaluated['actual_deduct_amount'];
|
||||
$successTotalEstimatedPayout += (int) $evaluated['estimated_max_payout'];
|
||||
}
|
||||
|
||||
if ($successfulItems === []) {
|
||||
throw $firstFailure ?? new TicketOperationException('risk_sold_out', ErrorCode::RiskPoolSoldOut->value);
|
||||
}
|
||||
|
||||
$order->forceFill([
|
||||
'total_bet_amount' => $successTotalBet,
|
||||
'total_rebate_amount' => $successTotalRebate,
|
||||
'total_actual_deduct' => $successTotalActualDeduct,
|
||||
'total_estimated_payout' => $successTotalEstimatedPayout,
|
||||
'status' => $failedItems === [] ? 'placed' : 'partial_failed',
|
||||
])->save();
|
||||
|
||||
try {
|
||||
$balanceAfter = $this->ticketWalletService->deduct($player, $currencyCode, $successTotalActualDeduct, $order);
|
||||
|
||||
foreach ($successfulItems as $item) {
|
||||
$this->jackpotContribution->recordFromPlacedTicketItem($item, $draw, $currencyCode);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
foreach ($successfulEvaluatedLines as $row) {
|
||||
$locks = array_map(fn (array $combo): array => [
|
||||
'number_4d' => $combo['number_4d'],
|
||||
'amount' => $combo['estimated_payout'],
|
||||
], $row['evaluated']['combinations']);
|
||||
$this->riskPoolService->release((int) $draw->id, $row['item'], $locks);
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return [
|
||||
@@ -203,6 +267,8 @@ final class TicketPlacementService
|
||||
'total_rebate_amount' => (int) $order->total_rebate_amount,
|
||||
'total_actual_deduct' => (int) $order->total_actual_deduct,
|
||||
'total_estimated_payout' => (int) $order->total_estimated_payout,
|
||||
'success_count' => TicketItem::query()->where('order_id', $order->id)->where('status', 'success')->count(),
|
||||
'failure_count' => TicketItem::query()->where('order_id', $order->id)->where('status', 'failed')->count(),
|
||||
],
|
||||
'balance_after' => $balanceAfter,
|
||||
'items' => TicketItem::query()
|
||||
@@ -217,6 +283,9 @@ final class TicketPlacementService
|
||||
'actual_deduct_amount' => (int) $item->actual_deduct_amount,
|
||||
'estimated_max_payout' => (int) $item->estimated_max_payout,
|
||||
'combination_count' => (int) $item->combination_count,
|
||||
'status' => $item->status,
|
||||
'fail_reason_code' => $item->fail_reason_code,
|
||||
'fail_reason_text' => $item->fail_reason_text,
|
||||
])->values()->all(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ final class TicketPreviewService
|
||||
if ($draw === null) {
|
||||
throw new TicketOperationException('draw_not_found', ErrorCode::BetInvalidDraw->value);
|
||||
}
|
||||
if ($draw->status !== DrawStatus::Open->value) {
|
||||
if ($draw->status !== DrawStatus::Open->value || ($draw->close_time !== null && now()->greaterThanOrEqualTo($draw->close_time))) {
|
||||
throw new TicketOperationException('draw_closed', ErrorCode::DrawClosed->value);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ final class TicketPreviewService
|
||||
'client_line_no' => $index + 1,
|
||||
'play_code' => (string) ($line['play_code'] ?? ''),
|
||||
];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user