Subversion Repositories SmartDukaan

Rev

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

Rev 30028 Rev 30426
Line 135... Line 135...
135
	@Autowired
135
	@Autowired
136
	private StoreTimelineTatService storeTimelineTatService;
136
	private StoreTimelineTatService storeTimelineTatService;
137
 
137
 
138
	@RequestMapping(value = "/retailerDetails", method = RequestMethod.GET)
138
	@RequestMapping(value = "/retailerDetails", method = RequestMethod.GET)
139
	public String retailerInfoByEmailIdOrMobileNumber(HttpServletRequest request,
139
	public String retailerInfoByEmailIdOrMobileNumber(HttpServletRequest request,
140
													  @RequestParam(name = ProfitMandiConstants.EMAIL_ID_OR_MOBILE_NUMBER) String emailIdOrMobileNumber,
140
			@RequestParam(name = ProfitMandiConstants.EMAIL_ID_OR_MOBILE_NUMBER) String emailIdOrMobileNumber,
141
													  Model model) throws ProfitMandiBusinessException {
141
			Model model) throws ProfitMandiBusinessException {
142
		LOGGER.info("Request Received at url {} with emailIdOrMobileNumber {}", request.getRequestURI(),
142
		LOGGER.info("Request Received at url {} with emailIdOrMobileNumber {}", request.getRequestURI(),
143
				emailIdOrMobileNumber);
143
				emailIdOrMobileNumber);
144
 
144
 
145
		Map<String, Object> map = retailerService.getByEmailIdOrMobileNumber(emailIdOrMobileNumber);
145
		Map<String, Object> map = retailerService.getByEmailIdOrMobileNumber(emailIdOrMobileNumber);
146
 
146
 
Line 164... Line 164...
164
		return "retailer-details";
164
		return "retailer-details";
165
	}
165
	}
166
 
166
 
167
	@RequestMapping(value = "/retailerDetails", method = RequestMethod.PUT)
167
	@RequestMapping(value = "/retailerDetails", method = RequestMethod.PUT)
168
	public String updateRetailerDetails(HttpServletRequest request,
168
	public String updateRetailerDetails(HttpServletRequest request,
169
										@RequestBody UpdateRetailerRequest updateRetailerRequest, Model model) throws ProfitMandiBusinessException {
169
			@RequestBody UpdateRetailerRequest updateRetailerRequest, Model model) throws ProfitMandiBusinessException {
170
		LOGGER.info("Request Received at url {} with body {}", request.getRequestURI(), updateRetailerRequest);
170
		LOGGER.info("Request Received at url {} with body {}", request.getRequestURI(), updateRetailerRequest);
171
		Map<String, Object> map = retailerService.updateRetailerDetails(updateRetailerRequest);
171
		Map<String, Object> map = retailerService.updateRetailerDetails(updateRetailerRequest);
172
 
172
 
173
		model.addAllAttributes(map);
173
		model.addAllAttributes(map);
174
		model.addAttribute("counterSizes", CounterSize.values());
174
		model.addAttribute("counterSizes", CounterSize.values());
Line 189... Line 189...
189
		return responseSender.ok(retailerService.getAllDistrictMaster(stateName));
189
		return responseSender.ok(retailerService.getAllDistrictMaster(stateName));
190
	}
190
	}
191
 
191
 
192
	@RequestMapping(value = "/retailerDocument/documentId", method = RequestMethod.GET)
192
	@RequestMapping(value = "/retailerDocument/documentId", method = RequestMethod.GET)
193
	public ResponseEntity<?> retailerDocumentById(HttpServletRequest request,
193
	public ResponseEntity<?> retailerDocumentById(HttpServletRequest request,
194
												  @RequestParam(name = ProfitMandiConstants.DOCUMENT_ID) int documentId,
194
			@RequestParam(name = ProfitMandiConstants.DOCUMENT_ID) int documentId,
195
												  @RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId) throws ProfitMandiBusinessException {
195
			@RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId) throws ProfitMandiBusinessException {
196
		Document document = documentRepository.selectById(documentId);
196
		Document document = documentRepository.selectById(documentId);
197
		Retailer retailer = retailerRepository.selectById(retailerId);
197
		Retailer retailer = retailerRepository.selectById(retailerId);
198
 
198
 
199
		if (retailer.getDocumentId() == null) {
199
		if (retailer.getDocumentId() == null) {
200
			throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID, retailer.getId(), "RTLR_1012");
200
			throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID, retailer.getId(), "RTLR_1012");
Line 205... Line 205...
205
		return responseSender.ok(document);
205
		return responseSender.ok(document);
206
	}
206
	}
