Subversion Repositories SmartDukaan

Rev

Rev 35253 | Rev 35458 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 35253 Rev 35271
Line 185... Line 185...
185
            logger.warn("Item not found with ID: {}", itemId);
185
            logger.warn("Item not found with ID: {}", itemId);
186
        }
186
        }
187
        return item;
187
        return item;
188
    }
188
    }
189
 
189
 
190
    private boolean checkGiftAvailability(LocalDate date, int perDayMaxQty) {
190
    private boolean checkGiftAvailability(LocalDate date, int perDayMaxQty, OfferEntity offer) {
-
 
191
        int defaultGiftId = giftRepository.getDefaultGift(offer.getId()).getId();
191
        Integer giftCounts = scratchOfferRepository.countTodaysGiftDistribution(date.atStartOfDay(), date.atTime(LocalTime.MAX));
192
        Integer giftCounts = scratchOfferRepository.countTodaysGiftDistribution(date.atStartOfDay(), date.atTime(LocalTime.MAX), defaultGiftId);
192
        return giftCounts < perDayMaxQty;
193
        return giftCounts < perDayMaxQty;
193
    }
194
    }
194
 
195
 
195
    private boolean isAppleItem(FofoOrder fofoOrder) {
196
    private boolean isAppleItem(FofoOrder fofoOrder) {
196
        List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
197
        List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
Line 218... Line 219...
218
            }
219
            }
219
            return true;
220
            return true;
220
        }
221
        }
221
        int perDayMaxQty = offer.getUserLimit();
222
        int perDayMaxQty = offer.getUserLimit();
222
        LocalDate today = LocalDate.now();
223
        LocalDate today = LocalDate.now();
223
        boolean isMoreGiftAvailable = checkGiftAvailability(today, perDayMaxQty);
224
        boolean isMoreGiftAvailable = checkGiftAvailability(today, perDayMaxQty, offer);
224
        logger.info("Gift availability result: {}", isMoreGiftAvailable);
225
        logger.info("Gift availability result: {}", isMoreGiftAvailable);
225
 
226
 
226
        if (allGifts.isEmpty()) {
227
        if (allGifts.isEmpty()) {
227
            logger.warn("Offer {} has no gifts - cannot process scratch offer", offer.getId());
228
            logger.warn("Offer {} has no gifts - cannot process scratch offer", offer.getId());
228
            return false;
229
            return false;