refactor(stock): make reservation expiration authoritative

This commit is contained in:
2026-08-25 15:28:17 -03:00
parent 007b95b904
commit 624b246ff5
16 changed files with 304 additions and 207 deletions

View File

@@ -61,10 +61,7 @@ class CompleteCheckoutService
$this->purchaseState->lockCurrentCart($purchase);
if (
$purchase->status !== Purchase::STATUS_PENDING_PAYMENT
|| ($purchase->expires_at !== null && $purchase->expires_at->isPast())
) {
if ($purchase->status !== Purchase::STATUS_PENDING_PAYMENT) {
throw ValidationException::withMessages([
'purchase' => __('api.purchase.not_available_for_review'),
]);
@@ -72,9 +69,8 @@ class CompleteCheckoutService
$purchase->update([
'status' => Purchase::STATUS_IN_REVIEW,
'expires_at' => null,
]);
$this->reservations->syncPurchaseExpiration($purchase);
$this->reservations->refreshForPurchase($purchase, null);
return $this->loadPurchase($purchase);
});
@@ -195,7 +191,7 @@ class CompleteCheckoutService
private function loadPurchase(Purchase $purchase): Purchase
{
return $purchase->load(['items.imageAttachment']);
return $purchase->load(['items.imageAttachment', 'stockReservation']);
}
private function itemKey(int $catalogItemId, ?int $variantId): string