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

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

@Service(value="blOrderOfferProcessor")
public class OrderOfferProcessorImpl
extends AbstractBaseProcessor
implements OrderOfferProcessor

Author:
jfischer, bpolster

Field Summary
protected  OfferDao offerDao
           
protected  OrderItemDao orderItemDao
           
protected  PromotableItemFactory promotableItemFactory
           
 
Fields inherited from class org.broadleafcommerce.core.offer.service.processor.AbstractBaseProcessor
offerTimeZoneProcessor
 
Constructor Summary
OrderOfferProcessorImpl()
           
 
Method Summary
 void applyAllOrderOffers(List<PromotableCandidateOrderOffer> orderOffers, PromotableOrder promotableOrder)
          Takes a list of sorted CandidateOrderOffers and determines if each offer can be applied based on the restrictions (stackable and/or combinable) on that offer.
protected  void applyOrderOffer(PromotableOrder promotableOrder, PromotableCandidateOrderOffer orderOffer)
          Private method used by applyAllOrderOffers to create an OrderAdjustment from a CandidateOrderOffer and associates the OrderAdjustment to the Order.
protected  Map<Long,OrderItemPriceDetailAdjustment> buildItemDetailAdjustmentMap(OrderItemPriceDetail itemDetail)
           
protected  String buildItemPriceDetailKey(OrderItemPriceDetail itemDetail)
           
protected  List<OrderItem> buildOrderItemList(Order order)
           
protected  Map<Long,PromotableFulfillmentGroupAdjustment> buildPromFulfillmentAdjMap(PromotableFulfillmentGroup fg)
           
protected  Map<String,PromotableOrderItemPriceDetail> buildPromotableDetailsMap(PromotableOrderItem item)
           
protected  Map<Long,PromotableFulfillmentGroup> buildPromotableFulfillmentGroupMap(PromotableOrder order)
           
protected  Map<OrderItem,PromotableOrderItem> buildPromotableItemMap(PromotableOrder promotableOrder)
           
protected  Map<Long,PromotableOrderAdjustment> buildPromotableOrderAdjustmentsMap(PromotableOrder promotableOrder)
           
protected  Map<Long,PromotionQualifier> buildPromotableQualifiersMap(PromotableOrderItem item)
           
protected  void compareAndAdjustOrderAndItemOffers(PromotableOrder promotableOrder)
          Called when the system must determine whether to apply order or item adjustments.
 boolean couldOfferApplyToOrder(Offer offer, PromotableOrder promotableOrder)
          Executes the appliesToOrderRules in the Offer to determine if this offer can be applied to the Order, OrderItem, or FulfillmentGroup.
protected  boolean couldOfferApplyToOrder(Offer offer, PromotableOrder promotableOrder, PromotableFulfillmentGroup fulfillmentGroup)
          Private method which executes the appliesToOrderRules in the Offer to determine if this offer can be applied to the Order, OrderItem, or FulfillmentGroup.
protected  boolean couldOfferApplyToOrder(Offer offer, PromotableOrder promotableOrder, PromotableOrderItem orderItem)
          Private method which executes the appliesToOrderRules in the Offer to determine if this offer can be applied to the Order, OrderItem, or FulfillmentGroup.
protected  boolean couldOfferApplyToOrder(Offer offer, PromotableOrder promotableOrder, PromotableOrderItem promotableOrderItem, PromotableFulfillmentGroup promotableFulfillmentGroup)
          Private method which executes the appliesToOrderRules in the Offer to determine if this offer can be applied to the Order, OrderItem, or FulfillmentGroup.
protected  PromotableCandidateOrderOffer createCandidateOrderOffer(PromotableOrder promotableOrder, List<PromotableCandidateOrderOffer> qualifiedOrderOffers, Offer offer)
           
 void filterOrderLevelOffer(PromotableOrder promotableOrder, List<PromotableCandidateOrderOffer> qualifiedOrderOffers, Offer offer)
           
 PromotableItemFactory getPromotableItemFactory()
           
protected  void processMatchingDetails(OrderItemPriceDetail itemDetail, PromotableOrderItemPriceDetail promotableItemDetail)
           
 List<PromotableCandidateOrderOffer> removeTrailingNotCombinableOrderOffers(List<PromotableCandidateOrderOffer> candidateOffers)
           
 void setOfferDao(OfferDao offerDao)
          Set the offerDao (primarily for unit testing)
 void setOrderItemDao(OrderItemDao orderItemDao)
          Set the orderItemDao (primarily for unit testing)
 void setPromotableItemFactory(PromotableItemFactory promotableItemFactory)
           
 void synchronizeAdjustmentsAndPrices(PromotableOrder promotableOrder)
          Takes the adjustments and PriceDetails from the passed in PromotableOrder and transfers them to the actual order first checking to see if they already exist.
protected  void synchronizeFulfillmentGroupAdjustments(FulfillmentGroup fg, PromotableFulfillmentGroup promotableFG)
           
protected  void synchronizeFulfillmentGroups(PromotableOrder promotableOrder)
           
