Subversion Repositories SmartDukaan

Rev

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

Rev 34239 Rev 34242
Line 12... Line 12...
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.cart.CartItemMessage;
-
 
17
import com.spice.profitmandi.dao.entity.WebEntity.NavBar;
17
import com.spice.profitmandi.dao.entity.catalog.Item;
18
import com.spice.profitmandi.dao.entity.catalog.Item;
18
import com.spice.profitmandi.dao.entity.catalog.TagListing;
19
import com.spice.profitmandi.dao.entity.catalog.TagListing;
19
import com.spice.profitmandi.dao.entity.dtr.*;
20
import com.spice.profitmandi.dao.entity.dtr.*;
20
import com.spice.profitmandi.dao.entity.fofo.*;
21
import com.spice.profitmandi.dao.entity.fofo.*;
21
import com.spice.profitmandi.dao.entity.inventory.State;
22
import com.spice.profitmandi.dao.entity.inventory.State;
Line 32... Line 33...
32
import com.spice.profitmandi.dao.repository.fofo.*;
33
import com.spice.profitmandi.dao.repository.fofo.*;
33
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
34
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
34
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
35
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
35
import com.spice.profitmandi.dao.repository.user.AddressRepository;
36
import com.spice.profitmandi.dao.repository.user.AddressRepository;
36
import com.spice.profitmandi.dao.repository.user.UserRepository;
37
import com.spice.profitmandi.dao.repository.user.UserRepository;
-
 
38
import com.spice.profitmandi.dao.repository.webRepository.NavBarRepository;
37
import com.spice.profitmandi.service.CustomerService;
39
import com.spice.profitmandi.service.CustomerService;
38
import com.spice.profitmandi.service.EmailService;
40
import com.spice.profitmandi.service.EmailService;
39
import com.spice.profitmandi.service.NotificationService;
41
import com.spice.profitmandi.service.NotificationService;
40
import com.spice.profitmandi.service.authentication.RoleManager;
42
import com.spice.profitmandi.service.authentication.RoleManager;
41
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
43
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
Line 210... Line 212...
210
 
212
 
211
    @Autowired
213
    @Autowired
212
    private ScratchOfferRepository scratchOfferRepository;
214
    private ScratchOfferRepository scratchOfferRepository;
213
    private static final List<String> offlineOrders = Arrays.asList("EMIOD", "POD");
215
    private static final List<String> offlineOrders = Arrays.asList("EMIOD", "POD");
214
 
216
 
-
 
217
    @Autowired
-
 
218
    NavBarRepository navBarRepository;
-
 
219
 
215
    List<String> filterableParams = Arrays.asList("brand");
220
    List<String> filterableParams = Arrays.asList("brand");
216
 
221
 
