- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经实现了 BXGY 自定义促销。为了简化我的情况,假设您的购物车中有 X 个产品后,您将获得 Y 个免费产品。
如果我的购物车中有 2*X 件合格产品,则预期行为是获得 2*Y 件免费产品。
我的问题是多次触发该促销 Activity 。如果我将多重发射的最大计数设置为 4,则尽管我的购物车中有 2*X 个产品,但操作(获取免费产品)会被激活 4 次。
所以我的结论是,我需要消费合格的产品(包含该产品的条目),就像消费用户获得的免费产品一样,这样他们就无法参与其他促销 Activity 的资格。
我的研究结论是,我需要使用 (YFreeGift)RAOAction 中的条目,但随后我需要检索所有条件产品,但我不认为这是正确的方法(条件在行动中)。
有人知道如何使用符合资格的条目吗?
BXGY 的条件转换器(我也有强制合格产品,但这对于这个问题并不重要)
public class RuleHeinekenBXGYFQualifyingProductsConditionTranslator implements RuleConditionTranslator
{
@Override
public RuleIrCondition translate(RuleCompilerContext context, RuleConditionData ruleCondition, RuleConditionDefinitionData conditionDefinition) throws RuleCompilerException
{
List<String> mandatoryProducts = (List) getConditionParameterValue(ruleCondition, "mandatoryQualifyingProducts");
List<String> alternativeProducts = (List) getConditionParameterValue(ruleCondition, "alternativeQualifyingProducts");
Integer qualifyingCount = (Integer) getConditionParameterValue(ruleCondition, "qualifyingCount");
if(isEmpty(mandatoryProducts) && isEmpty(alternativeProducts) || qualifyingCount == null || qualifyingCount <= 0)
throw new PromotionConditionParametersValidationException();
String cartRAO = context.generateVariable(CartRAO.class);
List<RuleIrCondition> mandatoryProductsConditions = getMandatoryProductsConditions(context, mandatoryProducts, cartRAO);
List<RuleIrCondition> qualifyingCountCondition = getQualifyingCountCondition(context, qualifyingCount, cartRAO);
RuleIrGroupCondition qualifyingConditions = new RuleIrGroupCondition();
qualifyingConditions.setOperator(RuleIrGroupOperator.AND);
qualifyingConditions.setChildren(listUnion(mandatoryProductsConditions, qualifyingCountCondition));
return qualifyingConditions;
}
private List<RuleIrCondition> getQualifyingCountCondition(RuleCompilerContext context, Integer qualifyingCount, String cartRAO)
{
String qualifyingCountRAO = context.generateVariable(QualifyingCountRAO.class);
String promotionCode = context.getRule().getCode();
return getListOfRuleConditions(
aRuleCondition()
.withModelRAO(qualifyingCountRAO)
.withAttribute("promotionCode")
.withOperator(EQUAL)
.withValue(promotionCode)
.buildAttributeCondition(),
aRuleCondition()
.withModelRAO(qualifyingCountRAO)
.withAttribute("qualifyingCount")
.withOperator(GREATER_THAN_OR_EQUAL)
.withValue(qualifyingCount)
.buildAttributeCondition(),
aRuleCondition()
.withModelRAO(cartRAO)
.withAttribute("qualifyingCounts")
.withOperator(CONTAINS)
.withTargetVariable(qualifyingCountRAO)
.buildAttributeRelationCondition());
}
private List<RuleIrCondition> getMandatoryProductsConditions(RuleCompilerContext context, List<String> mandatoryProducts, String cartRAO)
{
if(isEmpty(mandatoryProducts))
return emptyList();
return getMapOfQualifyingProductsWithQuantities(mandatoryProducts)
.entrySet().stream()
.map(entry -> getMandatoryProductCondition(context, cartRAO, entry.getKey(), entry.getValue()))
.collect(toList());
}
private RuleIrExistsCondition getMandatoryProductCondition(RuleCompilerContext context, String cartRAO, String product, int qualifyingCount)
{
RuleIrLocalVariablesContainer variablesContainer = context.createLocalContainer();
String containsProductRAO = context.generateLocalVariable(variablesContainer, ProductRAO.class);
String containsOrderEntryRAO = context.generateLocalVariable(variablesContainer, OrderEntryRAO.class);
List<RuleIrCondition> listOfConditions = getListOfRuleConditions(
aRuleCondition()
.withModelRAO(containsProductRAO)
.withAttribute("code")
.withOperator(EQUAL)
.withValue(product)
.buildAttributeCondition(),
aRuleCondition()
.withModelRAO(containsOrderEntryRAO)
.withAttribute("product")
.withOperator(EQUAL)
.withTargetVariable(containsProductRAO)
.buildAttributeRelationCondition(),
aRuleCondition()
.withModelRAO(containsOrderEntryRAO)
.withAttribute("quantity")
.withOperator(GREATER_THAN_OR_EQUAL)
.withValue(qualifyingCount)
.buildAttributeCondition(),
aRuleCondition()
.withModelRAO(cartRAO)
.withAttribute("entries")
.withOperator(CONTAINS)
.withTargetVariable(containsOrderEntryRAO)
.buildAttributeRelationCondition());
RuleIrExistsCondition mandatoryProductsExistCondition = new RuleIrExistsCondition();
mandatoryProductsExistCondition.setVariablesContainer(variablesContainer);
mandatoryProductsExistCondition.setChildren(listOfConditions);
return mandatoryProductsExistCondition;
}
}
最佳答案
Rule Engine provides a mechanism for you to configure a limit on the number of times a rule can trigger Action Items.
The maximum rule executions allow you to control the maximum number of times the action for a rule can be executed, as long as the conditions are met. For all out-of-the-box promotions actions, the value of this attribute should be set to one.
查看 RuleConfigurationRRD 属性。
取自help.hybris.com。
关于java - BXGY促销多重火爆-合格订单消耗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44238254/
我是一名优秀的程序员,十分优秀!