| Line 125... |
Line 125... |
| 125 |
import java.time.format.DateTimeFormatter;
|
125 |
import java.time.format.DateTimeFormatter;
|
| 126 |
import java.time.temporal.ChronoField;
|
126 |
import java.time.temporal.ChronoField;
|
| 127 |
import java.time.temporal.ChronoUnit;
|
127 |
import java.time.temporal.ChronoUnit;
|
| 128 |
import java.util.*;
|
128 |
import java.util.*;
|
| 129 |
import java.util.Map.Entry;
|
129 |
import java.util.Map.Entry;
|
| - |
|
130 |
import java.util.stream.Collector;
|
| 130 |
import java.util.stream.Collectors;
|
131 |
import java.util.stream.Collectors;
|
| 131 |
import java.util.stream.Stream;
|
132 |
import java.util.stream.Stream;
|
| 132 |
|
133 |
|
| 133 |
@Component
|
134 |
@Component
|
| 134 |
@Transactional(rollbackFor = Throwable.class)
|
135 |
@Transactional(rollbackFor = Throwable.class)
|
| Line 358... |
Line 359... |
| 358 |
|
359 |
|
| 359 |
@Autowired
|
360 |
@Autowired
|
| 360 |
private SchemeRepository schemeRepository;
|
361 |
private SchemeRepository schemeRepository;
|
| 361 |
|
362 |
|
| 362 |
@Autowired
|
363 |
@Autowired
|
| - |
|
364 |
private SchemeItemRepository schemeItemRepository;
|
| - |
|
365 |
|
| - |
|
366 |
@Autowired
|
| 363 |
private JavaMailSender mailSender;
|
367 |
private JavaMailSender mailSender;
|
| 364 |
|
368 |
|
| 365 |
@Autowired
|
369 |
@Autowired
|
| 366 |
private PartnerTargetRepository partnerTargetRepository;
|
370 |
private PartnerTargetRepository partnerTargetRepository;
|
| 367 |
|
371 |
|
| Line 452... |
Line 456... |
| 452 |
|
456 |
|
| 453 |
@Autowired
|
457 |
@Autowired
|
| 454 |
CreditAccountRepository creditAccountRepository;
|
458 |
CreditAccountRepository creditAccountRepository;
|
| 455 |
|
459 |
|
| 456 |
@Autowired
|
460 |
@Autowired
|
| - |
|
461 |
CustomerOfferRepository customerOfferRepository;
|
| - |
|
462 |
|
| - |
|
463 |
@Autowired
|
| - |
|
464 |
CustomerOfferItemRepository customerOfferItemRepository;
|
| - |
|
465 |
@Autowired
|
| 457 |
private FofoSolr fofoSolr;
|
466 |
private FofoSolr fofoSolr;
|
| 458 |
private static final Logger LOGGER = LogManager.getLogger(ScheduledTasks.class);
|
467 |
private static final Logger LOGGER = LogManager.getLogger(ScheduledTasks.class);
|
| 459 |
|
468 |
|
| 460 |
private String FCM_URL = "https://fcm.googleapis.com/fcm/send";
|
469 |
private String FCM_URL = "https://fcm.googleapis.com/fcm/send";
|
| 461 |
private String FCM_API_KEY = "AAAASAjNcn4:APA91bG6fWRIgYJI0L9gCjP5ynaXz2hJHYKtD9dfH7Depdv31Nd9APJwhx-OPkAJ1WSz4BGNYG8lHThLFSjDGFxIwUZv241YcAJEGDLgt86mxq9FXJe-yBRu-S0_ZwHqmX-QaVKl5F_A";
|
470 |
private String FCM_API_KEY = "AAAASAjNcn4:APA91bG6fWRIgYJI0L9gCjP5ynaXz2hJHYKtD9dfH7Depdv31Nd9APJwhx-OPkAJ1WSz4BGNYG8lHThLFSjDGFxIwUZv241YcAJEGDLgt86mxq9FXJe-yBRu-S0_ZwHqmX-QaVKl5F_A";
|
| Line 4680... |
Line 4689... |
| 4680 |
for (Integer catalogItemId : catalogItemIds) {
|
4689 |
for (Integer catalogItemId : catalogItemIds) {
|
| 4681 |
|
4690 |
|
| 4682 |
WebProductListing webProductListing = new WebProductListing();
|
4691 |
WebProductListing webProductListing = new WebProductListing();
|
| 4683 |
webProductListing.setEntityId(catalogItemId);
|
4692 |
webProductListing.setEntityId(catalogItemId);
|
| 4684 |
webProductListing.setWebListingId(webListing.getId());
|
4693 |
webProductListing.setWebListingId(webListing.getId());
|
| - |
|
4694 |
count = count + 1;
|
| 4685 |
|
4695 |
|
| 4686 |
webProductListing.setRank(count + 1);
|
4696 |
webProductListing.setRank(count + 1);
|
| 4687 |
webProductListingRepository.persist(webProductListing);
|
4697 |
webProductListingRepository.persist(webProductListing);
|
| 4688 |
|
4698 |
|
| 4689 |
}
|
4699 |
}
|
| Line 4695... |
Line 4705... |
| 4695 |
WebListing webListing = webListingRepository.selectByUrl("partner-price-drop");
|
4705 |
WebListing webListing = webListingRepository.selectByUrl("partner-price-drop");
|
| 4696 |
|
4706 |
|
| 4697 |
List<WebProductListing> webProductListings = webProductListingRepository
|
4707 |
List<WebProductListing> webProductListings = webProductListingRepository
|
| 4698 |
.selectAllByWebListingId(webListing.getId());
|
4708 |
.selectAllByWebListingId(webListing.getId());
|
| 4699 |
|
4709 |
|
| 4700 |
List<Integer> catalogItemIds = priceDropRepository
|
4710 |
Set<Integer> catalogItemIds = priceDropRepository
|
| 4701 |
.selectAllByDatesBetweenSortByDate(LocalDateTime.now().minusDays(30), LocalDateTime.now()).stream()
|
4711 |
.selectAllByDatesBetweenSortByDate(LocalDateTime.now().minusDays(30), LocalDateTime.now()).stream()
|
| 4702 |
.map(x -> x.getCatalogItemId()).collect(Collectors.toList());
|
4712 |
.map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
|
| 4703 |
|
4713 |
|
| 4704 |
LOGGER.info("catalogItemIds {}", catalogItemIds);
|
4714 |
LOGGER.info("catalogItemIds {}", catalogItemIds);
|
| 4705 |
if (!catalogItemIds.isEmpty()) {
|
4715 |
if (!catalogItemIds.isEmpty()) {
|
| 4706 |
webProductListingRepository.deleteByEqual(webListing.getId());
|
4716 |
webProductListingRepository.deleteByEqual(webListing.getId());
|
| 4707 |
int count = 0;
|
4717 |
int count = 0;
|
| 4708 |
for (Integer catalogItemId : catalogItemIds) {
|
4718 |
for (Integer catalogItemId : catalogItemIds) {
|
| 4709 |
|
4719 |
|
| 4710 |
WebProductListing webProductListing = new WebProductListing();
|
4720 |
WebProductListing webProductListing = new WebProductListing();
|
| 4711 |
webProductListing.setEntityId(catalogItemId);
|
4721 |
webProductListing.setEntityId(catalogItemId);
|
| 4712 |
webProductListing.setWebListingId(webListing.getId());
|
4722 |
webProductListing.setWebListingId(webListing.getId());
|
| - |
|
4723 |
count = count + 1;
|
| - |
|
4724 |
webProductListing.setRank(count);
|
| - |
|
4725 |
webProductListingRepository.persist(webProductListing);
|
| 4713 |
|
4726 |
|
| - |
|
4727 |
}
|
| - |
|
4728 |
|
| - |
|
4729 |
}
|
| - |
|
4730 |
}
|
| - |
|
4731 |
|
| - |
|
4732 |
public void getNewLaunches() throws ProfitMandiBusinessException {
|
| - |
|
4733 |
WebListing webListing = webListingRepository.selectByUrl("new-launches");
|
| - |
|
4734 |
|
| - |
|
4735 |
Set<Integer> itemIds = tagListingRepository
|
| - |
|
4736 |
.selectAllByDatesBetweenSortByDate(LocalDateTime.now().minusDays(30), LocalDateTime.now()).stream()
|
| - |
|
4737 |
.map(x -> x.getItemId()).collect(Collectors.toSet());
|
| - |
|
4738 |
|
| - |
|
4739 |
Set<Integer> catalogItemIds = itemRepository.selectByIds(itemIds).stream().map(x -> x.getCatalogItemId())
|
| - |
|
4740 |
.collect(Collectors.toSet());
|
| - |
|
4741 |
|
| - |
|
4742 |
LOGGER.info("catalogItemIds {}", catalogItemIds);
|
| - |
|
4743 |
if (!catalogItemIds.isEmpty()) {
|
| - |
|
4744 |
webProductListingRepository.deleteByEqual(webListing.getId());
|
| - |
|
4745 |
int count = 0;
|
| - |
|
4746 |
for (Integer catalogItemId : catalogItemIds) {
|
| - |
|
4747 |
|
| - |
|
4748 |
WebProductListing webProductListing = new WebProductListing();
|
| - |
|
4749 |
webProductListing.setEntityId(catalogItemId);
|
| - |
|
4750 |
webProductListing.setWebListingId(webListing.getId());
|
| - |
|
4751 |
count = count + 1;
|
| - |
|
4752 |
webProductListing.setRank(count);
|
| - |
|
4753 |
webProductListingRepository.persist(webProductListing);
|
| - |
|
4754 |
|
| - |
|
4755 |
}
|
| - |
|
4756 |
|
| - |
|
4757 |
}
|
| - |
|
4758 |
}
|
| - |
|
4759 |
|
| - |
|
4760 |
public void getSpecialSupport() throws ProfitMandiBusinessException {
|
| - |
|
4761 |
WebListing webListing = webListingRepository.selectByUrl("special-support");
|
| - |
|
4762 |
|
| - |
|
4763 |
Set<Integer> schemeIds = schemeRepository.selectActiveAll(Arrays.asList(SchemeType.SPECIAL_SUPPORT),
|
| - |
|
4764 |
LocalDate.now().minusDays(30), LocalDate.now().plusDays(1), false).stream().map(x -> x.getId())
|
| - |
|
4765 |
.collect(Collectors.toSet());
|
| - |
|
4766 |
|
| - |
|
4767 |
Set<Integer> catalogItemIds = schemeItemRepository.selectBySchemeIds(schemeIds).stream()
|
| - |
|
4768 |
.map(x -> x.getCatalogId()).collect(Collectors.toSet());
|
| - |
|
4769 |
|
| - |
|
4770 |
LOGGER.info("catalogItemIds {}", catalogItemIds);
|
| - |
|
4771 |
if (!catalogItemIds.isEmpty()) {
|
| - |
|
4772 |
webProductListingRepository.deleteByEqual(webListing.getId());
|
| - |
|
4773 |
int count = 0;
|
| - |
|
4774 |
for (Integer catalogItemId : catalogItemIds) {
|
| - |
|
4775 |
|
| - |
|
4776 |
WebProductListing webProductListing = new WebProductListing();
|
| - |
|
4777 |
webProductListing.setEntityId(catalogItemId);
|
| - |
|
4778 |
webProductListing.setWebListingId(webListing.getId());
|
| - |
|
4779 |
count = count + 1;
|
| - |
|
4780 |
webProductListing.setRank(count);
|
| - |
|
4781 |
webProductListingRepository.persist(webProductListing);
|
| - |
|
4782 |
|
| - |
|
4783 |
}
|
| - |
|
4784 |
|
| - |
|
4785 |
}
|
| - |
|
4786 |
}
|
| - |
|
4787 |
|
| - |
|
4788 |
public void getUpgradeOffer() throws ProfitMandiBusinessException {
|
| - |
|
4789 |
WebListing webListing = webListingRepository.selectByUrl("upgrade-offer");
|
| - |
|
4790 |
|
| - |
|
4791 |
List<Integer> customerOfferIds = customerOfferRepository
|
| - |
|
4792 |
.selectOffers(LocalDateTime.now().minusDays(30), LocalDateTime.now().plusDays(1)).stream()
|
| - |
|
4793 |
.map(x -> x.getId()).collect(Collectors.toList());
|
| - |
|
4794 |
|
| - |
|
4795 |
Set<Integer> catalogItemIds = customerOfferItemRepository
|
| - |
|
4796 |
.selectByOfferIdsRange(customerOfferIds, LocalDate.now().minusDays(30), LocalDate.now().plusDays(1))
|
| - |
|
4797 |
.stream().map(x -> x.getCatalogId()).collect(Collectors.toSet());
|
| - |
|
4798 |
|
| - |
|
4799 |
LOGGER.info("catalogItemIds {}", catalogItemIds);
|
| - |
|
4800 |
if (!catalogItemIds.isEmpty()) {
|
| - |
|
4801 |
webProductListingRepository.deleteByEqual(webListing.getId());
|
| - |
|
4802 |
int count = 0;
|
| - |
|
4803 |
for (Integer catalogItemId : catalogItemIds) {
|
| - |
|
4804 |
|
| - |
|
4805 |
WebProductListing webProductListing = new WebProductListing();
|
| - |
|
4806 |
webProductListing.setEntityId(catalogItemId);
|
| - |
|
4807 |
webProductListing.setWebListingId(webListing.getId());
|
| - |
|
4808 |
count = count + 1;
|
| 4714 |
webProductListing.setRank(count + 1);
|
4809 |
webProductListing.setRank(count);
|
| 4715 |
webProductListingRepository.persist(webProductListing);
|
4810 |
webProductListingRepository.persist(webProductListing);
|
| 4716 |
|
4811 |
|
| 4717 |
}
|
4812 |
}
|
| 4718 |
|
4813 |
|
| 4719 |
}
|
4814 |
}
|