use of org.broadleafcommerce.core.offer.domain.OfferOfferRuleXref in project BroadleafCommerce by BroadleafCommerce.
the class PromotionMessageDTOServiceImpl method getCustomerRule.
protected String getCustomerRule(Offer offer) {
if (offer != null) {
Map<String, OfferOfferRuleXref> offerMatchRuleXrefs = offer.getOfferMatchRulesXref();
OfferOfferRuleXref customerRuleXref = offerMatchRuleXrefs.get(RuleIdentifier.CUSTOMER_FIELD_KEY);
if (customerRuleXref != null && customerRuleXref.getOfferRule() != null) {
OfferRule customerOfferRule = customerRuleXref.getOfferRule();
return customerOfferRule.getMatchRule();
}
}
return null;
}
use of org.broadleafcommerce.core.offer.domain.OfferOfferRuleXref in project BroadleafCommerce by BroadleafCommerce.
the class AbstractBaseProcessor method couldOfferApplyToTimePeriod.
protected boolean couldOfferApplyToTimePeriod(Offer offer) {
boolean appliesToTimePeriod = false;
String rule = null;
OfferOfferRuleXref ruleXref = offer.getOfferMatchRulesXref().get(OfferRuleType.TIME.getType());
if (ruleXref != null && ruleXref.getOfferRule() != null) {
rule = ruleXref.getOfferRule().getMatchRule();
}
if (rule != null) {
TimeZone timeZone = getOfferTimeZoneProcessor().getTimeZone(offer);
TimeDTO timeDto = new TimeDTO(SystemTime.asCalendar(timeZone));
HashMap<String, Object> vars = new HashMap<String, Object>();
vars.put("time", timeDto);
Boolean expressionOutcome = executeExpression(rule, vars);
if (expressionOutcome != null && expressionOutcome) {
appliesToTimePeriod = true;
}
} else {
appliesToTimePeriod = true;
}
return appliesToTimePeriod;
}
use of org.broadleafcommerce.core.offer.domain.OfferOfferRuleXref in project BroadleafCommerce by BroadleafCommerce.
the class AbstractBaseProcessor method couldOfferApplyToRequestDTO.
protected boolean couldOfferApplyToRequestDTO(Offer offer, RequestDTO requestDTO) {
boolean appliesToRequestRule = false;
String rule = null;
OfferOfferRuleXref ruleXref = offer.getOfferMatchRulesXref().get(OfferRuleType.REQUEST.getType());
if (ruleXref != null && ruleXref.getOfferRule() != null) {
rule = ruleXref.getOfferRule().getMatchRule();
}
if (rule != null) {
HashMap<String, Object> vars = new HashMap<String, Object>();
vars.put("request", requestDTO);
Boolean expressionOutcome = executeExpression(rule, vars);
if (expressionOutcome != null && expressionOutcome) {
appliesToRequestRule = true;
}
} else {
appliesToRequestRule = true;
}
return appliesToRequestRule;
}
use of org.broadleafcommerce.core.offer.domain.OfferOfferRuleXref in project BroadleafCommerce by BroadleafCommerce.
the class OrderOfferProcessorImpl method couldOfferApplyToOrder.
/**
* Private method which executes the appliesToOrderRules in the Offer to determine if this offer
* can be applied to the Order, OrderItem, or FulfillmentGroup.
*
* @param offer
* @param order
* @param promotableOrderItem
* @param promotableFulfillmentGroup
* @return true if offer can be applied, otherwise false
*/
protected boolean couldOfferApplyToOrder(Offer offer, PromotableOrder promotableOrder, PromotableOrderItem promotableOrderItem, PromotableFulfillmentGroup promotableFulfillmentGroup) {
boolean appliesToItem = false;
String rule = null;
OfferOfferRuleXref orderRule = offer.getOfferMatchRulesXref().get(OfferRuleType.ORDER.getType());
if (orderRule != null && orderRule.getOfferRule() != null) {
rule = orderRule.getOfferRule().getMatchRule();
}
if (rule != null) {
HashMap<String, Object> vars = new HashMap<String, Object>();
promotableOrder.updateRuleVariables(vars);
vars.put("offer", offer);
if (promotableFulfillmentGroup != null) {
promotableFulfillmentGroup.updateRuleVariables(vars);
}
if (promotableOrderItem != null) {
promotableOrderItem.updateRuleVariables(vars);
}
Boolean expressionOutcome = executeExpression(rule, vars);
if (expressionOutcome != null && expressionOutcome) {
appliesToItem = true;
}
} else {
appliesToItem = true;
}
return appliesToItem;
}
use of org.broadleafcommerce.core.offer.domain.OfferOfferRuleXref in project BroadleafCommerce by BroadleafCommerce.
the class AbstractBaseProcessor method couldOfferApplyToCustomer.
/**
* Private method which executes the appliesToCustomerRules in the Offer to determine if this Offer
* can be applied to the Customer.
*
* @param offer
* @param customer
* @return true if offer can be applied, otherwise false
*/
protected boolean couldOfferApplyToCustomer(Offer offer, Customer customer) {
boolean appliesToCustomer = false;
String rule = null;
OfferOfferRuleXref ruleXref = offer.getOfferMatchRulesXref().get(OfferRuleType.CUSTOMER.getType());
if (ruleXref != null && ruleXref.getOfferRule() != null) {
rule = ruleXref.getOfferRule().getMatchRule();
}
if (rule != null) {
HashMap<String, Object> vars = new HashMap<String, Object>();
vars.put("customer", customer);
Boolean expressionOutcome = executeExpression(rule, vars);
if (expressionOutcome != null && expressionOutcome) {
appliesToCustomer = true;
}
} else {
appliesToCustomer = true;
}
return appliesToCustomer;
}
Aggregations