Subversion Repositories SmartDukaan

Rev

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

Rev 34024 Rev 34186
Line 11... Line 11...
11
import com.spice.profitmandi.common.util.FormattingUtils;
11
import com.spice.profitmandi.common.util.FormattingUtils;
12
import com.spice.profitmandi.common.util.PdfUtils;
12
import com.spice.profitmandi.common.util.PdfUtils;
13
import com.spice.profitmandi.common.util.Utils;
13
import com.spice.profitmandi.common.util.Utils;
14
import com.spice.profitmandi.common.web.client.RestClient;
14
import com.spice.profitmandi.common.web.client.RestClient;
15
import com.spice.profitmandi.common.web.util.ResponseSender;
15
import com.spice.profitmandi.common.web.util.ResponseSender;
-
 
16
import com.spice.profitmandi.dao.cart.CartItemMessage;
16
import com.spice.profitmandi.dao.entity.catalog.Item;
17
import com.spice.profitmandi.dao.entity.catalog.Item;
17
import com.spice.profitmandi.dao.entity.catalog.TagListing;
18
import com.spice.profitmandi.dao.entity.catalog.TagListing;
18
import com.spice.profitmandi.dao.entity.dtr.*;
19
import com.spice.profitmandi.dao.entity.dtr.*;
19
import com.spice.profitmandi.dao.entity.fofo.*;
20
import com.spice.profitmandi.dao.entity.fofo.*;
20
import com.spice.profitmandi.dao.entity.inventory.State;
21
import com.spice.profitmandi.dao.entity.inventory.State;
Line 397... Line 398...
397
            cartItems.add(ci);
398
            cartItems.add(ci);
398
        });
399
        });
399
        logger.info("cartItems {}", cartItems);
400
        logger.info("cartItems {}", cartItems);
400
        CartResponse cr = this.validateCart(storeId, cartItems);
401
        CartResponse cr = this.validateCart(storeId, cartItems);
401
        if (cr.getCartMessageChanged() > 0 || cr.getTotalAmount() != createPendingOrderRequest.getTotalAmount()) {
402
        if (cr.getCartMessageChanged() > 0 || cr.getTotalAmount() != createPendingOrderRequest.getTotalAmount()) {
402
            return responseSender.badRequest("Invalid request");
403
            return responseSender.badRequest(cr.getCartMessages());
403
        }
404
        }
404
 
405
 
405
        Map<String, String> returnMap = this.pendingOrderService.createPendingOrder(createPendingOrderRequest, cr);
406
        Map<String, String> returnMap = this.pendingOrderService.createPendingOrder(createPendingOrderRequest, cr);
406
 
407
 
407
        PendingOrder pendingOrder = pendingOrderRepository.selectById(Integer.parseInt(returnMap.get("poId")));
408
        PendingOrder pendingOrder = pendingOrderRepository.selectById(Integer.parseInt(returnMap.get("poId")));
Line 451... Line 452...
451
 
452
 
452
            emailIds.addAll(
453
            emailIds.addAll(
453
                    csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_MARKETING, Arrays.asList(EscalationType.L1, EscalationType.L2, EscalationType.L3, EscalationType.L4)).stream().map(x -> x.getEmailId()).collect(Collectors.toList()));
454
                    csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_MARKETING, Arrays.asList(EscalationType.L1, EscalationType.L2, EscalationType.L3, EscalationType.L4)).stream().map(x -> x.getEmailId()).collect(Collectors.toList()));
454
            emailIds.add("tarun.verma@smartdukaan.com");
455
            emailIds.add("tarun.verma@smartdukaan.com");
455
            emailIds.add("devkinandan.lal@smartdukaan.com");
456
            emailIds.add("devkinandan.lal@smartdukaan.com");
456
            emailIds.add("tejbeer.kaur@shop2020.in");
457
            emailIds.add("vikas.jangra@smartdukaan.com");