protected  void synchronizeItemPriceDetails(OrderItem orderItem, PromotableOrderItem promotableOrderItem)
           
protected  void synchronizeItemQualifiers(OrderItem orderItem, PromotableOrderItem promotableOrderItem)
           
protected  void synchronizeOrderAdjustments(PromotableOrder promotableOrder)
           
protected  void synchronizeOrderItems(PromotableOrder promotableOrder)
           
protected  void updateItemAdjustment(OrderItemPriceDetailAdjustment itemAdjustment, PromotableOrderItemPriceDetailAdjustment promotableAdjustment)
           
protected  void updatePriceDetail(OrderItemPriceDetail itemDetail, PromotableOrderItemPriceDetail promotableDetail)
           
 
Methods inherited from class org.broadleafcommerce.core.offer.service.processor.AbstractBaseProcessor
checkForItemRequirements, clearAllNonFinalizedQuantities, couldOfferApplyToCustomer, couldOfferApplyToOrderItems, couldOfferApplyToRequestDTO, couldOfferApplyToTimePeriod, couldOrderItemMeetOfferRequirement, executeExpression, filterOffers, finalizeQuantities, getOfferTimeZoneProcessor, meetsItemQualifierSubtotal, removeInvalidCustomerOffers, removeInvalidRequestOffers, removeOutOfDateOffers, removeTimePeriodOffers, setOfferTimeZoneProcessor, splitDetailsIfNecessary
 
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
executeExpression
 
Methods inherited from interface org.broadleafcommerce.core.offer.service.processor.BaseProcessor
filterOffers
 

Field Detail

promotableItemFactory

protected PromotableItemFactory promotableItemFactory

offerDao

protected OfferDao offerDao

orderItemDao

protected OrderItemDao orderItemDao
Constructor Detail

OrderOfferProcessorImpl

public OrderOfferProcessorImpl()
Method Detail

filterOrderLevelOffer

public void filterOrderLevelOffer(PromotableOrder promotableOrder,
                                  List<PromotableCandidateOrderOffer> qualifiedOrderOffers,
                                  Offer offer)
Specified by:
filterOrderLevelOffer in interface OrderOfferProcessor

couldOfferApplyToOrder

public boolean couldOfferApplyToOrder(Offer offer,
                                      PromotableOrder promotableOrder)
Description copied from interface: OrderOfferProcessor
Executes the appliesToOrderRules in the Offer to determine if this offer can be applied to the Order, OrderItem, or FulfillmentGroup.

Specified by:
couldOfferApplyToOrder in interface OrderOfferProcessor
Returns:
true if offer can be applied, otherwise false

couldOfferApplyToOrder

protected boolean couldOfferApplyToOrder(Offer offer,
                                         PromotableOrder promotableOrder,
                                         PromotableOrderItem orderItem)
Private method which executes the appliesToOrderRules in the Offer to determine if this offer can be applied to the Order, OrderItem, or FulfillmentGroup.

Parameters:
offer -
order -
orderItem -
Returns:
true if offer can be applied, otherwise false

couldOfferApplyToOrder

protected boolean couldOfferApplyToOrder(Offer offer,
                                         PromotableOrder promotableOrder,
                                         PromotableFulfillmentGroup fulfillmentGroup)
Private method which executes the appliesToOrderRules in the Offer to determine if this offer can be applied to the Order, OrderItem, or FulfillmentGroup.

Parameters:
offer -
order -
fulfillmentGroup -
Returns:
true if offer can be applied, otherwise false

couldOfferApplyToOrder

protected boolean couldOfferApplyToOrder(Offer offer,
                                         PromotableOrder promotableOrder,
                                         PromotableOrderItem promotableOrderItem,
                                         PromotableFulfillmentGroup promotableFulfillmentGroup)
Private method which executes the appliesToOrderRules in the Offer to determine if this offer can be applied to the Order, OrderItem, or FulfillmentGroup.

Parameters:
offer -
order -
promotableOrderItem -
promotableFulfillmentGroup -
Returns:
true if offer can be applied, otherwise false

createCandidateOrderOffer

protected PromotableCandidateOrderOffer createCandidateOrderOffer(PromotableOrder promotableOrder,
                                                                  List<PromotableCandidateOrderOffer> qualifiedOrderOffers,
                                                                  Offer offer)

removeTrailingNotCombinableOrderOffers

public List<PromotableCandidateOrderOffer> removeTrailingNotCombinableOrderOffers(List<PromotableCandidateOrderOffer> candidateOffers)
Specified by:
removeTrailingNotCombinableOrderOffers in interface OrderOfferProcessor

applyAllOrderOffers

public void applyAllOrderOffers(List<PromotableCandidateOrderOffer> orderOffers,
                                PromotableOrder promotableOrder)
Description copied from interface: OrderOfferProcessor
Takes a list of sorted CandidateOrderOffers and determines if each offer can be applied based on the restrictions (stackable and/or combinable) on that offer. OrderAdjustments are create on the Order for each applied CandidateOrderOffer. An offer with stackable equals false cannot be applied to an Order that already contains an OrderAdjustment. An offer with combinable equals false cannot be applied to the Order if the Order already contains an OrderAdjustment.

