Class DefaultPromotionActionService

    • Constructor Detail

      • DefaultPromotionActionService

        public DefaultPromotionActionService()
    • Method Detail

      • findExistingPromotionResultModel

        protected PromotionResultModel findExistingPromotionResultModel​(AbstractRuleEngineRuleModel rule,
                                                                        AbstractOrderModel order)
        Tries to find an existing promotion result that has been fired by the same rule as the given rule.
        Parameters:
        rule - the rule
        order - the order
        Returns:
        an existing promotion result or null if none is found
      • createConsumedEntries

        protected java.util.Collection<PromotionOrderEntryConsumedModel> createConsumedEntries​(AbstractRuleActionRAO action)
        Creates a list of consumed order entries for the given action.
        Parameters:
        action - Action for which consumed order entries should be created
        Returns:
        Collection of created consumed order entries for given action
      • createDiscountValue

        public void createDiscountValue​(DiscountRAO discountRao,
                                        java.lang.String code,
                                        AbstractOrderModel order)
        Description copied from interface: PromotionActionService
        Creates a DiscountValue from the given discountRao and adds it to the given order. Note: The order is not saved!
        Specified by:
        createDiscountValue in interface PromotionActionService
        Parameters:
        discountRao - the discountRao to take the values from
        code - the code for the new DiscountValue (e.g. UUID from the respective AbstractPromotionActionModel that creates this discount)
        order - the order to apply the discount value to
      • removeDiscount

        protected boolean removeDiscount​(java.lang.String code,
                                         java.util.List<DiscountValue> discountValuesList,
                                         java.util.function.Consumer<java.util.List<DiscountValue>> setNewDiscountValues)
        Removes the DiscountValue with the given code from the given list of DiscountValue. Then calls setNewDiscountValues handler to process the newly gotten list (already w/o the removed item) of DiscountValue.
        Parameters:
        setNewDiscountValues - if null its method accept(..) is not called.
        Returns:
        true if the DiscountValue is removed, false - otherwise
      • removeOrderLevelDiscount

        protected boolean removeOrderLevelDiscount​(java.lang.String code,
                                                   AbstractOrderModel order)
        Removes the DiscountValue with the given code from the given order. Note: The Order is not saved!
        Returns:
        true if the DiscountValue is removed, false - otherwise
      • removeOrderEntryLevelDiscount

        protected boolean removeOrderEntryLevelDiscount​(java.lang.String code,
                                                        AbstractOrderEntryModel orderEntry)
        Removes the DiscountValue with the given code from the given orderEntry. Note: The OrderEntry is not saved!
        Returns:
        true if the DiscountValue is removed, false - otherwise
      • removeOrderEntryLevelDiscounts

        protected java.util.List<ItemModel> removeOrderEntryLevelDiscounts​(java.lang.String code,
                                                                           AbstractOrderModel order)
        Removes the DiscountValue with the given code from the OrderEntries of the given order. Note: The OrderEntries and Order are not saved!
        Returns:
        list of affected OrderEntries
      • removeDiscountValue

        public java.util.List<ItemModel> removeDiscountValue​(java.lang.String code,
                                                             AbstractOrderModel order)
        Description copied from interface: PromotionActionService
        Removes the DiscountValue with the given code from the given order and its order entries. Returns the list of all modified items (order, order entries). Note: The returned items are not saved!
        Specified by:
        removeDiscountValue in interface PromotionActionService
        Parameters:
        code - the code for the DiscountValue to be removed
        order - the order to remove the discount value from
        Returns:
        all items (order, order entries) that have been modified and need saving
      • createDiscountValue

        public void createDiscountValue​(DiscountRAO discountRao,
                                        java.lang.String code,
                                        AbstractOrderEntryModel orderEntry)
        Description copied from interface: PromotionActionService
        Creates a DiscountValue from the given discountRao and adds it to the given orderEntry. Note: The orderEntry is not saved!
        Specified by:
        createDiscountValue in interface PromotionActionService
        Parameters:
        discountRao - the discountRao to take the values from
        code - the code for the new DiscountValue (e.g. UUID from the respective AbstractPromotionActionModel that creates this discount)
        orderEntry - the orderEntry to apply the discount value to
      • getOrderInternal

        protected AbstractOrderModel getOrderInternal​(AbstractRuleActionRAO action)
        tries to look up the order for the given action.
        Parameters:
        action - the action
        Returns:
        the order or null
      • setExtendedOrderDao

        public void setExtendedOrderDao​(ExtendedOrderDao extendedOrderDao)
      • setModelService

        public void setModelService​(ModelService modelService)
      • getModelService

        protected ModelService getModelService()
      • setCalculationService

        public void setCalculationService​(CalculationService calculationService)
      • getProductDao

        protected ProductDao getProductDao()
      • setProductDao

        public void setProductDao​(ProductDao productDao)
      • setEngineRuleDao

        public void setEngineRuleDao​(EngineRuleDao engineRuleDao)
      • setModuleVersioningService

        public void setModuleVersioningService​(ModuleVersioningService moduleVersioningService)
      • setPromotionResultService

        public void setPromotionResultService​(PromotionResultService promotionResultService)
      • getCartService

        protected CartService getCartService()
      • setCartService

        public void setCartService​(CartService cartService)