457
            List<User> user = dtrUserRepository.selectAllByEmailIds(emailIds);
458
            List<User> user = dtrUserRepository.selectAllByEmailIds(emailIds);
458
            List<Integer> userIds = user.stream().map(x -> x.getId()).collect(Collectors.toList());
459
            List<Integer> userIds = user.stream().map(x -> x.getId()).collect(Collectors.toList());
459
 
460
 
460
            logger.info("userIds" + userIds);
461
            logger.info("userIds" + userIds);
461
            SendNotificationModel sendNotificationModel = new SendNotificationModel();
462
            SendNotificationModel sendNotificationModel = new SendNotificationModel();
Line 817... Line 818...
817
        // cartResponse.getCartItems()
818
        // cartResponse.getCartItems()
818
        int cartMessageChanged = 0;
819
        int cartMessageChanged = 0;
819
        int cartMessageOOS = 0;
820
        int cartMessageOOS = 0;
820
        int totalAmount = 0;
821
        int totalAmount = 0;
821
        int totalQty = 0;
822
        int totalQty = 0;
-
 
823
        List<CartMessage> itemMessages = new ArrayList<>();
822
        for (CartItem cartItem : cartItems) {
824
        for (CartItem cartItem : cartItems) {
823
            Item item = itemsMap.get(cartItem.getItemId());
825
            Item item = itemsMap.get(cartItem.getItemId());
-
 
826
            CartMessage itemMsg = new CartMessage();
824
            TagListing tagListing = tagListingMap.get(cartItem.getItemId());
827
            TagListing tagListing = tagListingMap.get(cartItem.getItemId());
825
            int catalogId = itemsMap.get(cartItem.getItemId()).getCatalogItemId();
828
            int catalogId = itemsMap.get(cartItem.getItemId()).getCatalogItemId();
826
            Float cashback = schemeService.getCatalogSchemeCashBack(storeId, Arrays.asList(catalogId))
829
            Float cashback = schemeService.getCatalogSchemeCashBack(storeId, Arrays.asList(catalogId))
827
                    .get(itemsMap.get(cartItem.getItemId()).getCatalogItemId());
830
                    .get(itemsMap.get(cartItem.getItemId()).getCatalogItemId());
828
            cashback = cashback == null ? 0 : cashback;
831
            cashback = cashback == null ? 0 : cashback;
829
            float itemSellingPrice = tagListing.getMop() - cashback;
832
            float itemSellingPrice = tagListing.getMop() - cashback;
830
            CartItemResponseModel cartItemResponseModel = new CartItemResponseModel();
833
            CartItemResponseModel cartItemResponseModel = new CartItemResponseModel();
831
            cartItemResponseModel.setSellingPrice(cartItem.getSellingPrice());
834
            cartItemResponseModel.setSellingPrice(cartItem.getSellingPrice());
832
            cartItemResponseModel.setPendingOrderItemPolicyPlan(cartItem.getPendingOrderItemPolicyPlan());
835
            cartItemResponseModel.setPendingOrderItemPolicyPlan(cartItem.getPendingOrderItemPolicyPlan());
833
            if (itemSellingPrice != cartItem.getSellingPrice()) {
836
            if (itemSellingPrice != cartItem.getSellingPrice()) {
-
 
837
                itemMsg.setType("price");
-
 
838
                itemMsg.setMessageText("Price has changed to "+itemSellingPrice);
834
                cartItemResponseModel.setSellingPrice(itemSellingPrice);
839
                cartItemResponseModel.setSellingPrice(itemSellingPrice);
835
                cartMessageChanged++;
840
                cartMessageChanged++;
836
            }
841
            }
837
            int estimate = -2;
842
            int estimate = -2;
838
            LocalDateTime promiseDeliveryTime = LocalDateTime.now();
843
            LocalDateTime promiseDeliveryTime = LocalDateTime.now();
839
            int qtyRequired = (int) cartItem.getQuantity();
844
            int qtyRequired = (int) cartItem.getQuantity();
840
            AvailabilityModel availabilityModel = inventoryItemAvailabilityMap.get(cartItem.getItemId());
845
            AvailabilityModel availabilityModel = inventoryItemAvailabilityMap.get(cartItem.getItemId());
841
            cartItemResponseModel.setMaxQuantity(availabilityModel.getMaxAvailability());
846
            cartItemResponseModel.setMaxQuantity(availabilityModel.getMaxAvailability());
842
            if (availabilityModel.getStoreAvailability() >= qtyRequired) {
847
            if (availabilityModel.getStoreAvailability() >= qtyRequired) {
-
 
848
                itemMsg.setType("estimate");
-
 
849
                itemMsg.setMessageText("Store availability is "+ availabilityModel.getStoreAvailability());
843
                estimate = 0;
850
                estimate = 0;
844
            } else if (availabilityModel.getWarehouseAvailability() >= qtyRequired) {
851
            } else if (availabilityModel.getWarehouseAvailability() >= qtyRequired) {
-
 
852
                itemMsg.setType("estimate");
-
 
853
                itemMsg.setMessageText("Store availability is "+ availabilityModel.getWarehouseAvailability());
845
                estimate = 2;
854
                estimate = 2;
846
            } else if (availabilityModel.getStoreAvailability() > 0) {
855
            } else if (availabilityModel.getStoreAvailability() > 0) {
847
                estimate = 0;
856
                estimate = 0;
848
                qtyRequired = availabilityModel.getStoreAvailability();
857
                qtyRequired = availabilityModel.getStoreAvailability();
849
                cartMessageChanged++;
858
                cartMessageChanged++;
-
 
859
                itemMsg.setType("quantity0");
-
 
860
                itemMsg.setMessageText("quantity is updated "+qtyRequired);
850
            } else if (availabilityModel.getWarehouseAvailability() > 0) {
861
            } else if (availabilityModel.getWarehouseAvailability() > 0) {
851
                qtyRequired = availabilityModel.getWarehouseAvailability();
862
                qtyRequired = availabilityModel.getWarehouseAvailability();
852
                estimate = 2;
863
                estimate = 2;
853
                cartMessageChanged++;
864
                cartMessageChanged++;
-
 
865
                itemMsg.setType("quantity2");
-
 
866
                itemMsg.setMessageText("quantity is updated "+qtyRequired);
854
            } else {
867
            } else {
855
                qtyRequired = 0;
868
                qtyRequired = 0;
856
                cartMessageChanged++;
869
                cartMessageChanged++;
-
 
870
                itemMsg.setType("item");
-
 
871
                itemMsg.setMessageText(item.getItemDescriptionNoColor() + " is out of stock");
857
            }
872
            }
858
            cartItemResponseModel.setQuantity(qtyRequired);
873
            cartItemResponseModel.setQuantity(qtyRequired);
859
            if (estimate >= 0 && LocalTime.now().isAfter(CUTOFF_TIME)) {
874
            if (estimate >= 0 && LocalTime.now().isAfter(CUTOFF_TIME)) {
860
                estimate = estimate + 1;
875
                estimate = estimate + 1;
861
                promiseDeliveryTime = promiseDeliveryTime.plusDays(3);
876
                promiseDeliveryTime = promiseDeliveryTime.plusDays(3);
Line 877... Line 892...
877
            cartItemResponseModel.setMaxQuantity(availabilityModel.getMaxAvailability());
892
            cartItemResponseModel.setMaxQuantity(availabilityModel.getMaxAvailability());
878
            cartItemResponseModel.setCatalogItemId(item.getCatalogItemId());
893
            cartItemResponseModel.setCatalogItemId(item.getCatalogItemId());
879
            cartItemResponseModel.setImageUrl(contentMap.get(item.getCatalogItemId()).getString("imageUrl_s"));
894
            cartItemResponseModel.setImageUrl(contentMap.get(item.getCatalogItemId()).getString("imageUrl_s"));
880
            cartItemResponseModel.setColor(item.getColor());
895
            cartItemResponseModel.setColor(item.getColor());
881
            cartItemResponseModels.add(cartItemResponseModel);
896
            cartItemResponseModels.add(cartItemResponseModel);
-
 
897
            itemMessages.add(itemMsg);
882
        }
898
        }
883
        cartResponse.setCartItems(cartItemResponseModels);
899
        cartResponse.setCartItems(cartItemResponseModels);
-
 
900
        cartResponse.setCartMessages(itemMessages);
884
        cartResponse.setCartMessageChanged(cartMessageChanged);
901
        cartResponse.setCartMessageChanged(cartMessageChanged);
885
        cartResponse.setCartMessageOOS(cartMessageOOS);
902
        cartResponse.setCartMessageOOS(cartMessageOOS);
886
        int maxEstimate = cartItemResponseModels.stream().mapToInt(x -> x.getEstimate()).max().getAsInt();
903
        int maxEstimate = cartItemResponseModels.stream().mapToInt(x -> x.getEstimate()).max().getAsInt();
887
        cartResponse.setMaxEstimate(maxEstimate);
904
        cartResponse.setMaxEstimate(maxEstimate);
888
        cartResponse.setTotalAmount(totalAmount);
905
        cartResponse.setTotalAmount(totalAmount);
Line 892... Line 909...
892
 
909
 
893
    }
910
    }
