@Override public PromotionStatusEnum isApplicable(OrderRequest request) { if (log.isDebugEnabled()) { log.debug( "Checking if BuyWorthXGetYRsOffOnZCategoryRuleImpl applies on order : " + request.getOrderId()); } Money orderValue = new Money(request.getOrderValue()); if (request.isValidClient(client_list)) { if (orderValue.gteq(minOrderValue)) { if (request.isAllProductsInCategory(categories)) { return PromotionStatusEnum.SUCCESS; } return PromotionStatusEnum.CATEGORY_MISMATCH; } return PromotionStatusEnum.LESS_ORDER_AMOUNT; } return PromotionStatusEnum.INVALID_CLIENT; }
@Override public void init(RuleConfiguration ruleConfig) { minOrderValue = new Money( BigDecimal.valueOf( Double.valueOf( ruleConfig.getConfigItemValue(RuleConfigConstants.MIN_ORDER_VALUE)))); fixedRsOff = new Money( BigDecimal.valueOf( Double.valueOf( ruleConfig.getConfigItemValue(RuleConfigConstants.FIXED_DISCOUNT_RS_OFF)))); StrTokenizer strTokCategories = new StrTokenizer(ruleConfig.getConfigItemValue(RuleConfigConstants.CATEGORY_LIST), ","); categories = StringToIntegerList.convert((List<String>) strTokCategories.getTokenList()); StrTokenizer strTokClients = new StrTokenizer(ruleConfig.getConfigItemValue(RuleConfigConstants.CLIENT_LIST), ","); client_list = StringToIntegerList.convert((List<String>) strTokClients.getTokenList()); log.info( "minOrderValue : " + minOrderValue.toString() + ", fixedRsOff : " + fixedRsOff.toString()); }