| 36376 |
aman |
1 |
package com.spice.profitmandi.dao.cart.v2;
|
|
|
2 |
|
|
|
3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
4 |
|
|
|
5 |
import java.util.List;
|
|
|
6 |
import java.util.Optional;
|
|
|
7 |
|
|
|
8 |
public interface CartReservationService {
|
|
|
9 |
|
|
|
10 |
/**
|
|
|
11 |
* Creates a stock reservation for the cart.
|
|
|
12 |
* TTL is {@value CartReservationConstants#RESERVATION_TTL_SECONDS}s.
|
|
|
13 |
* Idempotent per cartId — replaces any existing active reservation.
|
|
|
14 |
*/
|
|
|
15 |
Reservation create(int cartId, int userId, List<LineReservation> lines) throws ProfitMandiBusinessException;
|
|
|
16 |
|
|
|
17 |
/** Called by order creation. Returns empty if reservation expired or already consumed. */
|
|
|
18 |
Optional<Reservation> consume(String reservationId);
|
|
|
19 |
|
|
|
20 |
/** User aborts checkout. Safe to call even if reservation already expired. */
|
|
|
21 |
void release(String reservationId);
|
|
|
22 |
|
|
|
23 |
/** Returns the live reservation for a cart, if any. */
|
|
|
24 |
Optional<Reservation> findActive(int cartId);
|
|
|
25 |
}
|