org.broadleafcommerce.core.offer.service.processor
Class ItemOfferProcessorImpl

java.lang.Object
  extended by org.broadleafcommerce.core.offer.service.processor.AbstractBaseProcessor
      extended by org.broadleafcommerce.core.offer.service.processor.OrderOfferProcessorImpl
          extended by org.broadleafcommerce.core.offer.service.processor.ItemOfferProcessorImpl
All Implemented Interfaces:
BaseProcessor, ItemOfferProcessor, OrderOfferProcessor

@Service(value="blItemOfferProcessor")
public class ItemOfferProcessorImpl
extends OrderOfferProcessorImpl
implements ItemOfferProcessor

Filter and apply order item offers.

Author:
jfischer

Field Summary
 
Fields inherited from class org.broadleafcommerce.core.offer.service.processor.OrderOfferProcessorImpl
cartService, fulfillmentGroupItemDao, offerDao, orderItemService
 
Constructor Summary
ItemOfferProcessorImpl()
           
 
Method Summary
protected  int applyAdjustments(java.util.List<DiscreteOrderItem> discreteOrderItems, Order order, int appliedItemOffersCount, CandidateItemOffer itemOffer, int beforeCount)
           
 boolean applyAllItemOffers(java.util.List<CandidateItemOffer> itemOffers, java.util.List<DiscreteOrderItem> discreteOrderItems, Order order)
          Private method that takes a list of sorted CandidateItemOffers and determines if each offer can be applied based on the restrictions (stackable and/or combinable) on that offer.
 void applyAndCompareOrderAndItemOffers(Order order, java.util.List<CandidateOrderOffer> qualifiedOrderOffers, java.util.List<CandidateItemOffer> qualifiedItemOffers, java.util.List<DiscreteOrderItem> discreteOrderItems)
           
protected  void applyItemQualifiersAndTargets(java.util.List<DiscreteOrderItem> discreteOrderItems, CandidateItemOffer itemOffer, Order order)
           
protected  int applyLegacyAdjustments(java.util.List<DiscreteOrderItem> discreteOrderItems, int appliedItemOffersCount, CandidateItemOffer itemOffer, int beforeCount, OrderItem orderItem)
           
protected  void applyOrderItemAdjustment(CandidateItemOffer itemOffer, OrderItem orderItem)
          Private method used by applyAllItemOffers to create an OrderItemAdjustment from a CandidateItemOffer and associates the OrderItemAdjustment to the OrderItem.
protected  int checkAdjustments(Order order, int appliedItemOffersCount)
           
protected  int checkLegacyAdjustments(java.util.List<DiscreteOrderItem> discreteOrderItems, int appliedItemOffersCount)
           
protected  CandidateItemOffer createCandidateItemOffer(java.util.List<CandidateItemOffer> qualifiedItemOffers, Offer offer, OrderItem discreteOrderItem)
          Create a candidate item offer based on the offer in question and a specific order item
 void filterItemLevelOffer(Order order, java.util.List<CandidateItemOffer> qualifiedItemOffers, java.util.List<DiscreteOrderItem> discreteOrderItems, Offer offer)
          Review an item level offer against the list of discountable items from the order.
 java.util.List<DiscreteOrderItem> filterOffers(Order order, java.util.List<Offer> filteredOffers, java.util.List<CandidateOrderOffer> qualifiedOrderOffers, java.util.List<CandidateItemOffer> qualifiedItemOffers)
           
 
Methods inherited from class org.broadleafcommerce.core.offer.service.processor.OrderOfferProcessorImpl
applyAllOrderOffers, applyOrderOffer, compareAndAdjustOrderAndItemOffers, compileOrderTotal, couldOfferApplyToOrder, couldOfferApplyToOrder, couldOfferApplyToOrder, couldOfferApplyToOrder, createCandidateOrderOffer, filterOrderLevelOffer, gatherCart, getAllSplitItems, getCartService, getFulfillmentGroupItemDao, getOfferDao, getOrderItemService, initializeSplitItems, mergeSplitItems, removeTrailingNotCombinableOrderOffers, setCartService, setFulfillmentGroupItemDao, setOfferDao, setOrderItemService
 
Methods inherited from class org.broadleafcommerce.core.offer.service.processor.AbstractBaseProcessor
checkForItemRequirements, clearAllNonFinalizedQuantities, clearOffersandAdjustments, couldOfferApplyToCustomer, couldOfferApplyToOrderItems, couldOrderItemMeetOfferRequirement, executeExpression, filterOffers, finalizeQuantities, removeInvalidCustomerOffers, removeOutOfDateOffers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.broadleafcommerce.core.offer.service.processor.OrderOfferProcessor
applyAllOrderOffers, compileOrderTotal, couldOfferApplyToOrder, executeExpression, filterOrderLevelOffer, gatherCart, getAllSplitItems, getCartService, getFulfillmentGroupItemDao, getOfferDao, getOrderItemService, initializeSplitItems, removeTrailingNotCombinableOrderOffers, setCartService, setFulfillmentGroupItemDao, setOfferDao, setOrderItemService
 
