Class ExternalOfferProvider
java.lang.Object
com.broadleafcommerce.orderoperation.service.provider.external.AbstractExternalProvider
com.broadleafcommerce.orderoperation.service.provider.external.ExternalOfferProvider
- All Implemented Interfaces:
OfferProvider
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classprotected static final class -
Field Summary
FieldsFields inherited from class com.broadleafcommerce.orderoperation.service.provider.external.AbstractExternalProvider
ENTITY_NOT_FOUND, RSQL_FILTER_PARAM -
Constructor Summary
ConstructorsConstructorDescriptionExternalOfferProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalOfferProperties properties, UserTargetGenerationService userTargetGenerationService) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.broadleafcommerce.promotion.offer.client.web.context.OrderDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto>>buildOrderDto(com.broadleafcommerce.order.client.domain.Order order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected com.broadleafcommerce.promotion.offer.client.web.context.CustomerContextCreate aCustomerContextand add customer and customer segments.generateCodesForVouchers(VoucherCodeGenerationRequest voucherCodeGenerationRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) GeneratesOfferCodesfor voucher offers based on the givenVoucherCodeGenerationRequest.protected ObjectgetProductType(com.broadleafcommerce.order.client.domain.OrderItem orderItem) protected ExternalOfferPropertiesprotected Stringprotected Optional<javax.money.MonetaryAmount>getStandardPrice(com.broadleafcommerce.order.client.domain.OrderItem orderItem) protected UserTargetGenerationServiceprotected voidhandleWebClientResponseException(com.broadleafcommerce.order.client.domain.Order order, com.broadleafcommerce.promotion.offer.client.web.context.OfferAndOfferCodeUsageValidationResult result, Exception exception) Logs and set theOfferAndOfferCodeUsageValidationResult.getValidationFailureMessages()for all the voucher offers.protected voidhandleWebClientResponseException(com.broadleafcommerce.order.client.domain.Order order, com.broadleafcommerce.promotion.offer.client.web.context.OfferAndOfferCodeUsageValidationResult result, org.springframework.web.reactive.function.client.WebClientResponseException exception) Deprecated, for removal: This API element is subject to removal in a future version.since 1.8.1, in favor ofhandleWebClientResponseException(Order, OfferAndOfferCodeUsageValidationResult, Exception)protected booleanhasSalePrice(com.broadleafcommerce.order.client.domain.OrderItem orderItem) protected booleanhasStandardPrice(com.broadleafcommerce.order.client.domain.OrderItem orderItem) protected com.broadleafcommerce.promotion.offer.client.web.context.CodespopulateCodes(com.broadleafcommerce.order.client.domain.Order order) protected voidpopulateDependentLineItemDto(List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItems, com.broadleafcommerce.order.client.domain.OrderItem orderItem) protected com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDtopopulateLineItemDto(com.broadleafcommerce.order.client.domain.OrderItem orderItem) Returns a populatedOrderLineItemDtofrom givenOrderItem.protected List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto>populateLineItems(com.broadleafcommerce.order.client.domain.Order order) protected com.broadleafcommerce.promotion.offer.client.web.context.info.VoucherpopulateVoucherDto(com.broadleafcommerce.order.common.domain.Voucher voucher) Returns a populatedVoucherfrom givenVoucher.protected List<com.broadleafcommerce.promotion.offer.client.web.context.info.Voucher>populateVouchers(com.broadleafcommerce.order.client.domain.Order order) com.broadleafcommerce.promotion.offer.client.web.context.OfferAndOfferCodeUsageValidationResultvalidateVoucherOfferUsages(com.broadleafcommerce.order.client.domain.Order order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates existing vouchers stored inOrder.getVouchers()to ensure that they are still valid and applicable to the givenOrder.Methods inherited from class com.broadleafcommerce.orderoperation.service.provider.external.AbstractExternalProvider
buildNotFoundException, executeRequest, getHeaders, getObjectMapper, getTypeFactory, getWebClient, isEntityNotFound, pageableToParams
-
Field Details
-
OFFER_CLIENT_ID
Deprecated.- See Also:
-
-
Constructor Details
-
ExternalOfferProvider
public ExternalOfferProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalOfferProperties properties, UserTargetGenerationService userTargetGenerationService)
-
-
Method Details
-
validateVoucherOfferUsages
public com.broadleafcommerce.promotion.offer.client.web.context.OfferAndOfferCodeUsageValidationResult validateVoucherOfferUsages(com.broadleafcommerce.order.client.domain.Order order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:OfferProviderValidates existing vouchers stored inOrder.getVouchers()to ensure that they are still valid and applicable to the givenOrder.- Specified by:
validateVoucherOfferUsagesin interfaceOfferProvider- Parameters:
order- theOrdercontaining theVouchersto validate againstcontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- an
OfferAndOfferCodeUsageValidationResultcontaining details about any invalidOffersand failure messages
-
generateCodesForVouchers
public CodeGenerationResult generateCodesForVouchers(VoucherCodeGenerationRequest voucherCodeGenerationRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:OfferProviderGeneratesOfferCodesfor voucher offers based on the givenVoucherCodeGenerationRequest.This method will generate and return the
OfferCodesin the same request, therefore it's meant for small batch of code generation only.- Specified by:
generateCodesForVouchersin interfaceOfferProvider- Parameters:
voucherCodeGenerationRequest- theVoucherCodeGenerationRequestto generate the voucherOfferCodeswithcontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- the
CodeGenerationResultcontaining the generated voucherOfferCodesbased on the givenVoucherCodeGenerationRequest
-
handleWebClientResponseException
protected void handleWebClientResponseException(com.broadleafcommerce.order.client.domain.Order order, com.broadleafcommerce.promotion.offer.client.web.context.OfferAndOfferCodeUsageValidationResult result, Exception exception) Logs and set theOfferAndOfferCodeUsageValidationResult.getValidationFailureMessages()for all the voucher offers.- Parameters:
order- theOrdercontaining all the voucher offersresult- theOfferAndOfferCodeUsageValidationResultexception- theExceptionto log
-
handleWebClientResponseException
@Deprecated(since="1.8.1", forRemoval=true) protected void handleWebClientResponseException(com.broadleafcommerce.order.client.domain.Order order, com.broadleafcommerce.promotion.offer.client.web.context.OfferAndOfferCodeUsageValidationResult result, org.springframework.web.reactive.function.client.WebClientResponseException exception) Deprecated, for removal: This API element is subject to removal in a future version.since 1.8.1, in favor ofhandleWebClientResponseException(Order, OfferAndOfferCodeUsageValidationResult, Exception)Logs and set theOfferAndOfferCodeUsageValidationResult.getValidationFailureMessages()for all the voucher offers.- Parameters:
order- theOrdercontaining all the voucher offersresult- theOfferAndOfferCodeUsageValidationResultexception- theWebClientResponseExceptionto log
-
createCustomerContext
protected com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext createCustomerContext()Create aCustomerContextand add customer and customer segments. Uses the current authentication token to determine principal and details.- Returns:
- The created
CustomerContext
-
buildOrderDto
protected com.broadleafcommerce.promotion.offer.client.web.context.OrderDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto>> buildOrderDto(com.broadleafcommerce.order.client.domain.Order order, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
populateVouchers
protected List<com.broadleafcommerce.promotion.offer.client.web.context.info.Voucher> populateVouchers(com.broadleafcommerce.order.client.domain.Order order) -
populateLineItems
protected List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> populateLineItems(com.broadleafcommerce.order.client.domain.Order order) -
populateCodes
protected com.broadleafcommerce.promotion.offer.client.web.context.Codes populateCodes(com.broadleafcommerce.order.client.domain.Order order) -
getProductType
@Nullable protected Object getProductType(com.broadleafcommerce.order.client.domain.OrderItem orderItem) -
populateDependentLineItemDto
protected void populateDependentLineItemDto(List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItems, com.broadleafcommerce.order.client.domain.OrderItem orderItem) -
populateVoucherDto
protected com.broadleafcommerce.promotion.offer.client.web.context.info.Voucher populateVoucherDto(com.broadleafcommerce.order.common.domain.Voucher voucher) Returns a populatedVoucherfrom givenVoucher.- Parameters:
voucher- theVoucherto populate anVoucherfrom- Returns:
- populated
Voucherfrom givenVoucher
-
populateLineItemDto
protected com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto populateLineItemDto(com.broadleafcommerce.order.client.domain.OrderItem orderItem) Returns a populatedOrderLineItemDtofrom givenOrderItem.- Parameters:
orderItem- theOrderItemto populate anOrderLineItemDtofrom- Returns:
- populated
OrderLineItemDtofrom givenOrderItem
-
hasStandardPrice
protected boolean hasStandardPrice(com.broadleafcommerce.order.client.domain.OrderItem orderItem) -
hasSalePrice
protected boolean hasSalePrice(com.broadleafcommerce.order.client.domain.OrderItem orderItem) -
getStandardPrice
protected Optional<javax.money.MonetaryAmount> getStandardPrice(com.broadleafcommerce.order.client.domain.OrderItem orderItem) -
getServiceClient
-
getProperties
-
getUserTargetGenerationService
-
getServiceClient()