Package de.hybris.platform.voucher
Interface VoucherModelService
-
- All Known Implementing Classes:
DefaultVoucherModelService
public interface VoucherModelService
The vouchers are redeemed on the total value of an order. The calculation of the discount is done on the total value of the applicable product's prices, inclusive of VAT. Non-applicable products in the order are not subject to the discount rules. To discover to which products in the order the voucher is applicable one could assign various restrictions to the voucher.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
checkVoucherCode(VoucherModel voucher, java.lang.String voucherCode)
Returns true if the specified voucher code is valid for this voucher.VoucherInvalidationModel
createVoucherInvalidation(VoucherModel voucher, java.lang.String voucherCode, OrderModel order)
java.lang.String
generateVoucherCode(VoucherModel voucher)
VoucherEntrySet
getApplicableEntries(VoucherModel voucher, AbstractOrderModel order)
Returns all positions or parts of positions of the specified abstract order that are eligible for this voucher.VoucherValue
getAppliedValue(VoucherModel voucher, AbstractOrderModel order)
Returns a VoucherValue object representing the discount value of this voucher.DiscountValue
getDiscountValue(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)
VoucherValue
getVoucherValue(VoucherModel voucher, AbstractOrderModel order)
boolean
isApplicable(VoucherModel voucher, AbstractOrderModel order)
Returns true if the specified abstract order is eligible for this voucher.boolean
isApplicable(VoucherModel voucher, ProductModel product)
Returns true if the specified product is eligible for this voucher.boolean
isReservable(VoucherModel voucher, java.lang.String voucherCode, AbstractOrderModel order)
boolean
isReservable(VoucherModel voucher, java.lang.String voucherCode, UserModel user)
boolean
redeem(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.VoucherInvalidationModel
redeem(VoucherModel voucher, java.lang.String voucherCode, OrderModel order)
void
release(VoucherModel voucher, java.lang.String voucherCode, CartModel cart)
void
release(VoucherModel voucher, java.lang.String voucherCode, OrderModel order)
VoucherInvalidationModel
reserve(VoucherModel voucher, java.lang.String voucherCode, OrderModel order)
-
-
-
Method Detail
-
createVoucherInvalidation
VoucherInvalidationModel createVoucherInvalidation(VoucherModel voucher, java.lang.String voucherCode, OrderModel order)
-
checkVoucherCode
boolean checkVoucherCode(VoucherModel voucher, java.lang.String voucherCode)
Returns true if the specified voucher code is valid for this voucher.- 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.
-
getApplicableEntries
VoucherEntrySet getApplicableEntries(VoucherModel voucher, AbstractOrderModel order)
Returns all positions or parts of positions of the specified abstract order that are eligible for this voucher.- 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
VoucherValue getAppliedValue(VoucherModel voucher, AbstractOrderModel order)
Returns 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).- Parameters:
voucher
- the voucherorder
- the abstract order to get discount value of.- Returns:
- a VoucherValue representing the discount value of this voucher.
-
getDiscountValue
DiscountValue getDiscountValue(VoucherModel voucher, AbstractOrderModel order)
-
getViolatedRestrictions
java.util.List<RestrictionModel> getViolatedRestrictions(VoucherModel voucher, AbstractOrderModel order)
Returns all restrictions that are not fulfilled by the specified abstract order.- 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
java.util.List<RestrictionModel> getViolatedRestrictions(VoucherModel voucher, ProductModel product)
Returns all restrictions that are not fulfilled by the specified product.- 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
java.util.List<java.lang.String> getViolationMessages(VoucherModel voucher, AbstractOrderModel order)
-
getViolationMessages
java.util.List<java.lang.String> getViolationMessages(VoucherModel voucher, ProductModel product)
-
getVoucherValue
VoucherValue getVoucherValue(VoucherModel voucher, AbstractOrderModel order)
-
isApplicable
boolean isApplicable(VoucherModel voucher, AbstractOrderModel order)
Returns 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.- 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
boolean isApplicable(VoucherModel voucher, ProductModel product)
Returns 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.- 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
boolean isReservable(VoucherModel voucher, java.lang.String voucherCode, UserModel user)
-
isReservable
boolean isReservable(VoucherModel voucher, java.lang.String voucherCode, AbstractOrderModel order)
-
redeem
boolean redeem(VoucherModel voucher, java.lang.String voucherCode, CartModel cart) throws JaloPriceFactoryException
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.- Throws:
JaloPriceFactoryException
-
redeem
VoucherInvalidationModel redeem(VoucherModel voucher, java.lang.String voucherCode, OrderModel order)
-
release
void release(VoucherModel voucher, java.lang.String voucherCode, OrderModel order) throws ConsistencyCheckException
- Throws:
ConsistencyCheckException
-
release
void release(VoucherModel voucher, java.lang.String voucherCode, CartModel cart) throws JaloPriceFactoryException
- Throws:
JaloPriceFactoryException
-
reserve
VoucherInvalidationModel reserve(VoucherModel voucher, java.lang.String voucherCode, OrderModel order)
-
generateVoucherCode
java.lang.String generateVoucherCode(VoucherModel voucher) throws java.security.NoSuchAlgorithmException
- Throws:
java.security.NoSuchAlgorithmException
-
-