217
    @RequestMapping(value = "/store/entity/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
222
    @RequestMapping(value = "/store/entity/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
218
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
223
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
219
    @ApiOperation(value = "Get unit deal object")
224
    @ApiOperation(value = "Get unit deal object")
Line 335... Line 340...
335
    @RequestMapping(value = "/store/resetPassword", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
340
    @RequestMapping(value = "/store/resetPassword", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
336
    public ResponseEntity<?> resetPassword(@RequestBody UserModel userModel) throws Exception {
341
    public ResponseEntity<?> resetPassword(@RequestBody UserModel userModel) throws Exception {
337
        customerService.resetPassword(userModel.getMobile(), userModel.getPassword());
342
        customerService.resetPassword(userModel.getMobile(), userModel.getPassword());
338
        return responseSender.ok(true);
343
        return responseSender.ok(true);
339
    }
344
    }
-
 
345
 
340
    @RequestMapping(value = "/store/changePassword", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
346
    @RequestMapping(value = "/store/changePassword", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
341
    public ResponseEntity<?> changePassword(@RequestBody UserModel userModel) throws Exception {
347
    public ResponseEntity<?> changePassword(@RequestBody UserModel userModel) throws Exception {
342
        logger.info("UserModel - "+userModel);
348
        logger.info("UserModel - " + userModel);
343
        if(customerService.changePassword(userModel.getMobile(),  userModel.getOldPassword(),userModel.getPassword())) {
349
        if (customerService.changePassword(userModel.getMobile(), userModel.getOldPassword(), userModel.getPassword())) {
344
            return responseSender.ok(true);
350
            return responseSender.ok(true);
345
        }
-
 
346
        else {
351
        } else {
347
            throw new ProfitMandiBusinessException("error", "", "Error while changing the password ");
352
            throw new ProfitMandiBusinessException("error", "", "Error while changing the password ");
348
        }
353
        }
349
    }
354
    }
350
 
355
 
351
    @RequestMapping(value = "/store/register", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
356
    @RequestMapping(value = "/store/register", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
Line 498... Line 503...
498
 
503
 
499
        }
504
        }
500
        return responseSender.ok(returnMap);
505
        return responseSender.ok(returnMap);
501
 
506
 
502
    }
507
    }
-
 
508
 
503
    @RequestMapping(value = "/store/address", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
509
    @RequestMapping(value = "/store/address", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
504
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
510
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
505
    @ApiOperation(value = "Get brand list and count for category")
511
    @ApiOperation(value = "Get brand list and count for category")
506
    public ResponseEntity<?> getAddress(HttpServletRequest request) throws Exception {
512
    public ResponseEntity<?> getAddress(HttpServletRequest request) throws Exception {
507
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
513
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
Line 509... Line 515...
509
        CustomRetailer customRetailer = retailerService.getFofoRetailer(storeId);
515
        CustomRetailer customRetailer = retailerService.getFofoRetailer(storeId);
510
 
516
 
511
        return responseSender.ok(customRetailer.getAddress());
517
        return responseSender.ok(customRetailer.getAddress());
512
 
518
 
513
    }
519
    }
-
 
520
 
514
    @RequestMapping(value = "/store/address/defaultAddress/{addressId}/{customerId}", method = RequestMethod.POST)
521
    @RequestMapping(value = "/store/address/defaultAddress/{addressId}/{customerId}", method = RequestMethod.POST)
515
    @ApiImplicitParams({
522
    @ApiImplicitParams({
516
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")
523
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")
517
    })
524
    })
518
    @ApiOperation(value = "Set default address for a store")
525
    @ApiOperation(value = "Set default address for a store")
519
    public ResponseEntity<?> setDefaultAddress(HttpServletRequest request,@PathVariable int addressId, @PathVariable int customerId) throws Exception {
526
    public ResponseEntity<?> setDefaultAddress(HttpServletRequest request, @PathVariable int addressId, @PathVariable int customerId) throws Exception {
520
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
527
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
521
        CustomerAddress defaultAddress;
528
        CustomerAddress defaultAddress;
522
        try {
529
        try {
523
            defaultAddress = customerAddressRepository.selectById(addressId);
530
            defaultAddress = customerAddressRepository.selectById(addressId);
524
        } catch (ProfitMandiBusinessException e) {
531
        } catch (ProfitMandiBusinessException e) {
Line 868... Line 875...
868
            cashback = cashback == null ? 0 : cashback;
875
            cashback = cashback == null ? 0 : cashback;
869
            float itemSellingPrice = tagListing.getMop() - cashback;
876
            float itemSellingPrice = tagListing.getMop() - cashback;
870
            CartItemResponseModel cartItemResponseModel = new CartItemResponseModel();
877
            CartItemResponseModel cartItemResponseModel = new CartItemResponseModel();
871
            cartItemResponseModel.setSellingPrice(cartItem.getSellingPrice());
878
            cartItemResponseModel.setSellingPrice(cartItem.getSellingPrice());
872
            cartItemResponseModel.setPendingOrderItemPolicyPlan(cartItem.getPendingOrderItemPolicyPlan());
879
            cartItemResponseModel.setPendingOrderItemPolicyPlan(cartItem.getPendingOrderItemPolicyPlan());
873
            logger.info("itemSellingPrice: {}",itemSellingPrice);
880
            logger.info("itemSellingPrice: {}", itemSellingPrice);
874
            logger.info("cartItem: {}",cartItem.getSellingPrice());
881
            logger.info("cartItem: {}", cartItem.getSellingPrice());
875
            logger.info("cashback: {}",cashback);
882
            logger.info("cashback: {}", cashback);
876
            if (itemSellingPrice != cartItem.getSellingPrice()) {
883
            if (itemSellingPrice != cartItem.getSellingPrice()) {
877
                itemMsg.setType("price");
884
                itemMsg.setType("price");
878
                itemMsg.setMessageText("Price has changed to "+itemSellingPrice);
885
                itemMsg.setMessageText("Price has changed to " + itemSellingPrice);
879
                cartItemResponseModel.setSellingPrice(itemSellingPrice);
886
                cartItemResponseModel.setSellingPrice(itemSellingPrice);
880
                cartMessageChanged++;
887
                cartMessageChanged++;
881
            }
888
            }
882
            int estimate = -2;
889
            int estimate = -2;
883
            LocalDateTime promiseDeliveryTime = LocalDateTime.now();
890
            LocalDateTime promiseDeliveryTime = LocalDateTime.now();
884
            int qtyRequired = (int) cartItem.getQuantity();
891
            int qtyRequired = (int) cartItem.getQuantity();
885
            AvailabilityModel availabilityModel = inventoryItemAvailabilityMap.get(cartItem.getItemId());
892
            AvailabilityModel availabilityModel = inventoryItemAvailabilityMap.get(cartItem.getItemId());
886
            cartItemResponseModel.setMaxQuantity(availabilityModel.getMaxAvailability());
893
            cartItemResponseModel.setMaxQuantity(availabilityModel.getMaxAvailability());
887
            if (availabilityModel.getStoreAvailability() >= qtyRequired) {
894
            if (availabilityModel.getStoreAvailability() >= qtyRequired) {
888
                itemMsg.setType("estimate0");
895
                itemMsg.setType("estimate0");
889
                itemMsg.setMessageText("Store availability is "+ availabilityModel.getStoreAvailability());
896
                itemMsg.setMessageText("Store availability is " + availabilityModel.getStoreAvailability());
890
                estimate = 0;
897
                estimate = 0;
891
            } else if (availabilityModel.getWarehouseAvailability() >= qtyRequired) {
898
            } else if (availabilityModel.getWarehouseAvailability() >= qtyRequired) {
892
                itemMsg.setType("estimate2");
899
                itemMsg.setType("estimate2");
893
                itemMsg.setMessageText("Store availability is "+ availabilityModel.getWarehouseAvailability());
900
                itemMsg.setMessageText("Store availability is " + availabilityModel.getWarehouseAvailability());
894
                estimate = 2;
901
                estimate = 2;
895
            } else if (availabilityModel.getStoreAvailability() > 0) {
902
            } else if (availabilityModel.getStoreAvailability() > 0) {
896
                estimate = 0;
903
                estimate = 0;
897
                qtyRequired = availabilityModel.getStoreAvailability();
904
                qtyRequired = availabilityModel.getStoreAvailability();
898
                cartMessageChanged++;
905
                cartMessageChanged++;
899
                itemMsg.setType("quantity0");
906
                itemMsg.setType("quantity0");
900
                itemMsg.setMessageText("quantity is updated "+qtyRequired);
907
                itemMsg.setMessageText("quantity is updated " + qtyRequired);
901
            } else if (availabilityModel.getWarehouseAvailability() > 0) {
908
            } else if (availabilityModel.getWarehouseAvailability() > 0) {
902
                qtyRequired = availabilityModel.getWarehouseAvailability();
909
                qtyRequired = availabilityModel.getWarehouseAvailability();
903
                estimate = 2;
910
                estimate = 2;
904
                cartMessageChanged++;
911
                cartMessageChanged++;
905
                itemMsg.setType("quantity2");
912
                itemMsg.setType("quantity2");
906
                itemMsg.setMessageText("quantity is updated "+qtyRequired);
913
                itemMsg.setMessageText("quantity is updated " + qtyRequired);
907
            } else {
914
            } else {
908
                qtyRequired = 0;
915
                qtyRequired = 0;
909
                cartMessageChanged++;
916
                cartMessageChanged++;
910
                itemMsg.setType("item");
917
                itemMsg.setType("item");
911
                itemMsg.setMessageText(item.getItemDescriptionNoColor() + " is out of stock");
918
                itemMsg.setMessageText(item.getItemDescriptionNoColor() + " is out of stock");
Line 949... Line 956...
949
 
956
 
950
    }
957
    }
951
 
958
 
952
    @RequestMapping(value = "/store/partnerStock", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
959
    @RequestMapping(value = "/store/partnerStock", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
953
    public ResponseEntity<?> partnerStock(HttpServletRequest request, @RequestParam(required = false, defaultValue = "3") String categoryId, @RequestParam int offset,
960
    public ResponseEntity<?> partnerStock(HttpServletRequest request, @RequestParam(required = false, defaultValue = "3") String categoryId, @RequestParam int offset,
954
      @RequestParam int limit, @RequestParam(required = false) String sort, @RequestParam(required = false) String brand,
961
                                          @RequestParam int limit, @RequestParam(required = false) String sort, @RequestParam(required = false) String brand,
955
      @RequestParam(value = "subCategoryId", required = false) int subCategoryId, @RequestParam(required = false) String queryTerm,
962
                                          @RequestParam(value = "subCategoryId", required = false) int subCategoryId, @RequestParam(required = false) String queryTerm,
956
      @RequestParam(required = false) String listing, @RequestParam(required = false, defaultValue = "true") boolean partnerStockOnly) throws Throwable {
963
                                          @RequestParam(required = false) String listing, @RequestParam(required = false, defaultValue = "true") boolean partnerStockOnly) throws Throwable {
957
        List<FofoCatalogResponse> dealResponse = new ArrayList<>();
964
        List<FofoCatalogResponse> dealResponse = new ArrayList<>();
958
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
965
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
959
        FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
966
        FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
960
        sort = "w" + fs.getWarehouseId() + "_i desc";
967
        sort = "w" + fs.getWarehouseId() + "_i desc";
961
        dealResponse = this.getCatalogResponse(
968
        dealResponse = this.getCatalogResponse(
Line 1219... Line 1226...
1219
        scratchOffer.setScracthedAt(LocalDateTime.now());
1226
        scratchOffer.setScracthedAt(LocalDateTime.now());
1220
 
1227
 
1221
        return responseSender.ok(true);
1228
        return responseSender.ok(true);
1222
    }
1229
    }
1223
 
1230
 
-
 
1231
 
-
 
1232
    @RequestMapping(value = "/store/navbar", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
1233
    public ResponseEntity<?> navBars() throws Exception {
-
 
1234
        List<NavBar> navBars = navBarRepository.selectAllActive();
-
 
1235
        return responseSender.ok(navBars);
-
 
1236
    }
-
 
1237
 
-
 
1238
 
1224
}
1239
}
1225
1240