Class DefaultOfferEngineResponseBuilder<P extends EnhancedProratedItemOfferAdjustment>

java.lang.Object
com.broadleafcommerce.promotion.offer.service.engine.DefaultOfferEngineResponseBuilder<P>
All Implemented Interfaces:
OfferEngineResponseBuilder<P>

public class DefaultOfferEngineResponseBuilder<P extends EnhancedProratedItemOfferAdjustment> extends Object implements OfferEngineResponseBuilder<P>
Author:
Chad Harchar (charchar)
  • Constructor Details

    • DefaultOfferEngineResponseBuilder

      public DefaultOfferEngineResponseBuilder(com.broadleafcommerce.common.extension.TypeFactory offerFactory)
  • Method Details

    • build

      public com.broadleafcommerce.promotion.offer.client.web.context.discounts.OrderResponse<P> build(@NonNull @NonNull EnhancedOrder order)
      Description copied from interface: OfferEngineResponseBuilder
      Builds a response object detailing the adjustment information on the provided order. Intended to be used after applying offers to the order.
      Specified by:
      build in interface OfferEngineResponseBuilder<P extends EnhancedProratedItemOfferAdjustment>
      Parameters:
      order - the order from which to build the response DTO object.
      Returns:
      the response object detailing the adjustment information on the provided order
    • getAdjustedTotal

      protected javax.money.MonetaryAmount getAdjustedTotal(@NotNull @NotNull EnhancedOrder order, javax.money.MonetaryAmount adjustedSubtotal)
    • getAdjustedSubtotal

      protected javax.money.MonetaryAmount getAdjustedSubtotal(@NotNull @NotNull EnhancedOrder order, com.broadleafcommerce.promotion.offer.client.web.context.discounts.OrderResponse<P> orderResponse)
    • getFulfillmentGroupResponse

      protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.FulfillmentGroupResponse<P> getFulfillmentGroupResponse(@NonNull @NonNull EnhancedOrder order, @NonNull @NonNull EnhancedFulfillmentGroup group, @NonNull @NonNull OfferCodeData offerCodeData)
      Creates an offer fulfillment group response for a fulfillment group.
      Parameters:
      group - a fulfillment group to which offers may have been applied
      offerCodeData - set of all of the shared or campaign codes set on the order- these may have been used to apply an offer and should be recorded on any adjustments
      Returns:
      an offer fulfillment group response representing the passed in fulfillment group
    • getItemResponse

      protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponse<P> getItemResponse(@NonNull @NonNull EnhancedLineItem lineItem, @NonNull @NonNull OfferCodeData offerCodeData)
      Creates an Offer ItemResponse for a line item.
      Parameters:
      lineItem - a LineItem to which offers may have been applied
      offerCodeData - Set of all of the shared or campaign codes set on the order. These may have been used to apply an offer and should be recorded on any Adjustments.
      Returns:
      an Offer ItemResponse for a line item.
    • isUseSalePriceForItem

      protected boolean isUseSalePriceForItem(com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponse<P> itemResponse)
      Whether to use the sale price for the item or the default price. This is determined by the first adjustment found and whether that adjustment is applying to the sale price or the default price.
      Parameters:
      itemResponse - the item response to look for adjustments
      Returns:
      whether to use sale price for the item
    • getItemResponseDetail

      protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponseDetail<P> getItemResponseDetail(@NonNull @NonNull javax.money.CurrencyUnit currencyUnit, @NonNull @NonNull LineItemOfferDetail orderItemOfferDetail, @NonNull @NonNull OfferCodeData offerCodeData)
      Creates an Offer ItemResponseDetail for a LineItemOfferDetail.
      Parameters:
      orderItemOfferDetail - The LineItemOfferDetail to be converted into a ItemResponseDetail.
      offerCodeData - Set of all of the shared or campaign codes set on the order. These may have been used to apply an offer and should be recorded on any Adjustments.
      Returns:
      an Offer ItemResponseDetail for a LineItemOfferDetail.
    • getAdjustment

      protected com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment getAdjustment(@NonNull @NonNull Offer offer, @NonNull @NonNull javax.money.MonetaryAmount amount, @NonNull @NonNull OfferCodeData offerCodeData)
      Creates an Adjustment caused by the Offer for an order.
      Parameters:
      offer - Offer from which the adjustment is derived.
      amount - The amount of the adjustment caused by the offer for the order.
      offerCodeData - Set of all of the shared or campaign codes set on the order. These may have been used to apply an offer and should be recorded on any Adjustments.
      Returns:
      an Adjustment caused by the Offer for an order.
    • addOrderCodeToAdjustmentIfUsed

      protected void addOrderCodeToAdjustmentIfUsed(@NonNull @NonNull Offer offer, @NonNull @NonNull com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment adjustment, @NonNull @NonNull OfferCodeData offerCodeData)
      Adds an offer code to the given Adjustment if it is present on the order.
      Parameters:
      offer - Offer from which the adjustment is derived.
      adjustment - Adjustment The Adjustment for which an offer code may apply
      offerCodeData - Set of all of the shared or campaign codes set on the order. These may have been used to apply an offer and should be recorded on any Adjustments.
    • addCampaignTrackingIdToAdjustmentIfUsed

      protected void addCampaignTrackingIdToAdjustmentIfUsed(@NonNull @NonNull Offer offer, @NonNull @NonNull com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment adjustment, @NonNull @NonNull OfferCodeData offerCodeData)
    • addOfferCodeToProratedItemAdjustmentIfUsed

      protected void addOfferCodeToProratedItemAdjustmentIfUsed(@NonNull @NonNull com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef offer, @NonNull @NonNull EnhancedProratedItemOfferAdjustment proratedItemAdjustment, @NonNull @NonNull OfferCodeData offerCodeData)
      Adds an offer code to the given EnhancedProratedItemOfferAdjustment if it is present on the order.
      Parameters:
      offer - Offer from which the adjustment is derived.
      proratedItemAdjustment - The EnhancedProratedItemOfferAdjustment for which an offer code may apply
      offerCodeData - Set of all of the shared or campaign codes set on the order. These may have been used to apply an offer and should be recorded on any prorated item adjustments.
    • addOfferCodeToProratedAdjustmentIfUsed

      protected void addOfferCodeToProratedAdjustmentIfUsed(@NonNull @NonNull com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef offer, @NonNull @NonNull com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedOfferAdjustment proratedAdjustment, @NonNull @NonNull OfferCodeData offerCodeData)
      Adds an offer code to the given ProratedOfferAdjustment if it is present on the order.
      Parameters:
      offer - Offer from which the adjustment is derived.
      proratedAdjustment - Adjustment The ProratedOfferAdjustment for which an offer code may apply
      offerCodeData - Set of all of the shared or campaign codes set on the order. These may have been used to apply an offer and should be recorded on any prorated adjustments.
    • getItemAdjustment

      protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemAdjustment getItemAdjustment(@NonNull @NonNull ItemOfferAdjustment itemOfferAdjustment, @NonNull @NonNull OfferCodeData offerCodeData)
      Creates an ItemAdjustment for the ItemOfferAdjustment.
      Parameters:
      itemOfferAdjustment - An ItemOfferAdjustment to be converted into a ItemAdjustment.
      offerCodeData - Set of all of the shared or campaign codes set on the order. These may have been used to apply an offer and should be recorded on any Adjustments.
      Returns:
      an ItemAdjustment for the ItemOfferAdjustment.
    • getOfferRef

      protected com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef getOfferRef(@NonNull @NonNull Offer offer)
      Creates an OfferRef for the given Offer.
      Parameters:
      offer - Offer from which to make a ref
      Returns:
      an OfferRef for the given Offer.
    • getOfferFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getOfferFactory()