在AbstractOrderEntry类中使用/分配isRejected属性是什么?如何使用?

时间:2019-04-08 10:33:01

标签: hybris

最近,我遇到了“没有为产品定义价格” JaloPriceFactoryException。当调用“ getBasePrice”方法时,它来自Europe1PriceFactory类。

我已经尝试过挖掘,但是无法找到有关此状态的任何详细信息。在代码中,有一个if语句根据OrderEntry -s的'giveAway'或'rejected'状态进行处理。

我设法找到了有关'giveAway'状态的详细信息,并找到了可以对其进行切换的位置(后台,hmc)。

    public PriceValue getBasePrice(AbstractOrderEntry entry) throws JaloPriceFactoryException {
        SessionContext ctx = this.getSession().getSessionContext();
        AbstractOrder order = entry.getOrder(ctx);
        Currency currency = null;
        EnumerationValue productGroup = null;
        User user = null;
        EnumerationValue userGroup = null;
        Unit unit = null;
        long quantity = 0L;
        boolean net = false;
        Date date = null;
        Product product = entry.getProduct();
        boolean giveAwayMode = entry.isGiveAway(ctx);
        boolean entryIsRejected = entry.isRejected(ctx);
        PriceRow row;
        if (giveAwayMode && entryIsRejected) {
            row = null;
        } else {
            row = this.matchPriceRowForPrice(ctx, product, productGroup = this.getPPG(ctx, product), user = order.getUser(), userGroup = this.getUPG(ctx, user), quantity = entry.getQuantity(ctx), unit = entry.getUnit(ctx), currency = order.getCurrency(ctx), date = order.getDate(ctx), net = order.isNet(), giveAwayMode);
        }

        if (row != null) {
            Currency rowCurr = row.getCurrency();
            double price;
            if (currency.equals(rowCurr)) {
                price = row.getPriceAsPrimitive() / (double)row.getUnitFactorAsPrimitive();
            } else {
                price = rowCurr.convert(currency, row.getPriceAsPrimitive() / (double)row.getUnitFactorAsPrimitive());
            }

            Unit priceUnit = row.getUnit();
            Unit entryUnit = entry.getUnit();
            double convertedPrice = priceUnit.convertExact(entryUnit, price);
            return new PriceValue(currency.getIsoCode(), convertedPrice, row.isNetAsPrimitive());
        } else if (giveAwayMode) {
            return new PriceValue(order.getCurrency(ctx).getIsoCode(), 0.0D, order.isNet());
        } else {
            String msg = Localization.getLocalizedString("exception.europe1pricefactory.getbaseprice.jalopricefactoryexception1", new Object[]{product, productGroup, user, userGroup, Long.toString(quantity), unit, currency, date, Boolean.toString(net)});
            throw new JaloPriceFactoryException(msg, 0);
        }

isRejected的值来自AbstractOrderEntry类,该类从会话中获取值。

boolean entryIsRejected = entry.isRejected(ctx);
    public Boolean isRejected(SessionContext ctx) {
        Boolean result = super.isRejected(ctx);
        return result != null ? result : Boolean.FALSE;
    }

我知道,当购物车中有标记为要重新计算的产品时,就会运行购物车重新计算服务。 这些条件是:

    Product is be added to the cart
    Product is be removed from the cart
    User is changed
    Currency is changed

但是这些都不能再现被拒绝的状态。

0 个答案:

没有答案