Class DefaultOfferCandidateService<P extends Offer>
- All Implemented Interfaces:
OfferCandidateService<P>
- Author:
- Chad Harchar (charchar)
-
Field Summary
Modifier and TypeFieldDescriptionprotected final OfferAuditDetailService<? extends OfferAuditDetail>
protected final CandidateOfferUtility
protected static final Collector<ItemCriteriaRule,
?, Map<ItemCriteriaRule, Collection<EnhancedFulfillmentLineItem>>> protected static final String
protected static final Collector<ItemCriteriaRule,
?, Map<ItemCriteriaRule, Collection<EnhancedLineItem>>> protected OfferAndOfferCodeUsabilityService
protected final com.broadleafcommerce.common.extension.TypeFactory
protected final OfferUserService
protected final com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService
protected final OfferService<P>
-
Constructor Summary
ConstructorDescriptionDefaultOfferCandidateService
(OfferService<P> service, OfferAuditDetailService<? extends OfferAuditDetail> auditService, com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService, com.broadleafcommerce.common.extension.TypeFactory offerFactory, OfferUserService offerUserService, CandidateOfferUtility candidateOfferUtility) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addNewCandidateFG
(CandidateFulfillmentGroupOffer candidateOffer, EnhancedFulfillmentGroup fulfillmentGroup) protected void
addNewCandidateFG
(CandidateFulfillmentGroupOffer candidateOffer, EnhancedFulfillmentGroup fulfillmentGroup, Map<ItemCriteriaRule, Collection<EnhancedFulfillmentLineItem>> itemCriteriaMap) protected void
addQualifiersToMap
(BaseCandidateOffer candidateOffer, Map<ItemCriteriaRule, Collection<EnhancedLineItem>> itemCriteriaMap) protected void
buildOfferUsablilityCodeResponses
(EnhancedOrder order, List<P> offerList, OffersAndOfferCodesUsabilityInfo usabilityInfo) protected javax.money.MonetaryAmount
calculateStandardPriceSavings
(EnhancedOrderLineItem item, CandidateItemOffer itemOffer) protected boolean
canUseOrderLineItemsAsQualifiers
(String targetType) boolean
checkOfferActiveAndTimeCriteria
(EnhancedOrder order, P offer) checkOfferUsability
(Stream<P> offers, EnhancedOrder order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) constructCandidateOffer
(Offer offer, EnhancedOrder order) createCandidateOffersFromOffers
(@NonNull Stream<P> offerSet, @NonNull EnhancedOrder order) Creates aCandidateOffers
object by converting the providedoffers
into their corresponding DTO object based on theirDiscountTargetType
.protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.CodeResponse
createCodeResponse
(OfferNotAppliedReasonEnum notUsedReason) protected OfferCodeData
protected final boolean
evaluateAgainstRule
(String rule, @NonNull Serializable rootObject) Runs therule
against the suppliedrootObject
via theRuleEvaluationService
.protected boolean
evaluateFulfillmentItemCriteriaAgainstFulfillmentGroups
(EnhancedOrder order, CandidateFulfillmentGroupOffer candidateOffer) protected boolean
evaluateFulfillmentItemCriteriaAgainstOrder
(@NonNull EnhancedOrder order, @NonNull Map<ItemCriteriaRule, Collection<EnhancedFulfillmentLineItem>> itemCriteriaMap, String connectiveOperator) protected Set<EnhancedFulfillmentLineItem>
evaluateGroupForMatchingFulfillmentItems
(EnhancedFulfillmentGroup fulfillmentGroup, ItemCriteriaRule itemCriteria) protected boolean
evaluateOfferItemCriteriaAgainstOrder
(@NonNull EnhancedOrder order, @NonNull BaseCandidateOffer offer, @NonNull Map<ItemCriteriaRule, Collection<EnhancedLineItem>> itemCriteriaMap, String connectiveOperator, boolean allowMatchesOnNonDiscountableItems) Evaluates theItemCriteriaRules
from an order or order item targeting offer against theOrder
to determine whether the offer is applicable.protected Set<EnhancedFulfillmentLineItem>
evaluateOrderForMatchingFulfillmentItems
(EnhancedOrder order, ItemCriteriaRule itemCriteria) protected Set<EnhancedLineItem>
evaluateOrderForMatchingItems
(@NonNull List<EnhancedOrderLineItem> orderLineItems, @NonNull ItemCriteriaRule itemCriteriaRule, boolean allowMatchesOnNonDiscountableItems) Evaluates theItemCriteriaRule
against theOrder's line items
to determine if the order matches.protected boolean
evaluateSubscriptionDiscountAgainstItems
(@NonNull Offer offer, @NonNull Map<ItemCriteriaRule, Collection<EnhancedLineItem>> itemCriteriaMap) protected List<BaseCandidateOffer>
expandOffersBySegment
(BaseCandidateOffer offer, EnhancedOrder order) It is possible for a single offer to be activated using two separate codes that are restricted to different segments.<T extends BaseCandidateOffer>
List<T>filterOffersByItemQualifiers
(@NonNull List<T> candidateOffers, @NonNull EnhancedOrder order) Filter the provided offer set based on if the items of the provided order match as qualifiers.filterOffersByOrderCurrency
(Stream<P> offerSet, EnhancedOrder order) Filters out anyOffers
whoseOffer.getCurrency()
doesn't match theEnhancedOrder.getCurrency()
, if specified.filterOffersByRequest
(@NonNull Stream<P> offerSet, @NonNull EnhancedOrder order) Filter the provided offer set based on information in the given context of the order.filterOffersByTotalUses
(@NonNull Stream<P> offerSet, @NonNull EnhancedOrder order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Filter the provided offer set based on thetotal uses
of the offer as well asuser uses
, while also factoring inOffer.getMaxUsesPerUserFrequency()
.filterOffersByUserTarget
(Stream<P> offerSet, EnhancedOrder order) protected OffersAndOfferCodesUsabilityInfo
gatherOfferAndOfferCodeUsabilityInfo
(EnhancedOrder order, List<P> offerList, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) getAllOfferCodes
(@NonNull List<com.broadleafcommerce.promotion.offer.client.web.context.OfferCodeDto> offerCodesDtos, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) getAutomaticAndCodeAndCustomerOffers
(@NonNull Set<String> offerIdsToFilterOn, @NonNull Set<String> campaignIdsToFilterOn, EnhancedOrder order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve offers that are set to automatically be considered or that correspond to the provided offer code(s) or customer specific offers for the provided customer.getAutomaticAndCodeAndCustomerOffers
(com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, @NonNull com.broadleafcommerce.promotion.offer.client.web.context.Codes codes, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected int
getBundleItemQuantity
(EnhancedFulfillmentLineItem fulfillmentItem) getCandidateOfferCodes
(@NonNull EnhancedOrder order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) getCandidateOffers
(@NonNull EnhancedOrder order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Get the candidate offers for the provided order and context.getCandidateVoucherOffers
(@NonNull EnhancedOrder order, boolean isPostCheckout, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Get the candidate voucher offers for the provided order and context.protected org.apache.commons.lang3.tuple.Pair<Set<EnhancedFulfillmentLineItem>,
Integer> getFulfillmentItemMatchResults
(String itemCriteriaRule, EnhancedFulfillmentGroup fulfillmentGroup) protected Map<ItemCriteriaRule,
Collection<EnhancedFulfillmentLineItem>> getItemCriteriaCollectionMap
(@NonNull ItemCriteria itemQualifierCriteria, @NonNull EnhancedFulfillmentGroup fulfillmentGroup) protected org.springframework.context.MessageSource
protected OfferAndOfferCodeUsabilityService
protected OfferCodeService<OfferCode>
getOffersForMessaging
(Set<String> offerIds, EnhancedOrder order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve offers that are automatically applied and applicable for marketing messaging.getOffersToFilter
(@NonNull EnhancedOrder order, @NonNull Set<String> offerIdsToFilterOn, @NonNull Set<String> campaignIdsToFilterOn, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Get available offers that need to be filtered to become candidates.getVoucherOffers
(com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, @NonNull List<com.broadleafcommerce.promotion.offer.client.web.context.OfferCodeDto> offerCodeDtos, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve voucher offers that are set to automatically be considered or that correspond to the provided offer code(s) or customer specific offers for the provided customer.void
initializeWithCodeProperties
(EnhancedOrder order, CandidateOffers candidateOffers, BaseCandidateOffer candidateOffer) protected final boolean
isAnyMatchCriteria
(String connectiveOperator) Checks whether the operator matchesDefaultConnectiveOperatorType.OR
, meaning that only 1 of theItemCriteria's rules
need be matched.protected boolean
isAnyMatchFoundAcrossAllItems
(@NonNull EnhancedOrder order, @NonNull CandidateFulfillmentGroupOffer candidateOffer, @NonNull Offer offer) protected boolean
isAnyMatchFoundInAnyFulfillmentGroup
(EnhancedOrder order, CandidateFulfillmentGroupOffer candidateOffer, Offer offer) protected boolean
isCanUseOfferCodes
(OffersAndOfferCodesUsabilityInfo usabilityInfo, P offer) protected boolean
isFreeGiftItem
(@NonNull EnhancedLineItem orderItem) Determines if the givenEnhancedLineItem
is a free gift item.protected boolean
isMinSubtotalMet
(javax.money.MonetaryAmount minSubtotalRequired, Set<? extends EnhancedLineItem> itemsToSum) protected boolean
matchIsAllowedForItem
(@NonNull EnhancedLineItem orderItem, boolean allowMatchesOnNonDiscountableItems) Determine whether or not a match is allowed for the line item.populateOrRemoveByFulfillmentGroupTargets
(@NonNull List<CandidateFulfillmentGroupOffer> candidateOfferList, EnhancedOrder order) Filter the provided offer set based on if the provided fulfillment groups of the order match as shipping targets.populateOrRemoveCandidateOffers
(@NonNull Stream<P> offerSet, @NonNull EnhancedOrder order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Filter out the provided offer set by matching their configurations against the information on the provided context and order.populateOrRemoveOffersByFulfillmentGroupQualifiers
(@NonNull List<CandidateFulfillmentGroupOffer> candidateOfferSet, @NonNull EnhancedOrder order) Filter the provided offer set based on if the items of the provided order match as qualifiers.populateOrRemoveOffersByFulfillmentItemQualifiers
(@NonNull List<CandidateItemOffer> candidateOfferSet, @NonNull EnhancedOrder order) Filter the provided offer set based on if the fulfillment items of the provided order match as qualifiers.populateOrRemoveOffersByFulfillmentItemTargets
(@NonNull List<CandidateItemOffer> candidateOfferSet, @NonNull EnhancedOrder order) Filter the provided offer set based on if the provided fulfillment items of the order match as shipping targets.populateOrRemoveOffersByItemTargets
(@NonNull List<CandidateItemOffer> candidateOfferSet, @NonNull EnhancedOrder order) Filter the provided offer set based on if the items of the provided order match as targets.void
setMessageSource
(org.springframework.context.MessageSource messageSource) void
setOfferAndOfferCodeUsabilityService
(OfferAndOfferCodeUsabilityService offerAndOfferCodeUsabilityService) void
setOfferCodeService
(OfferCodeService<OfferCode> offerCodeService) protected boolean
shouldIncludeItem
(EnhancedOrderLineItem item, EnhancedOrder order, BaseCandidateOffer offer) Deprecated, for removal: This API element is subject to removal in a future version.protected boolean
shouldIncludeItem
(EnhancedOrderLineItem item, EnhancedOrder order, BaseCandidateOffer offer, boolean allowMatchesOnNonDiscountableItems) Whether the givenEnhancedOrderLineItem
should be considered when evaluating anItemCriteriaRule
.protected boolean
shouldIncludeOnSaleItem
(EnhancedOrderLineItem item, BaseCandidateOffer candidateOffer) protected void
updateNotFoundCodes
(EnhancedOrder order, List<OfferCode> offerCodes) protected void
updateReasonResponsesForTargetNotMet
(@NotNull EnhancedOrder order, Offer offer)
-
Field Details
-
ITEM_CRITERIA_MAP_COLLECTOR
protected static final Collector<ItemCriteriaRule,?, ITEM_CRITERIA_MAP_COLLECTORMap<ItemCriteriaRule, Collection<EnhancedLineItem>>> -
FULFILLMENT_ITEM_CRITERIA_MAP_COLLECTOR
protected static final Collector<ItemCriteriaRule,?, FULFILLMENT_ITEM_CRITERIA_MAP_COLLECTORMap<ItemCriteriaRule, Collection<EnhancedFulfillmentLineItem>>> -
IS_FREE_GIFT_ITEM
- See Also:
-
service
-
auditService
-
ruleEvaluationService
protected final com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService -
offerFactory
protected final com.broadleafcommerce.common.extension.TypeFactory offerFactory -
offerUserService
-
candidateOfferUtility
-
offerAndOfferCodeUsabilityService
-
-
Constructor Details
-
DefaultOfferCandidateService
public DefaultOfferCandidateService(OfferService<P> service, OfferAuditDetailService<? extends OfferAuditDetail> auditService, com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService, com.broadleafcommerce.common.extension.TypeFactory offerFactory, OfferUserService offerUserService, CandidateOfferUtility candidateOfferUtility)
-
-
Method Details
-
getCandidateOffers
@NonNull public CandidateOffers getCandidateOffers(@NonNull @NonNull EnhancedOrder order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:OfferCandidateService
Get the candidate offers for the provided order and context.- Specified by:
getCandidateOffers
in interfaceOfferCandidateService<P extends Offer>
- Parameters:
order
- context information around the offercontextInfo
- context information around sandbox and multitenant state- Returns:
- the list of offers that are candidates to be applied to the provided order.
-
updateNotFoundCodes
-
createCodeResponse
protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.CodeResponse createCodeResponse(OfferNotAppliedReasonEnum notUsedReason) -
createOfferCodeData
-
getCandidateOfferCodes
protected List<OfferCode> getCandidateOfferCodes(@NonNull @NonNull EnhancedOrder order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getCandidateVoucherOffers
@NonNull public List<CandidateOrderOffer> getCandidateVoucherOffers(@NonNull @NonNull EnhancedOrder order, boolean isPostCheckout, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:OfferCandidateService
Get the candidate voucher offers for the provided order and context.- Specified by:
getCandidateVoucherOffers
in interfaceOfferCandidateService<P extends Offer>
- Parameters:
order
- context information around the offercontextInfo
- context information around sandbox and multitenant state- Returns:
- the list of voucher offers that are candidates to be applied to the provided order.
-
getOffersToFilter
@NonNull public Stream<P> getOffersToFilter(@NonNull @NonNull EnhancedOrder order, @NonNull @NonNull Set<String> offerIdsToFilterOn, @NonNull @NonNull Set<String> campaignIdsToFilterOn, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:OfferCandidateService
Get available offers that need to be filtered to become candidates. This gets offers by user, codes, and automatic offers.- Specified by:
getOffersToFilter
in interfaceOfferCandidateService<P extends Offer>
- Parameters:
order
- context information around the offercontextInfo
- context information around sandbox and multitenant state- Returns:
- a set of all available offers that need to be filtered down to become candidates.
-
getOffersForMessaging
@NonNull public List<P> getOffersForMessaging(Set<String> offerIds, @Nullable EnhancedOrder order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:OfferCandidateService
Retrieve offers that are automatically applied and applicable for marketing messaging. The implementation will utilize the order to filter the returned offers.- Specified by:
getOffersForMessaging
in interfaceOfferCandidateService<P extends Offer>
order
- the order to determine context information around the customer and other filterscontextInfo
- context information around sandbox and multitenant state- Returns:
- list of offers for automatic consideration or customer specific for the provided customer or that correspond to the provided offer code(s).
-
getAutomaticAndCodeAndCustomerOffers
@NonNull public Stream<P> getAutomaticAndCodeAndCustomerOffers(@Nullable com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, @NonNull @NonNull com.broadleafcommerce.promotion.offer.client.web.context.Codes codes, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
getAutomaticAndCodeAndCustomerOffers
in interfaceOfferCandidateService<P extends Offer>
-
getAutomaticAndCodeAndCustomerOffers
@NonNull public Stream<P> getAutomaticAndCodeAndCustomerOffers(@NonNull @NonNull Set<String> offerIdsToFilterOn, @NonNull @NonNull Set<String> campaignIdsToFilterOn, @Nullable EnhancedOrder order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:OfferCandidateService
Retrieve offers that are set to automatically be considered or that correspond to the provided offer code(s) or customer specific offers for the provided customer.- Specified by:
getAutomaticAndCodeAndCustomerOffers
in interfaceOfferCandidateService<P extends Offer>
- Parameters:
offerIdsToFilterOn
- List of relevant offer Ids to filter query on.campaignIdsToFilterOn
- List of relevant campaign Ids to filter query on.order
- the order to determine context information around the customer and other filterscontextInfo
- context information around sandbox and multitenant state- Returns:
- list of offers for automatic consideration or customer specific for the provided customer or that correspond to the provided offer code(s).
-
getVoucherOffers
@NonNull public Stream<P> getVoucherOffers(@Nullable com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, @NonNull @NonNull List<com.broadleafcommerce.promotion.offer.client.web.context.OfferCodeDto> offerCodeDtos, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:OfferCandidateService
Retrieve voucher offers that are set to automatically be considered or that correspond to the provided offer code(s) or customer specific offers for the provided customer.- Specified by:
getVoucherOffers
in interfaceOfferCandidateService<P extends Offer>
- Parameters:
customerContext
- context information around the customerofferCodeDtos
- DTO containing relevant codes such asshared codes
and Campaign tracking IDs.contextInfo
- context information around sandbox and multitenant state- Returns:
- list of voucher offers based on the customer context or the provided offer codes
-
getAllOfferCodes
-
populateOrRemoveCandidateOffers
@NonNull public CandidateOffers populateOrRemoveCandidateOffers(@NonNull @NonNull Stream<P> offerSet, @NonNull @NonNull EnhancedOrder order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:OfferCandidateService
Filter out the provided offer set by matching their configurations against the information on the provided context and order. For matching offers, associate the relevant item qualifiers and targets that might be used for the offer.- Specified by:
populateOrRemoveCandidateOffers
in interfaceOfferCandidateService<P extends Offer>
- Parameters:
offerSet
- filtered offer set that can apply to the order for the context.order
- context information around the ordercontextInfo
- context information around sandbox and multitenant state
-
createCandidateOffersFromOffers
@NonNull public CandidateOffers createCandidateOffersFromOffers(@NonNull @NonNull Stream<P> offerSet, @NonNull @NonNull EnhancedOrder order) Description copied from interface:OfferCandidateService
Creates aCandidateOffers
object by converting the providedoffers
into their corresponding DTO object based on theirDiscountTargetType
. The DTO objects areCandidateOrderOffer
,CandidateItemOffer
, andCandidateFulfillmentGroupOffer
- Specified by:
createCandidateOffersFromOffers
in interfaceOfferCandidateService<P extends Offer>
- Parameters:
offerSet
- The set of offers to use to create aCandidateOffers
order
- order context to pupulate the candidate offers onCandidateOffers
- Returns:
- the
CandidateOffers
built from the provided offer set
-
initializeWithCodeProperties
public void initializeWithCodeProperties(EnhancedOrder order, CandidateOffers candidateOffers, BaseCandidateOffer candidateOffer) -
constructCandidateOffer
-
expandOffersBySegment
protected List<BaseCandidateOffer> expandOffersBySegment(BaseCandidateOffer offer, EnhancedOrder order) It is possible for a single offer to be activated using two separate codes that are restricted to different segments. In this case, the process copies the offer which is processed separately for each segment.- Parameters:
offer
-- Returns:
-
filterOffersByRequest
public Stream<P> filterOffersByRequest(@NonNull @NonNull Stream<P> offerSet, @NonNull @NonNull EnhancedOrder order) Description copied from interface:OfferCandidateService
Filter the provided offer set based on information in the given context of the order. This evaluates theEnhancedOrder
against the offer'sorder criteria
andOffer.getTargetItemCriteria()
.- Specified by:
filterOffersByRequest
in interfaceOfferCandidateService<P extends Offer>
- Parameters:
offerSet
- filtered offer set that can apply to the order for the context.order
- the order with which to evaluate request criteria against- Returns:
-
checkOfferActiveAndTimeCriteria
-
filterOffersByTotalUses
public Stream<P> filterOffersByTotalUses(@NonNull @NonNull Stream<P> offerSet, @NonNull @NonNull EnhancedOrder order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:OfferCandidateService
Filter the provided offer set based on thetotal uses
of the offer as well asuser uses
, while also factoring inOffer.getMaxUsesPerUserFrequency()
.- Specified by:
filterOffersByTotalUses
in interfaceOfferCandidateService<P extends Offer>
- Parameters:
offerSet
- filtered offer set that can apply to the order.order
- context information around the ordercontextInfo
- context information around sandbox and multitenant state
-
filterOffersByUserTarget
-
filterOffersByOrderCurrency
Filters out anyOffers
whoseOffer.getCurrency()
doesn't match theEnhancedOrder.getCurrency()
, if specified.- Parameters:
offerSet
- the set of offers to filterorder
- theEnhancedOrder
to check the currency against- Returns:
- a filtered stream of offers where the specified currency is null or matches
EnhancedOrder.getCurrency()
- See Also:
-
checkOfferUsability
protected Stream<P> checkOfferUsability(Stream<P> offers, EnhancedOrder order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
isCanUseOfferCodes
-
buildOfferUsablilityCodeResponses
protected void buildOfferUsablilityCodeResponses(EnhancedOrder order, List<P> offerList, OffersAndOfferCodesUsabilityInfo usabilityInfo) -
gatherOfferAndOfferCodeUsabilityInfo
protected OffersAndOfferCodesUsabilityInfo gatherOfferAndOfferCodeUsabilityInfo(EnhancedOrder order, List<P> offerList, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
filterOffersByItemQualifiers
public <T extends BaseCandidateOffer> List<T> filterOffersByItemQualifiers(@NonNull @NonNull List<T> candidateOffers, @NonNull @NonNull EnhancedOrder order) Description copied from interface:OfferCandidateService
Filter the provided offer set based on if the items of the provided order match as qualifiers. For each of theOffer.getItemQualifierCriteria()
, a quantity of at leastItemCriteriaRule.getNumberOfMatchesRequired()
items must match againstItemCriteriaRule.getRule()
. In addition, the summed price of these items must be at leastOffer.getMinTotalOfQualifierPrices()
.- Specified by:
filterOffersByItemQualifiers
in interfaceOfferCandidateService<P extends Offer>
- Parameters:
candidateOffers
- filtered offer set that can apply to the order.order
- the order with which to evaluate items against- Returns:
- the filtered offer set that can apply to the order.
-
populateOrRemoveOffersByFulfillmentGroupQualifiers
public List<CandidateFulfillmentGroupOffer> populateOrRemoveOffersByFulfillmentGroupQualifiers(@NonNull @NonNull List<CandidateFulfillmentGroupOffer> candidateOfferSet, @NonNull @NonNull EnhancedOrder order) Description copied from interface:OfferCandidateService
Filter the provided offer set based on if the items of the provided order match as qualifiers. For each of theOffer.getItemQualifierCriteria()
, a quantity of at leastItemCriteriaRule.getNumberOfMatchesRequired()
items must match againstItemCriteriaRule.getRule()
. In addition, the summed price of these items must be at leastOffer.getMinTotalOfQualifierPrices()
.- Specified by:
populateOrRemoveOffersByFulfillmentGroupQualifiers
in interfaceOfferCandidateService<P extends Offer>
- Parameters:
candidateOfferSet
- filtered offer set that can apply to the order.order
- the order with which to evaluate items against- Returns:
- the filtered offer set that can apply to the order.
-
canUseOrderLineItemsAsQualifiers
-
addQualifiersToMap
protected void addQualifiersToMap(BaseCandidateOffer candidateOffer, Map<ItemCriteriaRule, Collection<EnhancedLineItem>> itemCriteriaMap) -
evaluateFulfillmentItemCriteriaAgainstFulfillmentGroups
protected boolean evaluateFulfillmentItemCriteriaAgainstFulfillmentGroups(EnhancedOrder order, CandidateFulfillmentGroupOffer candidateOffer) -
isAnyMatchFoundInAnyFulfillmentGroup
protected boolean isAnyMatchFoundInAnyFulfillmentGroup(EnhancedOrder order, CandidateFulfillmentGroupOffer candidateOffer, Offer offer) -
isAnyMatchFoundAcrossAllItems
protected boolean isAnyMatchFoundAcrossAllItems(@NonNull @NonNull EnhancedOrder order, @NonNull @NonNull CandidateFulfillmentGroupOffer candidateOffer, @NonNull @NonNull Offer offer) -
getItemCriteriaCollectionMap
protected Map<ItemCriteriaRule,Collection<EnhancedFulfillmentLineItem>> getItemCriteriaCollectionMap(@NonNull @NonNull ItemCriteria itemQualifierCriteria, @NonNull @NonNull EnhancedFulfillmentGroup fulfillmentGroup) -
addNewCandidateFG
protected void addNewCandidateFG(CandidateFulfillmentGroupOffer candidateOffer, EnhancedFulfillmentGroup fulfillmentGroup) -
addNewCandidateFG
protected void addNewCandidateFG(CandidateFulfillmentGroupOffer candidateOffer, EnhancedFulfillmentGroup fulfillmentGroup, @Nullable Map<ItemCriteriaRule, Collection<EnhancedFulfillmentLineItem>> itemCriteriaMap) -
evaluateOrderForMatchingItems
protected Set<EnhancedLineItem> evaluateOrderForMatchingItems(@NonNull @NonNull List<EnhancedOrderLineItem> orderLineItems, @NonNull @NonNull ItemCriteriaRule itemCriteriaRule, boolean allowMatchesOnNonDiscountableItems) Evaluates theItemCriteriaRule
against theOrder's line items
to determine if the order matches.- Parameters:
orderLineItems
- Line item to evaluate theitemCriteriaRule
againstitemCriteriaRule
- Rule to evaluateallowMatchesOnNonDiscountableItems
- Whether or not matches will be allowed for non-discountable items. For target rule evaluation, we expect this value to be false. For qualifier rule evaluation, we expect this value to be true.- Returns:
- The
order line items
that matched the criteria or empty if none.
-
matchIsAllowedForItem
protected boolean matchIsAllowedForItem(@NonNull @NonNull EnhancedLineItem orderItem, boolean allowMatchesOnNonDiscountableItems) Determine whether or not a match is allowed for the line item.By default, free gift items are not allowed to match the criteria. Additionally, items that are not free gifts and not discountable are only allowed to match the criteria if allowMatchesOnNonDiscountableItems is true. This allows us to block the matching of offer target criteria against items that are not eligible to receive a discount. For offer qualifying criteria, it doesn't matter whether or not the item is discountable. Therefore, we'd expect allowMatchesOnNonDiscountableItems to be true when evaluating qualifier rules.
- Parameters:
orderItem
- The item who's being evaluated as a match to the promotion's criteriaallowMatchesOnNonDiscountableItems
- Whether or not matches will be allowed for non-discountable items. For target rule evaluation, we expect this value to be false. For qualifier rule evaluation, we expect this value to be true.- Returns:
- Whether or not the criteria should be evaluated against the item
-
isFreeGiftItem
Determines if the givenEnhancedLineItem
is a free gift item.- Parameters:
orderItem
- theEnhancedLineItem
to check against- Returns:
- true if the given
EnhancedLineItem
is a free gift item, otherwise false
-
populateOrRemoveOffersByItemTargets
public List<CandidateItemOffer> populateOrRemoveOffersByItemTargets(@NonNull @NonNull List<CandidateItemOffer> candidateOfferSet, @NonNull @NonNull EnhancedOrder order) Description copied from interface:OfferCandidateService
Filter the provided offer set based on if the items of the provided order match as targets. For each of theOffer.getTargetItemCriteria()
, a quantity of at leastItemCriteriaRule.getNumberOfMatchesRequired()
items must match againstItemCriteriaRule.getRule()
. In addition, the summed price of these items must be at leastOffer.getMinTotalOfTargetPrices()
.- Specified by:
populateOrRemoveOffersByItemTargets
in interfaceOfferCandidateService<P extends Offer>
- Parameters:
candidateOfferSet
- filtered offer set that can apply to the order.order
- the order with which to evaluate items against- Returns:
- the filtered offer set that can apply to the order.
-
updateReasonResponsesForTargetNotMet
protected void updateReasonResponsesForTargetNotMet(@NotNull @NotNull EnhancedOrder order, Offer offer) -
evaluateSubscriptionDiscountAgainstItems
protected boolean evaluateSubscriptionDiscountAgainstItems(@NonNull @NonNull Offer offer, @NonNull @NonNull Map<ItemCriteriaRule, Collection<EnhancedLineItem>> itemCriteriaMap) -
isMinSubtotalMet
protected boolean isMinSubtotalMet(javax.money.MonetaryAmount minSubtotalRequired, Set<? extends EnhancedLineItem> itemsToSum) -
evaluateOfferItemCriteriaAgainstOrder
protected boolean evaluateOfferItemCriteriaAgainstOrder(@NonNull @NonNull EnhancedOrder order, @NonNull @NonNull BaseCandidateOffer offer, @NonNull @NonNull Map<ItemCriteriaRule, Collection<EnhancedLineItem>> itemCriteriaMap, String connectiveOperator, boolean allowMatchesOnNonDiscountableItems) Evaluates theItemCriteriaRules
from an order or order item targeting offer against theOrder
to determine whether the offer is applicable.- Parameters:
order
- Order to evaluate the rules againstoffer
- Offer the Offer being evaluateditemCriteriaMap
- Map containing the rules as keys to be populated with the matching line items as valuesconnectiveOperator
- How the rules should be connected logically. This is usually "and" or "or" and determines whether all must match or just any. SeeItemCriteria.getConnectiveOperator()
.allowMatchesOnNonDiscountableItems
- Whether or not matches will be allowed for non-discountable items. For target rule evaluation, we expect this value to be false. For qualifier rule evaluation, we expect this value to be true.Non-discountable includes dependent items when the offer does not allow discounting dependents:
Discount.isApplicableToDependentItems()
.- Returns:
- Whether enough of the offer's criteria were satisfied by the
order
.
-
shouldIncludeItem
@Deprecated(forRemoval=true) protected boolean shouldIncludeItem(EnhancedOrderLineItem item, EnhancedOrder order, BaseCandidateOffer offer) Deprecated, for removal: This API element is subject to removal in a future version. -
shouldIncludeItem
protected boolean shouldIncludeItem(EnhancedOrderLineItem item, EnhancedOrder order, BaseCandidateOffer offer, boolean allowMatchesOnNonDiscountableItems) Whether the givenEnhancedOrderLineItem
should be considered when evaluating anItemCriteriaRule
.- Parameters:
item
- The item to determine whether to include for evaluation.order
- The parent orderoffer
- The parent of theItemCriteriaRule
that will be evaluated.allowMatchesOnNonDiscountableItems
- Whether matches will be allowed for non-discountable items. For target rule evaluation, we expect this value to be false. For qualifier rule evaluation, we expect this value to be true.Non-discountable includes dependent items when the offer does not allow discounting dependents:
Discount.isApplicableToDependentItems()
.- Returns:
- Whether the given
EnhancedOrderLineItem
should be considered when evaluating anItemCriteriaRule
.
-
shouldIncludeOnSaleItem
protected boolean shouldIncludeOnSaleItem(EnhancedOrderLineItem item, BaseCandidateOffer candidateOffer) -
calculateStandardPriceSavings
protected javax.money.MonetaryAmount calculateStandardPriceSavings(@NonNull EnhancedOrderLineItem item, CandidateItemOffer itemOffer) -
populateOrRemoveByFulfillmentGroupTargets
public List<CandidateFulfillmentGroupOffer> populateOrRemoveByFulfillmentGroupTargets(@NonNull @NonNull List<CandidateFulfillmentGroupOffer> candidateOfferList, EnhancedOrder order) Description copied from interface:OfferCandidateService
Filter the provided offer set based on if the provided fulfillment groups of the order match as shipping targets. Thefulfillment group's
details are evaluated against theoffer's fulfillment group criteria
.- Specified by:
populateOrRemoveByFulfillmentGroupTargets
in interfaceOfferCandidateService<P extends Offer>
- Parameters:
candidateOfferList
- filtered offer set that can apply to the order.order
- the order with which to evaluate items against- Returns:
- the filtered offer set that can apply to the order.
-
populateOrRemoveOffersByFulfillmentItemQualifiers
public List<CandidateItemOffer> populateOrRemoveOffersByFulfillmentItemQualifiers(@NonNull @NonNull @NonNull List<CandidateItemOffer> candidateOfferSet, @NonNull @NonNull @NonNull EnhancedOrder order) Description copied from interface:OfferCandidateService
Filter the provided offer set based on if the fulfillment items of the provided order match as qualifiers. For each of theOffer.getItemQualifierCriteria()
, a quantity of at leastItemCriteriaRule.getNumberOfMatchesRequired()
items must match againstItemCriteriaRule.getRule()
. In addition, the summed price of these items must be at leastOffer.getMinTotalOfQualifierPrices()
.- Specified by:
populateOrRemoveOffersByFulfillmentItemQualifiers
in interfaceOfferCandidateService<P extends Offer>
- Parameters:
candidateOfferSet
- filtered offer set that can apply to the order.order
- the order with which to evaluate items against- Returns:
- the filtered offer set that can apply to the order.
-
populateOrRemoveOffersByFulfillmentItemTargets
public List<CandidateItemOffer> populateOrRemoveOffersByFulfillmentItemTargets(@NonNull @NonNull List<CandidateItemOffer> candidateOfferSet, @NonNull @NonNull EnhancedOrder order) Description copied from interface:OfferCandidateService
Filter the provided offer set based on if the provided fulfillment items of the order match as shipping targets. At least oneEnhancedFulfillmentLineItem
must match the offer'sItemCriteriaRule.getRule()
with the total quantity matchingItemCriteriaRule.getNumberOfMatchesRequired()
.- Specified by:
populateOrRemoveOffersByFulfillmentItemTargets
in interfaceOfferCandidateService<P extends Offer>
- Parameters:
candidateOfferSet
- filtered offer set that can apply to the order.order
- the order with which to evaluate items against- Returns:
- the filtered offer set that can apply to the order.
-
evaluateAgainstRule
protected final boolean evaluateAgainstRule(@Nullable String rule, @NonNull @NonNull Serializable rootObject) Runs therule
against the suppliedrootObject
via theRuleEvaluationService
.- Parameters:
rule
- Rule to evaluaterootObject
- Object against which to evaluaterule
- Returns:
- Whether the
rootObject
satisfied therule
-
evaluateFulfillmentItemCriteriaAgainstOrder
protected boolean evaluateFulfillmentItemCriteriaAgainstOrder(@NonNull @NonNull EnhancedOrder order, @NonNull @NonNull Map<ItemCriteriaRule, Collection<EnhancedFulfillmentLineItem>> itemCriteriaMap, String connectiveOperator) -
evaluateOrderForMatchingFulfillmentItems
protected Set<EnhancedFulfillmentLineItem> evaluateOrderForMatchingFulfillmentItems(EnhancedOrder order, ItemCriteriaRule itemCriteria) -
getFulfillmentItemMatchResults
protected org.apache.commons.lang3.tuple.Pair<Set<EnhancedFulfillmentLineItem>,Integer> getFulfillmentItemMatchResults(String itemCriteriaRule, EnhancedFulfillmentGroup fulfillmentGroup) -
getBundleItemQuantity
-
evaluateGroupForMatchingFulfillmentItems
protected Set<EnhancedFulfillmentLineItem> evaluateGroupForMatchingFulfillmentItems(EnhancedFulfillmentGroup fulfillmentGroup, ItemCriteriaRule itemCriteria) -
isAnyMatchCriteria
Checks whether the operator matchesDefaultConnectiveOperatorType.OR
, meaning that only 1 of theItemCriteria's rules
need be matched.- Parameters:
connectiveOperator
- AItemCriteria.getConnectiveOperator()
from an offer whose criteria is to be evaluated- Returns:
- whether the operator matches
DefaultConnectiveOperatorType.OR
, meaning that only 1 of theItemCriteria's rules
need be matched.
-
getOfferAndOfferCodeUsabilityService
-
setOfferAndOfferCodeUsabilityService
@Autowired public void setOfferAndOfferCodeUsabilityService(OfferAndOfferCodeUsabilityService offerAndOfferCodeUsabilityService) -
getOfferCodeService
-
setOfferCodeService
-
getMessageSource
protected org.springframework.context.MessageSource getMessageSource() -
setMessageSource
@Autowired public void setMessageSource(org.springframework.context.MessageSource messageSource)
-
shouldIncludeItem(EnhancedOrderLineItem, EnhancedOrder, BaseCandidateOffer, boolean)
.