Class DefaultOrderAndItemOfferHelper
- java.lang.Object
-
- com.broadleafcommerce.promotion.offer.service.engine.application.processor.helper.DefaultOrderAndItemOfferHelper
-
- All Implemented Interfaces:
OrderAndItemOfferHelper
public class DefaultOrderAndItemOfferHelper extends Object implements OrderAndItemOfferHelper
- Author:
- Nathan Moore (nathanmoore).
-
-
Field Summary
Fields Modifier and Type Field Description protected com.broadleafcommerce.common.extension.TypeFactoryofferFactoryprotected com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationServiceruleEvaluationService
-
Constructor Summary
Constructors Constructor Description DefaultOrderAndItemOfferHelper(com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService, com.broadleafcommerce.common.extension.TypeFactory offerFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidassertCandidateOfferNotNull(BaseCandidateOffer offer)protected intcalculateNumberOfTimesCriteriaIsMet(ItemCriteriaRule criteriaRule, Collection<EnhancedLineItem> lineItems)Calculates and returns the total number of times the givenEnhancedLineItemsare met with the givenItemCriteriaRule.com.broadleafcommerce.common.extension.TypeFactorygetOfferFactory()com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationServicegetRuleEvaluationService()Map<ItemCriteriaRule,Integer>getTotalTimesCriteriaIsMetByCriteria(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.booleanorderMeetsTargetTotalRequirements(CandidateItemOffer itemOffer)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.
-
-
-
Method Detail
-
orderMeetsQualifyingTotalRequirements
public boolean orderMeetsQualifyingTotalRequirements(@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 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
public boolean orderMeetsTargetTotalRequirements(@NonNull CandidateItemOffer itemOffer)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.
-
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
-
orderMeetsItemTotalRequirements
protected <P extends EnhancedLineItem> boolean orderMeetsItemTotalRequirements(javax.money.MonetaryAmount minTotal, Map<ItemCriteriaRule,Collection<P>> candidateItemsMap, boolean useSalePrice)
-
assertCandidateOfferNotNull
protected void assertCandidateOfferNotNull(BaseCandidateOffer offer)
-
-