| 36376 |
aman |
1 |
package com.spice.profitmandi.dao.cart.v2;
|
|
|
2 |
|
|
|
3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
4 |
|
|
|
5 |
public interface CartValidationService {
|
|
|
6 |
|
|
|
7 |
/**
|
|
|
8 |
* STEP 1 — soft validation on cart-open.
|
|
|
9 |
* Never blocks. Auto-downgrades qty when stock is short, drops unavailable lines
|
|
|
10 |
* to {@link LineStatus#UNAVAILABLE}, and surfaces warnings for the UI.
|
|
|
11 |
* Side effect: refreshes {@code last_seen_price} / {@code last_seen_at} on every active line
|
|
|
12 |
* so Step 2 has a baseline for drift detection.
|
|
|
13 |
*/
|
|
|
14 |
/**
|
|
|
15 |
* The hydration layer reads {@code cart.sale_type} directly from the DB
|
|
|
16 |
* and picks the right stock source (procurement = warehouse, tertiary =
|
|
|
17 |
* partner's in-store snapshot). Callers don't need to pass saleType.
|
|
|
18 |
*/
|
|
|
19 |
OpenCartValidationResult validateForOpen(int cartId, int storeId) throws ProfitMandiBusinessException;
|
|
|
20 |
|
|
|
21 |
/**
|
|
|
22 |
* STEP 2 — hard validation immediately before payment.
|
|
|
23 |
* Returns {@code valid=false} with {@link BlockerType#PRICE_CHANGED_SINCE_OPEN}
|
|
|
24 |
* on any price drift vs. last_seen_price (user must re-confirm by reloading the cart).
|
|
|
25 |
*
|
|
|
26 |
* Reservation is created ONLY when {@code saleType == TERTIARY_SALE}. Partner
|
|
|
27 |
* procurement flows run all the same checks (price, stock, address) but do
|
|
|
28 |
* not hold stock — partner POs resolve stock downstream at warehouse dispatch.
|
|
|
29 |
*/
|
|
|
30 |
CheckoutValidationResult validateForCheckout(int cartId, int userId, int storeId,
|
|
|
31 |
long addressId, SaleType saleType)
|
|
|
32 |
throws ProfitMandiBusinessException;
|
|
|
33 |
}
|