| Line 31... |
Line 31... |
| 31 |
import org.springframework.web.bind.annotation.RequestParam;
|
31 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 32 |
|
32 |
|
| 33 |
import com.google.gson.Gson;
|
33 |
import com.google.gson.Gson;
|
| 34 |
import com.mongodb.DBObject;
|
34 |
import com.mongodb.DBObject;
|
| 35 |
import com.spice.profitmandi.common.enumuration.ContentType;
|
35 |
import com.spice.profitmandi.common.enumuration.ContentType;
|
| - |
|
36 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 36 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
37 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 37 |
import com.spice.profitmandi.common.model.BrandStockPrice;
|
38 |
import com.spice.profitmandi.common.model.BrandStockPrice;
|
| 38 |
import com.spice.profitmandi.common.model.Notification;
|
39 |
import com.spice.profitmandi.common.model.Notification;
|
| 39 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
40 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 40 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
41 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| Line 44... |
Line 45... |
| 44 |
import com.spice.profitmandi.dao.entity.dtr.UserCampaign;
|
45 |
import com.spice.profitmandi.dao.entity.dtr.UserCampaign;
|
| 45 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
46 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 46 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
47 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 47 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
48 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
| 48 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
49 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| - |
|
50 |
|
| 49 |
import com.spice.profitmandi.dao.model.SimpleCampaign;
|
51 |
import com.spice.profitmandi.dao.model.SimpleCampaign;
|
| 50 |
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
|
52 |
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
|
| 51 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
53 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
| 52 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
54 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 53 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
55 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| Line 103... |
Line 105... |
| 103 |
@Autowired
|
105 |
@Autowired
|
| 104 |
private PartnerInvestmentService partnerInvestmentService;
|
106 |
private PartnerInvestmentService partnerInvestmentService;
|
| 105 |
|
107 |
|
| 106 |
@Autowired
|
108 |
@Autowired
|
| 107 |
DocumentRepository documentRepository;
|
109 |
DocumentRepository documentRepository;
|
| 108 |
|
110 |
|
| 109 |
@Autowired
|
111 |
@Autowired
|
| 110 |
InventoryService inventoryService;
|
112 |
InventoryService inventoryService;
|
| 111 |
|
113 |
|
| 112 |
@Autowired
|
114 |
@Autowired
|
| 113 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
115 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| Line 323... |
Line 325... |
| 323 |
model.addAttribute("appContextPath", request.getContextPath());
|
325 |
model.addAttribute("appContextPath", request.getContextPath());
|
| 324 |
return "contact-us";
|
326 |
return "contact-us";
|
| 325 |
}
|
327 |
}
|
| 326 |
|
328 |
|
| 327 |
@RequestMapping(value = "/notifications", method = RequestMethod.GET)
|
329 |
@RequestMapping(value = "/notifications", method = RequestMethod.GET)
|
| 328 |
public String getNotificationsWithType(HttpServletRequest request, @RequestParam(value = "") String notifyType,
|
330 |
public String getNotificationsWithType(HttpServletRequest request,
|
| - |
|
331 |
@RequestParam(required = false) MessageType messageType,
|
| 329 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
332 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 330 |
@RequestParam(name = "limit", defaultValue = "20") int limit, Model model) throws Exception {
|
333 |
@RequestParam(name = "limit", defaultValue = "20") int limit, Model model) throws Exception {
|
| 331 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
334 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 332 |
int userId = userAccountRepository.selectUserIdByRetailerId(loginDetails.getFofoId());
|
335 |
int userId = userAccountRepository.selectUserIdByRetailerId(loginDetails.getFofoId());
|
| 333 |
List<UserCampaign> userCampaigns = userCampaignRepository.selectByUserId(userId);
|
336 |
List<UserCampaign> userCampaigns = userCampaignRepository.selectByUserId(userId);
|
| - |
|
337 |
|
| 334 |
List<Notification> notifications = new ArrayList<>();
|
338 |
List<Notification> notifications = null;
|
| 335 |
Document document = null;
|
- |
|
| 336 |
if (!userCampaigns.isEmpty()) {
|
339 |
if (!userCampaigns.isEmpty()) {
|
| 337 |
List<Integer> campaignIds = new ArrayList<>();
|
340 |
List<Integer> campaignIds = new ArrayList<>();
|
| 338 |
for (UserCampaign userCampaign : userCampaigns) {
|
341 |
for (UserCampaign userCampaign : userCampaigns) {
|
| 339 |
campaignIds.add(userCampaign.getCampaignId());
|
342 |
campaignIds.add(userCampaign.getCampaignId());
|
| 340 |
}
|
343 |
}
|
| 341 |
List<NotificationCampaign> notificationCampaigns = notificationCampaignRepository.selectbyCids(campaignIds);
|
344 |
List<NotificationCampaign> notificationCampaigns = notificationCampaignRepository.selectbyCids(campaignIds);
|
| 342 |
if (notifyType.equals("annoucement")) {
|
- |
|
| 343 |
for (NotificationCampaign notificationCampaign : notificationCampaigns) {
|
- |
|
| 344 |
if (notificationCampaign.isAnnoucement() == true) {
|
- |
|
| 345 |
Notification ns = new Notification();
|
- |
|
| 346 |
SimpleCampaignParams scp = gson.fromJson(notificationCampaign.getImplementationParams(),
|
- |
|
| 347 |
SimpleCampaignParams.class);
|
- |
|
| 348 |
Campaign campaign = new SimpleCampaign(scp);
|
- |
|
| 349 |
LocalDateTime expire = campaign.getExpireTimestamp();
|
- |
|
| 350 |
ns.setCid(Integer.toString(notificationCampaign.getId()));
|
- |
|
| 351 |
ns.setType(campaign.getType());
|
- |
|
| 352 |
ns.setMessage(campaign.getMessage());
|
345 |
LOGGER.info("messageType" + messageType);
|
| 353 |
ns.setTitle(campaign.getTitle());
|
- |
|
| 354 |
if (notificationCampaign.getDocumentId() != null) {
|
- |
|
| 355 |
document = documentRepository.selectById(notificationCampaign.getDocumentId());
|
346 |
notifications = getNotifications(notificationCampaigns, messageType);
|
| 356 |
ns.setDocumentName(document.getDisplayName());
|
- |
|
| - |
|
347 |
|
| 357 |
}
|
348 |
}
|
| 358 |
ns.setUrl(campaign.getUrl());
|
- |
|
| 359 |
ns.setShowImage(campaign.getShowImage());
|
- |
|
| 360 |
ns.setImageUrl(campaign.getImageUrl());
|
- |
|
| - |
|
349 |
|
| 361 |
ns.setDocumentId(notificationCampaign.getDocumentId());
|
350 |
model.addAttribute("notifications", notifications);
|
| - |
|
351 |
|
| 362 |
ns.setAnnoucement(notificationCampaign.isAnnoucement());
|
352 |
LOGGER.info("notifications" + notifications);
|
| 363 |
ns.setCreated(notificationCampaign.getCreatedTimestamp()
|
- |
|
| 364 |
.toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30)) * 1000);
|
- |
|
| 365 |
if (LocalDateTime.now().isAfter(expire)) {
|
- |
|
| 366 |
ns.setExpired(true);
|
- |
|
| 367 |
} else {
|
- |
|
| 368 |
ns.setExpired(false);
|
- |
|
| 369 |
}
|
- |
|
| 370 |
notifications.add(ns);
|
353 |
return "notification-template";
|
| 371 |
}
|
354 |
}
|
| 372 |
}
|
355 |
|
| 373 |
} else if (notifyType.equals("notification")) {
|
- |
|
| 374 |
for (NotificationCampaign notificationCampaign : notificationCampaigns) {
|
356 |
public List<Notification> getNotifications(List<NotificationCampaign> nc, MessageType messageType)
|
| 375 |
if (notificationCampaign.isAnnoucement() == false) {
|
357 |
throws ProfitMandiBusinessException {
|
| 376 |
Notification ns = new Notification();
|
358 |
List<Notification> notifications = new ArrayList<>();
|
| 377 |
SimpleCampaignParams scp = gson.fromJson(notificationCampaign.getImplementationParams(),
|
- |
|
| 378 |
SimpleCampaignParams.class);
|
- |
|
| 379 |
Campaign campaign = new SimpleCampaign(scp);
|
- |
|
| 380 |
LocalDateTime expire = campaign.getExpireTimestamp();
|
- |
|
| 381 |
ns.setCid(Integer.toString(notificationCampaign.getId()));
|
- |
|
| 382 |
ns.setType(campaign.getType());
|
359 |
Document document = null;
|
| 383 |
ns.setMessage(campaign.getMessage());
|
360 |
if (messageType != null) {
|
| 384 |
ns.setTitle(campaign.getTitle());
|
- |
|
| 385 |
ns.setUrl(campaign.getUrl());
|
- |
|
| 386 |
if (notificationCampaign.getDocumentId() != null) {
|
361 |
for (NotificationCampaign notificationCampaign : nc) {
|
| 387 |
document = documentRepository.selectById(notificationCampaign.getDocumentId());
|
- |
|
| 388 |
ns.setDocumentName(document.getDisplayName());
|
- |
|
| 389 |
}
|
- |
|
| 390 |
ns.setShowImage(campaign.getShowImage());
|
- |
|
| 391 |
ns.setImageUrl(campaign.getImageUrl());
|
- |
|
| 392 |
ns.setDocumentId(notificationCampaign.getDocumentId());
|
- |
|
| 393 |
ns.setAnnoucement(notificationCampaign.isAnnoucement());
|
- |
|
| 394 |
ns.setCreated(notificationCampaign.getCreatedTimestamp()
|
362 |
if (notificationCampaign.getMessageType() == messageType) {
|
| 395 |
.toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30)) * 1000);
|
- |
|
| 396 |
if (LocalDateTime.now().isAfter(expire)) {
|
- |
|
| 397 |
ns.setExpired(true);
|
- |
|
| 398 |
} else {
|
- |
|
| 399 |
ns.setExpired(false);
|
- |
|
| 400 |
}
|
- |
|
| 401 |
notifications.add(ns);
|
- |
|
| 402 |
}
|
- |
|
| 403 |
}
|
- |
|
| 404 |
} else {
|
- |
|
| 405 |
for (NotificationCampaign notificationCampaign : notificationCampaigns) {
|
- |
|
| 406 |
Notification ns = new Notification();
|
363 |
Notification ns = new Notification();
|
| 407 |
SimpleCampaignParams scp = gson.fromJson(notificationCampaign.getImplementationParams(),
|
364 |
SimpleCampaignParams scp = gson.fromJson(notificationCampaign.getImplementationParams(),
|
| 408 |
SimpleCampaignParams.class);
|
365 |
SimpleCampaignParams.class);
|
| 409 |
Campaign campaign = new SimpleCampaign(scp);
|
366 |
Campaign campaign = new SimpleCampaign(scp);
|
| 410 |
LocalDateTime expire = campaign.getExpireTimestamp();
|
367 |
LocalDateTime expire = campaign.getExpireTimestamp();
|
| 411 |
ns.setCid(Integer.toString(notificationCampaign.getId()));
|
368 |
ns.setCid(Integer.toString(notificationCampaign.getId()));
|
| 412 |
ns.setType(campaign.getType());
|
369 |
ns.setType(campaign.getType());
|
| 413 |
ns.setMessage(campaign.getMessage());
|
370 |
ns.setMessage(campaign.getMessage());
|
| 414 |
ns.setTitle(campaign.getTitle());
|
371 |
ns.setTitle(campaign.getTitle());
|
| 415 |
ns.setUrl(campaign.getUrl());
|
- |
|
| 416 |
if (notificationCampaign.getDocumentId() != null) {
|
372 |
if (notificationCampaign.getDocumentId() != null) {
|
| 417 |
document = documentRepository.selectById(notificationCampaign.getDocumentId());
|
373 |
document = documentRepository.selectById(notificationCampaign.getDocumentId());
|
| 418 |
ns.setDocumentName(document.getDisplayName());
|
374 |
ns.setDocumentName(document.getDisplayName());
|
| 419 |
}
|
375 |
}
|
| 420 |
ns.setDocumentId(notificationCampaign.getDocumentId());
|
376 |
ns.setUrl(campaign.getUrl());
|
| 421 |
ns.setShowImage(campaign.getShowImage());
|
377 |
ns.setShowImage(campaign.getShowImage());
|
| 422 |
ns.setImageUrl(campaign.getImageUrl());
|
378 |
ns.setImageUrl(campaign.getImageUrl());
|
| 423 |
ns.setAnnoucement(notificationCampaign.isAnnoucement());
|
379 |
ns.setDocumentId(notificationCampaign.getDocumentId());
|
| - |
|
380 |
ns.setMessageType(notificationCampaign.getMessageType());
|
| 424 |
ns.setCreated(
|
381 |
ns.setCreated(
|
| 425 |
notificationCampaign.getCreatedTimestamp().toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30))
|
382 |
notificationCampaign.getCreatedTimestamp().toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30))
|
| 426 |
* 1000);
|
383 |
* 1000);
|
| 427 |
if (LocalDateTime.now().isAfter(expire)) {
|
384 |
if (LocalDateTime.now().isAfter(expire)) {
|
| 428 |
ns.setExpired(true);
|
385 |
ns.setExpired(true);
|
| Line 430... |
Line 387... |
| 430 |
ns.setExpired(false);
|
387 |
ns.setExpired(false);
|
| 431 |
}
|
388 |
}
|
| 432 |
notifications.add(ns);
|
389 |
notifications.add(ns);
|
| 433 |
}
|
390 |
}
|
| 434 |
}
|
391 |
}
|
| 435 |
}
|
392 |
} else {
|
| - |
|
393 |
for (NotificationCampaign notificationCampaign : nc) {
|
| 436 |
|
394 |
|
| 437 |
model.addAttribute("notifications", notifications);
|
395 |
Notification ns = new Notification();
|
| - |
|
396 |
SimpleCampaignParams scp = gson.fromJson(notificationCampaign.getImplementationParams(),
|
| - |
|
397 |
SimpleCampaignParams.class);
|
| - |
|
398 |
Campaign campaign = new SimpleCampaign(scp);
|
| - |
|
399 |
LocalDateTime expire = campaign.getExpireTimestamp();
|
| - |
|
400 |
ns.setCid(Integer.toString(notificationCampaign.getId()));
|
| - |
|
401 |
ns.setType(campaign.getType());
|
| - |
|
402 |
ns.setMessage(campaign.getMessage());
|
| - |
|
403 |
ns.setTitle(campaign.getTitle());
|
| - |
|
404 |
if (notificationCampaign.getDocumentId() != null) {
|
| - |
|
405 |
document = documentRepository.selectById(notificationCampaign.getDocumentId());
|
| - |
|
406 |
ns.setDocumentName(document.getDisplayName());
|
| - |
|
407 |
}
|
| - |
|
408 |
ns.setUrl(campaign.getUrl());
|
| - |
|
409 |
ns.setShowImage(campaign.getShowImage());
|
| - |
|
410 |
ns.setImageUrl(campaign.getImageUrl());
|
| - |
|
411 |
ns.setDocumentId(notificationCampaign.getDocumentId());
|
| - |
|
412 |
ns.setMessageType(notificationCampaign.getMessageType());
|
| - |
|
413 |
ns.setCreated(notificationCampaign.getCreatedTimestamp().toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30))
|
| - |
|
414 |
* 1000);
|
| - |
|
415 |
if (LocalDateTime.now().isAfter(expire)) {
|
| - |
|
416 |
ns.setExpired(true);
|
| - |
|
417 |
} else {
|
| - |
|
418 |
ns.setExpired(false);
|
| - |
|
419 |
}
|
| - |
|
420 |
notifications.add(ns);
|
| - |
|
421 |
}
|
| - |
|
422 |
|
| - |
|
423 |
}
|
| - |
|
424 |
return notifications;
|
| 438 |
|
425 |
|
| 439 |
LOGGER.info("notifications" + notifications);
|
- |
|
| 440 |
return "notification-template";
|
- |
|
| 441 |
}
|
426 |
}
|
| 442 |
|
427 |
|
| 443 |
@RequestMapping(value = "/notifyDocument/documentId", method = RequestMethod.GET)
|
428 |
@RequestMapping(value = "/notifyDocument/documentId", method = RequestMethod.GET)
|
| 444 |
public ResponseEntity<?> retailerDocumentById(HttpServletRequest request,
|
429 |
public ResponseEntity<?> retailerDocumentById(HttpServletRequest request,
|
| 445 |
@RequestParam(name = ProfitMandiConstants.DOCUMENT_ID) int documentId, @RequestParam int cid)
|
430 |
@RequestParam(name = ProfitMandiConstants.DOCUMENT_ID) int documentId, @RequestParam int cid)
|