| Line 644... |
Line 644... |
| 644 |
|
644 |
|
| 645 |
LocalDateTime startDate = date.toLocalDate().minusDays(1).atTime(LocalTime.MAX);
|
645 |
LocalDateTime startDate = date.toLocalDate().minusDays(1).atTime(LocalTime.MAX);
|
| 646 |
LocalDateTime endDate = date.toLocalDate().plusDays(1).atTime(LocalTime.MAX);
|
646 |
LocalDateTime endDate = date.toLocalDate().plusDays(1).atTime(LocalTime.MAX);
|
| 647 |
List<BulletinOfferModal> bulletinOfferModals = new ArrayList<>();
|
647 |
List<BulletinOfferModal> bulletinOfferModals = new ArrayList<>();
|
| 648 |
|
648 |
|
| - |
|
649 |
// Each sub-fetch is best-effort — one failing shouldn't wipe out the whole
|
| - |
|
650 |
// bulletin response (especially the always-present Thought of the Day).
|
| - |
|
651 |
try {
|
| 649 |
List<Bulletin> bulletins = bulletinRepository.selectALlTodayBulletinByRegionIds(regionIds, startDate, endDate);
|
652 |
List<Bulletin> bulletins = bulletinRepository.selectALlTodayBulletinByRegionIds(regionIds, startDate, endDate);
|
| 650 |
for (Bulletin b : bulletins) {
|
653 |
for (Bulletin b : bulletins) {
|
| - |
|
654 |
|
| - |
|
655 |
BulletinOfferModal modal = new BulletinOfferModal();
|
| - |
|
656 |
modal.setOfferId(b.getId());
|
| - |
|
657 |
modal.setDescription(b.getDescription());
|
| - |
|
658 |
modal.setCreatedTime(formatter.format(b.getCreatedAt()));
|
| - |
|
659 |
modal.setCatalogOffer(false);
|
| - |
|
660 |
modal.setCreatedAt(b.getCreatedAt());
|
| - |
|
661 |
modal.setCreatedBy(b.getCreatedBy());
|
| - |
|
662 |
modal.setBulletinType(ProfitMandiConstants.BULLETIN_TYPE_ENUM.BULLETIN);
|
| - |
|
663 |
|
| - |
|
664 |
if (b.getDocumentIds() != null && !b.getDocumentIds().isEmpty()) {
|
| - |
|
665 |
List<Integer> docIds = Arrays.stream(b.getDocumentIds().split(","))
|
| - |
|
666 |
.map(String::trim)
|
| - |
|
667 |
.map(Integer::parseInt)
|
| - |
|
668 |
.collect(Collectors.toList());
|
| 651 |
|
669 |
|
| 652 |
BulletinOfferModal modal = new BulletinOfferModal();
|
- |
|
| 653 |
modal.setOfferId(b.getId());
|
670 |
modal.setDocumentIds(docIds);
|
| 654 |
modal.setDescription(b.getDescription());
|
- |
|
| 655 |
modal.setCreatedTime(formatter.format(b.getCreatedAt()));
|
- |
|
| 656 |
modal.setCatalogOffer(false);
|
- |
|
| 657 |
modal.setCreatedAt(b.getCreatedAt());
|
- |
|
| 658 |
modal.setCreatedBy(b.getCreatedBy());
|
- |
|
| 659 |
modal.setBulletinType(ProfitMandiConstants.BULLETIN_TYPE_ENUM.BULLETIN);
|
- |
|
| 660 |
|
- |
|
| 661 |
// ADD THIS BLOCK
|
671 |
}
|
| 662 |
if (b.getDocumentIds() != null && !b.getDocumentIds().isEmpty()) {
|
- |
|
| 663 |
List<Integer> docIds = Arrays.stream(b.getDocumentIds().split(","))
|
- |
|
| 664 |
.map(String::trim)
|
- |
|
| 665 |
.map(Integer::parseInt)
|
- |
|
| 666 |
.collect(Collectors.toList());
|
- |
|
| 667 |
|
672 |
|
| 668 |
modal.setDocumentIds(docIds);
|
673 |
bulletinOfferModals.add(modal);
|
| 669 |
}
|
674 |
}
|
| 670 |
|
- |
|
| 671 |
bulletinOfferModals.add(modal);
|
675 |
} catch (Exception e) {
|
| - |
|
676 |
LOGGER.warn("selectALlTodayBulletinByRegionIds failed: {}", e.getMessage());
|
| 672 |
}
|
677 |
}
|
| 673 |
|
678 |
|
| 674 |
// 0️⃣ Thought of the Day (virtual bulletin)
|
679 |
// 0️⃣ Thought of the Day (virtual bulletin) — always added, does not depend
|
| - |
|
680 |
// on any DB/service call.
|
| 675 |
BulletinOfferModal thoughtModal = new BulletinOfferModal();
|
681 |
BulletinOfferModal thoughtModal = new BulletinOfferModal();
|
| 676 |
thoughtModal.setOfferId(0L); // dummy
|
682 |
thoughtModal.setOfferId(0L); // dummy
|
| 677 |
thoughtModal.setDescription(SalesThoughtConstants.getTodayThought());
|
683 |
thoughtModal.setDescription(SalesThoughtConstants.getTodayThought());
|
| 678 |
thoughtModal.setCreatedAt(LocalDateTime.MAX); // IMPORTANT → always first
|
684 |
thoughtModal.setCreatedAt(LocalDateTime.MAX); // IMPORTANT → always first
|
| 679 |
thoughtModal.setCreatedTime("");
|
685 |
thoughtModal.setCreatedTime("");
|
| Line 682... |
Line 688... |
| 682 |
thoughtModal.setBulletinType(ProfitMandiConstants.BULLETIN_TYPE_ENUM.BULLETIN);
|
688 |
thoughtModal.setBulletinType(ProfitMandiConstants.BULLETIN_TYPE_ENUM.BULLETIN);
|
| 683 |
|
689 |
|
| 684 |
bulletinOfferModals.add(thoughtModal);
|
690 |
bulletinOfferModals.add(thoughtModal);
|
| 685 |
|
691 |
|
| 686 |
|
692 |
|
| - |
|
693 |
try {
|
| 687 |
List<BulletinOfferModal> getTodayCreatedCatalogOffer = todayOfferService.findAllTodayCatalogOfferBulletin(regionIds.stream().map(x -> x.intValue()).collect(Collectors.toList()), startDate, endDate);
|
694 |
List<BulletinOfferModal> getTodayCreatedCatalogOffer = todayOfferService.findAllTodayCatalogOfferBulletin(regionIds.stream().map(x -> x.intValue()).collect(Collectors.toList()), startDate, endDate);
|
| 688 |
bulletinOfferModals.addAll(getTodayCreatedCatalogOffer);
|
695 |
bulletinOfferModals.addAll(getTodayCreatedCatalogOffer);
|
| - |
|
696 |
} catch (Exception e) {
|
| - |
|
697 |
LOGGER.warn("findAllTodayCatalogOfferBulletin failed: {}", e.getMessage());
|
| - |
|
698 |
}
|
| 689 |
|
699 |
|
| - |
|
700 |
try {
|
| 690 |
List<BulletinOfferModal> getTodaySchemes = todayOfferService.findAllTodaySchemeBulletin(regionIds.stream().map(x -> x.intValue()).collect(Collectors.toList()), startDate, endDate);
|
701 |
List<BulletinOfferModal> getTodaySchemes = todayOfferService.findAllTodaySchemeBulletin(regionIds.stream().map(x -> x.intValue()).collect(Collectors.toList()), startDate, endDate);
|
| 691 |
bulletinOfferModals.addAll(getTodaySchemes);
|
702 |
bulletinOfferModals.addAll(getTodaySchemes);
|
| - |
|
703 |
} catch (Exception e) {
|
| - |
|
704 |
LOGGER.warn("findAllTodaySchemeBulletin failed: {}", e.getMessage());
|
| - |
|
705 |
}
|
| 692 |
|
706 |
|
| - |
|
707 |
try {
|
| 693 |
List<BulletinOfferModal> getTodayCardCashback = todayOfferService.findAllTodayWebOfferBulletin(startDate, endDate);
|
708 |
List<BulletinOfferModal> getTodayCardCashback = todayOfferService.findAllTodayWebOfferBulletin(startDate, endDate);
|
| 694 |
bulletinOfferModals.addAll(getTodayCardCashback);
|
709 |
bulletinOfferModals.addAll(getTodayCardCashback);
|
| - |
|
710 |
} catch (Exception e) {
|
| - |
|
711 |
LOGGER.warn("findAllTodayWebOfferBulletin failed: {}", e.getMessage());
|
| - |
|
712 |
}
|
| 695 |
|
713 |
|
| - |
|
714 |
try {
|
| 696 |
List<BulletinOfferModal> getTodayPrebookingList = todayOfferService.getAllTodayCreatedPreBookingList(startDate, endDate);
|
715 |
List<BulletinOfferModal> getTodayPrebookingList = todayOfferService.getAllTodayCreatedPreBookingList(startDate, endDate);
|
| 697 |
bulletinOfferModals.addAll(getTodayPrebookingList);
|
716 |
bulletinOfferModals.addAll(getTodayPrebookingList);
|
| - |
|
717 |
} catch (Exception e) {
|
| - |
|
718 |
LOGGER.warn("getAllTodayCreatedPreBookingList failed: {}", e.getMessage());
|
| - |
|
719 |
}
|
| 698 |
|
720 |
|
| 699 |
bulletinOfferModals.sort(
|
721 |
bulletinOfferModals.sort(
|
| 700 |
Comparator.comparing(BulletinOfferModal::getCreatedAt).reversed()
|
722 |
Comparator.comparing(BulletinOfferModal::getCreatedAt).reversed()
|
| 701 |
);
|
723 |
);
|
| 702 |
|
724 |
|