| Line 145... |
Line 145... |
| 145 |
private PriceCircularService priceCircularService;
|
145 |
private PriceCircularService priceCircularService;
|
| 146 |
|
146 |
|
| 147 |
@Autowired
|
147 |
@Autowired
|
| 148 |
private WalletService walletService;
|
148 |
private WalletService walletService;
|
| 149 |
|
149 |
|
| - |
|
150 |
/**
|
| - |
|
151 |
* Evicts all caches related to a specific offer.
|
| - |
|
152 |
*
|
| - |
|
153 |
* Cache inventory (all Redis, 6h TTL unless noted):
|
| - |
|
154 |
* - monthOfferIds : Set<Integer> of offer IDs for a month. Key = YearMonth.
|
| - |
|
155 |
* Used by /offerHistory admin listing (activeOnly=false).
|
| - |
|
156 |
* - offer.definition : CreateOfferRequest per offer. Key = offerId.
|
| - |
|
157 |
* - catalog.published_yearmonth : Map<fofoId, List<Offer>> for partner-facing published view.
|
| - |
|
158 |
* Key = YearMonth. Filtered by activeOnly=true.
|
| - |
|
159 |
* - offer.slabpayout : Slab payout map per offer. Key = offerId.
|
| - |
|
160 |
* - offer.achievement : Sellin/sellout achievement per (offerId, fofoId). 30 min TTL.
|
| - |
|
161 |
* - todayOffers : Today's offers per (brand, fofoId). 60 min TTL (redisShortCacheManager).
|
| - |
|
162 |
*/
|
| 150 |
@Override
|
163 |
@Override
|
| 151 |
public void evictOfferCaches(int offerId) {
|
164 |
public void evictOfferCaches(int offerId) {
|
| 152 |
Offer offer = offerRepository.selectById(offerId);
|
165 |
Offer offer = offerRepository.selectById(offerId);
|
| 153 |
YearMonth ym = YearMonth.from(offer.getStartDate());
|
166 |
YearMonth ym = YearMonth.from(offer.getStartDate());
|
| 154 |
redisCacheManager.getCache("monthOfferIds").evict(ym);
|
167 |
evictMonthCaches(ym);
|
| 155 |
redisCacheManager.getCache("offer.definition").evict(offerId);
|
168 |
redisCacheManager.getCache("offer.definition").evict(offerId);
|
| 156 |
redisCacheManager.getCache("catalog.published_yearmonth").evict(ym);
|
- |
|
| 157 |
redisCacheManager.getCache("offer.slabpayout").evict(offerId);
|
169 |
redisCacheManager.getCache("offer.slabpayout").evict(offerId);
|
| 158 |
redisCacheManager.getCache("offer.achievement").clear();
|
170 |
redisCacheManager.getCache("offer.achievement").clear();
|
| 159 |
redisShortCacheManager.getCache("todayOffers").clear();
|
- |
|
| 160 |
}
|
171 |
}
|
| 161 |
|
172 |
|
| 162 |
@Override
|
173 |
@Override
|
| 163 |
public void evictOfferDefinitionCache(int offerId) {
|
174 |
public void evictOfferDefinitionCache(int offerId) {
|
| 164 |
redisCacheManager.getCache("offer.definition").evict(offerId);
|
175 |
redisCacheManager.getCache("offer.definition").evict(offerId);
|
| 165 |
}
|
176 |
}
|
| 166 |
|
177 |
|
| 167 |
@Override
|
178 |
@Override
|
| - |
|
179 |
public void evictMonthCaches(YearMonth yearMonth) {
|
| - |
|
180 |
redisCacheManager.getCache("monthOfferIds").evict(yearMonth);
|
| - |
|
181 |
redisCacheManager.getCache("catalog.published_yearmonth").evict(yearMonth);
|
| - |
|
182 |
redisShortCacheManager.getCache("todayOffers").clear();
|
| - |
|
183 |
}
|
| - |
|
184 |
|
| - |
|
185 |
@Override
|
| 168 |
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
186 |
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
| 169 |
public List<Offer> activateOffers(List<Integer> offerIds, boolean active) throws ProfitMandiBusinessException {
|
187 |
public List<Offer> activateOffers(List<Integer> offerIds, boolean active) throws ProfitMandiBusinessException {
|
| 170 |
List<Offer> offers = offerRepository.selectAllByIds(offerIds);
|
188 |
List<Offer> offers = offerRepository.selectAllByIds(offerIds);
|
| 171 |
offers = offers.stream().filter(x -> x.isActive() != active).collect(Collectors.toList());
|
189 |
offers = offers.stream().filter(x -> x.isActive() != active).collect(Collectors.toList());
|
| 172 |
for (Offer offer : offers) {
|
190 |
for (Offer offer : offers) {
|
| Line 545... |
Line 563... |
| 545 |
this.addOfferService(createOfferRequest);
|
563 |
this.addOfferService(createOfferRequest);
|
| 546 |
}
|
564 |
}
|
| 547 |
ymListToEvict.add(YearMonth.from(createOfferRequest.getStartDate()));
|
565 |
ymListToEvict.add(YearMonth.from(createOfferRequest.getStartDate()));
|
| 548 |
}
|
566 |
}
|
| 549 |
for (YearMonth ymToEvict : ymListToEvict) {
|
567 |
for (YearMonth ymToEvict : ymListToEvict) {
|
| 550 |
redisCacheManager.getCache("monthOfferIds").evict(ymToEvict);
|
568 |
evictMonthCaches(ymToEvict);
|
| 551 |
}
|
569 |
}
|
| 552 |
}
|
570 |
}
|
| 553 |
|
571 |
|
| 554 |
private Map<CreateOfferRequest, List<PartnerTargetModel>> parseFromExcel(InputStream inputStream)
|
572 |
private Map<CreateOfferRequest, List<PartnerTargetModel>> parseFromExcel(InputStream inputStream)
|
| 555 |
throws ProfitMandiBusinessException {
|
573 |
throws ProfitMandiBusinessException {
|