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 Summary

    Constructors
    Constructor
    Description
    DefaultOfferEngineResponseBuilder(com.broadleafcommerce.common.extension.TypeFactory offerFactory)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addCampaignTrackingIdToAdjustmentIfUsed(@NonNull Offer offer, @NonNull com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment adjustment, @NonNull OfferCodeData offerCodeData)
     
    protected void
    addOfferCodeToProratedAdjustmentIfUsed(@NonNull com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef offer, @NonNull com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedOfferAdjustment proratedAdjustment, @NonNull OfferCodeData offerCodeData)
    Adds an offer code to the given ProratedOfferAdjustment if it is present on the order.
    protected void
    addOfferCodeToProratedItemAdjustmentIfUsed(@NonNull com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef offer, @NonNull EnhancedProratedItemOfferAdjustment proratedItemAdjustment, @NonNull OfferCodeData offerCodeData)
    Adds an offer code to the given EnhancedProratedItemOfferAdjustment if it is present on the order.
    protected void
    addOrderCodeToAdjustmentIfUsed(@NonNull Offer offer, @NonNull com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment adjustment, @NonNull OfferCodeData offerCodeData)
    Adds an offer code to the given Adjustment if it is present on the order.
    com.broadleafcommerce.promotion.offer.client.web.context.discounts.OrderResponse<P>
    build(@NonNull EnhancedOrder order)
    Builds a response object detailing the adjustment information on the provided order.
    protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponseDetail<P>
    buildItemResponseDetail(com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponseDetail<? extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustment> itemResponseDetail)
    Builds an ItemResponseDetail object with a parameterized type of ProratedItemOfferAdjustment with details based on the ItemResponseDetail generic object that is passed in.
    protected javax.money.MonetaryAmount
    getAdjustedSubtotal(@NotNull EnhancedOrder order, com.broadleafcommerce.promotion.offer.client.web.context.discounts.OrderResponse<P> orderResponse)
     
    protected javax.money.MonetaryAmount
    getAdjustedTotal(@NotNull EnhancedOrder order, javax.money.MonetaryAmount adjustedSubtotal)
     
    protected com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment
    getAdjustment(@NonNull OfferCodeData offerCodeData, @NonNull Offer offer, @NonNull com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef offerRef, @NonNull javax.money.MonetaryAmount amount, String discountMethodType)
    Creates an Adjustment caused by the Offer for an order or fulfillment group.
    protected com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment
    getAdjustment(@NonNull FulfillmentGroupAdjustment offerAdjustment, @NonNull OfferCodeData offerCodeData)
    Creates an Adjustment caused by the Offer for a fulfillment group.
    protected com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment
    getAdjustment(@NonNull OrderOfferAdjustment offerAdjustment, @NonNull OfferCodeData offerCodeData)
    Creates an Adjustment caused by the Offer for an order.
    protected Optional<com.broadleafcommerce.promotion.offer.client.web.context.discounts.ConvertedCurrencyDetail>
    getConvertedCurrencyDetails(@NonNull ItemOfferAdjustment itemOfferAdjustment)
     
    protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.FulfillmentGroupResponse<P>
    getFulfillmentGroupResponse(@NonNull EnhancedOrder order, @NonNull EnhancedFulfillmentGroup group, @NonNull OfferCodeData offerCodeData)
    Creates an offer fulfillment group response for a fulfillment group.
    protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemAdjustment
    getItemAdjustment(@NonNull ItemOfferAdjustment itemOfferAdjustment, @NonNull OfferCodeData offerCodeData)
    Creates an ItemAdjustment for the ItemOfferAdjustment.
    protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponse<P>
    getItemResponse(@NonNull EnhancedLineItem lineItem, @NonNull OfferCodeData offerCodeData)
    Creates an Offer ItemResponse for a line item.
    protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponseDetail<P>
    getItemResponseDetail(@NonNull javax.money.CurrencyUnit currencyUnit, @NonNull LineItemOfferDetail orderItemOfferDetail, @NonNull OfferCodeData offerCodeData)
    Creates an Offer ItemResponseDetail for a LineItemOfferDetail.
    protected com.broadleafcommerce.common.extension.TypeFactory
     
    protected com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef
    getOfferRef(@NonNull Offer offer, @NonNull BaseCandidateOffer candidateOffer)
    Creates an OfferRef for the given Offer and candidate offer.
    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.
    protected boolean
    isUseSaleRecurringPriceForItem(com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponse<P> itemResponse)
    Whether to use the sale or standard recurring price.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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
    • buildItemResponseDetail

      protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponseDetail<P> buildItemResponseDetail(com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponseDetail<? extends com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedItemOfferAdjustment> itemResponseDetail)
      Builds an ItemResponseDetail object with a parameterized type of ProratedItemOfferAdjustment with details based on the ItemResponseDetail generic object that is passed in.
      Parameters:
      itemResponseDetail - the generic object with the details to build the ItemResponseDetail object with
      Returns:
      the hydrated ItemResponseDetail object with a parameterized type of ProratedItemOfferAdjustment
    • 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 true if any adjustment is found that applies to the sale price. This does not consider recurring adjustments.
      Parameters:
      itemResponse - the item response to look for adjustments
      Returns:
      whether to use sale price for the item
    • isUseSaleRecurringPriceForItem

      protected boolean isUseSaleRecurringPriceForItem(com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponse<P> itemResponse)
      Whether to use the sale or standard recurring price. This is true if any adjustment is applied to the sale price. This does not consider standard adjustments.
      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 FulfillmentGroupAdjustment offerAdjustment, @NonNull @NonNull OfferCodeData offerCodeData)
      Creates an Adjustment caused by the Offer for a fulfillment group.
      Parameters:
      offerAdjustment - The FulfillmentGroupAdjustment
      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.
      Since:
      Offer Services 3.2.0, Release Train 2.3.0
    • getAdjustment

      protected com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment getAdjustment(@NonNull @NonNull OrderOfferAdjustment offerAdjustment, @NonNull @NonNull OfferCodeData offerCodeData)
      Creates an Adjustment caused by the Offer for an order.
      Parameters:
      offerAdjustment - The OrderOfferAdjustment.
      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.
      Since:
      Offer Services 3.2.0, Release Train 2.3.0
    • getAdjustment

      protected com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment getAdjustment(@NonNull @NonNull OfferCodeData offerCodeData, @NonNull @NonNull Offer offer, @NonNull @NonNull com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef offerRef, @NonNull @NonNull javax.money.MonetaryAmount amount, String discountMethodType)
      Creates an Adjustment caused by the Offer for an order or fulfillment group.
      Parameters:
      offer - Offer from which the adjustment is derived.
      offerRef - OfferRef 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.
      Since:
      Offer Services 3.2.0, Release Train 2.3.0
    • 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.
    • getConvertedCurrencyDetails

      protected Optional<com.broadleafcommerce.promotion.offer.client.web.context.discounts.ConvertedCurrencyDetail> getConvertedCurrencyDetails(@NonNull @NonNull ItemOfferAdjustment itemOfferAdjustment)
    • getOfferRef

      protected com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef getOfferRef(@NonNull @NonNull Offer offer, @NonNull @NonNull BaseCandidateOffer candidateOffer)
      Creates an OfferRef for the given Offer and candidate offer. This will populate the OfferRef.getDiscountMethodType() and OfferRef.getDiscountFactor() with the values from the BaseCandidateOffer in order to take the method and amount from a chosen DiscountTier instead of just looking at the Offer.
      Parameters:
      offer - Offer from which to make a ref
      candidateOffer - Candidate offer from which to retrieve the discount method type and amount
      Returns:
      an OfferRef for the given ItemOfferAdjustment.
      Since:
      Offer Services 3.2.0, Release Train 2.3.0
    • getOfferFactory

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