Subversion Repositories SmartDukaan

Rev

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

Rev 26479 Rev 26588
Line 55... Line 55...
55
import com.spice.profitmandi.common.model.TitleModel;
55
import com.spice.profitmandi.common.model.TitleModel;
56
import com.spice.profitmandi.common.web.util.ResponseSender;
56
import com.spice.profitmandi.common.web.util.ResponseSender;
57
import com.spice.profitmandi.dao.Interface.Campaign;
57
import com.spice.profitmandi.dao.Interface.Campaign;
58
import com.spice.profitmandi.dao.entity.auth.AuthUser;
58
import com.spice.profitmandi.dao.entity.auth.AuthUser;
59
import com.spice.profitmandi.dao.entity.auth.Menu;
59
import com.spice.profitmandi.dao.entity.auth.Menu;
-
 
60
import com.spice.profitmandi.dao.entity.catalog.Offer;
-
 
61
import com.spice.profitmandi.dao.entity.catalog.OfferPartner;
-
 
62
import com.spice.profitmandi.dao.entity.catalog.Offermargin;
60
import com.spice.profitmandi.dao.entity.cs.Position;
63
import com.spice.profitmandi.dao.entity.cs.Position;
61
import com.spice.profitmandi.dao.entity.dtr.Document;
64
import com.spice.profitmandi.dao.entity.dtr.Document;
62
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
65
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
63
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
66
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
64
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
67
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
65
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
68
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
66
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
69
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
67
import com.spice.profitmandi.dao.entity.user.Lead;
70
import com.spice.profitmandi.dao.entity.user.Lead;
68
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
71
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
69
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
72
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
-
 
73
import com.spice.profitmandi.dao.model.CreateOfferRequest;
70
import com.spice.profitmandi.dao.model.PartnerDetailModel;
74
import com.spice.profitmandi.dao.model.PartnerDetailModel;
71
import com.spice.profitmandi.dao.model.SimpleCampaign;
75
import com.spice.profitmandi.dao.model.SimpleCampaign;
72
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
76
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
73
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
77
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
74
import com.spice.profitmandi.dao.repository.auth.MenuCategoryRepository;
78
import com.spice.profitmandi.dao.repository.auth.MenuCategoryRepository;
75
import com.spice.profitmandi.dao.repository.auth.MenuRepository;
79
import com.spice.profitmandi.dao.repository.auth.MenuRepository;
-
 
80
import com.spice.profitmandi.dao.repository.catalog.OfferMarginRepository;
-
 
81
import com.spice.profitmandi.dao.repository.catalog.OfferPartnerRepository;
-
 
82
import com.spice.profitmandi.dao.repository.catalog.OfferRepository;
76
import com.spice.profitmandi.dao.repository.cs.CsService;
83
import com.spice.profitmandi.dao.repository.cs.CsService;
77
import com.spice.profitmandi.dao.repository.cs.PartnersPositionRepository;
84
import com.spice.profitmandi.dao.repository.cs.PartnersPositionRepository;
78
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
85
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
79
import com.spice.profitmandi.dao.repository.cs.TicketCategoryRepository;
86
import com.spice.profitmandi.dao.repository.cs.TicketCategoryRepository;
80
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
87
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
Line 212... Line 219...
212
	TicketRepository ticketRepository;
219
	TicketRepository ticketRepository;
213
 
220
 
214
	@Autowired
221
	@Autowired
215
	private LeadRepository leadRepository;
222
	private LeadRepository leadRepository;
216
 
223
 
-
 
224
	@Autowired
-
 
225
	private OfferRepository offerRepository;
-
 
226
 
-
 
227
	@Autowired
-
 
228
	private OfferPartnerRepository offerPartnerRepository;
-
 
229
 
-
 
230
	@Autowired
-
 
231
	private OfferMarginRepository offerMarginRepository;
-
 
232
 
217
	private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
233
	private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
218
 
234
 
219
	@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
235
	@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
220
	public String dashboard1(HttpServletRequest request, Model model, @RequestParam int fofoId) throws Exception {
236
	public String dashboard1(HttpServletRequest request, Model model, @RequestParam int fofoId) throws Exception {
221
		boolean isAdmin = false;
237
		boolean isAdmin = false;
Line 425... Line 441...
425
				model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(),
441
				model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(),
426
						10, ProfitMandiConstants.CUTOFF_INVESTMENT));
442
						10, ProfitMandiConstants.CUTOFF_INVESTMENT));
427
 
443
 
428
				// Hardcoded for valentine
444
				// Hardcoded for valentine
429
				// Hardcoded for valentine
445
				// Hardcoded for valentine
-
 
446
 
-
 
447
				List<Offer> offers = offerRepository.selectAll();
-
 
