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
ConstructorsConstructorDescriptionDefaultOfferEngineResponseBuilder(com.broadleafcommerce.common.extension.TypeFactory offerFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddCampaignTrackingIdToAdjustmentIfUsed(@NonNull Offer offer, @NonNull com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment adjustment, @NonNull OfferCodeData offerCodeData) protected voidaddOfferCodeToProratedAdjustmentIfUsed(@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 givenProratedOfferAdjustmentif it is present on the order.protected voidaddOfferCodeToProratedItemAdjustmentIfUsed(@NonNull com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef offer, @NonNull EnhancedProratedItemOfferAdjustment proratedItemAdjustment, @NonNull OfferCodeData offerCodeData) Adds an offer code to the givenEnhancedProratedItemOfferAdjustmentif it is present on the order.protected voidaddOrderCodeToAdjustmentIfUsed(@NonNull Offer offer, @NonNull com.broadleafcommerce.promotion.offer.client.web.context.info.Adjustment adjustment, @NonNull OfferCodeData offerCodeData) Adds an offer code to the givenAdjustmentif 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 anItemResponseDetailobject with a parameterized type ofProratedItemOfferAdjustmentwith details based on theItemResponseDetailgeneric object that is passed in.protected javax.money.MonetaryAmountgetAdjustedSubtotal(@NotNull EnhancedOrder order, com.broadleafcommerce.promotion.offer.client.web.context.discounts.OrderResponse<P> orderResponse) protected javax.money.MonetaryAmountgetAdjustedTotal(@NotNull EnhancedOrder order, javax.money.MonetaryAmount adjustedSubtotal) protected com.broadleafcommerce.promotion.offer.client.web.context.info.AdjustmentgetAdjustment(@NonNull Offer offer, @NonNull javax.money.MonetaryAmount amount, @NonNull OfferCodeData offerCodeData) Creates anAdjustmentcaused by theOfferfor an order.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.ItemAdjustmentgetItemAdjustment(@NonNull ItemOfferAdjustment itemOfferAdjustment, @NonNull OfferCodeData offerCodeData) Creates anItemAdjustmentfor theItemOfferAdjustment.protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponse<P>getItemResponse(@NonNull EnhancedLineItem lineItem, @NonNull OfferCodeData offerCodeData) Creates anOffer ItemResponsefor aline 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 anOffer ItemResponseDetailfor aLineItemOfferDetail.protected com.broadleafcommerce.common.extension.TypeFactoryprotected com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRefgetOfferRef(@NonNull Offer offer) Creates anOfferReffor the givenOffer.protected booleanisUseSalePriceForItem(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 booleanisUseSaleRecurringPriceForItem(com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponse<P> itemResponse) Whether to use the sale or standard recurring price.
-
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:OfferEngineResponseBuilderBuilds a response object detailing the adjustment information on the provided order. Intended to be used after applying offers to the order.- Specified by:
buildin interfaceOfferEngineResponseBuilder<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 anItemResponseDetailobject with a parameterized type ofProratedItemOfferAdjustmentwith details based on theItemResponseDetailgeneric object that is passed in.- Parameters:
itemResponseDetail- the generic object with the details to build theItemResponseDetailobject with- Returns:
- the hydrated
ItemResponseDetailobject with a parameterized type ofProratedItemOfferAdjustment
-
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 appliedofferCodeData- 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 anOffer ItemResponsefor aline 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 anOffer ItemResponseDetailfor aLineItemOfferDetail.- Parameters:
orderItemOfferDetail- TheLineItemOfferDetailto be converted into aItemResponseDetail.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 anyAdjustments.- Returns:
- an
Offer ItemResponseDetailfor aLineItemOfferDetail.
-
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 anAdjustmentcaused by theOfferfor an order.- Parameters:
offer-Offerfrom which theadjustmentis derived.amount- The amount of the adjustment caused by theofferfor 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 anyAdjustments.- Returns:
- an
Adjustmentcaused by theOfferfor 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 givenAdjustmentif it is present on the order.- Parameters:
offer-Offerfrom which theadjustmentis derived.adjustment- Adjustment TheAdjustmentfor which an offer code may applyofferCodeData- 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 anyAdjustments.
-
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 givenEnhancedProratedItemOfferAdjustmentif it is present on the order.- Parameters:
offer-Offerfrom which theadjustmentis derived.proratedItemAdjustment- TheEnhancedProratedItemOfferAdjustmentfor which an offer code may applyofferCodeData- 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 anyprorated 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 givenProratedOfferAdjustmentif it is present on the order.- Parameters:
offer-Offerfrom which theadjustmentis derived.proratedAdjustment- Adjustment TheProratedOfferAdjustmentfor which an offer code may applyofferCodeData- 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 anyprorated adjustments.
-
getItemAdjustment
protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemAdjustment getItemAdjustment(@NonNull @NonNull ItemOfferAdjustment itemOfferAdjustment, @NonNull @NonNull OfferCodeData offerCodeData) Creates anItemAdjustmentfor theItemOfferAdjustment.- Parameters:
itemOfferAdjustment- AnItemOfferAdjustmentto be converted into aItemAdjustment.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 anyAdjustments.- Returns:
- an
ItemAdjustmentfor theItemOfferAdjustment.
-
getOfferRef
protected com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef getOfferRef(@NonNull @NonNull Offer offer) Creates anOfferReffor the givenOffer.- Parameters:
offer- Offer from which to make a ref- Returns:
- an
OfferReffor the givenOffer.
-
getOfferFactory
protected com.broadleafcommerce.common.extension.TypeFactory getOfferFactory()
-