refactor(stock): propagate reservation expiration
This commit is contained in:
@@ -129,13 +129,25 @@ class ReleaseCheckoutService
|
||||
return;
|
||||
}
|
||||
|
||||
if ($cart->status === 'active') {
|
||||
if ($targetStatus === Purchase::STATUS_EXPIRED
|
||||
&& in_array($cart->status, [Cart::STATUS_ACTIVE, Cart::STATUS_CHECKOUT], true)) {
|
||||
Cart::query()
|
||||
->whereKey($cart->getKey())
|
||||
->where('current_purchase_id', $purchase->getKey())
|
||||
->where('current_stock_reservation_id', $purchase->stock_reservation_id)
|
||||
->update([
|
||||
'status' => Cart::STATUS_EXPIRED,
|
||||
'current_purchase_id' => null,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($cart->status === Cart::STATUS_ACTIVE) {
|
||||
$cartUpdate = [
|
||||
'current_purchase_id' => null,
|
||||
'current_stock_reservation_id' => null,
|
||||
];
|
||||
if ($targetStatus !== Purchase::STATUS_EXPIRED) {
|
||||
$cartUpdate['current_stock_reservation_id'] = null;
|
||||
}
|
||||
|
||||
Cart::query()
|
||||
->whereKey($cart->getKey())
|
||||
@@ -145,7 +157,7 @@ class ReleaseCheckoutService
|
||||
return;
|
||||
}
|
||||
|
||||
if ($cart->status !== 'checkout') {
|
||||
if ($cart->status !== Cart::STATUS_CHECKOUT) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user