| Line 282... |
Line 282... |
| 282 |
return "catalog";
|
282 |
return "catalog";
|
| 283 |
}
|
283 |
}
|
| 284 |
|
284 |
|
| 285 |
@RequestMapping(value = "/getWebOfferByCatalogId")
|
285 |
@RequestMapping(value = "/getWebOfferByCatalogId")
|
| 286 |
public String getCatalog(HttpServletRequest request, @RequestParam int catalogItemId, Model model)
|
286 |
public String getCatalog(HttpServletRequest request, @RequestParam int catalogItemId, Model model)
|
| 287 |
|
- |
|
| 288 |
throws ProfitMandiBusinessException {
|
287 |
throws ProfitMandiBusinessException {
|
| 289 |
|
288 |
|
| 290 |
List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers().get(catalogItemId);
|
289 |
List<WebOffer> webOffers = webOfferRepository.selectAllActiveOffers().get(catalogItemId);
|
| 291 |
|
290 |
|
| 292 |
LocalDateTime todayDateTime = LocalDateTime.now();
|
291 |
LocalDateTime todayDateTime = LocalDateTime.now();
|
| 293 |
LocalDate todayDate = LocalDate.now();
|
292 |
LocalDate todayDate = LocalDate.now();
|
| 294 |
|
293 |
|
| 295 |
List<CustomerOffer> customerOffers = customerOfferRepository.selectOffersByDate(todayDateTime);
|
294 |
List<CustomerOffer> customerOffers = customerOfferRepository.selectOffersByDate(todayDateTime);
|
| 296 |
List<Integer> customerOfferIds = customerOffers.stream().map(x -> x.getId()).collect(Collectors.toList());
|
295 |
List<Integer> customerOfferIds = customerOffers.stream().map(CustomerOffer::getId).collect(Collectors.toList());
|
| - |
|
296 |
|
| - |
|
297 |
// Retrieve customer offer items
|
| 297 |
List<CustomerOfferItem> customerOfferItems = customerOfferItemRepository.selectByOfferIds(customerOfferIds, catalogItemId, todayDate);
|
298 |
List<CustomerOfferItem> customerOfferItems = customerOfferItemRepository.selectByOfferIds(customerOfferIds, catalogItemId, todayDate);
|
| 298 |
|
299 |
|
| - |
|
300 |
// Filter customer offer items with endDate greater than today
|
| - |
|
301 |
List<CustomerOfferItem> filteredCustomerOfferItems = customerOfferItems.stream()
|
| - |
|
302 |
.filter(item -> item.getEndDate() != null && item.getEndDate().isAfter(todayDate))
|
| - |
|
303 |
.collect(Collectors.toList());
|
| - |
|
304 |
|
| 299 |
model.addAttribute("webOffers", webOffers);
|
305 |
model.addAttribute("webOffers", webOffers);
|
| 300 |
model.addAttribute("customerOfferItems", customerOfferItems);
|
306 |
model.addAttribute("customerOfferItems", filteredCustomerOfferItems);
|
| 301 |
|
307 |
|
| 302 |
return "web-offer-model";
|
308 |
return "web-offer-model";
|
| 303 |
}
|
309 |
}
|
| 304 |
|
310 |
|
| - |
|
311 |
|
| 305 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
312 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
| 306 |
private boolean hasGift(int fofoId) {
|
313 |
private boolean hasGift(int fofoId) {
|
| 307 |
try {
|
314 |
try {
|
| 308 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId).getAvailability() > 0;
|
315 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId).getAvailability() > 0;
|
| 309 |
} catch (ProfitMandiBusinessException e) {
|
316 |
} catch (ProfitMandiBusinessException e) {
|