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
FieldsModifier and TypeFieldDescriptionprotected final com.broadleafcommerce.common.extension.TypeFactoryprotected final com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService -
Constructor Summary
ConstructorsConstructorDescriptionDefaultOrderAndItemOfferHelper(com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService, com.broadleafcommerce.common.extension.TypeFactory offerFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidjavax.money.MonetaryAmountcalculateFulfillmentItemTotalFromPermutation(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.MonetaryAmountcalculateItemTotalFromPermutation(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 intcalculateNumberOfTimesCriteriaIsMet(ItemCriteriaRule criteriaRule, Collection<EnhancedLineItem> lineItems) Calculates and returns the total number of times the givenEnhancedLineItemsare met with the givenItemCriteriaRule.com.broadleafcommerce.promotion.offer.client.web.context.discounts.CodeResponsecreateCodeResponse(OfferNotAppliedReasonEnum notUsedReason) Returns the CodeResponse built from the suppliedOfferNotAppliedReasonEnum.org.springframework.context.MessageSourcecom.broadleafcommerce.common.extension.TypeFactorycom.broadleafcommerce.rulesengine.expression.service.RuleEvaluationServicegetTotalTimesCriteriaIsMetByCriteria(Map<ItemCriteriaRule, Collection<EnhancedLineItem>> itemsMetByCriteriaRule) Gets a map of total number of times theItemCriteriaRuleis met byItemCriteriaRule.protected <P extends EnhancedLineItem>
booleanorderMeetsItemTotalRequirements(javax.money.MonetaryAmount minTotal, Map<ItemCriteriaRule, Collection<P>> candidateItemsMap, boolean useSalePrice) booleanorderMeetsQualifyingTotalRequirements(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.booleanorderMeetsSubtotalRequirements(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.booleanAs 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.voidsetMessageSource(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:OrderAndItemOfferHelperReturns the CodeResponse built from the suppliedOfferNotAppliedReasonEnum.- Specified by:
createCodeResponsein interfaceOrderAndItemOfferHelper- Parameters:
notUsedReason- theOfferNotAppliedReasonEnumwhich provides information on why an offer was not applied.- Returns:
- the CodeResponse built from the supplied
OfferNotAppliedReasonEnum
-
orderMeetsQualifyingTotalRequirements
Description copied from interface:OrderAndItemOfferHelperAs 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:
orderMeetsQualifyingTotalRequirementsin interfaceOrderAndItemOfferHelper- Parameters:
candidateOffer-candidate offerto 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:OrderAndItemOfferHelperAs 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:
orderMeetsTargetTotalRequirementsin interfaceOrderAndItemOfferHelper- Parameters:
itemOffer-candidate offerto 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:
calculateItemTotalFromPermutationin interfaceOrderAndItemOfferHelper
-
calculateFulfillmentItemTotalFromPermutation
public javax.money.MonetaryAmount calculateFulfillmentItemTotalFromPermutation(Optional<ItemOfferPermutationResult> itemResult, EnhancedFulfillmentLineItem item, DiscountableItemInfo discountableItemTotal) Description copied from interface:OrderAndItemOfferHelperUses 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:
calculateFulfillmentItemTotalFromPermutationin 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
itembased on the permutation result.
-
orderMeetsSubtotalRequirements
public boolean orderMeetsSubtotalRequirements(@NonNull EnhancedOrder order, @NonNull BaseCandidateOffer candidateOffer) Description copied from interface:OrderAndItemOfferHelperAs 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:
orderMeetsSubtotalRequirementsin interfaceOrderAndItemOfferHelper- Parameters:
order-EnhancedOrderagainst whose subtotal to verify the candidate offer's applicabilitycandidateOffer-candidate offerto 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:OrderAndItemOfferHelperGets a map of total number of times theItemCriteriaRuleis met byItemCriteriaRule.- Specified by:
getTotalTimesCriteriaIsMetByCriteriain interfaceOrderAndItemOfferHelper- Parameters:
itemsMetByCriteriaRule- a map ofEnhancedLineItemsthat meet theItemCriteriaRule- Returns:
- a map of total number of times the
ItemCriteriaRuleis met byItemCriteriaRule
-
calculateNumberOfTimesCriteriaIsMet
protected int calculateNumberOfTimesCriteriaIsMet(ItemCriteriaRule criteriaRule, Collection<EnhancedLineItem> lineItems) Calculates and returns the total number of times the givenEnhancedLineItemsare met with the givenItemCriteriaRule.- Parameters:
criteriaRule- theItemCriteriaRuleto get theItemCriteriaRule.getNumberOfMatchesRequired()fromlineItems- theEnhancedLineItemsto calculate the total number of times are met with the givenItemCriteriaRule- Returns:
- the total number of times the given
EnhancedLineItemsare met with the givenItemCriteriaRule
-
getRuleEvaluationService
public com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService getRuleEvaluationService()- Specified by:
getRuleEvaluationServicein interfaceOrderAndItemOfferHelper- Returns:
- an instance of
RuleEvaluationService.
-
getOfferFactory
public com.broadleafcommerce.common.extension.TypeFactory getOfferFactory()- Specified by:
getOfferFactoryin interfaceOrderAndItemOfferHelper- Returns:
- an instance of
TypeFactorythat creates offer domain objects
-
getMessageSource
public org.springframework.context.MessageSource getMessageSource()- Specified by:
getMessageSourcein 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)
-