207
 
207
 
208
	@RequestMapping(value = "/retailerDocument/download", method = RequestMethod.GET)
208
	@RequestMapping(value = "/retailerDocument/download", method = RequestMethod.GET)
209
	public ResponseEntity<?> downloadRetailerDocument(HttpServletRequest request,
209
	public ResponseEntity<?> downloadRetailerDocument(HttpServletRequest request,
210
													  @RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId, Model model)
210
			@RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId, Model model)
211
			throws ProfitMandiBusinessException {
211
			throws ProfitMandiBusinessException {
212
 
212
 
213
		Retailer retailer = retailerRepository.selectById(retailerId);
213
		Retailer retailer = retailerRepository.selectById(retailerId);
214
 
214
 
215
		if (retailer.getDocumentId() == null) {
215
		if (retailer.getDocumentId() == null) {
Line 248... Line 248...
248
		// responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
248
		// responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
249
	}
249
	}
250
 
250
 
251
	@RequestMapping(value = "/retailerShopDocument/shopId", method = RequestMethod.GET)
251
	@RequestMapping(value = "/retailerShopDocument/shopId", method = RequestMethod.GET)
252
	public ResponseEntity<?> retailerShopDocumentById(HttpServletRequest request,
252
	public ResponseEntity<?> retailerShopDocumentById(HttpServletRequest request,
253
													  @RequestParam(name = ProfitMandiConstants.SHOP_ID) int shopId,
253
			@RequestParam(name = ProfitMandiConstants.SHOP_ID) int shopId,
254
													  @RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId) throws ProfitMandiBusinessException {
254
			@RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId) throws ProfitMandiBusinessException {
255
		Shop shop = shopRepository.selectById(shopId);
255
		Shop shop = shopRepository.selectById(shopId);
256
 
256
 
257
		if (shop.getRetailerId() != retailerId) {
257
		if (shop.getRetailerId() != retailerId) {
258
			throw new ProfitMandiBusinessException(ProfitMandiConstants.SHOP_ID, shop.getId(), "SHP_1004");
258
			throw new ProfitMandiBusinessException(ProfitMandiConstants.SHOP_ID, shop.getId(), "SHP_1004");
259
		}
259
		}
Line 266... Line 266...
266
		return responseSender.ok(document);
266
		return responseSender.ok(document);
267
	}
267
	}
268
 
268
 
269
	@RequestMapping(value = "/retailerShopDocument/download", method = RequestMethod.GET)
269
	@RequestMapping(value = "/retailerShopDocument/download", method = RequestMethod.GET)
270
	public ResponseEntity<?> downloadRetailerShopDocument(HttpServletRequest request,
270
	public ResponseEntity<?> downloadRetailerShopDocument(HttpServletRequest request,
271
														  @RequestParam(name = ProfitMandiConstants.SHOP_ID) int shopId,
271
			@RequestParam(name = ProfitMandiConstants.SHOP_ID) int shopId,
272
														  @RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId, Model model)
272
			@RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId, Model model)
273
			throws ProfitMandiBusinessException {
273
			throws ProfitMandiBusinessException {
274
 
274
 
275
		Shop shop = shopRepository.selectById(shopId);
275
		Shop shop = shopRepository.selectById(shopId);
276
 
276
 
277
		if (shop.getRetailerId() != retailerId) {
277
		if (shop.getRetailerId() != retailerId) {
Line 317... Line 317...
317
	@GetMapping(value = "/getstore")
317
	@GetMapping(value = "/getstore")
318
	public String getstore(HttpServletRequest request, Model model) {
318
	public String getstore(HttpServletRequest request, Model model) {
319
 
319
 
320
		List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
320
		List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
321
				.collect(Collectors.toList());
321
				.collect(Collectors.toList());
322
		;
322
 
323
		Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = retailerService.getFofoRetailers(fofoIds);
323
		Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
-
 
324
 
-
 
325
		Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = fofoIds.stream().map(x -> customRetailerMap.get(x))
-
 
326
				.filter(x -> x != null).collect(Collectors.toList()).stream()
-
 
327
				.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
328
 
324
		LOGGER.info("fofoIds" + fofoIds);
329
		LOGGER.info("fofoIds" + fofoIds);
325
		model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
330
		model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
326
		LOGGER.info("fofoIdsAndCustomRetailer" + fofoIdsAndCustomRetailer);
331
		LOGGER.info("fofoIdsAndCustomRetailer" + fofoIdsAndCustomRetailer);
327
		model.addAttribute("fofoIds", fofoIds);
332
		model.addAttribute("fofoIds", fofoIds);
328
 
333
 
329
 
-
 
330
		return "store";
334
		return "store";
331
 
335
 
332
	}
336
	}
333
 
337
 
334
	@RequestMapping(value = "/getPartnerinfo")
338
	@RequestMapping(value = "/getPartnerinfo")
335
	public String getPartnerinfo(HttpServletRequest request,
339
	public String getPartnerinfo(HttpServletRequest request, @RequestBody SelectStorePartnerInfo selectStorePartnerInfo,
336
								 @RequestBody SelectStorePartnerInfo selectStorePartnerInfo, Model model) throws ProfitMandiBusinessException {
340
			Model model) throws ProfitMandiBusinessException {
337
 
341
 
338
		LOGGER.info("selectStorePartnerInfo" + selectStorePartnerInfo.getUserIds());
342
		LOGGER.info("selectStorePartnerInfo" + selectStorePartnerInfo.getUserIds());
339
		List<FofoStore> fofoStores = fofoStoreRepository.selectByRetailerIds(selectStorePartnerInfo.getUserIds());
343
		List<FofoStore> fofoStores = fofoStoreRepository.selectByRetailerIds(selectStorePartnerInfo.getUserIds());
340
		LOGGER.info("fofoStoresInfo" + fofoStores);
344
		LOGGER.info("fofoStoresInfo" + fofoStores);
341
		Map<Integer, Boolean> investments = new HashMap<>();
345
		Map<Integer, Boolean> investments = new HashMap<>();
Line 366... Line 370...
366
 
370
 
367
		return "store-investment";
371
		return "store-investment";
368
 
372
 
369
	}
373
	}
370
 
374
 
371
 
-
 
372
	@GetMapping(value = "/getAllStores")
375
	@GetMapping(value = "/getAllStores")
373
	public String getAllStores(HttpServletRequest request, Model model) {
376
	public String getAllStores(HttpServletRequest request, Model model) {
374
 
377
 
375
		List<FofoStore> fofoStores = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive())
378
		List<FofoStore> fofoStores = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive())
376
				.collect(Collectors.toList());
379
				.collect(Collectors.toList());
Line 415... Line 418...
415
		return "partner-category";
418
		return "partner-category";
416
	}
419
	}
417
 
420
 
418
	@PostMapping(value = "/updatePartnerCategory")
421
	@PostMapping(value = "/updatePartnerCategory")
419
	public String updatePartnerCategory(HttpServletRequest request, @RequestParam(name = "fofoId") int fofoId,
422
	public String updatePartnerCategory(HttpServletRequest request, @RequestParam(name = "fofoId") int fofoId,
420
										@RequestParam(name = "partnerType") PartnerType partnerType, Model model) throws Exception {
423
			@RequestParam(name = "partnerType") PartnerType partnerType, Model model) throws Exception {
421
 
424
 
422
		PartnerTypeChange ptc = new PartnerTypeChange();
425
		PartnerTypeChange ptc = new PartnerTypeChange();
423
		ptc.setFofoId(fofoId);
426
		ptc.setFofoId(fofoId);
424
		ptc.setPartnerType(partnerType);
427
		ptc.setPartnerType(partnerType);
425
		ptc.setCreateTimestamp(LocalDate.now().atStartOfDay().plusDays(1));
428
		ptc.setCreateTimestamp(LocalDate.now().atStartOfDay().plusDays(1));
Line 438... Line 441...
438
		return "response";
441
		return "response";
439
	}
442
	}
440
 
443
 
441
	@PostMapping(value = "/deactivateStore")
444
	@PostMapping(value = "/deactivateStore")
442
	public String deActivateStore(HttpServletRequest request,
445
	public String deActivateStore(HttpServletRequest request,
443
								  @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
446
			@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
444
		FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
447
		FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
445
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
448
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
446
		if (!Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com")
449
		if (!Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com")
447
				.contains(loginDetails.getEmailId())) {
450
				.contains(loginDetails.getEmailId())) {
448
			throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
451
			throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
Line 455... Line 458...
455
		return "response";
458
		return "response";
456
	}
459
	}
457
 
460
 
458
	@PostMapping(value = "/activateStoreForever")
461
	@PostMapping(value = "/activateStoreForever")
459
	public String activateStoreForever(HttpServletRequest request,
462
	public String activateStoreForever(HttpServletRequest request,
460
									   @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
463
			@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
461
		FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
464
		FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
462
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
465
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
463
		if (!Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com",
466
		if (!Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com",
464
				"manish.tiwari@smartdukaan.com").contains(loginDetails.getEmailId())) {
467
				"manish.tiwari@smartdukaan.com").contains(loginDetails.getEmailId())) {
465
			throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
468
			throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
Line 472... Line 475...
472
		return "response";
475
		return "response";
473
	}
476
	}
474
 
477
 
475
	@PostMapping(value = "/activateStoreTemporary")
478
	@PostMapping(value = "/activateStoreTemporary")
476
	public String activateStoreTemporary(HttpServletRequest request,
479
	public String activateStoreTemporary(HttpServletRequest request,
477
										 @RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId,
480
			@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId,
478
										 @RequestParam(name = "days", required = true) int days, Model model) throws Exception {
481
			@RequestParam(name = "days", required = true) int days, Model model) throws Exception {
479
 
482
 
480
		FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
483
		FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
481
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
484
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
482
		if (!Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com",
485
		if (!Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com",
483
				"manish.tiwari@smartdukaan.com").contains(loginDetails.getEmailId())) {
486
				"manish.tiwari@smartdukaan.com").contains(loginDetails.getEmailId())) {
Line 506... Line 509...
506
	}
509
	}
507
 
510
 
508
	@GetMapping(value = "/getAllInactiveStores")
511
	@GetMapping(value = "/getAllInactiveStores")
509
	public String getInactiveStores(HttpServletRequest request, Model model) {
512
	public String getInactiveStores(HttpServletRequest request, Model model) {
510
		List<FofoStore> inActiveFofoStores = fofoStoreRepository.selectInActiveStore();
513
		List<FofoStore> inActiveFofoStores = fofoStoreRepository.selectInActiveStore();
-
 
514
 
511
		Map<Integer, CustomRetailer> customRetailers = retailerService
515
		Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
-
 
516
 
512
				.getFofoRetailers(inActiveFofoStores.stream().map(x -> x.getId()).collect(Collectors.toList()));
517
		Map<Integer, CustomRetailer> customRetailers = inActiveFofoStores.stream().map(x -> customRetailerMap.get(x))
-
 
518
				.filter(x -> x != null).collect(Collectors.toList()).stream()
-
 
519
				.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
520
 
513
		model.addAttribute("inActiveFofoStores", inActiveFofoStores);
521
		model.addAttribute("inActiveFofoStores", inActiveFofoStores);
514
		model.addAttribute("customRetailers", customRetailers);
522
		model.addAttribute("customRetailers", customRetailers);
515
		return "inactive-stores";
523
		return "inactive-stores";
516
	}
524
	}
517
 
525
 
518
	// Extend billing for 2 days
526
	// Extend billing for 2 days
519
	@PostMapping(value = "/extendBilling")
527
	@PostMapping(value = "/extendBilling")
520
	public String extendBilling(HttpServletRequest request,
528
	public String extendBilling(HttpServletRequest request,
521
								@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
529
			@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
522
		FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
530
		FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
523
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
531
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
524
		if (Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "prakash.rai@smartdukaan.com",
532
		if (Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "prakash.rai@smartdukaan.com",
525
				"amit.gupta@smartdukaan.com").contains(loginDetails.getEmailId())) {
533
				"amit.gupta@smartdukaan.com").contains(loginDetails.getEmailId())) {
526
			fofoStore.setGraceDate(LocalDate.now().plusDays(2));
534
			fofoStore.setGraceDate(LocalDate.now().plusDays(2));
Line 535... Line 543...
535
 
543
 
536
	}
544
	}
537
 
545
 
538
	@RequestMapping(value = "/getPromoterInfo", method = RequestMethod.GET)
546
	@RequestMapping(value = "/getPromoterInfo", method = RequestMethod.GET)
539
	public String getPromoterInfo(HttpServletRequest request,
547
	public String getPromoterInfo(HttpServletRequest request,
540
								  @RequestParam(name = "offset", defaultValue = "0") int offset,
548
			@RequestParam(name = "offset", defaultValue = "0") int offset,
541
								  @RequestParam(name = "limit", defaultValue = "10") int limit,
549
			@RequestParam(name = "limit", defaultValue = "10") int limit,
542
								  @RequestParam(name = "fofoId", required = false, defaultValue = "0") int fofoId, Model model)
550
			@RequestParam(name = "fofoId", required = false, defaultValue = "0") int fofoId, Model model)
543
			throws Exception {
551
			throws Exception {
544
		LOGGER.info("requested url : " + request.getRequestURL().toString());
552
		LOGGER.info("requested url : " + request.getRequestURL().toString());
545
		List<Promoter> promoterInfo = null;
553
		List<Promoter> promoterInfo = null;
546
 
554
 
547
		long size = 0;
555
		long size = 0;
548
 
556
 
549
		List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
557
		List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
550
				.collect(Collectors.toList());
558
				.collect(Collectors.toList());
-
 
559
 
551
		Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(fofoIds);
560
		Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
-
 
561
 
-
 
562
		Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> customRetailerMap.get(x))
-
 
563
				.filter(x -> x != null).collect(Collectors.toList()).stream()
-
 
564
				.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
552
		String customRetailers = JSONObject.valueToString(customRetailersMap.values());
565
		String customRetailers = JSONObject.valueToString(customRetailersMap.values());
553
		Set<String> brands = inventoryService.getAllTagListingBrands(ProfitMandiConstants.MOBILE_CATEGORY_ID);
566
		Set<String> brands = inventoryService.getAllTagListingBrands(ProfitMandiConstants.MOBILE_CATEGORY_ID);
554
		brands.add("Airtel");
567
		brands.add("Airtel");
555
		brands.add("Vodafone");
568
		brands.add("Vodafone");
556
		brands.add("Idea");
569
		brands.add("Idea");
Line 576... Line 589...
576
				partnerIds.add(promoterdetail.getRetailerId());
589
				partnerIds.add(promoterdetail.getRetailerId());
577
			}
590
			}
578
			Map<Integer, CustomRetailer> partnersMap = null;
591
			Map<Integer, CustomRetailer> partnersMap = null;
579
			if (!partnerIds.equals(null)) {
592
			if (!partnerIds.equals(null)) {
580
				LOGGER.info("partnerIds" + partnerIds);
593
				LOGGER.info("partnerIds" + partnerIds);
-
 
594
 
581
				partnersMap = retailerService.getFofoRetailers(partnerIds);
595
				partnersMap = partnerIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null)
-
 
596
						.collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
597
 
582
			}
598
			}
583
 
599
 
584
			LOGGER.info("partnerIds" + partnersMap);
600
			LOGGER.info("partnerIds" + partnersMap);
585
			model.addAttribute("promoterInfo", promoterInfo);
601
			model.addAttribute("promoterInfo", promoterInfo);
586
			model.addAttribute("partnersMap", partnersMap);
602
			model.addAttribute("partnersMap", partnersMap);
Line 601... Line 617...
601
 
617
 
602
	}
618
	}
603
 
619
 
604
	@RequestMapping(value = "/getPaginatedPromoterInfo", method = RequestMethod.GET)
620
	@RequestMapping(value = "/getPaginatedPromoterInfo", method = RequestMethod.GET)
605
	public String getPaginatedPromoterInfo(HttpServletRequest request,
621
	public String getPaginatedPromoterInfo(HttpServletRequest request,
606
										   @RequestParam(name = "offset", defaultValue = "0") int offset,
622
			@RequestParam(name = "offset", defaultValue = "0") int offset,
607
										   @RequestParam(name = "limit", defaultValue = "10") int limit,
623
			@RequestParam(name = "limit", defaultValue = "10") int limit,
608
										   @RequestParam(name = "fofoId", required = false, defaultValue = "0") int fofoId, Model model)
624
			@RequestParam(name = "fofoId", required = false, defaultValue = "0") int fofoId, Model model)
609
			throws ProfitMandiBusinessException {
625
			throws ProfitMandiBusinessException {
610
		LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
626
		LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
611
		List<Promoter> promoterInfo = null;
627
		List<Promoter> promoterInfo = null;
612
		if (fofoId != 0) {
628
		if (fofoId != 0) {
613
			promoterInfo = promoterRepository.selectAllPromoterByFofoId(fofoId, offset, limit);
629
			promoterInfo = promoterRepository.selectAllPromoterByFofoId(fofoId, offset, limit);
Line 622... Line 638...
622
				partnerIds.add(promoterdetail.getRetailerId());
638
				partnerIds.add(promoterdetail.getRetailerId());
623
			}
639
			}
624
			Map<Integer, CustomRetailer> partnersMap = null;
640
			Map<Integer, CustomRetailer> partnersMap = null;
625
			if (!partnerIds.equals(null)) {
641
			if (!partnerIds.equals(null)) {
626
				LOGGER.info("partnerIds" + partnerIds);
642
				LOGGER.info("partnerIds" + partnerIds);
-
 
643
 
627
				partnersMap = retailerService.getFofoRetailers(partnerIds);
644
				Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
-
 
645
 
-
 
646
				partnersMap = partnerIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null)
-
 
647
						.collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
-
 
648
 
628
			}
649
			}
629
 
650
 
630
			LOGGER.info("partnerIds" + partnersMap);
651
			LOGGER.info("partnerIds" + partnersMap);
631
			model.addAttribute("promoterInfo", promoterInfo);
652
			model.addAttribute("promoterInfo", promoterInfo);
632
			model.addAttribute("partnersMap", partnersMap);
653
			model.addAttribute("partnersMap", partnersMap);
Line 639... Line 660...
639
		return "promoter-info-paginated";
660
		return "promoter-info-paginated";
640
	}
661
	}
641
 
662
 
642
	@RequestMapping(value = "/createPromoter", method = RequestMethod.POST)
663
	@RequestMapping(value = "/createPromoter", method = RequestMethod.POST)
643
	public String createPromoter(HttpServletRequest request, @RequestBody PromoterDetailModel promoterdetailModel,
664
	public String createPromoter(HttpServletRequest request, @RequestBody PromoterDetailModel promoterdetailModel,
644
								 Model model) throws Exception {
665
			Model model) throws Exception {
645
		LOGGER.info("requested url : " + request.getRequestURL().toString());
666
		LOGGER.info("requested url : " + request.getRequestURL().toString());
646
		LOGGER.info("requested url : " + promoterdetailModel);
667
		LOGGER.info("requested url : " + promoterdetailModel);
647
		Promoter promoter = promoterRepository.selectById(promoterdetailModel.getId());
668
		Promoter promoter = promoterRepository.selectById(promoterdetailModel.getId());
648
		if (promoter == null) {
669
		if (promoter == null) {
649
			promoter = new Promoter();
670
			promoter = new Promoter();
Line 681... Line 702...
681
 
702
 
682
	}
703
	}
683
 
704
 
684
	@RequestMapping(value = "/removePromoterfromPartnerStore", method = RequestMethod.POST)
705
	@RequestMapping(value = "/removePromoterfromPartnerStore", method = RequestMethod.POST)
685
	public String removePromoterfromPartnerStore(HttpServletRequest request,
706
	public String removePromoterfromPartnerStore(HttpServletRequest request,
686
												 @RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
707
			@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
687
 
708
 
688
		Promoter promoter = promoterRepository.selectById(id);
709
		Promoter promoter = promoterRepository.selectById(id);
689
 
710
 
690
		promoter.setStatus(false);
711
		promoter.setStatus(false);
691
		promoterRepository.persist(promoter);
712
		promoterRepository.persist(promoter);
Line 719... Line 740...
719
 
740
 
720
	}
741
	}
721
 
742
 
722
	@RequestMapping(value = "/updateLocation", method = RequestMethod.POST)
743
	@RequestMapping(value = "/updateLocation", method = RequestMethod.POST)
723
	public String updateLocation(HttpServletRequest request, @RequestBody AddLocationModel addLocationModel,
744
	public String updateLocation(HttpServletRequest request, @RequestBody AddLocationModel addLocationModel,
724
								 Model model) throws Exception {
745
			Model model) throws Exception {
725
 
746
 
726
		Location userlocation = locationRepository.selectById(addLocationModel.getUserId());
747
		Location userlocation = locationRepository.selectById(addLocationModel.getUserId());
727
 
748
 
728
		userlocation.setName(addLocationModel.getName());
749
		userlocation.setName(addLocationModel.getName());
729
		userlocation.setCity(addLocationModel.getCity());
750
		userlocation.setCity(addLocationModel.getCity());
Line 780... Line 801...
780
 
801
 
781
	}
802
	}
782
 
803
 
783
	@RequestMapping(value = "/getBlockBrand")
804
	@RequestMapping(value = "/getBlockBrand")
784
	public String getBlockBrand(HttpServletRequest request,
805
	public String getBlockBrand(HttpServletRequest request,
785
								@RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model)
806
			@RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model)
786
			throws Exception {
807
			throws Exception {
787
 
808
 
788
		List<RetailerBlockBrands> retailerBlockBrands = retailerBlockBrandsRepository.selectAllByBrands(brand);
809
		List<RetailerBlockBrands> retailerBlockBrands = retailerBlockBrandsRepository.selectAllByBrands(brand);
789
 
810
 
790
		List<Integer> blockBrandPartners = retailerBlockBrands.stream().map(x -> x.getFofoId())
811
		List<Integer> blockBrandPartners = retailerBlockBrands.stream().map(x -> x.getFofoId())
Line 800... Line 821...
800
 
821
 
801
	}
822
	}
802
 
823
 
803
	@RequestMapping(value = "/getRetailerBlockBrandMappping", method = RequestMethod.POST)
824
	@RequestMapping(value = "/getRetailerBlockBrandMappping", method = RequestMethod.POST)
804
	public String getBlockBrandMappping(HttpServletRequest request,
825
	public String getBlockBrandMappping(HttpServletRequest request,
805
										@RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
826
			@RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
806
										@RequestParam(name = "fofoIds", required = true, defaultValue = "0") List<Integer> fofoIds, Model model)
827
			@RequestParam(name = "fofoIds", required = true, defaultValue = "0") List<Integer> fofoIds, Model model)
807
			throws Exception {
828
			throws Exception {
808
		List<RetailerBlockBrands> retailerBlockBrands = retailerBlockBrandsRepository.selectAllByBrands(brand);
829
		List<RetailerBlockBrands> retailerBlockBrands = retailerBlockBrandsRepository.selectAllByBrands(brand);
809
		if (!retailerBlockBrands.isEmpty()) {
830
		if (!retailerBlockBrands.isEmpty()) {
810
			retailerBlockBrandsRepository.deleteAllbyBrands(brand);
831
			retailerBlockBrandsRepository.deleteAllbyBrands(brand);
811
		}
832
		}
Line 911... Line 932...
911
 
932
 
912
	}
933
	}
913
 
934
 
914
	@RequestMapping(value = "/getRetailerBrandslimitMapping", method = RequestMethod.GET)
935
	@RequestMapping(value = "/getRetailerBrandslimitMapping", method = RequestMethod.GET)
915
	public String getRetailerBrandslimit(HttpServletRequest request,
936
	public String getRetailerBrandslimit(HttpServletRequest request,
916
										 @RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model)
937
			@RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model)
917
			throws Exception {
938
			throws Exception {
918
 
939
 
919
		Map<Integer, CustomRetailer> customRetailers = retailerService.getFofoRetailers(true);
940
		Map<Integer, CustomRetailer> customRetailers = retailerService.getFofoRetailers(true);
920
		List<RetailerBrandsLimit> retailerBrandsLimit = retailerBrandsLimitRepository.setAllLimitByBrands(brand);
941
		List<RetailerBrandsLimit> retailerBrandsLimit = retailerBrandsLimitRepository.setAllLimitByBrands(brand);
921
		Map<Integer, RetailerBrandsLimit> retailerBrandsLimitMap = retailerBrandsLimit.stream()
942
		Map<Integer, RetailerBrandsLimit> retailerBrandsLimitMap = retailerBrandsLimit.stream()
Line 930... Line 951...
930
		model.addAttribute("brandLimit", brandLimit);
951
		model.addAttribute("brandLimit", brandLimit);
931
 
952
 
932
		return "brands-limit-mapping";
953
		return "brands-limit-mapping";
933
 
954
 
934
	}
955
	}
-
 
956
 
935
	@RequestMapping(value = "/setBrandWiseLimit", method = RequestMethod.POST)
957
	@RequestMapping(value = "/setBrandWiseLimit", method = RequestMethod.POST)
936
	public String brandwiseLimit(HttpServletRequest request,
958
	public String brandwiseLimit(HttpServletRequest request,
937
			@RequestParam(name = "brands", required = true, defaultValue = "") String brands,
959
			@RequestParam(name = "brands", required = true, defaultValue = "") String brands,
938
			@RequestParam(name = "limit", required = true, defaultValue = "") float limit, Model model)
960
			@RequestParam(name = "limit", required = true, defaultValue = "") float limit, Model model)
939
			throws Exception {
961
			throws Exception {
Line 1024... Line 1046...
1024
 
1046
 
1025
	}
1047
	}
1026
 
1048
 
1027
	@RequestMapping(value = "/setPartnerPincode", method = RequestMethod.POST)
1049
	@RequestMapping(value = "/setPartnerPincode", method = RequestMethod.POST)
1028
	public String setPartnerPincode(HttpServletRequest request,
1050
	public String setPartnerPincode(HttpServletRequest request,
1029
									@RequestParam(name = "pincode", required = true, defaultValue = "") String pincode,
1051
			@RequestParam(name = "pincode", required = true, defaultValue = "") String pincode,
1030
									@RequestParam(name = "fofoId", required = true, defaultValue = "") int fofoId, Model model)
1052
			@RequestParam(name = "fofoId", required = true, defaultValue = "") int fofoId, Model model)
1031
			throws Exception {
1053
			throws Exception {
1032
 
1054
 
1033
		if (!pincode.equals("")) {
1055
		if (!pincode.equals("")) {
1034
			PincodePartner pinPartner = new PincodePartner();
1056
			PincodePartner pinPartner = new PincodePartner();
1035
			pinPartner.setFofoId(fofoId);
1057
			pinPartner.setFofoId(fofoId);
Line 1046... Line 1068...
1046
 
1068
 
1047
	}
1069
	}
1048
 
1070
 
1049
	@RequestMapping(value = "/removePartnerPincode", method = RequestMethod.POST)
1071
	@RequestMapping(value = "/removePartnerPincode", method = RequestMethod.POST)
1050
	public String removePartnerPincode(HttpServletRequest request, @RequestParam int id,
1072
	public String removePartnerPincode(HttpServletRequest request, @RequestParam int id,
1051
									   @RequestParam(name = "fofoId", required = true, defaultValue = "") int fofoId, Model model)
1073
			@RequestParam(name = "fofoId", required = true, defaultValue = "") int fofoId, Model model)
1052
			throws Exception {
1074
			throws Exception {
1053
 
1075
 
1054
		PincodePartnerRepository.delete(id);
1076
		PincodePartnerRepository.delete(id);
1055
 
1077
 
1056
		List<PincodePartner> partnerPincodeList = PincodePartnerRepository.selectByPartnerId(fofoId);
1078
		List<PincodePartner> partnerPincodeList = PincodePartnerRepository.selectByPartnerId(fofoId);
Line 1063... Line 1085...
1063
 
1085
 
1064
	}
1086
	}
1065
 
1087
 
1066
	@RequestMapping(value = "/removeSearchPincode", method = RequestMethod.POST)
1088
	@RequestMapping(value = "/removeSearchPincode", method = RequestMethod.POST)
1067
	public String removeSearchPincode(HttpServletRequest request, @RequestParam int id,
1089
	public String removeSearchPincode(HttpServletRequest request, @RequestParam int id,
1068
									  @RequestParam(name = "pin", required = true, defaultValue = "") String pin,
1090
			@RequestParam(name = "pin", required = true, defaultValue = "") String pin,
1069
									  @RequestParam(name = "fofoId", required = true, defaultValue = "") int fofoId, Model model)
1091
			@RequestParam(name = "fofoId", required = true, defaultValue = "") int fofoId, Model model)
1070
			throws Exception {
1092
			throws Exception {
1071
 
1093
 
1072
		PincodePartnerRepository.delete(id);
1094
		PincodePartnerRepository.delete(id);
1073
 
1095
 
1074
		List<PincodePartner> partnerPincodeList = PincodePartnerRepository.selectPartnersByPincode(pin);
1096
		List<PincodePartner> partnerPincodeList = PincodePartnerRepository.selectPartnersByPincode(pin);
Line 1083... Line 1105...
1083
 
1105
 
1084
	}
1106
	}
1085
 
1107
 
1086
	@RequestMapping(value = "/searchPincodePartner", method = RequestMethod.GET)
1108
	@RequestMapping(value = "/searchPincodePartner", method = RequestMethod.GET)
1087
	public String searchPincodePartner(HttpServletRequest request,
1109
	public String searchPincodePartner(HttpServletRequest request,
1088
									   @RequestParam(name = "pincode", required = true, defaultValue = "") String pincode, Model model)
1110
			@RequestParam(name = "pincode", required = true, defaultValue = "") String pincode, Model model)
1089
			throws Exception {
1111
			throws Exception {
1090
 
1112
 
1091
		List<PincodePartner> partnerPincodeList = PincodePartnerRepository.selectPartnersByPincode(pincode);
1113
		List<PincodePartner> partnerPincodeList = PincodePartnerRepository.selectPartnersByPincode(pincode);
1092
 
1114
 
1093
		Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(true);
1115
		Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(true);
Line 1100... Line 1122...
1100
 
1122
 
1101
	}
1123
	}
1102
 
1124
 
1103
	@RequestMapping(value = "/showPartnerPincode", method = RequestMethod.GET)
1125
	@RequestMapping(value = "/showPartnerPincode", method = RequestMethod.GET)
1104
	public String showPartnerPincode(HttpServletRequest request,
1126
	public String showPartnerPincode(HttpServletRequest request,
1105
									 @RequestParam(name = "partnerId", required = true, defaultValue = "") int partnerId, Model model)
1127
			@RequestParam(name = "partnerId", required = true, defaultValue = "") int partnerId, Model model)
1106
			throws Exception {
1128
			throws Exception {
1107
 
1129
 
1108
		List<PincodePartner> partnerPincodeList = PincodePartnerRepository.selectByPartnerId(partnerId);
1130
		List<PincodePartner> partnerPincodeList = PincodePartnerRepository.selectByPartnerId(partnerId);
1109
 
1131
 
1110
		model.addAttribute("partnerPincodeList", partnerPincodeList);
1132
		model.addAttribute("partnerPincodeList", partnerPincodeList);