Class DefaultFulfillmentOperationService

java.lang.Object
com.broadleafcommerce.orderoperation.service.DefaultFulfillmentOperationService
All Implemented Interfaces:
FulfillmentOperationService

public class DefaultFulfillmentOperationService extends Object implements FulfillmentOperationService
  • Constructor Details

  • Method Details

    • changeFulfillmentStatus

      @Nullable public com.broadleafcommerce.order.client.domain.OrderFulfillment changeFulfillmentStatus(FulfillmentStatusChangeRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: FulfillmentOperationService
      Perform the requested status change for the OrderFulfillment.
      Specified by:
      changeFulfillmentStatus in interface FulfillmentOperationService
      Parameters:
      request - the request to change the status of the fulfillment
      contextInfo - context information around sandbox and multitenant state.
      Returns:
      the fulfillment, or part of it, which has changed status
    • processStatusChangeForOfferTargetItems

      protected void processStatusChangeForOfferTargetItems(FulfillmentStatusChangeRequest request, com.broadleafcommerce.order.client.domain.OrderFulfillment orderFulfillment, com.broadleafcommerce.order.client.domain.Order order)
      Makes sure that whenever an offer qualifier item's status is being changed, the offer target item is being changed as well based on its qualifier details.

      For example, itemA is a free gift offer qualifier item, and itemFG is the target item that was added from the offer. Whenever the status of itemA is being changed, itemFG will automatically be added to the given FulfillmentStatusChangeRequest.

      By default, only the status of free gift items are automatically changed along with their qualifiers.

      Parameters:
      request - the request to change the status of the fulfillment
      orderFulfillment - the order fulfillment that the status is being changed
    • processTargetItemToChangeStatus

      protected void processTargetItemToChangeStatus(com.broadleafcommerce.order.client.domain.OrderFulfillmentItem targetItem, List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem> itemsChangingStatus, Map<String,com.broadleafcommerce.order.client.domain.OrderItem> orderItemById, Map<String,Integer> quantityByItemId)
      Adds the given target item to quantityByItemId for status change based on its qualifier details.
      Parameters:
      targetItem - the OrderFulfillmentItem that is an offer target item
      itemsChangingStatus - a list of OrderFulfillmentItems whose status are being changed
      orderItemById - a map of OrderItem by OrderItem.getId()
      quantityByItemId - a map of quantity having a status change by OrderFulfillmentItem.getId()
    • getStatusChangeableTargetItems

      protected List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem> getStatusChangeableTargetItems(com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment, com.broadleafcommerce.order.client.domain.Order order)
      Gets a list of OrderFulfillmentItems that are offer targets, and whose status should automatically be changed along with their qualifier items.

      By default, only free gift items will automatically change status along with their qualifier items.

      Parameters:
      fulfillment - the OrderFulfillment to get the offer target items from
      order - the Order to get the corresponding OrderItem from
      Returns:
      a list of OrderFulfillmentItems that are offer targets, and whose status should automatically be changed along with their qualifier items
    • getQualifierDetails

      protected List<com.broadleafcommerce.order.common.domain.OfferItemDetail> getQualifierDetails(com.broadleafcommerce.order.client.domain.OrderFulfillmentItem item, Map<String,com.broadleafcommerce.order.client.domain.OrderItem> orderItemById)
      Gets a list of OfferItemDetails representing qualifier details for the given OrderFulfillmentItem.

      The OrderFulfillmentItem itself can have qualifier details pointing to other OrderFulfillmentItems, but only the qualifier details for the corresponding OrderItem is obtained by default.

      Parameters:
      item - the OrderFulfillmentItem to get the qualifier details from
      orderItemById - a map of OrderItem by OrderItem.getId()
      Returns:
      a list of OfferItemDetails representing qualifier details for the given OrderFulfillmentItem
    • getFulfillmentItemsByOrderItemId

      protected List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem> getFulfillmentItemsByOrderItemId(List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem> fulfillmentItems, String orderItemId)
      Gets a list of OrderFulfillmentItems based on the given OrderFulfillmentItem.getOrderItemId().

      Note that there can be many OrderFulfillmentItems that have the same OrderFulfillmentItem.getOrderItemId(), since they can be split.

      Parameters:
      fulfillmentItems - the OrderFulfillmentItems to find the items from
      orderItemId - the OrderFulfillmentItem.getOrderItemId() to filter by
      Returns:
      a list of OrderFulfillmentItems based on the given OrderFulfillmentItem.getOrderItemId()
    • getFulfillmentItemsChangingStatus

      protected List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem> getFulfillmentItemsChangingStatus(com.broadleafcommerce.order.client.domain.OrderFulfillment orderFulfillment, Map<String,Integer> quantityByItemId)
      Gets a list of OrderFulfillmentItems whose status is being changed.
      Parameters:
      orderFulfillment - the OrderFulfillment to find the itemsfrom
      quantityByItemId - a map of quantity having a status change by OrderFulfillmentItem.getId()
      Returns:
      a list of OrderFulfillmentItems whose status is being changed
    • getTargetItemQuantityToChangeStatus

      protected int getTargetItemQuantityToChangeStatus(Map<String,Integer> quantityByItemId, com.broadleafcommerce.order.client.domain.OrderFulfillmentItem qualifierItem, com.broadleafcommerce.order.client.domain.OrderFulfillmentItem targetItem, com.broadleafcommerce.order.common.domain.OfferItemDetail qualifierDetail, Map<String,com.broadleafcommerce.order.client.domain.OrderItem> orderItemById)
      Calculates and returns the quantity of the target item to change status along with its qualifier.

      Additionally, if the qualifier and target are the same item, then we'll add the quantity to confirm on top of the quantity already having a status change.

      Parameters:
      quantityByItemId - a map of quantity having a status change by OrderFulfillmentItem.getId()
      qualifierItem - the OrderFulfillmentItem that is the qualifier
      targetItem - the target OrderFulfillmentItem to calculate the quantity for
      qualifierDetail - the OfferItemDetail representing the qualifier details
      orderItemById - a map of OrderItem by OrderItem.getId()
      Returns:
      the quantity of the target item to change status
    • getFulfillmentProvider

      protected FulfillmentProvider<com.broadleafcommerce.order.client.domain.OrderFulfillment> getFulfillmentProvider()
    • getFulfillmentStatusChangeValidator

      protected FulfillmentStatusChangeValidator getFulfillmentStatusChangeValidator()
    • getFulfillmentStatusChangeHandlers

      protected List<FulfillmentStatusChangeHandler> getFulfillmentStatusChangeHandlers()
    • getOfferUtils

      protected OrderOperationServiceOfferUtils getOfferUtils()
    • setOfferUtils

      @Autowired public void setOfferUtils(OrderOperationServiceOfferUtils offerUtils)
    • getOrderProvider

      protected OrderProvider<com.broadleafcommerce.order.client.domain.Order> getOrderProvider()
    • setOrderProvider

      @Autowired public void setOrderProvider(OrderProvider<com.broadleafcommerce.order.client.domain.Order> orderProvider)