Class DefaultSubscriptionCommerceCartService
- java.lang.Object
-
- de.hybris.platform.commerceservices.order.impl.DefaultCommerceCartService
-
- de.hybris.platform.subscriptionservices.subscription.impl.DefaultSubscriptionCommerceCartService
-
- All Implemented Interfaces:
CommerceCartService
,SubscriptionCommerceCartService
public class DefaultSubscriptionCommerceCartService extends DefaultCommerceCartService implements SubscriptionCommerceCartService
Default implementation ofSubscriptionCommerceCartService
.
-
-
Field Summary
-
Fields inherited from class de.hybris.platform.commerceservices.order.impl.DefaultCommerceCartService
ESTIMATED_TAXES
-
-
Constructor Summary
Constructors Constructor Description DefaultSubscriptionCommerceCartService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addOneRecurringFrequency(SubscriptionPricePlanModel subscriptionPricePlan, java.util.List<BillingTimeModel> billingFrequencies)
void
checkMasterCart(CartModel cartModel, BillingTimeModel masterCartBillingTimeModel)
Checks if the givenCartModel
is a master cart and has the correctBillingTimeModel
.void
checkQuantityToAdd(long quantityToAdd)
Checks if given quantity can be added.protected void
checkQuantityToAdd(long quantityToAdd, long maxQuantity)
CartModel
createChildCartForBillingTime(CartModel masterCart, BillingTimeModel billFreq)
Creates a new child cart for the given billing frequency and assigns it as child cart to the given master cart.protected long
getAvailableStockLevel(ProductModel productModel, PointOfServiceModel pointOfServiceModel)
Find the available stock quantity for a product.protected BaseStoreService
getBaseStoreService()
java.util.List<BillingTimeModel>
getBillingFrequenciesForMasterEntry(AbstractOrderEntryModel entry)
Get billing frequencies for the master entry.protected BillingTimeModel
getBillingTimeForCode(java.lang.String code)
protected BillingTimeService
getBillingTimeService()
protected AbstractOrderEntryModel
getCartEntryToBeUpdated(CartModel cartModel, long entryNumber)
Searches in the givencartModel
for the cart entry with has the givenentryNumber
and returns it.CartModel
getChildCartForBillingTime(CartModel masterCart, BillingTimeModel billFreq)
Get the child cart for the givenBillingTimeModel
, if any.protected SubscriptionCommercePriceService
getCommercePriceService()
protected CommerceStockService
getCommerceStockService()
java.lang.String
getMasterCartBillingTimeCode()
Get the billing frequency code for the master cart.CartModel
getMasterCartForCartEntry(CartEntryModel cartEntryModel)
Get the master cart for the givencartEntryModel
.protected SubscriptionCommerceCartStrategy
getSubscriptionCommerceCartStrategy()
protected SubscriptionProductService
getSubscriptionProductService()
protected int
getSubscriptionProductStockQuantity()
protected boolean
isMasterCart(CartModel cartModel)
void
recalculateCart(CommerceCartParameter parameter)
Overrides the super class' method to make sure that in a multi-cart system the master cart and its child carts are re-calculated.void
recalculateCart(CartModel masterCartModel)
Overrides the super class' method to make sure that in a multi-cart system the master cart and its child carts are re-calculated.void
removeAllEntries(CartModel masterCartModel)
void
setBaseStoreService(BaseStoreService baseStoreService)
void
setBillingTimeService(BillingTimeService billingTimeService)
void
setCommercePriceService(SubscriptionCommercePriceService commercePriceService)
void
setCommerceStockService(CommerceStockService commerceStockService)
void
setMasterCartBillingTimeCode(java.lang.String masterCartBillingTimeCode)
void
setSubscriptionCommerceCartStrategy(SubscriptionCommerceCartStrategy subscriptionCommerceCartStrategy)
void
setSubscriptionProductService(SubscriptionProductService subscriptionProductService)
void
setSubscriptionProductStockQuantity(int subscriptionProductStockQuantity)
protected boolean
useBillingFrequencyForProduct(ProductModel subscriptionProduct, SubscriptionPricePlanModel subscriptionPricePlan)
-
Methods inherited from class de.hybris.platform.commerceservices.order.impl.DefaultCommerceCartService
addToCart, addToCart, addToCart, afterCalculate, beforeCalculate, calculateCart, calculateCart, configureCartEntry, estimateTaxes, estimateTaxes, getBaseSiteService, getCartForCodeAndUser, getCartForGuidAndSite, getCartForGuidAndSiteAndUser, getCartsForSiteAndUser, getCartValidationStrategy, getCommerceAddToCartStrategy, getCommerceCartCalculationStrategy, getCommerceCartDao, getCommerceCartEstimateTaxesStrategy, getCommerceCartHashCalculationStrategy, getCommerceCartMergingStrategy, getCommerceCartMetadataUpdateStrategy, getCommerceCartRestorationStrategy, getCommerceCartSplitStrategy, getCommerceRemoveEntriesStrategy, getCommerceUpdateCartEntryStrategy, getModelService, getProductConfigurationStrategy, getRemoveEntryGroupStrategy, getSessionService, getStaleCartRemovalStrategy, mergeCarts, removeAllEntries, removeEntryGroup, removeStaleCarts, removeStaleCarts, restoreCart, restoreCart, setBaseSiteService, setCartValidationStrategy, setCommerceAddToCartStrategy, setCommerceCartCalculationStrategy, setCommerceCartDao, setCommerceCartEstimateTaxesStrategy, setCommerceCartHashCalculationStrategy, setCommerceCartMergingStrategy, setCommerceCartMetadataUpdateStrategy, setCommerceCartRestorationStrategy, setCommerceCartSplitStrategy, setCommerceRemoveEntriesStrategy, setCommerceUpdateCartEntryStrategy, setModelService, setProductConfigurationStrategy, setRemoveEntryGroupStrategy, setSessionService, setStaleCartRemovalStrategy, split, split, updateCartMetadata, updatePointOfServiceForCartEntry, updatePointOfServiceForCartEntry, updateQuantityForCartEntry, updateQuantityForCartEntry, updateToShippingModeForCartEntry, updateToShippingModeForCartEntry, validateCart, validateCart
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.hybris.platform.commerceservices.order.CommerceCartService
addToCart, addToCart, addToCart, calculateCart, calculateCart, configureCartEntry, estimateTaxes, estimateTaxes, getCartForCodeAndUser, getCartForGuidAndSite, getCartForGuidAndSiteAndUser, getCartsForSiteAndUser, mergeCarts, removeAllEntries, removeEntryGroup, removeStaleCarts, removeStaleCarts, restoreCart, restoreCart, split, split, updateCartMetadata, updatePointOfServiceForCartEntry, updatePointOfServiceForCartEntry, updateQuantityForCartEntry, updateQuantityForCartEntry, updateToShippingModeForCartEntry, updateToShippingModeForCartEntry, validateCart, validateCart
-
-
-
-
Method Detail
-
getBillingFrequenciesForMasterEntry
@Nonnull public java.util.List<BillingTimeModel> getBillingFrequenciesForMasterEntry(@Nonnull AbstractOrderEntryModel entry)
Description copied from interface:SubscriptionCommerceCartService
Get billing frequencies for the master entry.- Specified by:
getBillingFrequenciesForMasterEntry
in interfaceSubscriptionCommerceCartService
- Parameters:
entry
-AbstractOrderEntryModel
to get list of billing frequencies for- Returns:
- List of
BillingTimeModel
s
-
addOneRecurringFrequency
protected void addOneRecurringFrequency(SubscriptionPricePlanModel subscriptionPricePlan, java.util.List<BillingTimeModel> billingFrequencies)
-
useBillingFrequencyForProduct
protected boolean useBillingFrequencyForProduct(ProductModel subscriptionProduct, SubscriptionPricePlanModel subscriptionPricePlan)
-
removeAllEntries
public void removeAllEntries(CartModel masterCartModel)
- Specified by:
removeAllEntries
in interfaceCommerceCartService
- Overrides:
removeAllEntries
in classDefaultCommerceCartService
- Parameters:
masterCartModel
- the user's cart in session
-
getCartEntryToBeUpdated
protected AbstractOrderEntryModel getCartEntryToBeUpdated(CartModel cartModel, long entryNumber) throws CommerceCartModificationException
Searches in the givencartModel
for the cart entry with has the givenentryNumber
and returns it.- Parameters:
cartModel
- the cartentryNumber
- number of the cart entry- Returns:
- the cart entry with the given
entryNumber
- Throws:
CommerceCartModificationException
- if there is no cart entry with the givenentryNumber
-
getAvailableStockLevel
protected long getAvailableStockLevel(ProductModel productModel, PointOfServiceModel pointOfServiceModel)
Find the available stock quantity for a product. Overrides the method in the super class in order to handle stock availability also for subscription products which do not have a physically available stock- Parameters:
productModel
- the product in the cart- Returns:
- the available stock level
-
getChildCartForBillingTime
@Nullable public CartModel getChildCartForBillingTime(@Nonnull CartModel masterCart, @Nonnull BillingTimeModel billFreq)
Description copied from interface:SubscriptionCommerceCartService
Get the child cart for the givenBillingTimeModel
, if any.- Specified by:
getChildCartForBillingTime
in interfaceSubscriptionCommerceCartService
- Parameters:
masterCart
- theCartModel
of the master cartbillFreq
- theBillingTimeModel
to look for- Returns:
- the
CartModel
for the givenBillingTimeModel
or null.
-
createChildCartForBillingTime
public CartModel createChildCartForBillingTime(CartModel masterCart, BillingTimeModel billFreq)
Creates a new child cart for the given billing frequency and assigns it as child cart to the given master cart.- Specified by:
createChildCartForBillingTime
in interfaceSubscriptionCommerceCartService
- Parameters:
masterCart
-CartModel
representing master cart for which child cart should be createdbillFreq
-BillingTimeModel
for child cart- Returns:
- Created child cart.
-
isMasterCart
protected boolean isMasterCart(CartModel cartModel)
-
checkMasterCart
public void checkMasterCart(CartModel cartModel, BillingTimeModel masterCartBillingTimeModel) throws java.lang.IllegalArgumentException, CommerceCartModificationException
Checks if the givenCartModel
is a master cart and has the correctBillingTimeModel
.- Specified by:
checkMasterCart
in interfaceSubscriptionCommerceCartService
- Parameters:
cartModel
- the cart model to be checked whether it is a master cartmasterCartBillingTimeModel
- theBillingTimeModel
that a master cart must have. If the given cart's billing frequency is empty themasterCartBillingTimeModel
will be set as billing frequency- Throws:
java.lang.IllegalArgumentException
- if the given cart is not a master cartCommerceCartModificationException
- if the given cart's billing frequency does no equal the givenmasterCartBillingTimeModel
-
recalculateCart
public void recalculateCart(CartModel masterCartModel) throws CalculationException
Overrides the super class' method to make sure that in a multi-cart system the master cart and its child carts are re-calculated. This includes finding prices, taxes, discounts, payment and delivery costs by calling the currently installed price factory.- Specified by:
recalculateCart
in interfaceCommerceCartService
- Overrides:
recalculateCart
in classDefaultCommerceCartService
- Parameters:
masterCartModel
- the cart modelCartModel
(must exist) that will be recalculatedCartModel
. It must be the master cart of the multi-cart system. In addition, the master cart's child carts will also be re-calculated.- Throws:
java.lang.IllegalArgumentException
- in case the givenmasterCartModel
is not a master cartCalculationException
-
recalculateCart
public void recalculateCart(CommerceCartParameter parameter)
Overrides the super class' method to make sure that in a multi-cart system the master cart and its child carts are re-calculated. This includes finding prices, taxes, discounts, payment and delivery costs by calling the currently installed price factory.- Specified by:
recalculateCart
in interfaceCommerceCartService
- Overrides:
recalculateCart
in classDefaultCommerceCartService
- Parameters:
parameter
- checkout parameter containing the the master cart of the multi-cart
-
getMasterCartForCartEntry
@Nonnull public CartModel getMasterCartForCartEntry(@Nonnull CartEntryModel cartEntryModel)
Description copied from interface:SubscriptionCommerceCartService
Get the master cart for the givencartEntryModel
. ThecartEntryModel
may be a master or child cart entry.- Specified by:
getMasterCartForCartEntry
in interfaceSubscriptionCommerceCartService
- Parameters:
cartEntryModel
- theCartEntryModel
whose masterCartModel
is searched- Returns:
- the given
cartEntryModel
's masterCartModel
-
checkQuantityToAdd
protected void checkQuantityToAdd(long quantityToAdd, long maxQuantity) throws CommerceCartModificationException
-
checkQuantityToAdd
public void checkQuantityToAdd(long quantityToAdd) throws CommerceCartModificationException
Description copied from interface:SubscriptionCommerceCartService
Checks if given quantity can be added.- Specified by:
checkQuantityToAdd
in interfaceSubscriptionCommerceCartService
- Parameters:
quantityToAdd
- quantyty to add- Throws:
CommerceCartModificationException
- If given quantity is not allowed to add.
-
getBillingTimeForCode
protected BillingTimeModel getBillingTimeForCode(java.lang.String code)
-
setMasterCartBillingTimeCode
public void setMasterCartBillingTimeCode(java.lang.String masterCartBillingTimeCode)
-
getMasterCartBillingTimeCode
public java.lang.String getMasterCartBillingTimeCode()
Description copied from interface:SubscriptionCommerceCartService
Get the billing frequency code for the master cart.- Specified by:
getMasterCartBillingTimeCode
in interfaceSubscriptionCommerceCartService
- Returns:
- a String with the billing frequency code for the master cart
-
setBillingTimeService
public void setBillingTimeService(BillingTimeService billingTimeService)
-
getBillingTimeService
protected BillingTimeService getBillingTimeService()
-
setSubscriptionProductStockQuantity
public void setSubscriptionProductStockQuantity(int subscriptionProductStockQuantity)
-
getSubscriptionProductStockQuantity
protected int getSubscriptionProductStockQuantity()
-
getCommercePriceService
protected SubscriptionCommercePriceService getCommercePriceService()
-
setCommercePriceService
public void setCommercePriceService(SubscriptionCommercePriceService commercePriceService)
-
getSubscriptionCommerceCartStrategy
protected SubscriptionCommerceCartStrategy getSubscriptionCommerceCartStrategy()
-
setSubscriptionCommerceCartStrategy
public void setSubscriptionCommerceCartStrategy(SubscriptionCommerceCartStrategy subscriptionCommerceCartStrategy)
-
getBaseStoreService
protected BaseStoreService getBaseStoreService()
-
setBaseStoreService
public void setBaseStoreService(BaseStoreService baseStoreService)
-
getCommerceStockService
protected CommerceStockService getCommerceStockService()
-
setCommerceStockService
public void setCommerceStockService(CommerceStockService commerceStockService)
-
getSubscriptionProductService
protected SubscriptionProductService getSubscriptionProductService()
- Returns:
- subscription product service
-
setSubscriptionProductService
public void setSubscriptionProductService(SubscriptionProductService subscriptionProductService)
-
-