@Service(value="blOrderService")
@ManagedResource(objectName="org.broadleafcommerce:name=OrderService",
description="Order Service",
currencyTimeLimit=15)
public class OrderServiceImpl
extends Object
implements OrderService
| Constructor and Description |
|---|
OrderServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
Order |
addAllItemsFromNamedOrder(Order namedOrder,
boolean priceOrder)
Adds all orderItems to the current cart from the same Customer that owns the named
order.
|
OrderItem |
addGiftWrapItemToOrder(Order order,
GiftWrapOrderItemRequest itemRequest,
boolean priceOrder)
Adds a GiftWrapItem to the order based on the itemRequest.
|
Order |
addItem(Long orderId,
OrderItemRequestDTO orderItemRequestDTO,
boolean priceOrder)
Initiates the addItem workflow that will attempt to add the given quantity of the specified item
to the Order.
|
Order |
addItemFromNamedOrder(Order namedOrder,
OrderItem item,
boolean priceOrder)
Adds the passed in orderItem to the current cart for the same Customer that owns the
named order.
|
Order |
addItemFromNamedOrder(Order namedOrder,
OrderItem item,
int quantity,
boolean priceOrder)
This method performs the same function as addItemFromNamedOrder(Order, OrderItem, boolean)
except that instead of adding all of the quantity from the named order to the cart, it will
only add/move the specific quantity requested.
|
Order |
addItemWithPriceOverrides(Long orderId,
OrderItemRequestDTO orderItemRequestDTO,
boolean priceOrder)
Initiates the addItem workflow that will attempt to add the given quantity of the specified item
to the Order.
|
Order |
addOfferCode(Order order,
OfferCode offerCode,
boolean priceOrder)
Adds the given OfferCode to the order.
|
OrderPayment |
addPaymentToOrder(Order order,
OrderPayment payment,
Referenced securePaymentInfo)
Associates a given OrderPayment with an Order and then saves the order.
|
void |
cancelOrder(Order order)
Deletes the given order.
|
protected boolean |
compareAttributes(Map<String,OrderItemAttribute> item1Attributes,
OrderItemRequestDTO item2)
Returns true if the two items attributes exactly match.
|
Order |
confirmOrder(Order order)
Changes the OrderStatus to SUBMITTED
|
Order |
createNamedOrderForCustomer(String name,
Customer customer)
Creates a new Order for the given customer with the given name.
|
Order |
createNewCartForCustomer(Customer customer)
Creates a new Order for the given customer.
|
void |
deleteOrder(Order order) |
Order |
findCartForCustomer(Customer customer)
Looks up the current shopping cart for the customer.
|
OrderItem |
findLastMatchingItem(Order order,
Long skuId,
Long productId)
Looks through the given order and returns the latest added OrderItem that matches on the skuId
and productId.
|
protected OrderItem |
findMatchingItem(Order order,
OrderItemRequestDTO itemToFind) |
Order |
findNamedOrderForCustomer(String name,
Customer customer)
Looks up an Order by the given customer and a specified order name.
|
Order |
findOrderById(Long orderId)
Looks up an Order by its database id
|
Order |
findOrderById(Long orderId,
boolean refresh)
Looks up an Order by its database id
and optionally calls refresh to ensure that the entity manager pulls the instance from the DB and not from cache
|
Order |
findOrderByOrderNumber(String orderNumber)
Looks up Orders and returns the order matching the given orderNumber
|
List<Order> |
findOrdersForCustomer(Customer customer)
Looks up all Orders for the specified customer, regardless of current OrderStatus
|
List<Order> |
findOrdersForCustomer(Customer customer,
OrderStatus status)
Looks up all Orders for the specified customer that are in the specified OrderStatus.
|
List<OrderPayment> |
findPaymentsForOrder(Order order)
Returns all OrderPayment objects that are associated with the given order
|
boolean |
getAutomaticallyMergeLikeItems() |
protected Throwable |
getCartOperationExceptionRootCause(WorkflowException e)
This method will return the exception that is immediately below the deepest
WorkflowException in the current stack trace.
|
Order |
getNullOrder()
The null order is the default order for all customers when they initially
enter the site.
|
boolean |
isDeleteEmptyNamedOrders() |
boolean |
isMoveNamedOrderItems() |
protected boolean |
itemMatches(Sku item1Sku,
Product item1Product,
Map<String,OrderItemAttribute> item1Attributes,
OrderItemRequestDTO item2) |
protected Order |
persist(Order order) |
void |
preValidateCartOperation(Order cart)
Invokes the extension handler of the same name to provide the ability for a module to throw an exception
and interrupt a cart operation.
|
void |
printOrder(Order order,
org.apache.commons.logging.Log log)
This debugging method will print out a console-suitable representation of the current state of the order, including
the items in the order and all pricing related information for the order.
|
Order |
removeAllOfferCodes(Order order,
boolean priceOrder)
Removes all offer codes for the given order.
|
void |
removeAllPaymentsFromOrder(Order order)
Deletes all the OrderPayment Info's on the order.
|
Order |
removeInactiveItems(Long orderId,
boolean priceOrder) |
Order |
removeItem(Long orderId,
Long orderItemId,
boolean priceOrder)
Initiates the removeItem workflow that will attempt to remove the specified OrderItem from
the given Order
|
protected Order |
removeItemInternal(Long orderId,
Long orderItemId,
boolean priceOrder) |
Order |
removeOfferCode(Order order,
OfferCode offerCode,
boolean priceOrder)
Remove the given OfferCode for the order.
|
void |
removePaymentFromOrder(Order order,
OrderPayment payment)
Deletes the OrderPayment Info from the order.
|
void |
removePaymentsFromOrder(Order order,
PaymentType paymentInfoType)
Deletes the OrderPayment Info of the passed in type from the order
Note that this method will also delete any associated Secure OrderPayment Infos if necessary.
|
Order |
save(Order order,
Boolean priceOrder)
Persists the given order to the database.
|
void |
setAutomaticallyMergeLikeItems(boolean automaticallyMergeLikeItems)
When set to true, the system when items are added to the cart, they will
automatically be merged.
|
void |
setDeleteEmptyNamedOrders(boolean deleteEmptyNamedOrders)
Sets whether or not to delete named orders once all items have been removed.
|
void |
setMoveNamedOrderItems(boolean moveNamedOrderItems)
Determines whether or not items will be removed from the named order (wishlist)
when they are moved to the Customer's current cart.
|
Order |
updateItemQuantity(Long orderId,
OrderItemRequestDTO orderItemRequestDTO,
boolean priceOrder)
Initiates the updateItem workflow that will attempt to update the item quantity for the specified
OrderItem in the given Order.
|
Order |
updateProductOptionsForItem(Long orderId,
OrderItemRequestDTO orderItemRequestDTO,
boolean priceOrder)
Since required product option can be added after the item is in the cart, we use this method
to apply product option on an existing item in the cart.
|
protected OrderPaymentDao paymentDao
protected OrderDao orderDao
protected OfferDao offerDao
protected NullOrderFactory nullOrderFactory
protected PricingService pricingService
protected OrderItemService orderItemService
protected FulfillmentGroupService fulfillmentGroupService
protected OfferService offerService
protected SecureOrderPaymentService securePaymentInfoService
protected MergeCartService mergeCartService
protected OrderServiceExtensionManager extensionManager
protected Processor addItemWorkflow
protected Processor updateItemWorkflow
protected Processor removeItemWorkflow
protected org.springframework.transaction.PlatformTransactionManager transactionManager
@Value(value="${pricing.retry.count.for.lock.failure}")
protected int pricingRetryCountForLockFailure
@Value(value="${pricing.retry.wait.interval.for.lock.failure}")
protected long pricingRetryWaitIntervalForLockFailure
protected boolean moveNamedOrderItems
protected boolean deleteEmptyNamedOrders
@Value(value="${automatically.merge.like.items}")
protected boolean automaticallyMergeLikeItems
protected OrderMultishipOptionService orderMultishipOptionService
@Transactional(value="blTransactionManager") public Order createNewCartForCustomer(Customer customer)
OrderServicecreateNewCartForCustomer in interface OrderServiceCustomerState@Transactional(value="blTransactionManager") public Order createNamedOrderForCustomer(String name, Customer customer)
OrderServicecreateNamedOrderForCustomer in interface OrderServicename - the wishlist namepublic Order findNamedOrderForCustomer(String name, Customer customer)
OrderServicefindNamedOrderForCustomer in interface OrderServiceOrderService.createNamedOrderForCustomer(String name, Customer customer)public Order findOrderById(Long orderId)
OrderServicefindOrderById in interface OrderServicepublic Order findOrderById(Long orderId, boolean refresh)
OrderServicefindOrderById in interface OrderServicepublic Order getNullOrder()
OrderServicegetNullOrder in interface OrderServicefor more informationpublic Order findCartForCustomer(Customer customer)
OrderServicefindCartForCustomer in interface OrderServicepublic List<Order> findOrdersForCustomer(Customer customer)
OrderServicefindOrdersForCustomer in interface OrderServicepublic List<Order> findOrdersForCustomer(Customer customer, OrderStatus status)
OrderServicefindOrdersForCustomer in interface OrderServicepublic Order findOrderByOrderNumber(String orderNumber)
OrderServicefindOrderByOrderNumber in interface OrderServicepublic List<OrderPayment> findPaymentsForOrder(Order order)
OrderServicefindPaymentsForOrder in interface OrderService@Transactional(value="blTransactionManager") public OrderPayment addPaymentToOrder(Order order, OrderPayment payment, Referenced securePaymentInfo)
OrderServiceaddPaymentToOrder in interface OrderServicesecurePaymentInfo - - null if it doesn't existpublic Order save(Order order, Boolean priceOrder) throws PricingException
OrderServicesave in interface OrderServicePricingException@Transactional(value="blTransactionManager") public void cancelOrder(Order order)
OrderServicecancelOrder in interface OrderService@Transactional(value="blTransactionManager") public void deleteOrder(Order order)
deleteOrder in interface OrderService@Transactional(value="blTransactionManager") public Order addOfferCode(Order order, OfferCode offerCode, boolean priceOrder) throws PricingException, OfferMaxUseExceededException
OrderServiceaddOfferCode in interface OrderServicePricingExceptionOfferMaxUseExceededException@Transactional(value="blTransactionManager") public Order removeOfferCode(Order order, OfferCode offerCode, boolean priceOrder) throws PricingException
OrderServiceremoveOfferCode in interface OrderServicePricingException@Transactional(value="blTransactionManager") public Order removeAllOfferCodes(Order order, boolean priceOrder) throws PricingException
OrderServiceremoveAllOfferCodes in interface OrderServicePricingException@ManagedAttribute(description="The delete empty named order after adding items to cart attribute",
currencyTimeLimit=15)
public void setDeleteEmptyNamedOrders(boolean deleteEmptyNamedOrders)
OrderServicesetDeleteEmptyNamedOrders in interface OrderServicepublic OrderItem findLastMatchingItem(Order order, Long skuId, Long productId)
OrderServicesetAutomaticallyMergeLikeItems
is set to true and the last added sku matches on a previously added sku. In this case, the sku that has the
merged items would be returned, so the total quantity of the OrderItem might not match exactly what was
just added.findLastMatchingItem in interface OrderService@Transactional(value="blTransactionManager") public Order confirmOrder(Order order)
OrderServiceconfirmOrder in interface OrderServiceorder - to confirm@Transactional(value="blTransactionManager") public Order addAllItemsFromNamedOrder(Order namedOrder, boolean priceOrder) throws RemoveFromCartException, AddToCartException
OrderServicesetMoveNamedOrderItems flag is set.
Note that any items that are in the wishlist but are no longer able to be added to a cart
will still be removed from the wishlist.
Note that this method does not change the association of the OrderItems to the new
order -- instead, those OrderItems is completely removed and a new OrderItem that mirrors
it is created.addAllItemsFromNamedOrder in interface OrderServiceRemoveFromCartExceptionAddToCartException@Transactional(value="blTransactionManager") public Order addItemFromNamedOrder(Order namedOrder, OrderItem item, boolean priceOrder) throws RemoveFromCartException, AddToCartException
OrderServicesetMoveNamedOrderItems flag is set.
Note that if an item was in a wishlist and is no longer able to be added to the cart,
the item will still be removed from the wishlist.
Note that this method does not change the association of the OrderItems to the new
order -- instead, those OrderItems is completely removed and a new OrderItem that mirrors
it is created.addItemFromNamedOrder in interface OrderServiceRemoveFromCartExceptionAddToCartException@Transactional(value="blTransactionManager") public Order addItemFromNamedOrder(Order namedOrder, OrderItem item, int quantity, boolean priceOrder) throws RemoveFromCartException, AddToCartException, UpdateCartException
OrderServiceaddItemFromNamedOrder in interface OrderServiceRemoveFromCartExceptionAddToCartExceptionUpdateCartExceptionOrderService.addItemFromNamedOrder(Order, OrderItem, boolean)@Transactional(value="blTransactionManager") public OrderItem addGiftWrapItemToOrder(Order order, GiftWrapOrderItemRequest itemRequest, boolean priceOrder) throws PricingException
OrderServiceaddGiftWrapItemToOrder in interface OrderServicePricingException@Transactional(value="blTransactionManager",
rollbackFor=AddToCartException.class)
public Order addItem(Long orderId,
OrderItemRequestDTO orderItemRequestDTO,
boolean priceOrder)
throws AddToCartException
OrderServiceOrderService.addItemWithPriceOverrides(Long, OrderItemRequestDTO, boolean) in that it
will clear any values set on the OrderItemRequestDTO for the overrideSalePrice or overrideRetailPrice.
This design is intended to ensure that override pricing is not called by mistake. Implementors should
use this method when no manual price overrides are allowed.addItem in interface OrderServiceAddToCartExceptionOrderItemRequestDTO@Transactional(value="blTransactionManager",
rollbackFor=AddToCartException.class)
public Order addItemWithPriceOverrides(Long orderId,
OrderItemRequestDTO orderItemRequestDTO,
boolean priceOrder)
throws AddToCartException
OrderServiceOrderService.addItem(Long, OrderItemRequestDTO, boolean) method, this method allows
the passed in OrderItemRequestDTO to contain values for the overrideSale or overrideRetail
price fields.
This design is intended to ensure that override pricing is not called by mistake. Implementors should
use this method when manual price overrides are allowed.addItemWithPriceOverrides in interface OrderServiceAddToCartExceptionOrderItemRequestDTO@Transactional(value="blTransactionManager",
rollbackFor={UpdateCartException.class,RemoveFromCartException.class})
public Order updateItemQuantity(Long orderId,
OrderItemRequestDTO orderItemRequestDTO,
boolean priceOrder)
throws UpdateCartException,
RemoveFromCartException
OrderServiceupdateItemQuantity in interface OrderServiceUpdateCartExceptionRemoveFromCartExceptionOrderItemRequestDTO@Transactional(value="blTransactionManager",
rollbackFor=RemoveFromCartException.class)
public Order removeItem(Long orderId,
Long orderItemId,
boolean priceOrder)
throws RemoveFromCartException
OrderServiceremoveItem in interface OrderServiceRemoveFromCartExceptionOrderItemRequestDTOprotected Order removeItemInternal(Long orderId, Long orderItemId, boolean priceOrder) throws WorkflowException
WorkflowException@Transactional(value="blTransactionManager",
rollbackFor=RemoveFromCartException.class)
public Order removeInactiveItems(Long orderId,
boolean priceOrder)
throws RemoveFromCartException
removeInactiveItems in interface OrderServiceRemoveFromCartExceptionpublic boolean getAutomaticallyMergeLikeItems()
getAutomaticallyMergeLikeItems in interface OrderServiceOrderService.setAutomaticallyMergeLikeItems(boolean)public void setAutomaticallyMergeLikeItems(boolean automaticallyMergeLikeItems)
OrderServicesetAutomaticallyMergeLikeItems in interface OrderService@ManagedAttribute(description="The move item from named order when adding to the cart attribute",
currencyTimeLimit=15)
public boolean isMoveNamedOrderItems()
isMoveNamedOrderItems in interface OrderServiceOrderService.setMoveNamedOrderItems(boolean)@ManagedAttribute(description="The move item from named order when adding to the cart attribute",
currencyTimeLimit=15)
public void setMoveNamedOrderItems(boolean moveNamedOrderItems)
OrderServicesetMoveNamedOrderItems in interface OrderService@ManagedAttribute(description="The delete empty named order after adding items to cart attribute",
currencyTimeLimit=15)
public boolean isDeleteEmptyNamedOrders()
isDeleteEmptyNamedOrders in interface OrderServiceOrderService.setDeleteEmptyNamedOrders(boolean)@Transactional(value="blTransactionManager") public void removeAllPaymentsFromOrder(Order order)
OrderServiceremoveAllPaymentsFromOrder in interface OrderService@Transactional(value="blTransactionManager") public void removePaymentsFromOrder(Order order, PaymentType paymentInfoType)
OrderServiceremovePaymentsFromOrder in interface OrderService@Transactional(value="blTransactionManager") public void removePaymentFromOrder(Order order, OrderPayment payment)
OrderServiceremovePaymentFromOrder in interface OrderServiceprotected Throwable getCartOperationExceptionRootCause(WorkflowException e)
e - the workflow exception that contains the requested root causeprotected boolean compareAttributes(Map<String,OrderItemAttribute> item1Attributes, OrderItemRequestDTO item2)
item1 - item2 - protected boolean itemMatches(Sku item1Sku, Product item1Product, Map<String,OrderItemAttribute> item1Attributes, OrderItemRequestDTO item2)
protected OrderItem findMatchingItem(Order order, OrderItemRequestDTO itemToFind)
@Transactional(value="blTransactionManager",
rollbackFor=UpdateCartException.class)
public Order updateProductOptionsForItem(Long orderId,
OrderItemRequestDTO orderItemRequestDTO,
boolean priceOrder)
throws UpdateCartException
OrderServiceupdateProductOptionsForItem in interface OrderServiceUpdateCartExceptionpublic void printOrder(Order order, org.apache.commons.logging.Log log)
OrderServiceprintOrder in interface OrderServiceorder - the order to debuglog - the Log to use to print a debug-level messagepublic void preValidateCartOperation(Order cart)
OrderServicepreValidateCartOperation in interface OrderServiceCopyright © 2014. All Rights Reserved.