Package de.hybris.platform.voucher.impl
Class DefaultVoucherModelService
- java.lang.Object
-
- de.hybris.platform.servicelayer.internal.service.AbstractService
-
- de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
-
- de.hybris.platform.voucher.impl.AbstractVoucherService
-
- de.hybris.platform.voucher.impl.DefaultVoucherModelService
-
- All Implemented Interfaces:
VoucherModelService,java.io.Serializable,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.InitializingBean
public class DefaultVoucherModelService extends AbstractVoucherService implements VoucherModelService
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
AbstractService.SerializableDTO
-
-
Field Summary
-
Fields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
modelService, sessionService, txManager
-
Fields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
tenant
-
-
Constructor Summary
Constructors Constructor Description DefaultVoucherModelService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckVoucherCode(VoucherModel voucher, java.lang.String voucherCode)Returns true if the specified voucher code is valid for this voucher.VoucherInvalidationModelcreateVoucherInvalidation(VoucherModel voucher, java.lang.String voucherCode, OrderModel order)java.lang.StringgenerateVoucherCode(VoucherModel voucher)VoucherEntrySetgetApplicableEntries(VoucherModel voucher, AbstractOrderModel order)Returns all positions or parts of positions of the specified abstract order that are eligible for this voucher.VoucherValuegetAppliedValue(VoucherModel voucher, AbstractOrderModel order)Returns a VoucherValue object representing the discount value of this voucher.DiscountValuegetDiscountValue(VoucherModel voucher, AbstractOrderModel order)java.util.List<RestrictionModel>getViolatedRestrictions(VoucherModel voucher, AbstractOrderModel order)Returns all restrictions that are not fulfilled by the specified abstract order.java.util.List<RestrictionModel>getViolatedRestrictions(VoucherModel voucher, ProductModel product)Returns all restrictions that are not fulfilled by the specified product.java.util.List<java.lang.String>getViolationMessages(VoucherModel voucher, AbstractOrderModel order)java.util.List<java.lang.String>getViolationMessages(VoucherModel voucher, ProductModel product)VoucherValuegetVoucherValue(VoucherModel voucher, AbstractOrderModel order)booleanisApplicable(VoucherModel voucher, AbstractOrderModel order)Returns true if the specified abstract order is eligible for this voucher.booleanisApplicable(VoucherModel voucher, ProductModel product)Returns true if the specified product is eligible for this voucher.booleanisReservable(VoucherModel voucher, java.lang.String voucherCode, AbstractOrderModel order)booleanisReservable(VoucherModel voucher, java.lang.String voucherCode, UserModel user)booleanredeem(VoucherModel voucher, java.lang.String voucherCode, CartModel cart)WARNING!
If some methods for checking voucher availability are called before this method, all these methods have to be in one synchronize block! Suggested synchronization object is cart.VoucherInvalidationModelredeem(VoucherModel voucher, java.lang.String voucherCode, OrderModel order)voidrelease(VoucherModel voucher, java.lang.String voucherCode, CartModel cart)voidrelease(VoucherModel voucher, java.lang.String voucherCode, OrderModel order)VoucherInvalidationModelreserve(VoucherModel voucher, java.lang.String voucherCode, OrderModel order)-
Methods inherited from class de.hybris.platform.voucher.impl.AbstractVoucherService
getAbstractOrder, getCart, getOrder, getProduct, getRestriction, getUser, getVoucher
-
Methods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
getModelService, getSessionService, getTxManager, setModelService, setSessionService, setTxManager
-
Methods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
afterPropertiesSet, getCurrentTenant, setBeanName, setCurrentTenant, writeReplace
-
-
-
-
Method Detail
-
checkVoucherCode
public boolean checkVoucherCode(VoucherModel voucher, java.lang.String voucherCode)
Description copied from interface:VoucherModelServiceReturns true if the specified voucher code is valid for this voucher.- Specified by:
checkVoucherCodein interfaceVoucherModelService- Parameters:
voucher- the vouchervoucherCode- the voucher code to check validity of.- Returns:
- true if the specified voucher code is valid for this voucher, false else.
-
createVoucherInvalidation
public VoucherInvalidationModel createVoucherInvalidation(VoucherModel voucher, java.lang.String voucherCode, OrderModel order)
- Specified by:
createVoucherInvalidationin interfaceVoucherModelService
-
generateVoucherCode
public java.lang.String generateVoucherCode(VoucherModel voucher) throws java.security.NoSuchAlgorithmException
- Specified by:
generateVoucherCodein interfaceVoucherModelService- Throws:
java.security.NoSuchAlgorithmException
-
getApplicableEntries
public VoucherEntrySet getApplicableEntries(VoucherModel voucher, AbstractOrderModel order)
Description copied from interface:VoucherModelServiceReturns all positions or parts of positions of the specified abstract order that are eligible for this voucher.- Specified by:
getApplicableEntriesin interfaceVoucherModelService- Parameters:
voucher- the voucherorder- the abstract order to get eligible positions of.- Returns:
- a VoucherEntrySet containing a VoucherEntry object for every position that is fully or partly eligible for this voucher.
-
getAppliedValue
public VoucherValue getAppliedValue(VoucherModel voucher, AbstractOrderModel order)
Description copied from interface:VoucherModelServiceReturns a VoucherValue object representing the discount value of this voucher. If the voucher is applicable to the specified abstract order this value is calculated in consideration of the applicable value returned by getApplicableValue(AbstractOrder).- Specified by:
getAppliedValuein interfaceVoucherModelService- Parameters:
voucher- the voucherorder- the abstract order to get discount value of.- Returns:
- a VoucherValue representing the discount value of this voucher.
-
getDiscountValue
public DiscountValue getDiscountValue(VoucherModel voucher, AbstractOrderModel order)
- Specified by:
getDiscountValuein interfaceVoucherModelService
-
getViolatedRestrictions
public java.util.List<RestrictionModel> getViolatedRestrictions(VoucherModel voucher, AbstractOrderModel order)
Description copied from interface:VoucherModelServiceReturns all restrictions that are not fulfilled by the specified abstract order.- Specified by:
getViolatedRestrictionsin interfaceVoucherModelService- Parameters:
voucher- the voucherorder- the abstract order to return violated restrictions for.- Returns:
- a List object containing all Restriction objects associated with this voucher that the specified abstract order does not fulfill.
-
getViolatedRestrictions
public java.util.List<RestrictionModel> getViolatedRestrictions(VoucherModel voucher, ProductModel product)
Description copied from interface:VoucherModelServiceReturns all restrictions that are not fulfilled by the specified product.- Specified by:
getViolatedRestrictionsin interfaceVoucherModelService- Parameters:
voucher- the voucherproduct- the product to return violated restrictions for.- Returns:
- a List object containing all Restriction objects associated with this voucher that the specified product does not fulfill.
-
getViolationMessages
public java.util.List<java.lang.String> getViolationMessages(VoucherModel voucher, AbstractOrderModel order)
- Specified by:
getViolationMessagesin interfaceVoucherModelService
-
getViolationMessages
public java.util.List<java.lang.String> getViolationMessages(VoucherModel voucher, ProductModel product)
- Specified by:
getViolationMessagesin interfaceVoucherModelService
-
getVoucherValue
public VoucherValue getVoucherValue(VoucherModel voucher, AbstractOrderModel order)
- Specified by:
getVoucherValuein interfaceVoucherModelService
-
isApplicable
public boolean isApplicable(VoucherModel voucher, AbstractOrderModel order)
Description copied from interface:VoucherModelServiceReturns true if the specified abstract order is eligible for this voucher. More formally, returns true if the specified abstract order fulfills all restrictions associated with this voucher.- Specified by:
isApplicablein interfaceVoucherModelService- Parameters:
voucher- the voucherorder- the abstract order to check whether it is eligible for this voucher.- Returns:
- true if the specified abstract order is eligible for this voucher, false else.
-
isApplicable
public boolean isApplicable(VoucherModel voucher, ProductModel product)
Description copied from interface:VoucherModelServiceReturns true if the specified product is eligible for this voucher. More formally, returns true if the specified product fulfills all restrictions associated with this voucher.- Specified by:
isApplicablein interfaceVoucherModelService- Parameters:
voucher- the voucherproduct- the product to check whether it is eligible for this voucher.- Returns:
- true if the specified product is eligible for this voucher, false else.
-
isReservable
public boolean isReservable(VoucherModel voucher, java.lang.String voucherCode, UserModel user)
- Specified by:
isReservablein interfaceVoucherModelService
-
isReservable
public boolean isReservable(VoucherModel voucher, java.lang.String voucherCode, AbstractOrderModel order)
- Specified by:
isReservablein interfaceVoucherModelService
-
redeem
public boolean redeem(VoucherModel voucher, java.lang.String voucherCode, CartModel cart) throws JaloPriceFactoryException
Description copied from interface:VoucherModelServiceWARNING!
If some methods for checking voucher availability are called before this method, all these methods have to be in one synchronize block! Suggested synchronization object is cart.- Specified by:
redeemin interfaceVoucherModelService- Throws:
JaloPriceFactoryException
-
redeem
public VoucherInvalidationModel redeem(VoucherModel voucher, java.lang.String voucherCode, OrderModel order)
- Specified by:
redeemin interfaceVoucherModelService
-
release
public void release(VoucherModel voucher, java.lang.String voucherCode, OrderModel order) throws ConsistencyCheckException
- Specified by:
releasein interfaceVoucherModelService- Throws:
ConsistencyCheckException
-
release
public void release(VoucherModel voucher, java.lang.String voucherCode, CartModel cart) throws JaloPriceFactoryException
- Specified by:
releasein interfaceVoucherModelService- Throws:
JaloPriceFactoryException
-
reserve
public VoucherInvalidationModel reserve(VoucherModel voucher, java.lang.String voucherCode, OrderModel order)
- Specified by:
reservein interfaceVoucherModelService
-
-