Subversion Repositories SmartDukaan

Rev

Rev 35674 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 35674 Rev 35962
Line 513... Line 513...
513
                        "rahul.katyal@smartdukaan.com", "vikas.jangra@smartdukaan.com", "sm@smartdukaan.com")
513
                        "rahul.katyal@smartdukaan.com", "vikas.jangra@smartdukaan.com", "sm@smartdukaan.com")
514
                .contains(loginDetails.getEmailId())) {
514
                .contains(loginDetails.getEmailId())) {
515
            throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
515
            throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
516
                    "You are not authorise to deactivate retailer");
516
                    "You are not authorise to deactivate retailer");
517
        }
517
        }
-
 
518
        if (fofoStore.isClosed()) {
-
 
519
            throw new ProfitMandiBusinessException("Store Closed", "Store Already Closed",
-
 
520
                    "This store is permanently closed and cannot be modified");
-
 
521
        }
518
        fofoStore.setActive(false);
522
        fofoStore.setActive(false);
519
        LOGGER.info("inserted into InActiveFofoStore successfully");
523
        LOGGER.info("inserted into InActiveFofoStore successfully");
520
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
524
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
521
        return "response";
525
        return "response";
522
    }
526
    }
523
 
527
 
-
 
528
    @PostMapping(value = "/closeStore")
-
 
529
    public String closeStore(HttpServletRequest request,
-
 
530
                             @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId,
-
 
531
                             @RequestParam(name = "storeCode") String storeCode, Model model) throws Exception {
-
 
532
        FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
-
 
533
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
-
 
534
        if (!Arrays
-
 
535
                .asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com",
-
 
536
                        "rahul.katyal@smartdukaan.com", "vikas.jangra@smartdukaan.com", "sm@smartdukaan.com")
-
 
537
                .contains(loginDetails.getEmailId())) {
-
 
538
            throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
-
 
539
                    "You are not authorise to close store");
-
 
540
        }
-
 
541
        if (fofoStore.isClosed()) {
-
 
542
            throw new ProfitMandiBusinessException("Store Closed", "Store Already Closed",
-
 
543
                    "This store is already permanently closed");
-
 
544
        }
-
 
545
        if (storeCode == null || !storeCode.equals(fofoStore.getCode())) {
-
 
546
            throw new ProfitMandiBusinessException("Invalid Store Code", "Store Code Mismatch",
-
 
547
                    "Please type the correct store code to confirm closure");
-
 
548
        }
-
 
549
        fofoStore.setActive(false);
-
 
550
        fofoStore.setClosed(true);
-
 
551
        fofoStore.setClosedTimestamp(LocalDateTime.now());
-
 
552
        LOGGER.info("Store {} closed permanently by {}", fofoStore.getCode(), loginDetails.getEmailId());
-
 
553
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
-
 
554
        return "response";
-
 
555
    }
-
 
556
 
524
    @PostMapping(value = "/activateStoreForever")
557
    @PostMapping(value = "/activateStoreForever")
525
    public String activateStoreForever(HttpServletRequest request,
558
    public String activateStoreForever(HttpServletRequest request,
526
                                       @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
559
                                       @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
527
        FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
560
        FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
528
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
561
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
529
        if (!Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com",
562
        if (!Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com",
530
                "rahul.katyal@smartdukaan.com", "sm@smartdukaan.com").contains(loginDetails.getEmailId())) {
563
                "rahul.katyal@smartdukaan.com", "sm@smartdukaan.com").contains(loginDetails.getEmailId())) {
531
            throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
564
            throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
532
                    "You are not authorise to activate retailer");
565
                    "You are not authorise to activate retailer");
533
        }
566
        }
-
 
567
        if (fofoStore.isClosed()) {
-
 
568
            throw new ProfitMandiBusinessException("Store Closed", "Store Permanently Closed",
-
 
569
                    "This store is permanently closed and cannot be reactivated");
-
 
570
        }
534
        fofoStore.setActive(true);
571
        fofoStore.setActive(true);
535
        LOGGER.info("inserted into ActiveFofoStore successfully");
572
        LOGGER.info("inserted into ActiveFofoStore successfully");
536
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
573
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
537
        return "response";
574
        return "response";
538
    }
575
    }
Line 548... Line 585...
548
                "rahul.katyal@smartdukaan.com", "sm@smartdukaan.com").contains(loginDetails.getEmailId())) {
585
                "rahul.katyal@smartdukaan.com", "sm@smartdukaan.com").contains(loginDetails.getEmailId())) {
549
            throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
586
            throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
550
                    "You are not authorise to deactivate retailer");
587
                    "You are not authorise to deactivate retailer");
551
        }
588
        }
552
 
589
 
-
 
590
        if (fofoStore.isClosed()) {
-
 
591
            throw new ProfitMandiBusinessException("Store Closed", "Store Permanently Closed",
-
 
592
                    "This store is permanently closed and cannot be reactivated");
-
 
593
        }
-
 
594
 
553
        LocalDateTime currentDate = LocalDate.now().atStartOfDay();
595
        LocalDateTime currentDate = LocalDate.now().atStartOfDay();
554
 
596
 
555
        LocalDateTime EndDate = currentDate.plusDays(days);
597
        LocalDateTime EndDate = currentDate.plusDays(days);
556
        fofoStore.setActiveTimeStamp(EndDate);
598
        fofoStore.setActiveTimeStamp(EndDate);
557
 
599