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 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 givenProratedOfferAdjustment
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 givenEnhancedProratedItemOfferAdjustment
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 givenAdjustment
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 anItemResponseDetail
object with a parameterized type ofProratedItemOfferAdjustment
with details based on theItemResponseDetail
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 Offer offer, @NonNull javax.money.MonetaryAmount amount, @NonNull OfferCodeData offerCodeData) Creates anAdjustment
caused by theOffer
for 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.ItemAdjustment
getItemAdjustment
(@NonNull ItemOfferAdjustment itemOfferAdjustment, @NonNull OfferCodeData offerCodeData) Creates anItemAdjustment
for theItemOfferAdjustment
.protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.ItemResponse<P>
getItemResponse
(@NonNull EnhancedLineItem lineItem, @NonNull OfferCodeData offerCodeData) Creates anOffer ItemResponse
for 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 ItemResponseDetail
for aLineItemOfferDetail
.protected com.broadleafcommerce.common.extension.TypeFactory
protected com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef
getOfferRef
(@NonNull Offer offer) Creates anOfferRef
for the givenOffer
.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.
-
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 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 anItemResponseDetail
object with a parameterized type ofProratedItemOfferAdjustment
with details based on theItemResponseDetail
generic object that is passed in.- Parameters:
itemResponseDetail
- the generic object with the details to build theItemResponseDetail
object with- Returns:
- the hydrated
ItemResponseDetail
object 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 ItemResponse
for 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 ItemResponseDetail
for aLineItemOfferDetail
.- Parameters:
orderItemOfferDetail
- TheLineItemOfferDetail
to 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 ItemResponseDetail
for 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 anAdjustment
caused by theOffer
for an order.- Parameters:
offer
-Offer
from which theadjustment
is derived.amount
- The amount of the adjustment caused by theoffer
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 anyAdjustments
.- Returns:
- an
Adjustment
caused by theOffer
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 givenAdjustment
if it is present on the order.- Parameters:
offer
-Offer
from which theadjustment
is derived.adjustment
- Adjustment TheAdjustment
for 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 givenEnhancedProratedItemOfferAdjustment
if it is present on the order.- Parameters:
offer
-Offer
from which theadjustment
is derived.proratedItemAdjustment
- TheEnhancedProratedItemOfferAdjustment
for 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 givenProratedOfferAdjustment
if it is present on the order.- Parameters:
offer
-Offer
from which theadjustment
is derived.proratedAdjustment
- Adjustment TheProratedOfferAdjustment
for 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 anItemAdjustment
for theItemOfferAdjustment
.- Parameters:
itemOfferAdjustment
- AnItemOfferAdjustment
to 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
ItemAdjustment
for theItemOfferAdjustment
.
-
getOfferRef
protected com.broadleafcommerce.promotion.offer.client.web.context.info.OfferRef getOfferRef(@NonNull @NonNull Offer offer) Creates anOfferRef
for the givenOffer
.- Parameters:
offer
- Offer from which to make a ref- Returns:
- an
OfferRef
for the givenOffer
.
-
getOfferFactory
protected com.broadleafcommerce.common.extension.TypeFactory getOfferFactory()
-