Subversion Repositories SmartDukaan

Rev

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

Rev 37630 Rev 37765
Line 30... Line 30...
30
import com.spice.profitmandi.dao.repository.warehouse.WarehouseSupplierInvoiceRepository;
30
import com.spice.profitmandi.dao.repository.warehouse.WarehouseSupplierInvoiceRepository;
31
import com.spice.profitmandi.service.PartnerInvestmentService;
31
import com.spice.profitmandi.service.PartnerInvestmentService;
32
import com.spice.profitmandi.service.authentication.RoleManager;
32
import com.spice.profitmandi.service.authentication.RoleManager;
33
import com.spice.profitmandi.service.catalog.BrandsService;
33
import com.spice.profitmandi.service.catalog.BrandsService;
34
import com.spice.profitmandi.service.inventory.InventoryService;
34
import com.spice.profitmandi.service.inventory.InventoryService;
-
 
35
import com.spice.profitmandi.dao.enumuration.fofo.StoreClosureReason;
35
import com.spice.profitmandi.service.user.RetailerService;
36
import com.spice.profitmandi.service.user.RetailerService;
-
 
37
import com.spice.profitmandi.service.user.StoreAccess;
-
 
38
import com.spice.profitmandi.service.user.StoreClosureService;
36
import com.spice.profitmandi.service.user.StoreTimelineTatService;
39
import com.spice.profitmandi.service.user.StoreTimelineTatService;
37
import com.spice.profitmandi.web.model.LoginDetails;
40
import com.spice.profitmandi.web.model.LoginDetails;
38
import com.spice.profitmandi.web.util.CookiesProcessor;
41
import com.spice.profitmandi.web.util.CookiesProcessor;
39
import com.spice.profitmandi.web.util.MVCResponseSender;
42
import com.spice.profitmandi.web.util.MVCResponseSender;
40
import org.apache.logging.log4j.LogManager;
43
import org.apache.logging.log4j.LogManager;
Line 70... Line 73...
70
    PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
73
    PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
71
    @Autowired
74
    @Autowired
72
    BrandsService brandsService;
75
    BrandsService brandsService;
73
    @Autowired
76
    @Autowired
74
    private RetailerService retailerService;
77
    private RetailerService retailerService;
-
 
78
 
-
 
79
    @Autowired
-
 
80
    private StoreClosureService storeClosureService;
75
    @Autowired
81
    @Autowired
76
    private RetailerRepository retailerRepository;
82
    private RetailerRepository retailerRepository;
77
    @Autowired
83
    @Autowired
78
    private PincodePartnerRepository pincodePartnerRepository;
84
    private PincodePartnerRepository pincodePartnerRepository;
79
    @Autowired
85
    @Autowired
Line 508... Line 514...
508
    @PostMapping(value = "/deactivateStore")
514
    @PostMapping(value = "/deactivateStore")
509
    public String deActivateStore(HttpServletRequest request,
515
    public String deActivateStore(HttpServletRequest request,
510
                                  @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
516
                                  @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
511
        FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
517
        FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
512
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
518
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
513
        if (!Arrays
-
 
514
                .asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com",
-
 
515
                        "vikas.jangra@smartdukaan.com")
-
 
516
                .contains(loginDetails.getEmailId())) {
-
 
517
            throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
-
 
518
                    "You are not authorise to deactivate retailer");
519
        StoreAccess.check(StoreAccess.DEACTIVATE, loginDetails.getEmailId(), "deactivate retailer");
519
        }
-
 
520
        if (fofoStore.isClosed()) {
520
        if (fofoStore.isClosed()) {
521
            throw new ProfitMandiBusinessException("Store Closed", "Store Already Closed",
521
            throw new ProfitMandiBusinessException("Store Closed", "Store Already Closed",
522
                    "This store is permanently closed and cannot be modified");
522
                    "This store is permanently closed and cannot be modified");
523
        }
523
        }
524
        fofoStore.setActive(false);
524
        fofoStore.setActive(false);
Line 528... Line 528...
528
    }
528
    }
529
 
529
 
530
    @PostMapping(value = "/closeStore")
530
    @PostMapping(value = "/closeStore")
531
    public String closeStore(HttpServletRequest request,
531
    public String closeStore(HttpServletRequest request,
532
                             @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId,
532
                             @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId,
533
                             @RequestParam(name = "storeCode") String storeCode, Model model) throws Exception {
533
                             @RequestParam(name = "storeCode") String storeCode,
-
 
534
                             @RequestParam(name = "reason", required = false) StoreClosureReason reason,
-
 
535
                             @RequestParam(name = "remark", required = false) String remark,
-
 
536
                             @RequestParam(name = "approvalDocumentId", defaultValue = "0") int approvalDocumentId,
534
        FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
537
                             Model model) throws Exception {
535
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
538
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
536
        if (!Arrays
-
 
537
                .asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com",
-
 
538
                        "vikas.jangra@smartdukaan.com")
-
 
539
                .contains(loginDetails.getEmailId())) {
-
 
540
            throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
-
 
541
                    "You are not authorise to close store");
-
 
542
        }
