Class OfferServiceImpl
- All Implemented Interfaces:
OfferService
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CustomerOfferDaoprotected org.broadleafcommerce.common.persistence.EntityDuplicatorprotected jakarta.persistence.EntityManagerprotected OfferServiceExtensionManagerprotected FulfillmentGroupOfferProcessorprotected ItemOfferProcessorprotected OfferAuditServiceprotected OfferCodeDaoprotected OfferDaoprotected org.broadleafcommerce.common.persistence.EntityDuplicateModifier<Offer>Deprecated.protected OrderOfferProcessorprotected OrderServiceprotected PromotableItemFactoryprotected org.broadleafcommerce.common.sandbox.SandBoxHelperprotected org.broadleafcommerce.common.util.StreamingTransactionCapableUtil -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyAndSaveFulfillmentGroupOffersToOrder(List<Offer> offers, Order order) applyAndSaveOffersToOrder(List<Offer> offers, Order order) Apply offers to order.voidapplyFulfillmentGroupOffersToOrder(List<Offer> offers, Order order) Deprecated.voidapplyOffersToOrder(List<Offer> offers, Order order) Deprecated.Attempts to resolve a list of offer codes associated explicitly with the customer.buildOfferCodeListForCustomer(org.broadleafcommerce.profile.core.domain.Customer customer) Deprecated.buildOfferListForOrder(Order order) Creates a list of offers that applies to this order.deleteOfferCode(OfferCode code) Make a production copy of an offer.Returns all offersfindOfferById(Long offerId) Lookup an OfferCode by its idgetOffersRetrievedFromCodes(List<OfferCode> codes, Set<Offer> appliedOffers) Given a list of offer codes and a set of offers, return a map of of offer codes that are keyed by the offer that was applied to the ordergetOffersRetrievedFromCodes(Order order) getUniqueOffersFromOrder(Order order) Returns a set of offers that have been used for this order by checking adjustments on the different levels like FulfillmentGroups and OrderItems.Lookup all OfferCodes by code.lookupAllOffersByCode(String code) Lookup all offers by code.Private method used to retrieve all offers with automaticallyAdded set to truelookupOfferByCode(String code) Creates a list of offers that applies to this order.lookupOfferCodeByCode(String code) Lookup OfferCode by code.protected List<CustomerOffer>lookupOfferCustomerByCustomer(org.broadleafcommerce.profile.core.domain.Customer customer) Private method used to retrieve all offers assigned to this customer.For enterprise installations, this will refresh any OfferCodes found to be out-of-date with current sandbox status.removeOutOfDateOfferCodes(List<OfferCode> offerCodes) Removes all out of date offerCodes based on the offerCode and its offer's start and end date.Save a new offer or updates an existing offersaveOfferCode(OfferCode offerCode) Saves a new Offer or updates an existing Offer that belongs to an OfferCode, then saves or updates the OfferCodevoidsetCustomerOfferDao(CustomerOfferDao customerOfferDao) voidsetFulfillmentGroupOfferProcessor(FulfillmentGroupOfferProcessor fulfillmentGroupOfferProcessor) voidsetItemOfferProcessor(ItemOfferProcessor itemOfferProcessor) voidsetOfferCodeDao(OfferCodeDao offerCodeDao) voidsetOfferDao(OfferDao offerDao) voidsetOrderOfferProcessor(OrderOfferProcessor orderOfferProcessor) voidsetOrderService(OrderService orderService) voidsetPromotableItemFactory(PromotableItemFactory promotableItemFactory) protected booleanverifyAdjustments(Order order, boolean beforeSave) booleanverifyMaxCustomerUsageThreshold(Order order, Offer offer) Validates that the Customer to whom an Order belongs has not exceeded the max uses for the passed in offer.booleanverifyMaxCustomerUsageThreshold(Order order, OfferCode code) Validates that the given OfferCode has not reached its maximum number of usages.booleanverifyMaxCustomerUsageThreshold(org.broadleafcommerce.profile.core.domain.Customer customer, Offer offer) Deprecated.booleanverifyMaxCustomerUsageThreshold(org.broadleafcommerce.profile.core.domain.Customer customer, OfferCode code) Deprecated.
-
Field Details
-
customerOfferDao
-
offerCodeDao
-
offerAuditService
-
offerDao
-
orderOfferProcessor
-
itemOfferProcessor
-
fulfillmentGroupOfferProcessor
-
promotableItemFactory
-
extensionManager
-
orderService
-
sandBoxHelper
protected org.broadleafcommerce.common.sandbox.SandBoxHelper sandBoxHelper -
em
protected jakarta.persistence.EntityManager em -
transUtil
protected org.broadleafcommerce.common.util.StreamingTransactionCapableUtil transUtil -
duplicator
protected org.broadleafcommerce.common.persistence.EntityDuplicator duplicator -
offerDuplicateModifier
@Deprecated protected org.broadleafcommerce.common.persistence.EntityDuplicateModifier<Offer> offerDuplicateModifierDeprecated.AddEntityDuplicateModifiers toblEntityDuplicationHelpers
-
-
Constructor Details
-
OfferServiceImpl
public OfferServiceImpl()
-
-
Method Details
-
findAllOffers
Description copied from interface:OfferServiceReturns all offers- Specified by:
findAllOffersin interfaceOfferService- Returns:
- all offers
-
save
Description copied from interface:OfferServiceSave a new offer or updates an existing offer- Specified by:
savein interfaceOfferService- Returns:
- the offer
-
saveOfferCode
Description copied from interface:OfferServiceSaves a new Offer or updates an existing Offer that belongs to an OfferCode, then saves or updates the OfferCode- Specified by:
saveOfferCodein interfaceOfferService- Returns:
- the offerCode
-
lookupOfferByCode
Creates a list of offers that applies to this order. All offers that are assigned to the customer, entered during checkout, or has a delivery type of automatic are added to the list. The same offer cannot appear more than once in the list.- Specified by:
lookupOfferByCodein interfaceOfferService- Parameters:
code-- Returns:
- a List of offers that may apply to this order
-
lookupOfferCodeByCode
Description copied from interface:OfferServiceLookup OfferCode by code.- Specified by:
lookupOfferCodeByCodein interfaceOfferService- Parameters:
code- the code- Returns:
- the offer
-
lookupAllOffersByCode
Description copied from interface:OfferServiceLookup all offers by code.- Specified by:
lookupAllOffersByCodein interfaceOfferService- Parameters:
code- the code- Returns:
- the list of offers
-
lookupAllOfferCodesByCode
Description copied from interface:OfferServiceLookup all OfferCodes by code.- Specified by:
lookupAllOfferCodesByCodein interfaceOfferService- Parameters:
code- the code- Returns:
- the list of offer codes
-
buildOfferListForOrder
Creates a list of offers that applies to this order. All offers that are assigned to the customer, entered during checkout, or has a delivery type of automatic are added to the list. The same offer cannot appear more than once in the list.- Specified by:
buildOfferListForOrderin interfaceOfferService- Parameters:
order-- Returns:
- a List of offers that may apply to this order
-
buildOfferCodeListForCustomer
Description copied from interface:OfferServiceAttempts to resolve a list of offer codes associated explicitly with the customer. For example, an implementation may choose to associate a specific offer code with a customer in a custom table or in customer attributes. This allows you to associate one or more offer codes with a customer without necessarily having them type it in (e.g. on a URL), or by allowing them to type it in, but before it has been actually applied to an order.- Specified by:
buildOfferCodeListForCustomerin interfaceOfferService- Returns:
- a list of offer codes associated explicitly with the customer
-
buildOfferCodeListForCustomer
@Deprecated public List<OfferCode> buildOfferCodeListForCustomer(org.broadleafcommerce.profile.core.domain.Customer customer) Deprecated.Description copied from interface:OfferServiceAttempts to resolve a list of offer codes associated explicitly with the customer. For example, an implementation may choose to associate a specific offer code with a customer in a custom table or in customer attributes. This allows you to associate one or more offer codes with a customer without necessarily having them type it in (e.g. on a URL), or by allowing them to type it in, but before it has been actually applied to an order.- Specified by:
buildOfferCodeListForCustomerin interfaceOfferService- Returns:
- a list of offer codes associated explicitly with the customer
-
lookupOfferCustomerByCustomer
protected List<CustomerOffer> lookupOfferCustomerByCustomer(org.broadleafcommerce.profile.core.domain.Customer customer) Private method used to retrieve all offers assigned to this customer. These offers are programmatically assigned to the customer.- Parameters:
customer-- Returns:
- a List of offers assigned to the customer
-
lookupAutomaticDeliveryOffers
Private method used to retrieve all offers with automaticallyAdded set to true- Returns:
- a List of automatic delivery offers
-
removeOutOfDateOfferCodes
Removes all out of date offerCodes based on the offerCode and its offer's start and end date. If an offerCode has a later start date, that offerCode will be removed. OfferCodes without a start date will still be processed. If the offerCode has a end date that has already passed, that offerCode will be removed. OfferCodes without a end date will be processed. The start and end dates on the offer will still need to be evaluated.- Parameters:
offerCodes-- Returns:
- a List of non-expired offers
-
refreshOfferCodesIfApplicable
For enterprise installations, this will refresh any OfferCodes found to be out-of-date with current sandbox status.- Parameters:
order- the order to check- Returns:
- the refreshed list of OfferCodes
-
applyAndSaveOffersToOrder
@Transactional("blTransactionManager") public Order applyAndSaveOffersToOrder(List<Offer> offers, Order order) throws PricingException Description copied from interface:OfferServiceApply offers to order. By default this does not re-price the order.- Specified by:
applyAndSaveOffersToOrderin interfaceOfferService- Parameters:
offers- the offersorder- the order- Returns:
- Throws:
PricingException
-
verifyAdjustments
-
applyOffersToOrder
@Transactional("blTransactionManager") @Deprecated public void applyOffersToOrder(List<Offer> offers, Order order) throws PricingException Deprecated.Description copied from interface:OfferServiceApply offers to order. By default this does not re-price the order. This method is deprecated and should not be used. The saved order should be returned from this method, which is the case in applyAndSaveOffersToOrder.- Specified by:
applyOffersToOrderin interfaceOfferService- Throws:
PricingException
-
applyFulfillmentGroupOffersToOrder
@Transactional("blTransactionManager") @Deprecated public void applyFulfillmentGroupOffersToOrder(List<Offer> offers, Order order) throws PricingException Deprecated.- Specified by:
applyFulfillmentGroupOffersToOrderin interfaceOfferService- Throws:
PricingException
-
applyAndSaveFulfillmentGroupOffersToOrder
@Transactional("blTransactionManager") public Order applyAndSaveFulfillmentGroupOffersToOrder(List<Offer> offers, Order order) throws PricingException - Specified by:
applyAndSaveFulfillmentGroupOffersToOrderin interfaceOfferService- Throws:
PricingException
-
verifyMaxCustomerUsageThreshold
Description copied from interface:OfferServiceValidates that the Customer to whom an Order belongs has not exceeded the max uses for the passed in offer. This method will take into account if the Offer has already been applied to the Order so as not to prevent the Offer from applying to new items added to the Order by a CRS.
This condition could pass if the system allows two concurrent carts for the same customer. The condition will fail at order submission time when the
VerifyCustomerMaxOfferUsesActivityruns (if that activity is configured as part of the checkout workflow.)This method only checks offers who have a max_customer_uses value that is greater than zero. By default offers can be used as many times as the customer's order qualifies.
This method offers no protection against systems that allow customers to create multiple ids in the system.
- Specified by:
verifyMaxCustomerUsageThresholdin interfaceOfferService- Parameters:
order- the order the offer is to be applied tooffer- the offer to check- Returns:
- true if it is ok for the customer to use this offer with their current order, false if not.
-
verifyMaxCustomerUsageThreshold
@Deprecated public boolean verifyMaxCustomerUsageThreshold(org.broadleafcommerce.profile.core.domain.Customer customer, Offer offer) Deprecated.Description copied from interface:OfferServiceValidates that the passed in customer has not exceeded the max uses for the passed in offer.
This condition could pass if the system allows two concurrent carts for the same customer. The condition will fail at order submission time when the
VerifyCustomerMaxOfferUsesActivityruns (if that activity is configured as part of the checkout workflow.)This method only checks offers who have a max_customer_uses value that is greater than zero. By default offers can be used as many times as the customer's order qualifies.
This method offers no protection against systems that allow customers to create multiple ids in the system.
- Specified by:
verifyMaxCustomerUsageThresholdin interfaceOfferService- Parameters:
customer- the customer attempting to use the offeroffer- the offer to check- Returns:
- true if it is ok for the customer to use this offer with their current order, false if not.
-
verifyMaxCustomerUsageThreshold
Description copied from interface:OfferServiceValidates that the given OfferCode has not reached its maximum number of usages. This method will also delegate to
OfferService.verifyMaxCustomerUsageThreshold(Order, Offer)for the code's Offer and the passed in Order's Customer.- Specified by:
verifyMaxCustomerUsageThresholdin interfaceOfferService- Parameters:
order- the order the offer is to be applied tocode- the code to check- Returns:
- true if it is ok for the customer to use this offer with their current order, false if not.
-
verifyMaxCustomerUsageThreshold
@Deprecated public boolean verifyMaxCustomerUsageThreshold(org.broadleafcommerce.profile.core.domain.Customer customer, OfferCode code) Deprecated.Description copied from interface:OfferServiceValidates that the given OfferCode has not reached its maximum number of usages. This method will also delegate to
OfferService.verifyMaxCustomerUsageThreshold(Order, Offer)for the code's Offer and the passed in Customer.- Specified by:
verifyMaxCustomerUsageThresholdin interfaceOfferService- Parameters:
customer- the customer attempting to use the codecode- the code to check- Returns:
- true if it is ok for the customer to use this offer with their current order, false if not.
-
getUniqueOffersFromOrder
Description copied from interface:OfferServiceReturns a set of offers that have been used for this order by checking adjustments on the different levels like FulfillmentGroups and OrderItems. This will return all of the unique offers used for instances where an offer can apply to multiple OrderItems or multiple FulfillmentGroups (and show up as different adjustments on each)- Specified by:
getUniqueOffersFromOrderin interfaceOfferService- Returns:
-
getOffersRetrievedFromCodes
Description copied from interface:OfferServiceFor a given order, give back a map of allOffers that were retrieved fromOfferCodes. More explicitly, this will look at all of the offers that have been used by looking at a givenOrder's adjustments and then match those up with the codes fromOrder.getAddedOfferCodes().- Specified by:
getOffersRetrievedFromCodesin interfaceOfferService- Returns:
- a map from
Offerto theOfferCodethat was used to obtain it
-
getOffersRetrievedFromCodes
public Map<Offer,OfferCode> getOffersRetrievedFromCodes(List<OfferCode> codes, Set<Offer> appliedOffers) Description copied from interface:OfferServiceGiven a list of offer codes and a set of offers, return a map of of offer codes that are keyed by the offer that was applied to the order- Specified by:
getOffersRetrievedFromCodesin interfaceOfferService- Returns:
-
deleteOfferCode
- Specified by:
deleteOfferCodein interfaceOfferService
-
duplicate
Description copied from interface:OfferServiceMake a production copy of an offer.- Specified by:
duplicatein interfaceOfferService- Returns:
-
getCustomerOfferDao
- Specified by:
getCustomerOfferDaoin interfaceOfferService
-
setCustomerOfferDao
- Specified by:
setCustomerOfferDaoin interfaceOfferService
-
getOfferCodeDao
- Specified by:
getOfferCodeDaoin interfaceOfferService
-
setOfferCodeDao
- Specified by:
setOfferCodeDaoin interfaceOfferService
-
getOfferDao
- Specified by:
getOfferDaoin interfaceOfferService
-
setOfferDao
- Specified by:
setOfferDaoin interfaceOfferService
-
getOrderOfferProcessor
- Specified by:
getOrderOfferProcessorin interfaceOfferService
-
setOrderOfferProcessor
- Specified by:
setOrderOfferProcessorin interfaceOfferService
-
getItemOfferProcessor
- Specified by:
getItemOfferProcessorin interfaceOfferService
-
setItemOfferProcessor
- Specified by:
setItemOfferProcessorin interfaceOfferService
-
getFulfillmentGroupOfferProcessor
- Specified by:
getFulfillmentGroupOfferProcessorin interfaceOfferService
-
setFulfillmentGroupOfferProcessor
public void setFulfillmentGroupOfferProcessor(FulfillmentGroupOfferProcessor fulfillmentGroupOfferProcessor) - Specified by:
setFulfillmentGroupOfferProcessorin interfaceOfferService
-
getPromotableItemFactory
- Specified by:
getPromotableItemFactoryin interfaceOfferService
-
setPromotableItemFactory
- Specified by:
setPromotableItemFactoryin interfaceOfferService
-
findOfferCodeById
Description copied from interface:OfferServiceLookup an OfferCode by its id- Specified by:
findOfferCodeByIdin interfaceOfferService- Parameters:
id- the offer id- Returns:
- the offer
-
findOfferCodesByIds
- Specified by:
findOfferCodesByIdsin interfaceOfferService
-
getOrderService
- Specified by:
getOrderServicein interfaceOfferService
-
setOrderService
- Specified by:
setOrderServicein interfaceOfferService
-
findOfferById
- Specified by:
findOfferByIdin interfaceOfferService
-
EntityDuplicateModifiers toblEntityDuplicationHelpers