Class DefaultOfferUserService
- java.lang.Object
-
- com.broadleafcommerce.promotion.offer.service.engine.candidate.DefaultOfferUserService
-
- All Implemented Interfaces:
OfferUserService
public class DefaultOfferUserService extends Object implements OfferUserService
- Author:
- Chad Harchar (charchar)
-
-
Field Summary
Fields Modifier and Type Field Description protected OfferAuditDetailService<? extends OfferAuditDetail>auditServiceprotected CustomerFieldscustomerFieldsprotected com.broadleafcommerce.common.extension.TypeFactoryofferFactory
-
Constructor Summary
Constructors Constructor Description DefaultOfferUserService(OfferAuditDetailService<? extends OfferAuditDetail> auditService, CustomerFields customerFields, com.broadleafcommerce.common.extension.TypeFactory offerFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected com.broadleafcommerce.promotion.offer.client.web.context.CodeUsabilityInfoaddCodeUsages(List<? extends Offer> offersForCode, com.broadleafcommerce.promotion.offer.client.web.context.CodeUsabilityInfo codeUsabilityInfo, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Set<UserTarget>buildUserTargetsForCustomerContext(com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext)Build and return a list ofUserTargetsbased on the information provided in theCustomerContext.booleancanUserUseOffer(Offer offer, com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)For the provided customer information, check if there are no more usages for the provided offer available.protected UserTargetcreateUserTarget(String targetValue, String targetType)protected UserTargetcreateUserTargetForOtherUserType(String userId, CustomerFields customerFields, String maxUsesPerUserStrategy)protected StringdetermineCodeUsability(String code, boolean canUse, boolean hasOffers)com.broadleafcommerce.promotion.offer.client.web.context.CodeUsabilityInfogetCodeUsabilityInfo(String code, List<? extends Offer> offersForCode, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Checks the providedSharedCode.getCode()SharedCode's code} against the providedOffers' SharedCodesto determine whether the code is usable.protected com.broadleafcommerce.promotion.offer.client.web.context.CodeUsagegetCodeUses(Offer offer, SharedCode sharedCode, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)protected LonggetCountMaxUserUses(Offer offer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, UserTarget userTarget)protected StringgetUserIdForOtherUserType(com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, String maxUsesPerUserStrategy)booleanisAnyCodeUsable(Set<String> codes, Offer offer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)For the provided codes, check if there is no more usage for the provided offer available.
-
-
-
Field Detail
-
auditService
protected final OfferAuditDetailService<? extends OfferAuditDetail> auditService
-
customerFields
protected final CustomerFields customerFields
-
offerFactory
protected final com.broadleafcommerce.common.extension.TypeFactory offerFactory
-
-
Constructor Detail
-
DefaultOfferUserService
public DefaultOfferUserService(OfferAuditDetailService<? extends OfferAuditDetail> auditService, CustomerFields customerFields, com.broadleafcommerce.common.extension.TypeFactory offerFactory)
-
-
Method Detail
-
buildUserTargetsForCustomerContext
@NonNull public Set<UserTarget> buildUserTargetsForCustomerContext(@Nullable com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext)
Description copied from interface:OfferUserServiceBuild and return a list ofUserTargetsbased on the information provided in theCustomerContext.- Specified by:
buildUserTargetsForCustomerContextin interfaceOfferUserService- Parameters:
customerContext- TheCustomerContextwith which to buildUserTargets- Returns:
- a set of
UserTargets
-
isAnyCodeUsable
public boolean isAnyCodeUsable(@Nullable Set<String> codes, @NonNull Offer offer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Description copied from interface:OfferUserServiceFor the provided codes, check if there is no more usage for the provided offer available.- Specified by:
isAnyCodeUsablein interfaceOfferUserService- Parameters:
codes- list of codes to check against the offeroffer- the offer that we are checking usage againstcontextInfo- context information around sandbox and multitenant state- Returns:
- whether this offer has met it's max code usage for the given order and context info
-
getCodeUsabilityInfo
@NonNull public com.broadleafcommerce.promotion.offer.client.web.context.CodeUsabilityInfo getCodeUsabilityInfo(@NonNull String code, @NonNull List<? extends Offer> offersForCode, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Description copied from interface:OfferUserServiceChecks the providedSharedCode.getCode()SharedCode's code} against the providedOffers' SharedCodesto determine whether the code is usable.- Specified by:
getCodeUsabilityInfoin interfaceOfferUserService- Parameters:
code- the code for which to check usabilityoffersForCode- the offers against which we are checking usabilitycontext- context information around sandbox and multitenant state- Returns:
- a
CodeUsabilityInfowhich contains a boolean to tell if the code can be used and a detailed structure informing on the code usage.
-
addCodeUsages
protected com.broadleafcommerce.promotion.offer.client.web.context.CodeUsabilityInfo addCodeUsages(List<? extends Offer> offersForCode, com.broadleafcommerce.promotion.offer.client.web.context.CodeUsabilityInfo codeUsabilityInfo, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
-
getCodeUses
protected com.broadleafcommerce.promotion.offer.client.web.context.CodeUsage getCodeUses(Offer offer, SharedCode sharedCode, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
-
determineCodeUsability
protected String determineCodeUsability(String code, boolean canUse, boolean hasOffers)
-
canUserUseOffer
public boolean canUserUseOffer(@NonNull Offer offer, @Nullable com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Description copied from interface:OfferUserServiceFor the provided customer information, check if there are no more usages for the provided offer available.- Specified by:
canUserUseOfferin interfaceOfferUserService- Parameters:
offer- the offer that we are checking usage againstcustomerContext- context information for the customercontextInfo- context information around sandbox and multitenant state- Returns:
- whether this offer has met it's max user usage for the given order and context info
-
createUserTargetForOtherUserType
protected UserTarget createUserTargetForOtherUserType(String userId, CustomerFields customerFields, String maxUsesPerUserStrategy)
-
getUserIdForOtherUserType
protected String getUserIdForOtherUserType(com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext customerContext, String maxUsesPerUserStrategy)
-
getCountMaxUserUses
protected Long getCountMaxUserUses(Offer offer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, UserTarget userTarget)
-
createUserTarget
protected UserTarget createUserTarget(String targetValue, String targetType)
-
-