Blame | Last modification | View Log | RSS feed
package com.spice.profitmandi.dao.cart.v2;import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;public interface CartValidationService {/*** STEP 1 — soft validation on cart-open.* Never blocks. Auto-downgrades qty when stock is short, drops unavailable lines* to {@link LineStatus#UNAVAILABLE}, and surfaces warnings for the UI.* Side effect: refreshes {@code last_seen_price} / {@code last_seen_at} on every active line* so Step 2 has a baseline for drift detection.*//*** The hydration layer reads {@code cart.sale_type} directly from the DB* and picks the right stock source (procurement = warehouse, tertiary =* partner's in-store snapshot). Callers don't need to pass saleType.*/OpenCartValidationResult validateForOpen(int cartId, int storeId) throws ProfitMandiBusinessException;/*** STEP 2 — hard validation immediately before payment.* Returns {@code valid=false} with {@link BlockerType#PRICE_CHANGED_SINCE_OPEN}* on any price drift vs. last_seen_price (user must re-confirm by reloading the cart).** Reservation is created ONLY when {@code saleType == TERTIARY_SALE}. Partner* procurement flows run all the same checks (price, stock, address) but do* not hold stock — partner POs resolve stock downstream at warehouse dispatch.*/CheckoutValidationResult validateForCheckout(int cartId, int userId, int storeId,long addressId, SaleType saleType)throws ProfitMandiBusinessException;}