Subversion Repositories SmartDukaan

Rev

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

Rev 33514 Rev 33573
Line 344... Line 344...
344
        customer.setLastName(userModel.getLastName());
344
        customer.setLastName(userModel.getLastName());
345
        customer.setMobileNumber(userModel.getMobile());
345
        customer.setMobileNumber(userModel.getMobile());
346
        return responseSender.ok(customerService.addCustomer(customer));
346
        return responseSender.ok(customerService.addCustomer(customer));
347
    }
347
    }
348
 
348
 
349
        @RequestMapping(value = "/store/checkplans", method = RequestMethod.GET)
349
    @RequestMapping(value = "/store/checkplans", method = RequestMethod.GET)
350
    public ResponseEntity<?> getInsurancePrices(HttpServletRequest request, @RequestParam float price, Model model,
350
    public ResponseEntity<?> getInsurancePrices(HttpServletRequest request, @RequestParam float price, Model model,
351
                                     @RequestParam int itemId) throws ProfitMandiBusinessException {
351
                                                @RequestParam int itemId) throws ProfitMandiBusinessException {
352
        logger.info("Request received at url : {}", request.getRequestURI());
352
        logger.info("Request received at url : {}", request.getRequestURI());
353
 
353
 
354
        try {
354
        try {
355
            Map<String, List<MobileInsurancePlan>> response = this.getPlans(price, itemId);
355
            Map<String, List<MobileInsurancePlan>> response = this.getPlans(price, itemId);
356
            List<MobileInsurancePlan> combinedPlans = new ArrayList<>();
356
            List<MobileInsurancePlan> combinedPlans = new ArrayList<>();
Line 369... Line 369...
369
    InsuranceService insuranceService;
369
    InsuranceService insuranceService;
370
 
370
 
371
    private Map<String, List<MobileInsurancePlan>> getPlans(float sellingPrice, int itemId)
371
    private Map<String, List<MobileInsurancePlan>> getPlans(float sellingPrice, int itemId)
372
            throws ProfitMandiBusinessException {
372
            throws ProfitMandiBusinessException {
373
        try {
373
        try {
374
            Map<String, List<MobileInsurancePlan>> productDurationPlans = insuranceService.getAllPlans(itemId, sellingPrice,true);
374
            Map<String, List<MobileInsurancePlan>> productDurationPlans = insuranceService.getAllPlans(itemId, sellingPrice, true);
375
            return productDurationPlans;
375
            return productDurationPlans;
376
        } catch (Exception e) {
376
        } catch (Exception e) {
377
            logger.info(e, e);
377
            logger.info(e, e);
378
            throw new ProfitMandiBusinessException("Fetch Insurance Plans", "Insurance",
378
            throw new ProfitMandiBusinessException("Fetch Insurance Plans", "Insurance",
379
                    "Could not fetch insurance Plans");
379
                    "Could not fetch insurance Plans");
Line 394... Line 394...
394
            ci.setQuantity(x.getQuantity());
394
            ci.setQuantity(x.getQuantity());
395
            ci.setSellingPrice(x.getSellingPrice());
395
            ci.setSellingPrice(x.getSellingPrice());
396
            ci.setPendingOrderItemPolicyPlan(x.getPendingOrderItemPolicyPlan());
396
            ci.setPendingOrderItemPolicyPlan(x.getPendingOrderItemPolicyPlan());
397
            cartItems.add(ci);
397
            cartItems.add(ci);
398
        });
398
        });
399
        logger.info("cartItems {}",cartItems);
399
        logger.info("cartItems {}", cartItems);
400
        CartResponse cr = this.validateCart(storeId, cartItems);
400
        CartResponse cr = this.validateCart(storeId, cartItems);
401
        if (cr.getCartMessageChanged() > 0 || cr.getTotalAmount() != createPendingOrderRequest.getTotalAmount()) {
401
        if (cr.getCartMessageChanged() > 0 || cr.getTotalAmount() != createPendingOrderRequest.getTotalAmount()) {
402
            return responseSender.badRequest("Invalid request");
402
            return responseSender.badRequest("Invalid request");
403
        }
403
        }
404
 
404
 
Line 794... Line 794...
794
    }
794
    }
795
 
795
 
796
    // Validate Cart for B2C Customers
796
    // Validate Cart for B2C Customers
797
    private CartResponse validateCart(int storeId, List<CartItem> cartItems) throws Exception {
797
    private CartResponse validateCart(int storeId, List<CartItem> cartItems) throws Exception {
798
 
798
 
799
        logger.info("cartItems {}",cartItems);
799
        logger.info("cartItems {}", cartItems);
800
        cartItems = cartItems.stream().filter(x -> x.getQuantity() > 0).collect(Collectors.toList());
800
        cartItems = cartItems.stream().filter(x -> x.getQuantity() > 0).collect(Collectors.toList());
801
        List<Integer> itemIds = cartItems.stream().map(x -> x.getItemId()).collect(Collectors.toList());
801
        List<Integer> itemIds = cartItems.stream().map(x -> x.getItemId()).collect(Collectors.toList());
802
        Map<Integer, AvailabilityModel> inventoryItemAvailabilityMap = inventoryService.getStoreAndOurStock(storeId, itemIds);
802
        Map<Integer, AvailabilityModel> inventoryItemAvailabilityMap = inventoryService.getStoreAndOurStock(storeId, itemIds);
803
        CartResponse cartResponse = new CartResponse();
803
        CartResponse cartResponse = new CartResponse();
804
        List<CartItemResponseModel> cartItemResponseModels = new ArrayList<>();
804
        List<CartItemResponseModel> cartItemResponseModels = new ArrayList<>();
Line 859... Line 859...
859
            if (estimate >= 0 && LocalTime.now().isAfter(CUTOFF_TIME)) {
859
            if (estimate >= 0 && LocalTime.now().isAfter(CUTOFF_TIME)) {
860
                estimate = estimate + 1;
860
                estimate = estimate + 1;
861
                promiseDeliveryTime = promiseDeliveryTime.plusDays(3);
861
                promiseDeliveryTime = promiseDeliveryTime.plusDays(3);
862
            }
862
            }
863
            totalQty += qtyRequired;
863
            totalQty += qtyRequired;
864
            if(cartItem.getPendingOrderItemPolicyPlan() != null){
864
            if (cartItem.getPendingOrderItemPolicyPlan() != null) {
865
                totalAmount += qtyRequired * itemSellingPrice + qtyRequired*cartItem.getPendingOrderItemPolicyPlan().getPrice() ;
865
                totalAmount += qtyRequired * itemSellingPrice + qtyRequired * cartItem.getPendingOrderItemPolicyPlan().getPrice();
866
            }else{
866
            } else {
867
                totalAmount += qtyRequired * itemSellingPrice;
867
                totalAmount += qtyRequired * itemSellingPrice;
868
            }
868
            }
869
 
869
 
870
            cartItemResponseModel.setEstimate(estimate);
870
            cartItemResponseModel.setEstimate(estimate);
871
            cartItemResponseModel.setTitle(item.getItemDescriptionNoColor());
871
            cartItemResponseModel.setTitle(item.getItemDescriptionNoColor());
Line 891... Line 891...
891
        return cartResponse;
891
        return cartResponse;
892
 
892
 
893
    }
893
    }
894
 
894
 
895
    @RequestMapping(value = "/store/partnerStock", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
895
    @RequestMapping(value = "/store/partnerStock", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
896
    public ResponseEntity<?> partnerStock(HttpServletRequest request, @RequestParam(value = "categoryId", required = false, defaultValue = "3") String categoryId, @RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit, @RequestParam(value = "sort", required = false) String sort, @RequestParam(value = "brand", required = false) String brand, @RequestParam(value = "subCategoryId", required = false) int subCategoryId, @RequestParam(value = "q", required = false) String queryTerm, @RequestParam(required = false) String listing, @RequestParam(required = false, defaultValue = "true") boolean partnerStockOnly) throws Throwable {
896
    public ResponseEntity<?> partnerStock(HttpServletRequest request, @RequestParam(required = false, defaultValue = "3") String categoryId, @RequestParam int offset,
-
 
897
                                          @RequestParam int limit, @RequestParam(required = false) String sort, @RequestParam(required = false) String brand,
-
 
898
                                          @RequestParam(value = "subCategoryId", required = false) int subCategoryId, @RequestParam(required = false) String queryTerm,
-
 
899
                                          @RequestParam(required = false) String listing, @RequestParam(required = false, defaultValue = "true") boolean partnerStockOnly) throws Throwable {
897
        List<FofoCatalogResponse> dealResponse = new ArrayList<>();
900
        List<FofoCatalogResponse> dealResponse = new ArrayList<>();
898
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
901
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
899
        FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
902
        FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
900
        sort = "w" + fs.getWarehouseId() + "_i desc";
903
        sort = "w" + fs.getWarehouseId() + "_i desc";
901
        dealResponse = this.getCatalogResponse(
904
        dealResponse = this.getCatalogResponse(
Line 1139... Line 1142...
1139
            } else {
1142
            } else {
1140
                so.setUnlocked(false);
1143
                so.setUnlocked(false);
1141
            }
1144
            }
1142
            LocalDateTime expiredTimestamp = ProfitMandiConstants.SCRATCH_OFFER_END_DATE.plusDays(1).atTime(LocalTime.MAX);
1145
            LocalDateTime expiredTimestamp = ProfitMandiConstants.SCRATCH_OFFER_END_DATE.plusDays(1).atTime(LocalTime.MAX);
1143
            so.setExpiredTimestamp(expiredTimestamp);
1146
            so.setExpiredTimestamp(expiredTimestamp);
1144
            if(LocalDateTime.now().isAfter(expiredTimestamp)) {
1147
            if (LocalDateTime.now().isAfter(expiredTimestamp)) {
1145
                so.setExpired(true);
1148
                so.setExpired(true);
1146
            }
1149
            }
1147
        }
1150
        }
1148
 
1151
 
1149
        return responseSender.ok(scratchOffers);
1152
        return responseSender.ok(scratchOffers);