Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

package com.spice.profitmandi.dao.cart.v2;

import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;

import java.util.List;
import java.util.Optional;

public interface CartReservationService {

        /**
         * Creates a stock reservation for the cart.
         * TTL is {@value CartReservationConstants#RESERVATION_TTL_SECONDS}s.
         * Idempotent per cartId — replaces any existing active reservation.
         */
        Reservation create(int cartId, int userId, List<LineReservation> lines) throws ProfitMandiBusinessException;

        /** Called by order creation. Returns empty if reservation expired or already consumed. */
        Optional<Reservation> consume(String reservationId);

        /** User aborts checkout. Safe to call even if reservation already expired. */
        void release(String reservationId);

        /** Returns the live reservation for a cart, if any. */
        Optional<Reservation> findActive(int cartId);
}