org.broadleafcommerce.core.offer.service
Class OfferServiceImpl

java.lang.Object
  extended by org.broadleafcommerce.core.offer.service.OfferServiceImpl
All Implemented Interfaces:
OfferService

@Service(value="blOfferService")
public class OfferServiceImpl
extends Object
implements OfferService

The Class OfferServiceImpl.


Field Summary
protected  CustomerOfferDao customerOfferDao
           
protected  OfferServiceExtensionManager extensionManager
           
protected  FulfillmentGroupOfferProcessor fulfillmentGroupOfferProcessor
           
protected  ItemOfferProcessor itemOfferProcessor
           
protected  OfferAuditService offerAuditService
           
protected  OfferCodeDao offerCodeDao
           
protected  OfferDao offerDao
           
protected  OrderOfferProcessor orderOfferProcessor
           
protected  OrderService orderService
           
protected  PromotableItemFactory promotableItemFactory
           
 
Constructor Summary
OfferServiceImpl()
           
 
Method Summary
 void applyFulfillmentGroupOffersToOrder(List<Offer> offers, Order order)
           
 void applyOffersToOrder(List<Offer> offers, Order order)
          Apply offers to order.
 List<Offer> buildOfferListForOrder(Order order)
          Creates a list of offers that applies to this order.
 List<Offer> findAllOffers()
          Returns all offers
 OfferCode findOfferCodeById(Long id)
          Lookup an OfferCode by its id
 CustomerOfferDao getCustomerOfferDao()
           
 FulfillmentGroupOfferProcessor getFulfillmentGroupOfferProcessor()
           
 ItemOfferProcessor getItemOfferProcessor()
           
 OfferCodeDao getOfferCodeDao()
           
 OfferDao getOfferDao()
           
 Map<Offer,OfferCode> getOffersRetrievedFromCodes(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 order
 Map<Offer,OfferCode> getOffersRetrievedFromCodes(Order order)
          For a given order, give back a map of all Offers that were retrieved from OfferCodes.
 OrderOfferProcessor getOrderOfferProcessor()
           
 OrderService getOrderService()
           
 PromotableItemFactory getPromotableItemFactory()
           
 Set<Offer> 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.
protected  List<Offer> lookupAutomaticDeliveryOffers()
          Private method used to retrieve all offers with DeliveryType of AUTOMATIC
 Offer lookupOfferByCode(String code)
          Creates a list of offers that applies to this order.
 OfferCode lookupOfferCodeByCode(String code)
          Lookup OfferCode by code.
protected  List<CustomerOffer> lookupOfferCustomerByCustomer(Customer customer)
          Private method used to retrieve all offers assigned to this customer.
protected  List<OfferCode> removeOutOfDateOfferCodes(List<OfferCode> offerCodes)
          Removes all out of date offerCodes based on the offerCode and its offer's start and end date.
 Offer save(Offer offer)
          Save a new offer or updates an existing offer
 OfferCode saveOfferCode(OfferCode offerCode)
          Saves a new Offer or updates an existing Offer that belongs to an OfferCode, then saves or updates the OfferCode
 void setCustomerOfferDao(CustomerOfferDao customerOfferDao)
           
 void setFulfillmentGroupOfferProcessor(FulfillmentGroupOfferProcessor fulfillmentGroupOfferProcessor)
           
 void setItemOfferProcessor(ItemOfferProcessor itemOfferProcessor)
           
 void setOfferCodeDao(OfferCodeDao offerCodeDao)
           
 void setOfferDao(OfferDao offerDao)
           
 void setOrderOfferProcessor(OrderOfferProcessor orderOfferProcessor)
           
 void setOrderService(OrderService orderService)
           
 void setPromotableItemFactory(PromotableItemFactory promotableItemFactory)
           
 boolean verifyMaxCustomerUsageThreshold(Customer customer, Offer offer)
          Validates that the passed in customer has not exceeded the max uses for the passed in offer.
 boolean verifyMaxCustomerUsageThreshold(Customer customer, OfferCode code)
          Validates that the given code is underneath the max uses for that code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

customerOfferDao

protected CustomerOfferDao customerOfferDao

offerCodeDao

protected OfferCodeDao offerCodeDao

offerAuditService

protected OfferAuditService offerAuditService

offerDao

protected OfferDao offerDao

orderOfferProcessor

protected OrderOfferProcessor orderOfferProcessor

itemOfferProcessor

protected ItemOfferProcessor itemOfferProcessor

fulfillmentGroupOfferProcessor

protected FulfillmentGroupOfferProcessor fulfillmentGroupOfferProcessor

promotableItemFactory

protected PromotableItemFactory promotableItemFactory

extensionManager

protected OfferServiceExtensionManager extensionManager

orderService

protected OrderService orderService
Constructor Detail

OfferServiceImpl

public OfferServiceImpl()
Method Detail

findAllOffers

public List<Offer> findAllOffers()
Description copied from interface: OfferService
Returns all offers

Specified by:
findAllOffers in interface OfferService
Returns:
all offers

save

@Transactional(value="blTransactionManager")
public Offer save(Offer offer)
Description copied from interface: OfferService
Save a new offer or updates an existing offer

Specified by:
save in interface OfferService
Returns:
the offer

saveOfferCode

@Transactional(value="blTransactionManager")
public OfferCode saveOfferCode(OfferCode offerCode)
Description copied from interface: OfferService
Saves a new Offer or updates an existing Offer that belongs to an OfferCode, then saves or updates the OfferCode

Specified by:
saveOfferCode in interface OfferService
Returns:
the offerCode

lookupOfferByCode

public Offer lookupOfferByCode(String code)
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:
lookupOfferByCode in interface OfferService
Parameters:
code -
Returns:
a List of offers that may apply to this order

lookupOfferCodeByCode

public OfferCode lookupOfferCodeByCode(String code)
Description copied from interface: OfferService
Lookup OfferCode by code.

Specified by:
lookupOfferCodeByCode in interface OfferService
Parameters:
code - the code
Returns:
the offer

buildOfferListForOrder

public List<Offer> buildOfferListForOrder(Order order)
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:
buildOfferListForOrder in interface OfferService
Parameters:
order -
Returns:
a List of offers that may apply to this order

lookupOfferCustomerByCustomer

protected List<CustomerOffer> lookupOfferCustomerByCustomer(Customer customer)
Private method used to retrieve all offers assigned to this customer. These offers have a DeliveryType of MANUAL and are programmatically assigned to the customer.

Parameters:
customer -
Returns:
a List of offers assigned to the customer

lookupAutomaticDeliveryOffers

protected List<Offer> lookupAutomaticDeliveryOffers()
Private method used to retrieve all offers with DeliveryType of AUTOMATIC

Returns:
a List of automatic delivery offers

removeOutOfDateOfferCodes

protected List<OfferCode> removeOutOfDateOfferCodes(List<OfferCode> offerCodes)
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

applyOffersToOrder

@Transactional(value="blTransactionManager")
public void applyOffersToOrder(List<Offer> offers,
                                             Order order)
                        throws PricingException
Description copied from interface: OfferService
Apply offers to order.

Specified by:
applyOffersToOrder in interface OfferService
Parameters:
offers - the offers
order - the order
Throws:
PricingException

applyFulfillmentGroupOffersToOrder

@Transactional(value="blTransactionManager")
public void applyFulfillmentGroupOffersToOrder(List<Offer> offers,
                                                             Order order)
                                        throws PricingException
Specified by:
applyFulfillmentGroupOffersToOrder in interface OfferService
Throws:
PricingException

verifyMaxCustomerUsageThreshold

public boolean verifyMaxCustomerUsageThreshold(Customer customer,
                                               Offer offer)
Description copied from interface: OfferService

Validates 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 VerifyCustomerMaxOfferUsesActivity runs (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:
verifyMaxCustomerUsageThreshold in interface OfferService
Parameters:
customer - the customer attempting to use the offer
offer - 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

public boolean verifyMaxCustomerUsageThreshold(@NotNull
                                               Customer customer,
                                               OfferCode code)
Description copied from interface: OfferService

Validates that the given code is underneath the max uses for that code. This method will also delegate to OfferService.verifyMaxCustomerUsageThreshold(Customer, Offer) for the code's offer and the passed in customer

Specified by:
verifyMaxCustomerUsageThreshold in interface OfferService
Parameters:
customer - the customer attempting to use the code
code - 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

public Set<Offer> getUniqueOffersFromOrder(Order order)
Description copied from interface: OfferService
Returns 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:
getUniqueOffersFromOrder in interface OfferService
Returns:

getOffersRetrievedFromCodes

public Map<Offer,OfferCode> getOffersRetrievedFromCodes(Order order)
Description copied from interface: OfferService
For a given order, give back a map of all Offers that were retrieved from OfferCodes. More explicitly, this will look at all of the offers that have been used by looking at a given Order's adjustments and then match those up with the codes from Order.getAddedOfferCodes().

Specified by:
getOffersRetrievedFromCodes in interface OfferService
Returns:
a map from Offer to the OfferCode that was used to obtain it

getOffersRetrievedFromCodes

public Map<Offer,OfferCode> getOffersRetrievedFromCodes(List<OfferCode> codes,
                                                        Set<Offer> appliedOffers)
Description copied from interface: OfferService
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 order

Specified by:
getOffersRetrievedFromCodes in interface OfferService
Returns:

getCustomerOfferDao

public CustomerOfferDao getCustomerOfferDao()
Specified by:
getCustomerOfferDao in interface OfferService

setCustomerOfferDao

public void setCustomerOfferDao(CustomerOfferDao customerOfferDao)
Specified by:
setCustomerOfferDao in interface OfferService

getOfferCodeDao

public OfferCodeDao getOfferCodeDao()
Specified by:
getOfferCodeDao in interface OfferService

setOfferCodeDao

public void setOfferCodeDao(OfferCodeDao offerCodeDao)
Specified by:
setOfferCodeDao in interface OfferService

getOfferDao

public OfferDao getOfferDao()
Specified by:
getOfferDao in interface OfferService

setOfferDao

public void setOfferDao(OfferDao offerDao)
Specified by:
setOfferDao in interface OfferService

getOrderOfferProcessor

public OrderOfferProcessor getOrderOfferProcessor()
Specified by:
getOrderOfferProcessor in interface OfferService

setOrderOfferProcessor

public void setOrderOfferProcessor(OrderOfferProcessor orderOfferProcessor)
Specified by:
setOrderOfferProcessor in interface OfferService

getItemOfferProcessor

public ItemOfferProcessor getItemOfferProcessor()
Specified by:
getItemOfferProcessor in interface OfferService

setItemOfferProcessor

public void setItemOfferProcessor(ItemOfferProcessor itemOfferProcessor)
Specified by:
setItemOfferProcessor in interface OfferService

getFulfillmentGroupOfferProcessor

public FulfillmentGroupOfferProcessor getFulfillmentGroupOfferProcessor()
Specified by:
getFulfillmentGroupOfferProcessor in interface OfferService

setFulfillmentGroupOfferProcessor

public void setFulfillmentGroupOfferProcessor(FulfillmentGroupOfferProcessor fulfillmentGroupOfferProcessor)
Specified by:
setFulfillmentGroupOfferProcessor in interface OfferService

getPromotableItemFactory

public PromotableItemFactory getPromotableItemFactory()
Specified by:
getPromotableItemFactory in interface OfferService

setPromotableItemFactory

public void setPromotableItemFactory(PromotableItemFactory promotableItemFactory)
Specified by:
setPromotableItemFactory in interface OfferService

findOfferCodeById

public OfferCode findOfferCodeById(Long id)
Description copied from interface: OfferService
Lookup an OfferCode by its id

Specified by:
findOfferCodeById in interface OfferService
Parameters:
id - the offer id
Returns:
the offer

getOrderService

public OrderService getOrderService()
Specified by:
getOrderService in interface OfferService

setOrderService

public void setOrderService(OrderService orderService)
Specified by:
setOrderService in interface OfferService


Copyright © 2013. All Rights Reserved.