Class DefaultOfferAndOfferCodeUsabilityService

java.lang.Object
com.broadleafcommerce.promotion.offer.service.DefaultOfferAndOfferCodeUsabilityService
All Implemented Interfaces:
OfferAndOfferCodeUsabilityService

public class DefaultOfferAndOfferCodeUsabilityService extends Object implements OfferAndOfferCodeUsabilityService
Author:
Chad Harchar (charchar)
  • Field Details

  • Constructor Details

  • Method Details

    • init

      @PostConstruct public void init()
    • getOfferAndOfferCodeUsabilityInfo

      @NonNull public OffersAndOfferCodesUsabilityInfo getOfferAndOfferCodeUsabilityInfo(@NonNull List<String> codes, @Nullable com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: OfferAndOfferCodeUsabilityService
      Checks the provided codes against the offer codes and offers to determine whether the code is usable.
      Specified by:
      getOfferAndOfferCodeUsabilityInfo in interface OfferAndOfferCodeUsabilityService
      Parameters:
      codes - the codes for which to check usability
      customerContext - context information for the customer
      context - context information around sandbox and multitenant state
      Returns:
      a OffersAndOfferCodesUsabilityInfo which contains information to determine whether or not the codes can be used
    • getOfferAndOfferCodeUsabilityInfo

      @NonNull public OffersAndOfferCodesUsabilityInfo getOfferAndOfferCodeUsabilityInfo(@NonNull List<String> codes, @NonNull List<? extends Offer> offers, @Nullable com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: OfferAndOfferCodeUsabilityService
      Checks the provided codes against the offer codes and provided offers to determine whether the code is usable.
      Specified by:
      getOfferAndOfferCodeUsabilityInfo in interface OfferAndOfferCodeUsabilityService
      Parameters:
      codes - the code for which to check usability
      offers - the list of offers to check usability
      customerContext - context information for the customer
      context - context information around sandbox and multitenant state
      Returns:
      a OffersAndOfferCodesUsabilityInfo which contains information to determine whether or not the offers and codes can be used
    • getOfferAndOfferCodeUsabilityInfo

      @NonNull protected OffersAndOfferCodesUsabilityInfo getOfferAndOfferCodeUsabilityInfo(@NonNull List<String> codes, @NonNull List<? extends Offer> offers, @NonNull List<? extends OfferCode> offerCodesForCode, @Nullable com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    • verifyUsabilityForOfferCodesHook

      protected void verifyUsabilityForOfferCodesHook(OffersAndOfferCodesUsabilityInfo usabilityInfo, List<Offer> offers, List<? extends OfferCode> offerCodes, @Nullable com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Hookpoint to use to add additional, custom verification logic for offer code usability besides what is provided out of box. This is run before determineCodeUsability(com.broadleafcommerce.promotion.offer.domain.OffersAndOfferCodesUsabilityInfo) but after default verification methods.
      Parameters:
      usabilityInfo - Usability info compiled to this point.
      offers - Offers pre-filtered by max uses.
      offerCodes - Offer Codes pre-filtered by max uses.
      customerContext - The customer context including username.
      contextInfo - Additional multitenant and sandbox info.
    • verifyUsabilityForOffersHook

      protected void verifyUsabilityForOffersHook(OffersAndOfferCodesUsabilityInfo usabilityInfo, List<Offer> offers, List<? extends OfferCode> offerCodes, @Nullable com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Hookpoint to use to add additional, custom verification logic for offer usability besides what is provided out of box. This is run before determineCodeUsability(com.broadleafcommerce.promotion.offer.domain.OffersAndOfferCodesUsabilityInfo) but after default verification methods.
      Parameters:
      usabilityInfo - Usability info compiled to this point.
      offers - Offers pre-filtered by max uses.
      offerCodes - Offer Codes pre-filtered by max uses.
      customerContext - The customer context including username.
      contextInfo - Additional multitenant and sandbox info.
    • resolveAuditVerificationFlags

      protected AuditVerificationFlags resolveAuditVerificationFlags(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo ctx)
    • initilizeOfferAndOfferCodeUsabilityInfos

      protected OffersAndOfferCodesUsabilityInfo initilizeOfferAndOfferCodeUsabilityInfos(List<String> codes, List<? extends Offer> offers, List<? extends OfferCode> offerCodesForCode, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • buildCodeUsabilityInfo

      protected com.broadleafcommerce.promotion.offer.client.web.context.CodeUsabilityInfo buildCodeUsabilityInfo(List<? extends Offer> offers, List<? extends OfferCode> offerCodesForCode, String code)
    • prioritizeCodeUsabilityType

      protected String prioritizeCodeUsabilityType(String result, String codeUsabilityType)
      If any OfferCode is usable for the provided code string, prioritize the "USABLE" type.

      By default, the other CodeUsabilityTypes are not prioritized against each other.

      Parameters:
      result - the CodeUsabilityType returned up to this point
      codeUsabilityType - the current CodeUsabilityType to check against
      Returns:
      the CodeUsabilityType for the string code
    • buildOfferUsabilityInfo

      protected com.broadleafcommerce.promotion.offer.client.web.context.OfferUsabilityInfo buildOfferUsabilityInfo(Offer offer)
    • determineCodeUsabilityType

      protected String determineCodeUsabilityType(List<? extends Offer> offers, OfferCode offerCode)
    • verifyUsabilityForMaxUseOffers

      protected void verifyUsabilityForMaxUseOffers(OffersAndOfferCodesUsabilityInfo usabilityInfo, List<? extends Offer> offers, List<? extends OfferCode> offerCodesForCode, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • checkOfferMaxUsageUsability

      protected void checkOfferMaxUsageUsability(OffersAndOfferCodesUsabilityInfo usabilityInfo, List<? extends OfferCode> offerCodesForCode, List<OfferAuditSummary> offerAuditSummaries, Offer offer)
    • checkTotalDiscountedBalance

      protected boolean checkTotalDiscountedBalance(Offer offer, javax.money.MonetaryAmount totalAlreadyDiscounted)
    • verifyUsabilityForSingleUseOfferCodes

      protected void verifyUsabilityForSingleUseOfferCodes(OffersAndOfferCodesUsabilityInfo usabilityInfo, List<? extends Offer> offers, List<? extends OfferCode> offerCodesForCode, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • verifyUsabilityForMultiUseOfferCodes

      protected void verifyUsabilityForMultiUseOfferCodes(OffersAndOfferCodesUsabilityInfo usabilityInfo, List<? extends Offer> offers, List<? extends OfferCode> offerCodesForCode, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • verifyUsabilityForCustomerUseOfferCodes

      protected void verifyUsabilityForCustomerUseOfferCodes(OffersAndOfferCodesUsabilityInfo usabilityInfo, List<? extends Offer> offers, List<? extends OfferCode> offerCodesForCode, @Nullable com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • markCodesUnavailableToUser

      protected void markCodesUnavailableToUser(@NonNull @NonNull OffersAndOfferCodesUsabilityInfo usabilityInfo, List<? extends OfferCode> codesWithMaxUsagesPerUser)
    • hasAnyUsagesAvailableForUser

      protected boolean hasAnyUsagesAvailableForUser(com.broadleafcommerce.promotion.offer.client.web.context.CodeUsabilityInfo codeUsabilityInfo)
    • verifyUsabilityForCustomerUseOffers

      protected void verifyUsabilityForCustomerUseOffers(OffersAndOfferCodesUsabilityInfo usabilityInfo, List<? extends Offer> offers, List<? extends OfferCode> offerCodesForCode, @Nullable com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • isAnonymousUser

      protected boolean isAnonymousUser(@Nullable com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext)
    • getCustomerTargetValue

      protected String getCustomerTargetValue(com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext)
      Retrieves the value to set for the UserTarget.getTargetValue() on the audit detail(s). This defaults to the user's email.
      Parameters:
      customerContext - The CustomerContext associated with the API request.
      Returns:
      the value to set for the UserTarget.getTargetValue() on the audit detail(s).
    • markOfferUnavailableToUser

      protected void markOfferUnavailableToUser(@NonNull @NonNull OffersAndOfferCodesUsabilityInfo usabilityInfo, @NonNull @NonNull List<? extends Offer> maxUsagesPerUserOffers, List<? extends OfferCode> offerCodesForCode)
    • checkOfferCustomerUsageUsability

      protected void checkOfferCustomerUsageUsability(OffersAndOfferCodesUsabilityInfo usabilityInfo, List<? extends OfferCode> offerCodesForCode, List<OfferAuditDetail> offerAuditDetails, Instant endDate, Offer offer)
    • determineMaxUsesPerCustomer

      protected int determineMaxUsesPerCustomer(List<OfferAuditDetail> offerAuditDetails, Instant endDate, Offer offer)
    • updateOfferCodeUsage

      protected void updateOfferCodeUsage(com.broadleafcommerce.promotion.offer.client.web.context.CodeUsabilityInfo codeUsabilityInfo, OfferCode offerCode, int usagesRemaining, boolean usable)
    • updateOfferCodeUsagePerUser

      protected void updateOfferCodeUsagePerUser(com.broadleafcommerce.promotion.offer.client.web.context.CodeUsabilityInfo codeUsabilityInfo, OfferCode offerCode, int usesRemainingPerUser, boolean usable)
    • buildOfferCodeUsage

      protected void buildOfferCodeUsage(com.broadleafcommerce.promotion.offer.client.web.context.CodeUsabilityInfo info, OfferCode offerCode, int usagesRemaining, int usagesRemainingPerUser, boolean usable)
    • determineCodeUsability

      protected void determineCodeUsability(OffersAndOfferCodesUsabilityInfo usabilityInfos)
    • verifyUsabilityForCodesEmailRegex

      protected void verifyUsabilityForCodesEmailRegex(OffersAndOfferCodesUsabilityInfo usabilityInfo, List<Offer> offers, List<? extends OfferCode> offerCodes, @Nullable com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • buildUsabilityInfoForCode

      protected void buildUsabilityInfoForCode(OffersAndOfferCodesUsabilityInfo usabilityInfo, OfferCode code, boolean canUse)
    • getOfferCacheProperties

      @Nullable protected OfferCacheProperties getOfferCacheProperties()
    • setOfferCacheProperties

      @Autowired(required=false) public void setOfferCacheProperties(OfferCacheProperties offerCacheProperties)
    • getPatternCache

      protected Map<String,Pattern> getPatternCache()
    • getStatusManager

      protected OfferMaxUseStatusManager getStatusManager()
    • setStatusManager

      @Autowired public void setStatusManager(@Nullable OfferMaxUseStatusManager statusManager)
    • getOfferMessagingProperties

      protected OfferMessagingProperties getOfferMessagingProperties()
    • setOfferMessagingProperties

      @Autowired public void setOfferMessagingProperties(OfferMessagingProperties offerMessagingProperties)