448
				if (!offers.isEmpty()) {
-
 
449
					List<CreateOfferRequest> cors = new ArrayList<>();
-
 
450
					for (Offer offer : offers) {
-
 
451
 
-
 
452
						List<OfferPartner> offerPartners = offerPartnerRepository.selectByOfferId(offer.getId());
-
 
453
 
-
 
454
						for (OfferPartner offerPartner : offerPartners) {
-
 
455
 
-
 
456
							if (offerPartner.getFofoId() == loginDetails.getFofoId()) {
430
				if (LocalDate.now().isBefore(LocalDate.of(2020, 3, 11))) {
457
								if (LocalDateTime.now().isAfter(offer.getStartDateTime())
431
					double valentineSales = fofoOrderItemRepository
458
										&& LocalDateTime.now().isBefore(offer.getEndDateTime())) {
432
							.selectSumAmountGroupByRetailer(LocalDate.of(2020, 3, 6).atStartOfDay(),
459
									LocalDateTime cur = LocalDate.now().minusMonths(4).atStartOfDay();
-
 
460
 
-
 
461
									Map<Integer, Double> value = offerRepository.selectSumOfferByRetailer(
433
									LocalDate.of(2020, 3, 10).atStartOfDay(), loginDetails.getFofoId(), false)
462
											offer.getStartDateTime(), offer.getEndDateTime(), loginDetails.getFofoId(),
434
							.get(loginDetails.getFofoId());
463
											offer, true);
-
 
464
									CreateOfferRequest createOfferRequest = new CreateOfferRequest();
435
					if (valentineSales < ONE_LAC) {
465
									List<Offermargin> offerMargins = offerMarginRepository
436
						model.addAttribute("valentineSale", "ONE_LAC");
466
											.selectByOfferId(offer.getId());
437
						model.addAttribute("valentineShort", ONE_LAC - valentineSales);
467
									LOGGER.info("value" + offer.getId());
438
					} else if (valentineSales < TWO_LAC) {
468
									LOGGER.info("value" + value);
439
						model.addAttribute("valentineSale", "TWO_LAC");
469
									for (Offermargin om : offerMargins) {
440
						model.addAttribute("valentineShort", TWO_LAC - valentineSales);
470
										if (value.get(loginDetails.getFofoId()) <= om.getMargin()) {
441
					} else if (valentineSales < FOUR_LAC) {
471
											createOfferRequest.setMargin(om.getMargin());
442
						model.addAttribute("valentineSale", "FOUR_LAC");
472
											createOfferRequest.setShortAmount(
443
						model.addAttribute("valentineShort", FOUR_LAC - valentineSales);
473
													om.getValue() - value.get(loginDetails.getFofoId()));
-
 
474
											break;
444
					} else {
475
										} else {
-
 
476
											createOfferRequest.setMargin(om.getMargin());
-
 
477
										}
-
 
478
 
-
 
479
									}
-
 
480
 
-
 
481
									createOfferRequest.setName(offer.getName());
-
 
482
									createOfferRequest.setDescription(offer.getDescription());
-
 
483
									createOfferRequest.setTargetType(offer.getTargetType());
-
 
484
									createOfferRequest.setAmountType(offer.getAmountType());
-
 
485
									createOfferRequest.setStartDate(offer.getStartDateTime());
-
 
486
									createOfferRequest.setEndDate(offer.getEndDateTime());
-
 
487
									createOfferRequest.setTotalSale(value.get(loginDetails.getFofoId()));
-
 
488
									cors.add(createOfferRequest);
-
 
489
 
445
						model.addAttribute("valentineSale", "CONGO");
490
									model.addAttribute("sales", value.get(loginDetails.getFofoId()));
-
 
491
								}
-
 
492
							}
-
 
493
 
-
 
494
						}
446
					}
495
					}
-
 
496
					model.addAttribute("offers", cors);
-
 
497
 
447
				}
498
				}
-
 
499
 
448
			} catch (ProfitMandiBusinessException e) {
500
			} catch (ProfitMandiBusinessException e) {
449
				LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
501
				LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
450
 
502
 
451
			}
503
			}
452
		}
504
		}
Line 576... Line 628...
576
			if (positions.size() > 0) {
628
			if (positions.size() > 0) {
577
				if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L3)).count() > 0) {
629
				if (positions.stream().filter(x -> x.getEscalationType().equals(EscalationType.L3)).count() > 0) {
578
 
630
 
579
					authIdAndAuthUserMap = authRepository.selectAllActiveUser().stream()
631
					authIdAndAuthUserMap = authRepository.selectAllActiveUser().stream()
580
							.collect(Collectors.toMap(x -> x.getId(), x -> x));
632
							.collect(Collectors.toMap(x -> x.getId(), x -> x));
581
					
633
 
582
					AuthUser dummyAuthUser = new AuthUser();
634
					AuthUser dummyAuthUser = new AuthUser();
583
					dummyAuthUser.setFirstName("Total");
635
					dummyAuthUser.setFirstName("Total");
584
					dummyAuthUser.setLastName("Values");
636
					dummyAuthUser.setLastName("Values");
585
					authIdAndAuthUserMap.put(0, dummyAuthUser);
637
					authIdAndAuthUserMap.put(0, dummyAuthUser);
586
 
638
 
Line 739... Line 791...
739
			List<Integer> fofoIds = pp.get(authId);
791
			List<Integer> fofoIds = pp.get(authId);
740
			fofoIdAndallValues = fofoIdAndallValues.entrySet().stream().filter(x -> fofoIds.contains(x.getKey()))
792
			fofoIdAndallValues = fofoIdAndallValues.entrySet().stream().filter(x -> fofoIds.contains(x.getKey()))
741
					.collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
793
					.collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
742
		} else {
794
		} else {
743
		}
795
		}
744
		
-
 
745
 
796
 
746
		model.addAttribute("fofoIdAndallValues", fofoIdAndallValues);
797
		model.addAttribute("fofoIdAndallValues", fofoIdAndallValues);
747
		model.addAttribute("fofoIdAndPartnerMap", fofoIdAndPartnerMap);
798
		model.addAttribute("fofoIdAndPartnerMap", fofoIdAndPartnerMap);
748
 
799
 
749
		return "auth_user_partner_detail";
800
		return "auth_user_partner_detail";