-
 
543
        if (fofoStore.isClosed()) {
-
 
544
            throw new ProfitMandiBusinessException("Store Closed", "Store Already Closed",
-
 
545
                    "This store is already permanently closed");
-
 
546
        }
-
 
547
        if (storeCode == null || !storeCode.equals(fofoStore.getCode())) {
-
 
548
            throw new ProfitMandiBusinessException("Invalid Store Code", "Store Code Mismatch",
-
 
549
                    "Please type the correct store code to confirm closure");
-
 
550
        }
-
 
551
        fofoStore.setActive(false);
-
 
552
        fofoStore.setClosed(true);
-
 
553
        fofoStore.setClosedTimestamp(LocalDateTime.now());
-
 
554
        LOGGER.info("Store {} closed permanently by {}", fofoStore.getCode(), loginDetails.getEmailId());
539
        storeClosureService.closeStore(fofoId, storeCode, reason, remark, approvalDocumentId, loginDetails.getEmailId());
555
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
540
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
556
        return "response";
541
        return "response";
557
    }
542
    }
558
 
543
 
559
    @PostMapping(value = "/activateStoreForever")
544
    @PostMapping(value = "/activateStoreForever")
560
    public String activateStoreForever(HttpServletRequest request,
545
    public String activateStoreForever(HttpServletRequest request,
561
                                       @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
546
                                       @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
562
        FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
547
        FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
563
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
548
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
564
        if (!Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com").contains(loginDetails.getEmailId())) {
-
 
565
            throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
-
 
566
                    "You are not authorise to activate retailer");
549
        StoreAccess.check(StoreAccess.ACTIVATE, loginDetails.getEmailId(), "activate retailer");
567
        }
-
 
568
        if (fofoStore.isClosed()) {
550
        if (fofoStore.isClosed()) {
569
            throw new ProfitMandiBusinessException("Store Closed", "Store Permanently Closed",
551
            throw new ProfitMandiBusinessException("Store Closed", "Store Permanently Closed",
570
                    "This store is permanently closed and cannot be reactivated");
552
                    "This store is permanently closed and cannot be reactivated");
571
        }
553
        }
572
        fofoStore.setActive(true);
554
        fofoStore.setActive(true);
Line 580... Line 562...
580
                                         @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId,
562
                                         @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId,
581
                                         @RequestParam(name = "days", required = true) int days, Model model) throws Exception {
563
                                         @RequestParam(name = "days", required = true) int days, Model model) throws Exception {
582
 
564
 
583
        FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
565
        FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
584
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
566
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
585
        if (!Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com").contains(loginDetails.getEmailId())) {
-
 
586
            throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
-
 
587
                    "You are not authorise to deactivate retailer");
567
        StoreAccess.check(StoreAccess.ACTIVATE, loginDetails.getEmailId(), "activate retailer");
588
        }
-
 
589
 
568
 
590
        if (fofoStore.isClosed()) {
569
        if (fofoStore.isClosed()) {
591
            throw new ProfitMandiBusinessException("Store Closed", "Store Permanently Closed",
570
            throw new ProfitMandiBusinessException("Store Closed", "Store Permanently Closed",
592
                    "This store is permanently closed and cannot be reactivated");
571
                    "This store is permanently closed and cannot be reactivated");
593
        }
572
        }
Line 632... Line 611...
632
    @PostMapping(value = "/extendBilling")
611
    @PostMapping(value = "/extendBilling")
633
    public String extendBilling(HttpServletRequest request,
612
    public String extendBilling(HttpServletRequest request,
634
                                @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
613
                                @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
635
        FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
614
        FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
636
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
615
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
637
        if (Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com",
-
 
638
                "mohit.gulati@smartdukaan.com").contains(loginDetails.getEmailId())) {
616
        StoreAccess.check(StoreAccess.EXTEND_BILLING, loginDetails.getEmailId(), "extend billing");
639
            fofoStore.setGraceDate(LocalDate.now().plusDays(2));
617
        fofoStore.setGraceDate(LocalDate.now().plusDays(2));
640
            fofoStore.setGraceCount(fofoStore.getGraceCount() + 1);
618
        fofoStore.setGraceCount(fofoStore.getGraceCount() + 1);
641
            model.addAttribute("response1", mvcResponseSender.createResponseString(fofoStore.getGraceCount()));
619
        model.addAttribute("response1", mvcResponseSender.createResponseString(fofoStore.getGraceCount()));
642
        } else {
-
 
643
            throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
-
 
644
                    "You are not authorise to extend billing");
-
 
645
        }
-
 
646
        return "response";
620
        return "response";
647
 
621
 
648
    }
622
    }
649
 
623
 
650
    @RequestMapping(value = "/getPromoterInfo", method = RequestMethod.GET)
624
    @RequestMapping(value = "/getPromoterInfo", method = RequestMethod.GET)