feat(invitation): update seat allocation structure and enhance provisioning logic
This commit is contained in:
@@ -17,21 +17,25 @@ class InvitationPurchaseProvisioner
|
||||
private const PAYMENT_METHOD = 'invitation';
|
||||
|
||||
/**
|
||||
* @var list<array{sector: string, row: int, seats: int, type: string}>
|
||||
* @var list<array{sector: string, row: int, first_seat: int, last_seat: int, type: string}>
|
||||
*/
|
||||
private const ALLOCATIONS = [
|
||||
['sector' => 'A', 'row' => 1, 'seats' => 16, 'type' => 'NORMAL'],
|
||||
['sector' => 'A', 'row' => 3, 'seats' => 14, 'type' => 'NORMAL'],
|
||||
['sector' => 'C', 'row' => 1, 'seats' => 16, 'type' => 'VIP + LUNCH'],
|
||||
['sector' => 'A', 'row' => 1, 'first_seat' => 1, 'last_seat' => 16, 'type' => 'NORMAL'],
|
||||
['sector' => 'A', 'row' => 3, 'first_seat' => 1, 'last_seat' => 14, 'type' => 'NORMAL'],
|
||||
['sector' => 'C', 'row' => 1, 'first_seat' => 1, 'last_seat' => 16, 'type' => 'VIP + LUNCH'],
|
||||
['sector' => 'C', 'row' => 3, 'first_seat' => 6, 'last_seat' => 7, 'type' => 'NORMAL'],
|
||||
];
|
||||
|
||||
public function provision(): void
|
||||
/**
|
||||
* @param list<array{sector: string, row: int, first_seat: int, last_seat: int, type: string}>|null $allocations
|
||||
*/
|
||||
public function provision(?array $allocations = null): void
|
||||
{
|
||||
if (! $this->prerequisitesExist()) {
|
||||
return;
|
||||
}
|
||||
|
||||
DB::transaction(function (): void {
|
||||
DB::transaction(function () use ($allocations): void {
|
||||
$now = now();
|
||||
$userId = $this->userId($now);
|
||||
$purchaseId = $this->purchaseId($userId, $now);
|
||||
@@ -44,8 +48,8 @@ class InvitationPurchaseProvisioner
|
||||
throw new RuntimeException('No se encontró el catálogo de entradas del desfile.');
|
||||
}
|
||||
|
||||
foreach (self::ALLOCATIONS as $allocation) {
|
||||
foreach (range(1, $allocation['seats']) as $seat) {
|
||||
foreach ($allocations ?? self::ALLOCATIONS as $allocation) {
|
||||
foreach (range($allocation['first_seat'], $allocation['last_seat']) as $seat) {
|
||||
$variant = $this->variant(
|
||||
(int) $catalogItem->id,
|
||||
$allocation['sector'],
|
||||
|
||||
Reference in New Issue
Block a user