| Line 190... |
Line 190... |
| 190 |
Set<YearMonth> yearMonthsToEvict = new HashSet<>();
|
190 |
Set<YearMonth> yearMonthsToEvict = new HashSet<>();
|
| 191 |
for (Offer offer : offers) {
|
191 |
for (Offer offer : offers) {
|
| 192 |
offer.setActive(active);
|
192 |
offer.setActive(active);
|
| 193 |
yearMonthsToEvict.add(YearMonth.from(offer.getStartDate()));
|
193 |
yearMonthsToEvict.add(YearMonth.from(offer.getStartDate()));
|
| 194 |
}
|
194 |
}
|
| 195 |
//Evict caches
|
195 |
// Evict partner-to-offer mapping (which partners see which offers)
|
| 196 |
for (YearMonth ymToEvict : yearMonthsToEvict) {
|
196 |
for (YearMonth ymToEvict : yearMonthsToEvict) {
|
| 197 |
redisCacheManager.getCache("catalog.published_yearmonth").evict(ymToEvict);
|
197 |
redisCacheManager.getCache("catalog.published_yearmonth").evict(ymToEvict);
|
| 198 |
oneDayCacheManager.getCache("allOffers").evict(ymToEvict);
|
198 |
oneDayCacheManager.getCache("allOffers").evict(ymToEvict);
|
| 199 |
}
|
199 |
}
|
| - |
|
200 |
// Evict partner's published offer list with achievement data
|
| 200 |
redisShortCacheManager.getCache("publishedOffersWithAchievement").clear();
|
201 |
redisShortCacheManager.getCache("publishedOffersWithAchievement").clear();
|
| 201 |
// Evict partnerOffers cache for involved partners + admin view
|
202 |
// Evict offer detail (price circular) for each involved partner; key=(fofoId, offerId), 0=admin
|
| 202 |
for (Offer offer : offers) {
|
203 |
for (Offer offer : offers) {
|
| 203 |
PartnerCriteria partnerCriteria = gson.fromJson(offer.getPartnerCriteria(), PartnerCriteria.class);
|
204 |
PartnerCriteria partnerCriteria = gson.fromJson(offer.getPartnerCriteria(), PartnerCriteria.class);
|
| 204 |
if (partnerCriteria != null && partnerCriteria.getFofoIds() != null) {
|
205 |
if (partnerCriteria != null && partnerCriteria.getFofoIds() != null) {
|
| 205 |
for (Integer fofoId : partnerCriteria.getFofoIds()) {
|
206 |
for (Integer fofoId : partnerCriteria.getFofoIds()) {
|
| 206 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(fofoId, offer.getId()));
|
207 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(fofoId, offer.getId()));
|
| Line 222... |
Line 223... |
| 222 |
@RequestMapping(value = "/offers/publishAll", method = RequestMethod.POST)
|
223 |
@RequestMapping(value = "/offers/publishAll", method = RequestMethod.POST)
|
| 223 |
public ResponseEntity<?> publishAllUnpublished(@RequestParam YearMonth yearMonth)
|
224 |
public ResponseEntity<?> publishAllUnpublished(@RequestParam YearMonth yearMonth)
|
| 224 |
throws ProfitMandiBusinessException, Exception {
|
225 |
throws ProfitMandiBusinessException, Exception {
|
| 225 |
List<Offer> published = offerService.publishAllUnpublished(yearMonth);
|
226 |
List<Offer> published = offerService.publishAllUnpublished(yearMonth);
|
| 226 |
if (!published.isEmpty()) {
|
227 |
if (!published.isEmpty()) {
|
| - |
|
228 |
// Evict partner-to-offer mapping and offer listing
|
| 227 |
redisCacheManager.getCache("catalog.published_yearmonth").evict(yearMonth);
|
229 |
redisCacheManager.getCache("catalog.published_yearmonth").evict(yearMonth);
|
| 228 |
oneDayCacheManager.getCache("allOffers").evict(yearMonth);
|
230 |
oneDayCacheManager.getCache("allOffers").evict(yearMonth);
|
| 229 |
redisShortCacheManager.getCache("publishedOffersWithAchievement").clear();
|
231 |
redisShortCacheManager.getCache("publishedOffersWithAchievement").clear();
|
| 230 |
// Evict partnerOffers cache for involved partners + admin view
|
232 |
// Evict offer detail (price circular) for each involved partner; key=(fofoId, offerId), 0=admin
|
| 231 |
for (Offer offer : published) {
|
233 |
for (Offer offer : published) {
|
| 232 |
PartnerCriteria pc = gson.fromJson(offer.getPartnerCriteria(), PartnerCriteria.class);
|
234 |
PartnerCriteria pc = gson.fromJson(offer.getPartnerCriteria(), PartnerCriteria.class);
|
| 233 |
if (pc != null && pc.getFofoIds() != null) {
|
235 |
if (pc != null && pc.getFofoIds() != null) {
|
| 234 |
for (Integer fofoId : pc.getFofoIds()) {
|
236 |
for (Integer fofoId : pc.getFofoIds()) {
|
| 235 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(fofoId, offer.getId()));
|
237 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(fofoId, offer.getId()));
|
| Line 676... |
Line 678... |
| 676 |
message = "Partner(s) removed from Offer #" + offerId + ". New Offer #" + newOfferId + " created (Unpublished).";
|
678 |
message = "Partner(s) removed from Offer #" + offerId + ". New Offer #" + newOfferId + " created (Unpublished).";
|
| 677 |
} else {
|
679 |
} else {
|
| 678 |
message = "Partner(s) removed from Offer #" + offerId + ".";
|
680 |
message = "Partner(s) removed from Offer #" + offerId + ".";
|
| 679 |
}
|
681 |
}
|
| 680 |
|
682 |
|
| - |
|
683 |
// Evict partner-to-offer mapping (removed partners no longer see this offer)
|
| 681 |
oneDayCacheManager.getCache("allOffers").evict(ym);
|
684 |
oneDayCacheManager.getCache("allOffers").evict(ym);
|
| 682 |
redisCacheManager.getCache("catalog.published_yearmonth").evict(ym);
|
685 |
redisCacheManager.getCache("catalog.published_yearmonth").evict(ym);
|
| 683 |
redisShortCacheManager.getCache("publishedOffersWithAchievement").clear();
|
686 |
redisShortCacheManager.getCache("publishedOffersWithAchievement").clear();
|
| 684 |
// Evict partnerOffers cache for removed partners + admin view
|
687 |
// Evict offer detail (price circular) for removed partners; key=(fofoId, offerId), 0=admin
|
| 685 |
for (Integer fofoId : fofoIds) {
|
688 |
for (Integer fofoId : fofoIds) {
|
| 686 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(fofoId, offerId));
|
689 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(fofoId, offerId));
|
| 687 |
}
|
690 |
}
|
| 688 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(0, offerId));
|
691 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(0, offerId));
|
| 689 |
|
692 |
|
| Line 703... |
Line 706... |
| 703 |
}
|
706 |
}
|
| 704 |
offerService.addPartnersToOffer(offerId, fofoIds);
|
707 |
offerService.addPartnersToOffer(offerId, fofoIds);
|
| 705 |
|
708 |
|
| 706 |
Offer offer = offerRepository.selectById(offerId);
|
709 |
Offer offer = offerRepository.selectById(offerId);
|
| 707 |
YearMonth ym = YearMonth.from(offer.getStartDate());
|
710 |
YearMonth ym = YearMonth.from(offer.getStartDate());
|
| - |
|
711 |
// Evict partner-to-offer mapping (added partners now see this offer)
|
| 708 |
oneDayCacheManager.getCache("allOffers").evict(ym);
|
712 |
oneDayCacheManager.getCache("allOffers").evict(ym);
|
| 709 |
redisCacheManager.getCache("catalog.published_yearmonth").evict(ym);
|
713 |
redisCacheManager.getCache("catalog.published_yearmonth").evict(ym);
|
| 710 |
redisShortCacheManager.getCache("publishedOffersWithAchievement").clear();
|
714 |
redisShortCacheManager.getCache("publishedOffersWithAchievement").clear();
|
| 711 |
// Evict partnerOffers cache for added partners + admin view
|
715 |
// Evict offer detail (price circular) for added partners; key=(fofoId, offerId), 0=admin
|
| 712 |
for (Integer fofoId : fofoIds) {
|
716 |
for (Integer fofoId : fofoIds) {
|
| 713 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(fofoId, offerId));
|
717 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(fofoId, offerId));
|
| 714 |
}
|
718 |
}
|
| 715 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(0, offerId));
|
719 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(0, offerId));
|
| 716 |
|
720 |
|
| Line 729... |
Line 733... |
| 729 |
}
|
733 |
}
|
| 730 |
offerService.updateOfferTargets(offerId, targets);
|
734 |
offerService.updateOfferTargets(offerId, targets);
|
| 731 |
|
735 |
|
| 732 |
Offer offer = offerRepository.selectById(offerId);
|
736 |
Offer offer = offerRepository.selectById(offerId);
|
| 733 |
YearMonth ym = YearMonth.from(offer.getStartDate());
|
737 |
YearMonth ym = YearMonth.from(offer.getStartDate());
|
| - |
|
738 |
// Evict offer listing and partner-to-offer mapping (targets changed for published offer)
|
| 734 |
oneDayCacheManager.getCache("allOffers").evict(ym);
|
739 |
oneDayCacheManager.getCache("allOffers").evict(ym);
|
| 735 |
redisCacheManager.getCache("catalog.published_yearmonth").evict(ym);
|
740 |
redisCacheManager.getCache("catalog.published_yearmonth").evict(ym);
|
| 736 |
redisShortCacheManager.getCache("publishedOffersWithAchievement").clear();
|
741 |
redisShortCacheManager.getCache("publishedOffersWithAchievement").clear();
|
| 737 |
// Evict partnerOffers cache for all partners of this offer + admin view
|
742 |
// Evict offer detail (price circular) for all partners of this offer; key=(fofoId, offerId), 0=admin
|
| 738 |
PartnerCriteria partnerCriteria = gson.fromJson(offer.getPartnerCriteria(), PartnerCriteria.class);
|
743 |
PartnerCriteria partnerCriteria = gson.fromJson(offer.getPartnerCriteria(), PartnerCriteria.class);
|
| 739 |
if (partnerCriteria != null && partnerCriteria.getFofoIds() != null) {
|
744 |
if (partnerCriteria != null && partnerCriteria.getFofoIds() != null) {
|
| 740 |
for (Integer fofoId : partnerCriteria.getFofoIds()) {
|
745 |
for (Integer fofoId : partnerCriteria.getFofoIds()) {
|
| 741 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(fofoId, offerId));
|
746 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(fofoId, offerId));
|
| 742 |
}
|
747 |
}
|