Class DefaultCouponService
- java.lang.Object
-
- de.hybris.platform.couponservices.services.impl.DefaultCouponService
-
- All Implemented Interfaces:
CouponService
- Direct Known Subclasses:
DefaultCustomerCouponService
public class DefaultCouponService extends java.lang.Object implements CouponService
Default CouponService implementation
-
-
Constructor Summary
Constructors Constructor Description DefaultCouponService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected CouponResponseassertCouponCodeInOrder(java.lang.String couponCode, AbstractOrderModel order)protected java.util.function.Predicate<java.lang.String>checkMatch(AbstractCouponModel coupon, java.lang.String couponCode)protected java.lang.StringclearCouponCode(java.lang.String couponCode)protected booleancontainsCouponCode(java.lang.String couponCode, AbstractOrderModel order)returns true if the given couponCode is part of the given orderprotected BaseSiteServicegetBaseSiteService()protected CalculationServicegetCalculationService()protected CouponCodeGenerationServicegetCouponCodeGenerationService()java.util.Optional<AbstractCouponModel>getCouponForCode(java.lang.String couponCode)Returns Coupon Model object for a given coupon codeprotected CouponManagementServicegetCouponManagementService()protected ModelServicegetModelService()protected java.util.Collection<PromotionGroupModel>getPromotionGroups()protected PromotionsServicegetPromotionsService()java.util.Optional<AbstractCouponModel>getValidatedCouponForCode(java.lang.String couponCode)Returns Coupon Model object for a given coupon code with validationprotected voidrecalculateOrder(AbstractOrderModel order)Recalculates the given order and updates the promotions.CouponResponseredeemCoupon(java.lang.String couponCode, CartModel cart)Redeem the coupon code associated with the cart.CouponResponseredeemCoupon(java.lang.String couponCode, OrderModel order)Create a coupon redemption instance for the coupon redeemed for the order.protected voidredeemCouponCode(CartModel cart, java.lang.String clearedCouponCode, CouponResponse response)voidreleaseCouponCode(java.lang.String couponCode, AbstractOrderModel order)Release the coupon code from given cart.protected voidremoveCouponAndTriggerCalculation(java.lang.String couponCode, AbstractOrderModel order)voidsetBaseSiteService(BaseSiteService baseSiteService)voidsetCalculationService(CalculationService calculationService)voidsetCouponCodeGenerationService(CouponCodeGenerationService couponCodeGenerationService)voidsetCouponManagementService(CouponManagementService couponManagementService)voidsetModelService(ModelService modelService)voidsetPromotionsService(PromotionsService promotionsService)CouponResponsevalidateCouponCode(java.lang.String couponCode, UserModel user)Validate if providedcouponCodeis valid.CouponResponseverifyCouponCode(java.lang.String couponCode, AbstractOrderModel order)Verify if providedcouponCodeis valid.
-
-
-
Method Detail
-
verifyCouponCode
public CouponResponse verifyCouponCode(java.lang.String couponCode, AbstractOrderModel order)
Description copied from interface:CouponServiceVerify if providedcouponCodeis valid.- Specified by:
verifyCouponCodein interfaceCouponService- Parameters:
couponCode- coupon code to validateorder- order for which coupon should be validated- Returns:
- CouponResponse containing true if coupon code is valid or false if not.
-
validateCouponCode
public CouponResponse validateCouponCode(java.lang.String couponCode, UserModel user)
Description copied from interface:CouponServiceValidate if providedcouponCodeis valid.- Specified by:
validateCouponCodein interfaceCouponService- Parameters:
couponCode- coupon code to validateuser- user for which coupon should be validated- Returns:
- CouponResponse containing true if coupon code is valid or false if not.
-
redeemCoupon
public CouponResponse redeemCoupon(java.lang.String couponCode, CartModel cart)
Description copied from interface:CouponServiceRedeem the coupon code associated with the cart.- Specified by:
redeemCouponin interfaceCouponService- Parameters:
couponCode- Coupon code to redeemcart-CartModelto redeem coupon- Returns:
- CouponResponse containing true if coupon code has been redeem at cart or false if not.
-
redeemCouponCode
protected void redeemCouponCode(CartModel cart, java.lang.String clearedCouponCode, CouponResponse response)
-
redeemCoupon
public CouponResponse redeemCoupon(java.lang.String couponCode, OrderModel order)
Description copied from interface:CouponServiceCreate a coupon redemption instance for the coupon redeemed for the order.- Specified by:
redeemCouponin interfaceCouponService- Parameters:
couponCode- Coupon code to redeemorder-OrderModelto redeem coupon- Returns:
- CouponResponse containing true when coupon redemption instance has been created if a coupon has been redeemed successfully.
-
clearCouponCode
protected java.lang.String clearCouponCode(java.lang.String couponCode)
-
assertCouponCodeInOrder
protected CouponResponse assertCouponCodeInOrder(java.lang.String couponCode, AbstractOrderModel order)
-
containsCouponCode
protected boolean containsCouponCode(java.lang.String couponCode, AbstractOrderModel order)returns true if the given couponCode is part of the given order- Parameters:
couponCode- the couponCode to checkorder- the abstract order to check
-
checkMatch
protected java.util.function.Predicate<java.lang.String> checkMatch(AbstractCouponModel coupon, java.lang.String couponCode)
-
recalculateOrder
protected void recalculateOrder(AbstractOrderModel order)
Recalculates the given order and updates the promotions. (callsCalculationService.calculate(AbstractOrderModel)andPromotionsService.updatePromotions(Collection, AbstractOrderModel)- Throws:
CouponServiceException- if any errors happen during recalculation
-
getCouponForCode
public java.util.Optional<AbstractCouponModel> getCouponForCode(java.lang.String couponCode)
Description copied from interface:CouponServiceReturns Coupon Model object for a given coupon code- Specified by:
getCouponForCodein interfaceCouponService- Parameters:
couponCode- Coupon code to get coupon details for- Returns:
AbstractCouponModel
-
getValidatedCouponForCode
public java.util.Optional<AbstractCouponModel> getValidatedCouponForCode(java.lang.String couponCode)
Description copied from interface:CouponServiceReturns Coupon Model object for a given coupon code with validation- Specified by:
getValidatedCouponForCodein interfaceCouponService- Parameters:
couponCode- Coupon code to get coupon details for- Returns:
AbstractCouponModel
-
releaseCouponCode
public void releaseCouponCode(java.lang.String couponCode, AbstractOrderModel order)Description copied from interface:CouponServiceRelease the coupon code from given cart.- Specified by:
releaseCouponCodein interfaceCouponService- Parameters:
couponCode- Coupon code to releaseorder-AbstractOrderModelto release the coupon from
-
removeCouponAndTriggerCalculation
protected void removeCouponAndTriggerCalculation(java.lang.String couponCode, AbstractOrderModel order)
-
getPromotionGroups
protected java.util.Collection<PromotionGroupModel> getPromotionGroups()
-
getCouponManagementService
protected CouponManagementService getCouponManagementService()
-
setCouponManagementService
public void setCouponManagementService(CouponManagementService couponManagementService)
-
getCalculationService
protected CalculationService getCalculationService()
-
setCalculationService
public void setCalculationService(CalculationService calculationService)
-
getPromotionsService
protected PromotionsService getPromotionsService()
-
setPromotionsService
public void setPromotionsService(PromotionsService promotionsService)
-
getBaseSiteService
protected BaseSiteService getBaseSiteService()
-
setBaseSiteService
public void setBaseSiteService(BaseSiteService baseSiteService)
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
getCouponCodeGenerationService
protected CouponCodeGenerationService getCouponCodeGenerationService()
-
setCouponCodeGenerationService
public void setCouponCodeGenerationService(CouponCodeGenerationService couponCodeGenerationService)
-
-