org.broadleafcommerce.core.offer.service
Class OrderItemMergeServiceImpl
java.lang.Object
org.broadleafcommerce.core.offer.service.OrderItemMergeServiceImpl
- All Implemented Interfaces:
- OrderItemMergeService
@Service(value="blOrderItemMergeService")
public class OrderItemMergeServiceImpl
- extends Object
- implements OrderItemMergeService
- Author:
- Jeff Fischer
|
Method Summary |
protected void |
addOptionAttributesToIdentifier(StringBuffer identifier,
OrderItem orderItem)
Appends the item attributes so that items with different attibutes are not merged together
as part of the merge/split logic. |
protected OrderItem |
addOrderItemToOrder(Order order,
OrderItem newOrderItem,
Boolean priceOrder)
|
String |
buildIdentifier(OrderItem orderItem,
String extraIdentifier)
Returns a key that determines whether or not two items can be merged together. |
String |
buildIdentifier(OrderItem orderItem,
String extraIdentifier,
boolean includePrice)
|
void |
finalizeCart(PromotableOrder order)
|
void |
gatherCart(PromotableOrder promotableOrder)
|
protected void |
gatherFulfillmentGroupLinkedBundleOrderItems(Order order)
|
protected void |
gatherFulfillmentGroupLinkedDiscreteOrderItem(List<DiscreteOrderItem> itemsToRemove,
List<FulfillmentGroupItem> fgItemsToRemove,
Map<String,Object[]> gatheredItem,
FulfillmentGroupItem fgItem,
DiscreteOrderItem orderItem,
String extraIdentifier,
List<OrderMultishipOption> options,
boolean includePrice)
|
protected void |
gatherFulfillmentGroupLinkedDiscreteOrderItems(Order order,
List<OrderMultishipOption> options)
|
protected void |
gatherOrderLinkedBundleOrderItems(Order order)
|
protected void |
gatherOrderLinkedDiscreteOrderItem(List<DiscreteOrderItem> itemsToRemove,
Map<String,OrderItem> gatheredItem,
DiscreteOrderItem orderItem,
String extraIdentifier)
|
protected void |
gatherOrderLinkedDiscreteOrderItems(Order order)
|
void |
gatherSplitItemsInBundles(Order order)
|
FulfillmentGroupItemDao |
getFulfillmentGroupItemDao()
|
FulfillmentGroupService |
getFulfillmentGroupService()
|
protected String |
getKey(Address address,
FulfillmentOption option)
|
OrderItemService |
getOrderItemService()
|
OrderMultishipOptionService |
getOrderMultishipOptionService()
|
OrderService |
getOrderService()
|
PromotableItemFactory |
getPromotableItemFactory()
|
void |
initializeBundleSplitItems(PromotableOrder order)
|
void |
initializeSplitItems(PromotableOrder order)
|
protected void |
mergeSplitBundleOrderItems(PromotableOrder order)
|
protected void |
mergeSplitDiscreteOrderItems(PromotableOrder order)
|
protected void |
mergeSplitGiftWrapOrderItems(PromotableOrder order,
List<GiftWrapOrderItem> giftWrapItems,
PromotableOrderItem itemToRemove,
DiscreteOrderItem delegateItem)
|
void |
mergeSplitItems(PromotableOrder order)
|
void |
prepareCart(PromotableOrder promotableOrder)
|
void |
setFulfillmentGroupItemDao(FulfillmentGroupItemDao fulfillmentGroupItemDao)
|
void |
setFulfillmentGroupService(FulfillmentGroupService fulfillmentGroupService)
|
void |
setOrderItemService(OrderItemService orderItemService)
|
void |
setOrderMultishipOptionService(OrderMultishipOptionService orderMultishipOptionService)
|
void |
setOrderService(OrderService orderService)
|
void |
setPromotableItemFactory(PromotableItemFactory promotableItemFactory)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
fulfillmentGroupItemDao
protected FulfillmentGroupItemDao fulfillmentGroupItemDao
fulfillmentGroupService
protected FulfillmentGroupService fulfillmentGroupService
orderItemService
protected OrderItemService orderItemService
orderMultishipOptionService
protected OrderMultishipOptionService orderMultishipOptionService
orderService
protected OrderService orderService
promotableItemFactory
protected PromotableItemFactory promotableItemFactory
OrderItemMergeServiceImpl
public OrderItemMergeServiceImpl()
gatherSplitItemsInBundles
public void gatherSplitItemsInBundles(Order order)
throws PricingException
- Specified by:
gatherSplitItemsInBundles in interface OrderItemMergeService
- Throws:
PricingException
mergeSplitItems
public void mergeSplitItems(PromotableOrder order)
- Specified by:
mergeSplitItems in interface OrderItemMergeService
getKey
protected String getKey(Address address,
FulfillmentOption option)
finalizeCart
public void finalizeCart(PromotableOrder order)
throws PricingException
- Specified by:
finalizeCart in interface OrderItemMergeService
- Throws:
PricingException
prepareCart
public void prepareCart(PromotableOrder promotableOrder)
- Specified by:
prepareCart in interface OrderItemMergeService
gatherCart
public void gatherCart(PromotableOrder promotableOrder)
- Specified by:
gatherCart in interface OrderItemMergeService
initializeBundleSplitItems
public void initializeBundleSplitItems(PromotableOrder order)
- Specified by:
initializeBundleSplitItems in interface OrderItemMergeService
initializeSplitItems
public void initializeSplitItems(PromotableOrder order)
- Specified by:
initializeSplitItems in interface OrderItemMergeService
gatherOrderLinkedBundleOrderItems
protected void gatherOrderLinkedBundleOrderItems(Order order)
throws PricingException
- Throws:
PricingException
gatherOrderLinkedDiscreteOrderItems
protected void gatherOrderLinkedDiscreteOrderItems(Order order)
throws PricingException
- Throws:
PricingException
gatherFulfillmentGroupLinkedBundleOrderItems
protected void gatherFulfillmentGroupLinkedBundleOrderItems(Order order)
throws PricingException
- Throws:
PricingException
gatherFulfillmentGroupLinkedDiscreteOrderItems
protected void gatherFulfillmentGroupLinkedDiscreteOrderItems(Order order,
List<OrderMultishipOption> options)
throws PricingException
- Throws:
PricingException
gatherOrderLinkedDiscreteOrderItem
protected void gatherOrderLinkedDiscreteOrderItem(List<DiscreteOrderItem> itemsToRemove,
Map<String,OrderItem> gatheredItem,
DiscreteOrderItem orderItem,
String extraIdentifier)
gatherFulfillmentGroupLinkedDiscreteOrderItem
protected void gatherFulfillmentGroupLinkedDiscreteOrderItem(List<DiscreteOrderItem> itemsToRemove,
List<FulfillmentGroupItem> fgItemsToRemove,
Map<String,Object[]> gatheredItem,
FulfillmentGroupItem fgItem,
DiscreteOrderItem orderItem,
String extraIdentifier,
List<OrderMultishipOption> options,
boolean includePrice)
mergeSplitDiscreteOrderItems
protected void mergeSplitDiscreteOrderItems(PromotableOrder order)
throws PricingException
- Throws:
PricingException
addOrderItemToOrder
protected OrderItem addOrderItemToOrder(Order order,
OrderItem newOrderItem,
Boolean priceOrder)
throws PricingException
- Throws:
PricingException
mergeSplitGiftWrapOrderItems
protected void mergeSplitGiftWrapOrderItems(PromotableOrder order,
List<GiftWrapOrderItem> giftWrapItems,
PromotableOrderItem itemToRemove,
DiscreteOrderItem delegateItem)
mergeSplitBundleOrderItems
protected void mergeSplitBundleOrderItems(PromotableOrder order)
throws PricingException
- Throws:
PricingException
buildIdentifier
public String buildIdentifier(OrderItem orderItem,
String extraIdentifier)
- Description copied from interface:
OrderItemMergeService
- Returns a key that determines whether or not two items can be merged together.
If the keys match, the system will merge the items.
Uses the CartService.automaticallyMergeLikeItems to determine if the key should
include non-promotion related merging.
This process complements the merging and splitting required for the system. To fully
understand this flag, you need to understand the reason that the system splits items.
In the cart, an item can only have one price. Consider the example, where you have a cart-item with a quantity
of two and a buy-one get one free promotion. After the promotion is applied, you would have two
items in the cart: one at the regular price, and one free.
Now, assume the promotion is removed. The system will automatically merge the two items
back together.
This method generates an "identifier" (or key) that determines whether two items can
be merged. The expected behavior allows users to amend the merging requirements for
promotions and choose to always merge like items by setting the CartService.automaticallyMergeLikeItems
to true.
If merging is too aggressive for your implementation, you might choose to override this
method to add more specific rules for merging like items. The key is that the system
will merge items that return the same String identifier.
The out of box implementation insures the following:
- Items in a bundle do not get merged outside of the bundle
- Items do not get merged with items in a separate fulfillment group
- If the CartService.automaticallyMergeLikeItems is false, only items that were
previously split by the promotion engine will be merged; otherwise, the system
will try to merge all like items.
- Specified by:
buildIdentifier in interface OrderItemMergeService
- Returns:
buildIdentifier
public String buildIdentifier(OrderItem orderItem,
String extraIdentifier,
boolean includePrice)
addOptionAttributesToIdentifier
protected void addOptionAttributesToIdentifier(StringBuffer identifier,
OrderItem orderItem)
- Appends the item attributes so that items with different attibutes are not merged together
as part of the merge/split logic.
- Parameters:
identifier - orderItem -
getFulfillmentGroupItemDao
public FulfillmentGroupItemDao getFulfillmentGroupItemDao()
- Specified by:
getFulfillmentGroupItemDao in interface OrderItemMergeService
setFulfillmentGroupItemDao
public void setFulfillmentGroupItemDao(FulfillmentGroupItemDao fulfillmentGroupItemDao)
- Specified by:
setFulfillmentGroupItemDao in interface OrderItemMergeService
getFulfillmentGroupService
public FulfillmentGroupService getFulfillmentGroupService()
- Specified by:
getFulfillmentGroupService in interface OrderItemMergeService
setFulfillmentGroupService
public void setFulfillmentGroupService(FulfillmentGroupService fulfillmentGroupService)
- Specified by:
setFulfillmentGroupService in interface OrderItemMergeService
getOrderItemService
public OrderItemService getOrderItemService()
- Specified by:
getOrderItemService in interface OrderItemMergeService
setOrderItemService
public void setOrderItemService(OrderItemService orderItemService)
- Specified by:
setOrderItemService in interface OrderItemMergeService
getOrderMultishipOptionService
public OrderMultishipOptionService getOrderMultishipOptionService()
- Specified by:
getOrderMultishipOptionService in interface OrderItemMergeService
setOrderMultishipOptionService
public void setOrderMultishipOptionService(OrderMultishipOptionService orderMultishipOptionService)
- Specified by:
setOrderMultishipOptionService in interface OrderItemMergeService
getOrderService
public OrderService getOrderService()
- Specified by:
getOrderService in interface OrderItemMergeService
setOrderService
public void setOrderService(OrderService orderService)
- Specified by:
setOrderService in interface OrderItemMergeService
getPromotableItemFactory
public PromotableItemFactory getPromotableItemFactory()
- Specified by:
getPromotableItemFactory in interface OrderItemMergeService
setPromotableItemFactory
public void setPromotableItemFactory(PromotableItemFactory promotableItemFactory)
- Specified by:
setPromotableItemFactory in interface OrderItemMergeService
Copyright © 2012. All Rights Reserved.