| Line 98... |
Line 98... |
| 98 |
@Autowired
|
98 |
@Autowired
|
| 99 |
private CookiesProcessor cookiesProcessor;
|
99 |
private CookiesProcessor cookiesProcessor;
|
| 100 |
|
100 |
|
| 101 |
@Autowired
|
101 |
@Autowired
|
| 102 |
private MenuRepository menuRepository;
|
102 |
private MenuRepository menuRepository;
|
| 103 |
|
103 |
|
| 104 |
@Autowired
|
104 |
@Autowired
|
| 105 |
private MenuCategoryRepository menuCategoryRepository;
|
105 |
private MenuCategoryRepository menuCategoryRepository;
|
| 106 |
|
106 |
|
| 107 |
@Autowired
|
107 |
@Autowired
|
| 108 |
private PartnerTargetRepository partnerTargetRepository;
|
108 |
private PartnerTargetRepository partnerTargetRepository;
|
| 109 |
|
109 |
|
| 110 |
@Autowired
|
110 |
@Autowired
|
| 111 |
private ResponseSender<?> responseSender;
|
111 |
private ResponseSender<?> responseSender;
|
| 112 |
|
112 |
|
| 113 |
@Autowired
|
113 |
@Autowired
|
| 114 |
RetailerService retailerService;
|
114 |
RetailerService retailerService;
|
| 115 |
|
115 |
|
| 116 |
@Autowired
|
116 |
@Autowired
|
| 117 |
private RoleManager roleManager;
|
117 |
private RoleManager roleManager;
|
| Line 134... |
Line 134... |
| 134 |
@Autowired
|
134 |
@Autowired
|
| 135 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
135 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| 136 |
|
136 |
|
| 137 |
@Autowired
|
137 |
@Autowired
|
| 138 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
138 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
| 139 |
|
139 |
|
| 140 |
@Autowired
|
140 |
@Autowired
|
| 141 |
private TicketCategoryRepository ticketCategoryRepository;
|
141 |
private TicketCategoryRepository ticketCategoryRepository;
|
| 142 |
|
142 |
|
| 143 |
@Autowired
|
143 |
@Autowired
|
| 144 |
private PartnerTypeChangeService partnerTypeChangeService;
|
144 |
private PartnerTypeChangeService partnerTypeChangeService;
|
| Line 146... |
Line 146... |
| 146 |
@Autowired
|
146 |
@Autowired
|
| 147 |
private HygieneDataRepository hygieneDataRepository;
|
147 |
private HygieneDataRepository hygieneDataRepository;
|
| 148 |
|
148 |
|
| 149 |
@Autowired
|
149 |
@Autowired
|
| 150 |
private UserCampaignRepository userCampaignRepository;
|
150 |
private UserCampaignRepository userCampaignRepository;
|
| 151 |
|
151 |
|
| 152 |
@Autowired
|
152 |
@Autowired
|
| 153 |
private PositionRepository positionRepository;
|
153 |
private PositionRepository positionRepository;
|
| 154 |
|
154 |
|
| 155 |
@Autowired
|
155 |
@Autowired
|
| 156 |
private UserAccountRepository userAccountRepository;
|
156 |
private UserAccountRepository userAccountRepository;
|
| Line 158... |
Line 158... |
| 158 |
@Autowired
|
158 |
@Autowired
|
| 159 |
private NotificationCampaignRepository notificationCampaignRepository;
|
159 |
private NotificationCampaignRepository notificationCampaignRepository;
|
| 160 |
|
160 |
|
| 161 |
@Autowired
|
161 |
@Autowired
|
| 162 |
private Mongo mongoClient;
|
162 |
private Mongo mongoClient;
|
| 163 |
|
163 |
|
| 164 |
@Autowired
|
164 |
@Autowired
|
| 165 |
private AuthRepository authRepository;
|
165 |
private AuthRepository authRepository;
|
| 166 |
|
166 |
|
| 167 |
@Autowired
|
167 |
@Autowired
|
| 168 |
private Gson gson;
|
168 |
private Gson gson;
|
| Line 200... |
Line 200... |
| 200 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(fofoId));
|
200 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(fofoId));
|
| 201 |
model.addAttribute("salesMap", this.getSales(fofoId));
|
201 |
model.addAttribute("salesMap", this.getSales(fofoId));
|
| 202 |
// this.setInvestments
|
202 |
// this.setInvestments
|
| 203 |
//
|
203 |
//
|
| 204 |
model.addAttribute("investments", this.getInvestments(fofoId));
|
204 |
model.addAttribute("investments", this.getInvestments(fofoId));
|
| 205 |
model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(fofoId,
|
205 |
model.addAttribute("isInvestmentOk",
|
| 206 |
10, ProfitMandiConstants.CUTOFF_INVESTMENT));
|
206 |
partnerInvestmentService.isInvestmentOk(fofoId, 10, ProfitMandiConstants.CUTOFF_INVESTMENT));
|
| 207 |
} catch (ProfitMandiBusinessException e) {
|
207 |
} catch (ProfitMandiBusinessException e) {
|
| 208 |
LOGGER.error("FofoStore Code not found of fofoId {}", fofoId);
|
208 |
LOGGER.error("FofoStore Code not found of fofoId {}", fofoId);
|
| 209 |
|
209 |
|
| 210 |
}
|
210 |
}
|
| 211 |
}
|
211 |
}
|
| 212 |
|
212 |
|
| 213 |
LocalDateTime currentMonthStart = LocalDateTime.now().withDayOfMonth(1);
|
213 |
LocalDateTime currentMonthStart = LocalDateTime.now().withDayOfMonth(1);
|
| 214 |
LocalDateTime currentMonthEnd = currentMonthStart.plusMonths(1).withDayOfMonth(1);
|
214 |
LocalDateTime currentMonthEnd = currentMonthStart.plusMonths(1).withDayOfMonth(1);
|
| 215 |
double currentMonthRating = hygieneDataRepository.selectRatingAvg(fofoId, currentMonthStart,
|
215 |
double currentMonthRating = hygieneDataRepository.selectRatingAvg(fofoId, currentMonthStart, currentMonthEnd)
|
| 216 |
currentMonthEnd) / 2;
|
216 |
/ 2;
|
| 217 |
double lastMonthRating = hygieneDataRepository.selectRatingAvg(fofoId, currentMonthStart,
|
217 |
double lastMonthRating = hygieneDataRepository.selectRatingAvg(fofoId, currentMonthStart, currentMonthEnd) / 2;
|
| 218 |
currentMonthEnd) / 2;
|
- |
|
| 219 |
double ratingTillDate = hygieneDataRepository.selectRatingAvg(fofoId, currentMonthStart,
|
218 |
double ratingTillDate = hygieneDataRepository.selectRatingAvg(fofoId, currentMonthStart, currentMonthEnd) / 2;
|
| 220 |
currentMonthEnd) / 2;
|
- |
|
| 221 |
model.addAttribute("currentMonthRating", (float) Math.round(currentMonthRating * 10) / 10);
|
219 |
model.addAttribute("currentMonthRating", (float) Math.round(currentMonthRating * 10) / 10);
|
| 222 |
model.addAttribute("lastMonthRating", (float) Math.round(lastMonthRating * 10) / 10);
|
220 |
model.addAttribute("lastMonthRating", (float) Math.round(lastMonthRating * 10) / 10);
|
| 223 |
model.addAttribute("ratingTillDate", (float) Math.round(ratingTillDate * 10) / 10);
|
221 |
model.addAttribute("ratingTillDate", (float) Math.round(ratingTillDate * 10) / 10);
|
| 224 |
|
222 |
|
| 225 |
long hygieneCount = hygieneDataRepository.selectHygieneCount(fofoId, true, currentMonthStart,
|
223 |
long hygieneCount = hygieneDataRepository.selectHygieneCount(fofoId, true, currentMonthStart, currentMonthEnd);
|
| 226 |
currentMonthEnd);
|
- |
|
| 227 |
|
224 |
|
| 228 |
long invalidHygieneCount = hygieneDataRepository.selectHygieneCount(fofoId, false,
|
225 |
long invalidHygieneCount = hygieneDataRepository.selectHygieneCount(fofoId, false, currentMonthStart,
|
| 229 |
currentMonthStart, currentMonthEnd);
|
226 |
currentMonthEnd);
|
| 230 |
if (hygieneCount == 0 && invalidHygieneCount == 0) {
|
227 |
if (hygieneCount == 0 && invalidHygieneCount == 0) {
|
| 231 |
invalidHygieneCount = 1;
|
228 |
invalidHygieneCount = 1;
|
| 232 |
}
|
229 |
}
|
| 233 |
model.addAttribute("hygienePercentage", (hygieneCount * 100) / (invalidHygieneCount + hygieneCount));
|
230 |
model.addAttribute("hygienePercentage", (hygieneCount * 100) / (invalidHygieneCount + hygieneCount));
|
| 234 |
|
231 |
|
| Line 264... |
Line 261... |
| 264 |
private Map<String, Object> getSales(int fofoId) {
|
261 |
private Map<String, Object> getSales(int fofoId) {
|
| 265 |
|
262 |
|
| 266 |
Map<String, Object> salesMap = new LinkedHashMap<>();
|
263 |
Map<String, Object> salesMap = new LinkedHashMap<>();
|
| 267 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
264 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 268 |
int monthLength = LocalDate.now().lengthOfMonth();
|
265 |
int monthLength = LocalDate.now().lengthOfMonth();
|
| - |
|
266 |
Double todaySale = fofoOrderItemRepository
|
| 269 |
Double todaySale = fofoOrderItemRepository.selectSumAmountGroupByRetailer(curDate, curDate.with(LocalTime.MAX),
|
267 |
.selectSumAmountGroupByRetailer(curDate, curDate.with(LocalTime.MAX), fofoId, false).get(fofoId);
|
| 270 |
fofoId, false).get(fofoId);
|
268 |
Double mtdSale = fofoOrderItemRepository
|
| 271 |
Double mtdSale = fofoOrderItemRepository.selectSumAmountGroupByRetailer(curDate.withDayOfMonth(1),
|
269 |
.selectSumAmountGroupByRetailer(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), fofoId, false)
|
| - |
|
270 |
.get(fofoId);
|
| 272 |
curDate.with(LocalTime.MAX), fofoId, false).get(fofoId);
|
271 |
Double lmtdSale = fofoOrderItemRepository
|
| 273 |
Double lmtdSale = fofoOrderItemRepository.selectSumAmountGroupByRetailer(curDate.withDayOfMonth(1).minusMonths(1),
|
272 |
.selectSumAmountGroupByRetailer(curDate.withDayOfMonth(1).minusMonths(1),
|
| 274 |
curDate.with(LocalTime.MAX).minusMonths(1), fofoId, false).get(fofoId);
|
273 |
curDate.with(LocalTime.MAX).minusMonths(1), fofoId, false)
|
| - |
|
274 |
.get(fofoId);
|
| 275 |
|
275 |
|
| 276 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
276 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
| 277 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|
277 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|
| 278 |
if (partnerTargetDetails.isEmpty()) {
|
278 |
if (partnerTargetDetails.isEmpty()) {
|
| 279 |
partnerTargetDetails = partnerTargetRepository
|
279 |
partnerTargetDetails = partnerTargetRepository
|
| Line 290... |
Line 290... |
| 290 |
salesMap.put("requiredRate", requiredRate);
|
290 |
salesMap.put("requiredRate", requiredRate);
|
| 291 |
salesMap.put("requiredTypeImage", PartnerType.imageMap.get(partnerType.next()));
|
291 |
salesMap.put("requiredTypeImage", PartnerType.imageMap.get(partnerType.next()));
|
| 292 |
|
292 |
|
| 293 |
salesMap.put("todaySale", todaySale == null ? 0 : todaySale);
|
293 |
salesMap.put("todaySale", todaySale == null ? 0 : todaySale);
|
| 294 |
salesMap.put("mtdSale", mtdSale == null ? 0 : mtdSale);
|
294 |
salesMap.put("mtdSale", mtdSale == null ? 0 : mtdSale);
|
| 295 |
salesMap.put("lmtdSale", lmtdSale == null ? 0 : lmtdSale);
|
295 |
salesMap.put("lmtdSale", lmtdSale == null ? 0 : lmtdSale);
|
| 296 |
|
296 |
|
| 297 |
PartnerType currentType = partnerTypeChangeService.getPartnerTypeByAmount(currentRate * monthLength);
|
297 |
PartnerType currentType = partnerTypeChangeService.getPartnerTypeByAmount(currentRate * monthLength);
|
| 298 |
salesMap.put("currentRate", currentRate);
|
298 |
salesMap.put("currentRate", currentRate);
|
| 299 |
salesMap.put("currentType", currentType);
|
299 |
salesMap.put("currentType", currentType);
|
| 300 |
salesMap.put("currentTypeImage", PartnerType.imageMap.get(currentType));
|
300 |
salesMap.put("currentTypeImage", PartnerType.imageMap.get(currentType));
|
| Line 394... |
Line 394... |
| 394 |
private String adminPanel(int fofoId, String email, Model model) throws ProfitMandiBusinessException {
|
394 |
private String adminPanel(int fofoId, String email, Model model) throws ProfitMandiBusinessException {
|
| 395 |
List<Menu> menus;
|
395 |
List<Menu> menus;
|
| 396 |
try {
|
396 |
try {
|
| 397 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
397 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
| 398 |
List<Position> positions = positionRepository.selectAll(authUser.getId());
|
398 |
List<Position> positions = positionRepository.selectAll(authUser.getId());
|
| 399 |
menus = menuRepository.selectAllByIds(menuCategoryRepository.selectAllByPositions(positions).stream().map(x->x.getMenuId()).collect(Collectors.toList()));
|
399 |
menus = menuRepository.selectAllByIds(menuCategoryRepository.selectAllByPositions(positions).stream()
|
| - |
|
400 |
.map(x -> x.getMenuId()).collect(Collectors.toList()));
|
| 400 |
} catch (ProfitMandiBusinessException e){
|
401 |
} catch (ProfitMandiBusinessException e) {
|
| 401 |
menus = menuRepository.selectAll();
|
402 |
menus = menuRepository.selectAll();
|
| 402 |
}
|
403 |
}
|
| - |
|
404 |
|
| - |
|
405 |
List<Menu> menu = this.prepareMenu(menus);
|
| - |
|
406 |
|
| - |
|
407 |
model.addAttribute("menu", menu);
|
| - |
|
408 |
return "admin";
|
| 403 |
|
409 |
}
|
| - |
|
410 |
|
| - |
|
411 |
private List<Menu> prepareMenu(List<Menu> menus) {
|
| - |
|
412 |
List<Menu> returnMenu = new ArrayList<>();
|
| 404 |
Map<Integer, List<Menu>> subMenuMap = new HashMap<Integer, List<Menu>>();
|
413 |
Map<Menu, List<Menu>> subMenuMap = new HashMap<Menu, List<Menu>>();
|
| 405 |
for(Menu menu : menus) {
|
414 |
for (Menu menu : menus) {
|
| 406 |
if(menu.get_parent()==null) {
|
415 |
if (menu.get_parent() == null) {
|
| 407 |
if(!subMenuMap.containsKey(menu.getId())) {
|
416 |
if (!subMenuMap.containsKey(menu.getId())) {
|
| 408 |
subMenuMap.put(menu.getId(), new ArrayList<>());
|
417 |
subMenuMap.put(menu, new ArrayList<>());
|
| 409 |
}
|
418 |
}
|
| 410 |
menu.setSubMenus(subMenuMap.get(menu.getId()));
|
419 |
menu.setSubMenus(subMenuMap.get(menu.getId()));
|
| 411 |
} else {
|
420 |
} else {
|
| 412 |
int parentId = menu.get_parent().getId();
|
421 |
Menu parentMenu = menu.get_parent();
|
| 413 |
if(!subMenuMap.containsKey(parentId)) {
|
422 |
if (!subMenuMap.containsKey(parentMenu)) {
|
| 414 |
subMenuMap.put(parentId, new ArrayList<>());
|
423 |
subMenuMap.put(parentMenu, new ArrayList<>());
|
| 415 |
}
|
424 |
}
|
| 416 |
subMenuMap.get(parentId).add(menu);
|
425 |
subMenuMap.get(parentMenu).add(menu);
|
| 417 |
}
|
426 |
}
|
| 418 |
}
|
427 |
}
|
| - |
|
428 |
subMenuMap.entrySet().stream().forEach(entry -> {
|
| - |
|
429 |
entry.getKey().setSubMenus(entry.getValue());
|
| 419 |
model.addAttribute("menu", menus);
|
430 |
returnMenu.add(entry.getKey());
|
| - |
|
431 |
});
|
| 420 |
return "admin";
|
432 |
return returnMenu;
|
| 421 |
}
|
433 |
}
|
| 422 |
|
434 |
|
| 423 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
435 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
| 424 |
private boolean hasGift(int fofoId) {
|
436 |
private boolean hasGift(int fofoId) {
|
| 425 |
try {
|
437 |
try {
|