Methods inherited from interface org.broadleafcommerce.core.offer.service.processor.BaseProcessor
clearOffersandAdjustments, filterOffers
 

Constructor Detail

ItemOfferProcessorImpl

public ItemOfferProcessorImpl()
Method Detail

filterItemLevelOffer

public void filterItemLevelOffer(Order order,
                                 java.util.List<CandidateItemOffer> qualifiedItemOffers,
                                 java.util.List<DiscreteOrderItem> discreteOrderItems,
                                 Offer offer)
Description copied from interface: ItemOfferProcessor
Review an item level offer against the list of discountable items from the order. If the offer applies, add it to the qualifiedItemOffers list.

Specified by:
filterItemLevelOffer in interface ItemOfferProcessor
Parameters:
order - the BLC order
qualifiedItemOffers - the container list for any qualified offers
discreteOrderItems - the order items to evaluate
offer - the offer in question

createCandidateItemOffer

protected CandidateItemOffer createCandidateItemOffer(java.util.List<CandidateItemOffer> qualifiedItemOffers,
                                                      Offer offer,
                                                      OrderItem discreteOrderItem)
Create a candidate item offer based on the offer in question and a specific order item

Parameters:
qualifiedItemOffers - the container list for candidate item offers
offer - the offer in question
discreteOrderItem - the specific order item
Returns:
the candidate item offer

applyAllItemOffers

public boolean applyAllItemOffers(java.util.List<CandidateItemOffer> itemOffers,
                                  java.util.List<DiscreteOrderItem> discreteOrderItems,
                                  Order order)
Description copied from interface: ItemOfferProcessor
Private method that takes a list of sorted CandidateItemOffers and determines if each offer can be applied based on the restrictions (stackable and/or combinable) on that offer. OrderItemAdjustments are create on the OrderItem for each applied CandidateItemOffer. An offer with stackable equals false cannot be applied to an OrderItem that already contains an OrderItemAdjustment. An offer with combinable equals false cannot be applied to an OrderItem if that OrderItem already contains an OrderItemAdjustment, unless the offer is the same offer as the OrderItemAdjustment offer.

Specified by:
applyAllItemOffers in interface ItemOfferProcessor
Parameters:
itemOffers - a sorted list of CandidateItemOffer
Returns:
true if an OrderItemOffer was applied, otherwise false

applyAdjustments

protected int applyAdjustments(java.util.List<DiscreteOrderItem> discreteOrderItems,
                               Order order,
                               int appliedItemOffersCount,
                               CandidateItemOffer itemOffer,
                               int beforeCount)

checkAdjustments

protected int checkAdjustments(Order order,
                               int appliedItemOffersCount)

checkLegacyAdjustments

protected int checkLegacyAdjustments(java.util.List<DiscreteOrderItem> discreteOrderItems,
                                     int appliedItemOffersCount)

applyLegacyAdjustments

protected int applyLegacyAdjustments(java.util.List<DiscreteOrderItem> discreteOrderItems,
                                     int appliedItemOffersCount,
                                     CandidateItemOffer itemOffer,
                                     int beforeCount,
                                     OrderItem orderItem)

applyItemQualifiersAndTargets

protected void applyItemQualifiersAndTargets(java.util.List<DiscreteOrderItem> discreteOrderItems,
                                             CandidateItemOffer itemOffer,
                                             Order order)

applyOrderItemAdjustment

protected void applyOrderItemAdjustment(CandidateItemOffer itemOffer,
                                        OrderItem orderItem)
Private method used by applyAllItemOffers to create an OrderItemAdjustment from a CandidateItemOffer and associates the OrderItemAdjustment to the OrderItem.

Parameters:
itemOffer - a CandidateItemOffer to apply to an OrderItem

filterOffers

public java.util.List<DiscreteOrderItem> filterOffers(Order order,
                                                      java.util.List<Offer> filteredOffers,
                                                      java.util.List<CandidateOrderOffer> qualifiedOrderOffers,
                                                      java.util.List<CandidateItemOffer> qualifiedItemOffers)
Specified by:
filterOffers in interface ItemOfferProcessor

applyAndCompareOrderAndItemOffers

public void applyAndCompareOrderAndItemOffers(Order order,
                                              java.util.List<CandidateOrderOffer> qualifiedOrderOffers,
                                              java.util.List<CandidateItemOffer> qualifiedItemOffers,
                                              java.util.List<DiscreteOrderItem> discreteOrderItems)
Specified by:
applyAndCompareOrderAndItemOffers in interface ItemOfferProcessor


Copyright © 2011. All Rights Reserved.