894
 
911
 
895
    @RequestMapping(value = "/store/partnerStock", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
912
    @RequestMapping(value = "/store/partnerStock", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
896
    public ResponseEntity<?> partnerStock(HttpServletRequest request, @RequestParam(required = false, defaultValue = "3") String categoryId, @RequestParam int offset,
913
    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,
914
      @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,
915
      @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 {
916
      @RequestParam(required = false) String listing, @RequestParam(required = false, defaultValue = "true") boolean partnerStockOnly) throws Throwable {
900
        List<FofoCatalogResponse> dealResponse = new ArrayList<>();
917
        List<FofoCatalogResponse> dealResponse = new ArrayList<>();
901
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
918
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
902
        FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
919
        FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
903
        sort = "w" + fs.getWarehouseId() + "_i desc";
920
        sort = "w" + fs.getWarehouseId() + "_i desc";
904
        dealResponse = this.getCatalogResponse(
921
        dealResponse = this.getCatalogResponse(
Line 1000... Line 1017...
1000
        List<PendingOrderItem> pendingOrderItems = pendingOrderItemRepository.selectByOrderId(pendingOrder.getId());
1017
        List<PendingOrderItem> pendingOrderItems = pendingOrderItemRepository.selectByOrderId(pendingOrder.getId());
1001
        List<Integer> catalogIds = new ArrayList<>();
1018
        List<Integer> catalogIds = new ArrayList<>();
1002
        for (PendingOrderItem pendingOrderItem : pendingOrderItems) {
1019
        for (PendingOrderItem pendingOrderItem : pendingOrderItems) {
1003
            Item item = itemRepository.selectById(pendingOrderItem.getItemId());
1020
            Item item = itemRepository.selectById(pendingOrderItem.getItemId());
1004
            pendingOrderItem.setItemName(item.getItemDescription());
1021
            pendingOrderItem.setItemName(item.getItemDescription());
-
 
1022
            pendingOrderItem.setCatalogId(item.getCatalogItemId());
1005
            catalogIds.add(item.getCatalogItemId());
1023
            catalogIds.add(item.getCatalogItemId());
1006
        }
1024
        }
1007
        Map<Integer, JSONObject> contentMap = commonSolrService.getContentByCatalogIds(catalogIds);
1025
        Map<Integer, JSONObject> contentMap = commonSolrService.getContentByCatalogIds(catalogIds);
1008
        for (PendingOrderItem pendingOrderItem : pendingOrderItems) {
1026
        for (PendingOrderItem pendingOrderItem : pendingOrderItems) {
1009
            Item item = itemRepository.selectById(pendingOrderItem.getItemId());
1027
            Item item = itemRepository.selectById(pendingOrderItem.getItemId());
Line 1036... Line 1054...
1036
    @RequestMapping(value = "/store/updateCustomer", method = RequestMethod.POST)
1054
    @RequestMapping(value = "/store/updateCustomer", method = RequestMethod.POST)
1037
    public ResponseEntity<?> updateCustomerProfile(HttpServletRequest request, @RequestBody Customer customer) throws Throwable {
1055
    public ResponseEntity<?> updateCustomerProfile(HttpServletRequest request, @RequestBody Customer customer) throws Throwable {
1038
        Customer cust = customerRepository.selectById(customer.getId());
1056
        Customer cust = customerRepository.selectById(customer.getId());
1039
        cust.setGender(customer.getGender());
1057
        cust.setGender(customer.getGender());
1040
        cust.setProfileImageId(customer.getProfileImageId());
1058
        cust.setProfileImageId(customer.getProfileImageId());
-
 
1059
        cust.setEmailId(customer.getEmailId());
1041
        cust.setDob(customer.getDob());
1060
        cust.setDob(customer.getDob());
1042
        return responseSender.ok(cust);
1061
        return responseSender.ok(cust);
1043
    }
1062
    }
1044
 
1063
 
1045
    @RequestMapping(value = "/stores/{state}/{city}/{storeCode}", method = RequestMethod.GET)
1064
    @RequestMapping(value = "/stores/{state}/{city}/{storeCode}", method = RequestMethod.GET)
Line 1053... Line 1072...
1053
        html = html.replace("Buy Mobiles and Accessories at exciting prices - SmartDukaan", String.format("%s is now ONLINE. Buy Mobiles, Accessories & more | SmartDukaan", retailerName));
1072
        html = html.replace("Buy Mobiles and Accessories at exciting prices - SmartDukaan", String.format("%s is now ONLINE. Buy Mobiles, Accessories & more | SmartDukaan", retailerName));
1054
        response.getWriter().write(html);
1073
        response.getWriter().write(html);
1055
    }
1074
    }
1056
 
1075
 
1057
    @RequestMapping(value = "/cancelPendingOrderItem", method = RequestMethod.POST)
1076
    @RequestMapping(value = "/cancelPendingOrderItem", method = RequestMethod.POST)
1058
    public ResponseEntity<?> cancelPendingOrderItem(HttpServletRequest request, @RequestParam int id,
-
 
1059
 
-
 
1060
                                                    @RequestParam String statusDescription, @RequestParam String reason) throws Exception {
1077
    public ResponseEntity<?> cancelPendingOrderItem(HttpServletRequest request, @RequestParam int id, @RequestParam String statusDescription, @RequestParam String reason) throws Exception {
1061
 
1078
 
1062
        PendingOrderItem pendingOrderItem = pendingOrderItemRepository.selectById(id);
1079
        PendingOrderItem pendingOrderItem = pendingOrderItemRepository.selectById(id);
1063
        PendingOrder pendingOrder = pendingOrderRepository.selectById(pendingOrderItem.getOrderId());
1080
        PendingOrder pendingOrder = pendingOrderRepository.selectById(pendingOrderItem.getOrderId());
1064
        Customer customer = customerRepository.selectById(pendingOrder.getCustomerId());
1081
        Customer customer = customerRepository.selectById(pendingOrder.getCustomerId());
1065
        if (pendingOrderItem.getBilledTimestamp() == null) {
1082
        if (pendingOrderItem.getBilledTimestamp() == null) {
Line 1098... Line 1115...
1098
 
1115
 
1099
            String[] customerEmail = null;
1116
            String[] customerEmail = null;
1100
            if (customer.getEmailId() != null) {
1117
            if (customer.getEmailId() != null) {
1101
                customerEmail = new String[]{customer.getEmailId()};
1118
                customerEmail = new String[]{customer.getEmailId()};
1102
 
1119
 
1103
                List<String> bccTo = Arrays.asList("tejbeer.kaur@smartdukaan.com");
1120
                List<String> bccTo = Arrays.asList("vikas.jangra@smartdukaan.com");
1104
 
1121
 
1105
                emailService.sendMailWithAttachments("Order Cancellation", "order-cancellation.vm", emailModel, customerEmail, null, bccTo.toArray(new String[0]));
1122
                emailService.sendMailWithAttachments("Order Cancellation", "order-cancellation.vm", emailModel, customerEmail, null, bccTo.toArray(new String[0]));
1106
 
1123
 
1107
            }
1124
            }
1108
        }
1125
        }
Line 1114... Line 1131...
1114
    @RequestMapping(value = "/store/checkEligibilityStoreOffers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
1131
    @RequestMapping(value = "/store/checkEligibilityStoreOffers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
1115
    public ResponseEntity<?> checkEligibilityStoreOffers(HttpServletRequest request, @RequestParam(value = "id") int id) throws Exception {
1132
    public ResponseEntity<?> checkEligibilityStoreOffers(HttpServletRequest request, @RequestParam(value = "id") int id) throws Exception {
1116
 
1133
 
1117
        boolean eligibility = false;
1134
        boolean eligibility = false;
1118
 
1135
 
1119
 
-
 
1120
        List<ScratchOffer> scratchOffers = scratchOfferRepository.selectBycCustomerIdAndDate(id,
-
 
1121
                ProfitMandiConstants.SCRATCH_OFFER_START_DATE, ProfitMandiConstants.SCRATCH_OFFER_END_DATE);
1136
        List<ScratchOffer> scratchOffers = scratchOfferRepository.selectBycCustomerIdAndDate(id, ProfitMandiConstants.SCRATCH_OFFER_START_DATE, ProfitMandiConstants.SCRATCH_OFFER_END_DATE);
1122
 
1137
 
1123
        if (!scratchOffers.isEmpty()) {
1138
        if (!scratchOffers.isEmpty()) {
1124
            eligibility = true;
1139
            eligibility = true;
1125
 
1140
 
1126
        }
1141
        }
Line 1128... Line 1143...
1128
    }
1143
    }
1129
 
1144
 
1130
    @RequestMapping(value = "/store/ScratchOffers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
1145
    @RequestMapping(value = "/store/ScratchOffers", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
1131
    public ResponseEntity<?> scratchOffers(HttpServletRequest request, @RequestParam(value = "id") int id) throws Exception {
1146
    public ResponseEntity<?> scratchOffers(HttpServletRequest request, @RequestParam(value = "id") int id) throws Exception {
1132
 
1147
 
1133
        List<ScratchOffer> scratchOffers = scratchOfferRepository.selectBycCustomerIdAndDate(id,
-
 
1134
                ProfitMandiConstants.SCRATCH_OFFER_START_DATE, ProfitMandiConstants.SCRATCH_OFFER_END_DATE);
1148
        List<ScratchOffer> scratchOffers = scratchOfferRepository.selectBycCustomerIdAndDate(id, ProfitMandiConstants.SCRATCH_OFFER_START_DATE, ProfitMandiConstants.SCRATCH_OFFER_END_DATE);
1135
 
1149
 
1136
        logger.info("scratchOffers {}", scratchOffers);
1150
        logger.info("scratchOffers {}", scratchOffers);
1137
        // List<ScratchOffer> scratchOffers =
1151
        // List<ScratchOffer> scratchOffers =
1138
        // scratchOfferRepository.selectBycCustomerId(id);
1152
        // scratchOfferRepository.selectBycCustomerId(id);
1139
        for (ScratchOffer so : scratchOffers) {
1153
        for (ScratchOffer so : scratchOffers) {