feat(refund): add support for event date suspension in cart invalidation process
This commit is contained in:
@@ -15,9 +15,12 @@ class InvalidateEventDateCartsService
|
||||
public function __construct(private readonly StockReservationService $reservations) {}
|
||||
|
||||
/** @param Collection<int, int> $eventDateIds */
|
||||
public function invalidate(Tenant $tenant, Collection $eventDateIds): void
|
||||
{
|
||||
DB::transaction(function () use ($tenant, $eventDateIds): void {
|
||||
public function invalidate(
|
||||
Tenant $tenant,
|
||||
Collection $eventDateIds,
|
||||
string $reason = StockReservationService::REASON_EVENT_DATE_RESCHEDULED,
|
||||
): void {
|
||||
DB::transaction(function () use ($tenant, $eventDateIds, $reason): void {
|
||||
$carts = Cart::query()
|
||||
->where('tenant_codigo', $tenant->codigo)
|
||||
->where('status', Cart::STATUS_ACTIVE)
|
||||
@@ -44,7 +47,7 @@ class InvalidateEventDateCartsService
|
||||
|
||||
$this->reservations->releaseCurrentCartReservation(
|
||||
$cart,
|
||||
StockReservationService::REASON_EVENT_DATE_RESCHEDULED,
|
||||
$reason,
|
||||
);
|
||||
|
||||
// Reuse the existing expired-cart flow: stale mutations receive the
|
||||
|
||||
@@ -21,6 +21,8 @@ class StockReservationService
|
||||
|
||||
public const REASON_EVENT_DATE_RESCHEDULED = 'event_date_rescheduled';
|
||||
|
||||
public const REASON_EVENT_DATE_SUSPENDED = 'event_date_suspended';
|
||||
|
||||
public const REASON_PURCHASE_SUPERSEDED = 'purchase_superseded';
|
||||
|
||||
public const REASON_PURCHASE_CANCELLED = 'purchase_cancelled';
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Domains\Event\Services;
|
||||
use App\Domains\Auth\Models\User;
|
||||
use App\Domains\Cart\Services\InvalidateEventDateCartsService;
|
||||
use App\Domains\Catalog\Models\Variant;
|
||||
use App\Domains\Catalog\Services\StockReservationService;
|
||||
use App\Domains\Catalog\Services\VariantReplacementService;
|
||||
use App\Domains\Event\Enums\EventDateChangeType;
|
||||
use App\Domains\Event\Events\EventDateRescheduled;
|
||||
@@ -177,10 +178,13 @@ class EventService
|
||||
return $date->load('validityTime');
|
||||
}
|
||||
|
||||
$purchaseTickets = $this->affectedPurchaseResolver->resolve(
|
||||
$affectedDateIds = $this->affectedDateIds($tenant, $date);
|
||||
$this->invalidateEventDateCarts->invalidate(
|
||||
$tenant,
|
||||
$this->affectedDateIds($tenant, $date),
|
||||
$affectedDateIds,
|
||||
StockReservationService::REASON_EVENT_DATE_SUSPENDED,
|
||||
);
|
||||
$purchaseTickets = $this->affectedPurchaseResolver->resolve($tenant, $affectedDateIds);
|
||||
$date->update(['suspended_at' => now()]);
|
||||
$this->variantReplacementService->disableForSuspension($date);
|
||||
$this->disableTicketsWithoutUsableDates($tenant, $date);
|
||||
|
||||
Reference in New Issue
Block a user