Subversion Repositories SmartDukaan

Rev

Rev 36479 | Rev 37015 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 36479 Rev 37014
Line 8... Line 8...
8
import com.spice.profitmandi.dao.cart.v2.CheckoutValidationResult;
8
import com.spice.profitmandi.dao.cart.v2.CheckoutValidationResult;
9
import com.spice.profitmandi.dao.cart.v2.OpenCartValidationResult;
9
import com.spice.profitmandi.dao.cart.v2.OpenCartValidationResult;
10
import com.spice.profitmandi.dao.cart.v2.SaleType;
10
import com.spice.profitmandi.dao.cart.v2.SaleType;
11
import com.spice.profitmandi.dao.entity.catalog.Item;
11
import com.spice.profitmandi.dao.entity.catalog.Item;
12
import com.spice.profitmandi.dao.entity.catalog.TagListing;
12
import com.spice.profitmandi.dao.entity.catalog.TagListing;
-
 
13
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
13
import com.spice.profitmandi.dao.entity.user.CartLine;
14
import com.spice.profitmandi.dao.entity.user.CartLine;
14
import com.spice.profitmandi.dao.enumuration.catalog.ByPassRequestStatus;
15
import com.spice.profitmandi.dao.enumuration.catalog.ByPassRequestStatus;
-
 
16
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
15
import com.spice.profitmandi.dao.model.AddCartRequest;
17
import com.spice.profitmandi.dao.model.AddCartRequest;
16
import com.spice.profitmandi.dao.model.CartItem;
18
import com.spice.profitmandi.dao.model.CartItem;
17
import com.spice.profitmandi.dao.model.UserCart;
19
import com.spice.profitmandi.dao.model.UserCart;
18
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
20
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
19
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
21
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
Line 27... Line 29...
27
import org.springframework.http.ResponseEntity;
29
import org.springframework.http.ResponseEntity;
28
import org.springframework.ui.Model;
30
import org.springframework.ui.Model;
29
import org.springframework.web.bind.annotation.*;
31
import org.springframework.web.bind.annotation.*;
30
 
32
 
31
import javax.servlet.http.HttpServletRequest;
33
import javax.servlet.http.HttpServletRequest;
-
 
34
import java.time.LocalDate;
32
import java.util.ArrayList;
35
import java.util.ArrayList;
33
import java.util.Arrays;
36
import java.util.Arrays;
34
import java.util.HashSet;
37
import java.util.HashSet;
35
import java.util.List;
38
import java.util.List;
36
import java.util.Map;
39
import java.util.Map;
Line 69... Line 72...
69
    private SchemeService schemeService;
72
    private SchemeService schemeService;
70
 
73
 
71
    @Autowired
74
    @Autowired
72
    private com.spice.profitmandi.dao.repository.user.CartRepository cartRepository;
75
    private com.spice.profitmandi.dao.repository.user.CartRepository cartRepository;
73
 
76
 
-
 
77
    @Autowired
-
 
78
    private PartnerTypeChangeService partnerTypeChangeService;
-
 
79
 
74
    private static final int MRP_TAG_ID = 4;
80
    private static final int MRP_TAG_ID = 4;
75
    private static final double CARRY_BAG_THRESHOLD = 12000d;
81
    private static final double CARRY_BAG_THRESHOLD = 12000d;
-
 
82
    // Premium tiers (Platinum/Diamond/Gold/Rising Star) get flat ₹1;
-
 
83
    // Silver/Bronze pay MRP from TagListing (matches CartServiceImpl.getCartValidation).
76
    private static final float CARRY_BAG_PRICE = 0.01f;
84
    private static final float CARRY_BAG_PREMIUM_PRICE = 1f;
77
 
85
 
78
    @GetMapping("/cart")
86
    @GetMapping("/cart")
79
    public ResponseEntity<ApiResponse<?>> validateCart(HttpServletRequest request,
87
    public ResponseEntity<ApiResponse<?>> validateCart(HttpServletRequest request,
80
                                                      @RequestParam(value = "pincode", defaultValue = "110001") String pincode,
88
                                                      @RequestParam(value = "pincode", defaultValue = "110001") String pincode,
81
                                                      @RequestParam int bucketId) throws Throwable {
89
                                                      @RequestParam int bucketId) throws Throwable {
Line 271... Line 279...
271
     * have their own controller.
279
     * have their own controller.
272
     */
280
     */
273
    private ResponseEntity<?> applyAndHydrate(AuthCtx ctx, List<CartItem> desired)
281
    private ResponseEntity<?> applyAndHydrate(AuthCtx ctx, List<CartItem> desired)
274
            throws ProfitMandiBusinessException {
282
            throws ProfitMandiBusinessException {
275
        enrichPrices(ctx, desired);
283
        enrichPrices(ctx, desired);
276
        rebalanceCarryBag(desired);
284
        rebalanceCarryBag(desired, ctx.storeId);
277
        cartService.addItemsToCart(ctx.cartId, desired);
285
        cartService.addItemsToCart(ctx.cartId, desired);
278
        return ResponseEntity.ok(ApiResponse.success(
286
        return ResponseEntity.ok(ApiResponse.success(
279
                cartValidationService.validateForOpen(ctx.cartId, ctx.storeId)));
287
                cartValidationService.validateForOpen(ctx.cartId, ctx.storeId)));
280
    }
288
    }
281
 
289