Specified by:
applyAllOrderOffers in interface OrderOfferProcessor
Parameters:
orderOffers - a sorted list of CandidateOrderOffer

compareAndAdjustOrderAndItemOffers

protected void compareAndAdjustOrderAndItemOffers(PromotableOrder promotableOrder)
Called when the system must determine whether to apply order or item adjustments.

Parameters:
promotableOrder -
orderOffersApplied -

applyOrderOffer

protected void applyOrderOffer(PromotableOrder promotableOrder,
                               PromotableCandidateOrderOffer orderOffer)
Private method used by applyAllOrderOffers to create an OrderAdjustment from a CandidateOrderOffer and associates the OrderAdjustment to the Order.

Parameters:
orderOffer - a CandidateOrderOffer to apply to an Order

getPromotableItemFactory

public PromotableItemFactory getPromotableItemFactory()
Specified by:
getPromotableItemFactory in interface OrderOfferProcessor

setPromotableItemFactory

public void setPromotableItemFactory(PromotableItemFactory promotableItemFactory)
Specified by:
setPromotableItemFactory in interface OrderOfferProcessor

buildPromotableOrderAdjustmentsMap

protected Map<Long,PromotableOrderAdjustment> buildPromotableOrderAdjustmentsMap(PromotableOrder promotableOrder)

synchronizeOrderAdjustments

protected void synchronizeOrderAdjustments(PromotableOrder promotableOrder)

buildOrderItemList

protected List<OrderItem> buildOrderItemList(Order order)

synchronizeOrderItems

protected void synchronizeOrderItems(PromotableOrder promotableOrder)

buildPromotableItemMap

protected Map<OrderItem,PromotableOrderItem> buildPromotableItemMap(PromotableOrder promotableOrder)

synchronizeItemPriceDetails

protected void synchronizeItemPriceDetails(OrderItem orderItem,
                                           PromotableOrderItem promotableOrderItem)

synchronizeItemQualifiers

protected void synchronizeItemQualifiers(OrderItem orderItem,
                                         PromotableOrderItem promotableOrderItem)

updatePriceDetail

protected void updatePriceDetail(OrderItemPriceDetail itemDetail,
                                 PromotableOrderItemPriceDetail promotableDetail)

updateItemAdjustment

protected void updateItemAdjustment(OrderItemPriceDetailAdjustment itemAdjustment,
                                    PromotableOrderItemPriceDetailAdjustment promotableAdjustment)

processMatchingDetails

protected void processMatchingDetails(OrderItemPriceDetail itemDetail,
                                      PromotableOrderItemPriceDetail promotableItemDetail)

buildItemDetailAdjustmentMap

protected Map<Long,OrderItemPriceDetailAdjustment> buildItemDetailAdjustmentMap(OrderItemPriceDetail itemDetail)

buildItemPriceDetailKey

protected String buildItemPriceDetailKey(OrderItemPriceDetail itemDetail)

buildPromotableDetailsMap

protected Map<String,PromotableOrderItemPriceDetail> buildPromotableDetailsMap(PromotableOrderItem item)

buildPromotableQualifiersMap

protected Map<Long,PromotionQualifier> buildPromotableQualifiersMap(PromotableOrderItem item)

synchronizeFulfillmentGroups

protected void synchronizeFulfillmentGroups(PromotableOrder promotableOrder)

buildPromotableFulfillmentGroupMap

protected Map<Long,PromotableFulfillmentGroup> buildPromotableFulfillmentGroupMap(PromotableOrder order)

buildPromFulfillmentAdjMap

protected Map<Long,PromotableFulfillmentGroupAdjustment> buildPromFulfillmentAdjMap(PromotableFulfillmentGroup fg)

synchronizeFulfillmentGroupAdjustments

protected void synchronizeFulfillmentGroupAdjustments(FulfillmentGroup fg,
                                                      PromotableFulfillmentGroup promotableFG)

synchronizeAdjustmentsAndPrices

public void synchronizeAdjustmentsAndPrices(PromotableOrder promotableOrder)
Description copied from interface: OrderOfferProcessor
Takes the adjustments and PriceDetails from the passed in PromotableOrder and transfers them to the actual order first checking to see if they already exist.

Specified by:
synchronizeAdjustmentsAndPrices in interface OrderOfferProcessor

setOfferDao

public void setOfferDao(OfferDao offerDao)
Description copied from interface: OrderOfferProcessor
Set the offerDao (primarily for unit testing)

Specified by:
setOfferDao in interface OrderOfferProcessor

setOrderItemDao

public void setOrderItemDao(OrderItemDao orderItemDao)
Description copied from interface: OrderOfferProcessor
Set the orderItemDao (primarily for unit testing)

Specified by:
setOrderItemDao in interface OrderOfferProcessor


Copyright © 2013. All Rights Reserved.