Class DefaultOrderAndItemOfferHelper
java.lang.Object
com.broadleafcommerce.promotion.offer.service.engine.application.processor.helper.DefaultOrderAndItemOfferHelper
- All Implemented Interfaces:
OrderAndItemOfferHelper
- Author:
- Nathan Moore (nathanmoore).
-
Field Summary
Modifier and TypeFieldDescriptionprotected final com.broadleafcommerce.common.extension.TypeFactory
protected final com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService
-
Constructor Summary
ConstructorDescriptionDefaultOrderAndItemOfferHelper
(com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService, com.broadleafcommerce.common.extension.TypeFactory offerFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
javax.money.MonetaryAmount
calculateFulfillmentItemTotalFromPermutation
(Optional<ItemOfferPermutationResult> itemResult, EnhancedFulfillmentLineItem item, DiscountableItemInfo discountableItemTotal) Uses the passed in results from a permutation result which holds the non-final item and offer adjustments relevant to the permutation.javax.money.MonetaryAmount
calculateItemTotalFromPermutation
(Optional<ItemOfferPermutationResult> itemResult, Optional<OrderOfferPermutationResult> orderResult, EnhancedOrderLineItem item, boolean excludeItemTotalsWithDiscounts, DiscountableItemInfo discountableItemTotal) Uses the passed in results from a permutation which stores the item adjustments and prorated order adjustments for an item.protected int
calculateNumberOfTimesCriteriaIsMet
(ItemCriteriaRule criteriaRule, Collection<EnhancedLineItem> lineItems) Calculates and returns the total number of times the givenEnhancedLineItems
are met with the givenItemCriteriaRule
.com.broadleafcommerce.promotion.offer.client.web.context.discounts.CodeResponse
createCodeResponse
(OfferNotAppliedReasonEnum notUsedReason) Returns the CodeResponse built from the suppliedOfferNotAppliedReasonEnum
.org.springframework.context.MessageSource
com.broadleafcommerce.common.extension.TypeFactory
com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService
getTotalTimesCriteriaIsMetByCriteria
(Map<ItemCriteriaRule, Collection<EnhancedLineItem>> itemsMetByCriteriaRule) Gets a map of total number of times theItemCriteriaRule
is met byItemCriteriaRule
.protected <P extends EnhancedLineItem>
booleanorderMeetsItemTotalRequirements
(javax.money.MonetaryAmount minTotal, Map<ItemCriteriaRule, Collection<P>> candidateItemsMap, boolean useSalePrice) boolean
orderMeetsQualifyingTotalRequirements
(BaseCandidateOffer candidateOffer) As offers are applied, recheck to ensure that the next offer in the collection of candidates can be applied based on the total of item qualifier prices.boolean
orderMeetsSubtotalRequirements
(EnhancedOrder order, BaseCandidateOffer candidateOffer) As offers are applied, recheck to ensure that the next offer in the collection of candidates can be applied based on the order subtotal.boolean
As offers are applied, recheck to ensure that the next offer in the collection of candidates can be applied based on the total of target item prices.void
setMessageSource
(org.springframework.context.MessageSource messageSource)
-
Field Details
-
ruleEvaluationService
protected final com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService -
offerFactory
protected final com.broadleafcommerce.common.extension.TypeFactory offerFactory
-
-
Constructor Details
-
DefaultOrderAndItemOfferHelper
public DefaultOrderAndItemOfferHelper(com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService, com.broadleafcommerce.common.extension.TypeFactory offerFactory)
-
-
Method Details
-
createCodeResponse
public com.broadleafcommerce.promotion.offer.client.web.context.discounts.CodeResponse createCodeResponse(OfferNotAppliedReasonEnum notUsedReason) Description copied from interface:OrderAndItemOfferHelper
Returns the CodeResponse built from the suppliedOfferNotAppliedReasonEnum
.- Specified by:
createCodeResponse
in interfaceOrderAndItemOfferHelper
- Parameters:
notUsedReason
- theOfferNotAppliedReasonEnum
which provides information on why an offer was not applied.- Returns:
- the CodeResponse built from the supplied
OfferNotAppliedReasonEnum
-
orderMeetsQualifyingTotalRequirements
Description copied from interface:OrderAndItemOfferHelper
As offers are applied, recheck to ensure that the next offer in the collection of candidates can be applied based on the total of item qualifier prices.- Specified by:
orderMeetsQualifyingTotalRequirements
in interfaceOrderAndItemOfferHelper
- Parameters:
candidateOffer
-candidate offer
to verify that it can be applied based on the total of item qualifier prices.- Returns:
- whether the offer can be applied based on the total of item qualifier prices.
-
orderMeetsTargetTotalRequirements
Description copied from interface:OrderAndItemOfferHelper
As offers are applied, recheck to ensure that the next offer in the collection of candidates can be applied based on the total of target item prices.- Specified by:
orderMeetsTargetTotalRequirements
in interfaceOrderAndItemOfferHelper
- Parameters:
itemOffer
-candidate offer
to verify that it can be applied based on the total of target item prices.- Returns:
- whether the offer can be applied based on the total of target item prices.
-
calculateItemTotalFromPermutation
public javax.money.MonetaryAmount calculateItemTotalFromPermutation(Optional<ItemOfferPermutationResult> itemResult, Optional<OrderOfferPermutationResult> orderResult, EnhancedOrderLineItem item, boolean excludeItemTotalsWithDiscounts, DiscountableItemInfo discountableItemTotal) Uses the passed in results from a permutation which stores the item adjustments and prorated order adjustments for an item. Stores the results in theDiscountableItemInfo
- Specified by:
calculateItemTotalFromPermutation
in interfaceOrderAndItemOfferHelper
-
calculateFulfillmentItemTotalFromPermutation
public javax.money.MonetaryAmount calculateFulfillmentItemTotalFromPermutation(Optional<ItemOfferPermutationResult> itemResult, EnhancedFulfillmentLineItem item, DiscountableItemInfo discountableItemTotal) Description copied from interface:OrderAndItemOfferHelper
Uses the passed in results from a permutation result which holds the non-final item and offer adjustments relevant to the permutation. Stores the details for the item total calculation on the passed in DiscountableItemTotal- Specified by:
calculateFulfillmentItemTotalFromPermutation
in interfaceOrderAndItemOfferHelper
- Parameters:
itemResult
- The permutation context to calculate the adjustments fromitem
- The fulfillment item to considerdiscountableItemTotal
- Stores the adjusted item amounts- Returns:
- Item total with adjustments for the
item
based on the permutation result.
-
orderMeetsSubtotalRequirements
public boolean orderMeetsSubtotalRequirements(@NonNull EnhancedOrder order, @NonNull BaseCandidateOffer candidateOffer) Description copied from interface:OrderAndItemOfferHelper
As offers are applied, recheck to ensure that the next offer in the collection of candidates can be applied based on the order subtotal.- Specified by:
orderMeetsSubtotalRequirements
in interfaceOrderAndItemOfferHelper
- Parameters:
order
-EnhancedOrder
against whose subtotal to verify the candidate offer's applicabilitycandidateOffer
-candidate offer
to verify that it can be applied based on the order subtotal.- Returns:
- whether the offer can be applied based on the order subtotal.
-
getTotalTimesCriteriaIsMetByCriteria
public Map<ItemCriteriaRule,Integer> getTotalTimesCriteriaIsMetByCriteria(@NonNull Map<ItemCriteriaRule, Collection<EnhancedLineItem>> itemsMetByCriteriaRule) Description copied from interface:OrderAndItemOfferHelper
Gets a map of total number of times theItemCriteriaRule
is met byItemCriteriaRule
.- Specified by:
getTotalTimesCriteriaIsMetByCriteria
in interfaceOrderAndItemOfferHelper
- Parameters:
itemsMetByCriteriaRule
- a map ofEnhancedLineItems
that meet theItemCriteriaRule
- Returns:
- a map of total number of times the
ItemCriteriaRule
is met byItemCriteriaRule
-
calculateNumberOfTimesCriteriaIsMet
protected int calculateNumberOfTimesCriteriaIsMet(ItemCriteriaRule criteriaRule, Collection<EnhancedLineItem> lineItems) Calculates and returns the total number of times the givenEnhancedLineItems
are met with the givenItemCriteriaRule
.- Parameters:
criteriaRule
- theItemCriteriaRule
to get theItemCriteriaRule.getNumberOfMatchesRequired()
fromlineItems
- theEnhancedLineItems
to calculate the total number of times are met with the givenItemCriteriaRule
- Returns:
- the total number of times the given
EnhancedLineItems
are met with the givenItemCriteriaRule
-
getRuleEvaluationService
public com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService getRuleEvaluationService()- Specified by:
getRuleEvaluationService
in interfaceOrderAndItemOfferHelper
- Returns:
- an instance of
RuleEvaluationService
.
-
getOfferFactory
public com.broadleafcommerce.common.extension.TypeFactory getOfferFactory()- Specified by:
getOfferFactory
in interfaceOrderAndItemOfferHelper
- Returns:
- an instance of
TypeFactory
that creates offer domain objects
-
getMessageSource
public org.springframework.context.MessageSource getMessageSource()- Specified by:
getMessageSource
in interfaceOrderAndItemOfferHelper
- Returns:
- an instance of
MessageSource
-
orderMeetsItemTotalRequirements
protected <P extends EnhancedLineItem> boolean orderMeetsItemTotalRequirements(javax.money.MonetaryAmount minTotal, Map<ItemCriteriaRule, Collection<P>> candidateItemsMap, boolean useSalePrice) -
assertCandidateOfferNotNull
-
setMessageSource
@Autowired public void setMessageSource(org.springframework.context.MessageSource messageSource)
-