当前位置: 首页>>代码示例>>Java>>正文


Java ProductPromoWorker类代码示例

本文整理汇总了Java中org.ofbiz.order.shoppingcart.product.ProductPromoWorker的典型用法代码示例。如果您正苦于以下问题:Java ProductPromoWorker类的具体用法?Java ProductPromoWorker怎么用?Java ProductPromoWorker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProductPromoWorker类属于org.ofbiz.order.shoppingcart.product包,在下文中一共展示了ProductPromoWorker类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleNewUser

import org.ofbiz.order.shoppingcart.product.ProductPromoWorker; //导入依赖的package包/类
public void handleNewUser(LocalDispatcher dispatcher) throws CartItemModifyException {
    String partyId = this.getPartyId();
    if (UtilValidate.isNotEmpty(partyId)) {
        // recalculate all prices
        for (ShoppingCartItem cartItem : this) {
            cartItem.updatePrice(dispatcher, this);
        }

        // check all promo codes, remove on failed check
        Iterator<String> promoCodeIter = this.productPromoCodes.iterator();
        while (promoCodeIter.hasNext()) {
            String promoCode = promoCodeIter.next();
            String checkResult = ProductPromoWorker.checkCanUsePromoCode(promoCode, partyId, this.getDelegator(), locale);
            if (checkResult != null) {
                promoCodeIter.remove();
                Debug.logWarning(UtilProperties.getMessage(resource_error,"OrderOnUserChangePromoCodeWasRemovedBecause", UtilMisc.toMap("checkResult",checkResult), locale), module);
            }
        }

        // rerun promotions
        ProductPromoWorker.doPromotions(this, dispatcher);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:24,代码来源:ShoppingCart.java

示例2: addProductPromoCode

import org.ofbiz.order.shoppingcart.product.ProductPromoWorker; //导入依赖的package包/类
/** Adds a promotion code to the cart, checking if it is valid. If it is valid this will return null, otherwise it will return a message stating why it was not valid
 * @param productPromoCodeId The promotion code to check and add
 * @return String that is null if valid, and added to cart, or an error message of the code was not valid and not added to the cart.
 */
public String addProductPromoCode(String productPromoCodeId, LocalDispatcher dispatcher) {
    if (this.productPromoCodes.contains(productPromoCodeId)) {
        return UtilProperties.getMessage(resource_error, "productpromoworker.promotion_code_already_been_entered", UtilMisc.toMap("productPromoCodeId", productPromoCodeId), locale);
    }
    if (!this.getDoPromotions()) {
        this.productPromoCodes.add(productPromoCodeId);
        return null;
    }
    // if the promo code requires it make sure the code is valid
    String checkResult = ProductPromoWorker.checkCanUsePromoCode(productPromoCodeId, this.getPartyId(), this.getDelegator(), this, locale);
    if (checkResult == null) {
        this.productPromoCodes.add(productPromoCodeId);
        // new promo code, re-evaluate promos
        ProductPromoWorker.doPromotions(this, dispatcher);
        return null;
    } else {
        return checkResult;
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:24,代码来源:ShoppingCart.java

示例3: handleNewUser

import org.ofbiz.order.shoppingcart.product.ProductPromoWorker; //导入依赖的package包/类
public void handleNewUser(LocalDispatcher dispatcher) throws CartItemModifyException {
    String partyId = this.getPartyId();
    if (UtilValidate.isNotEmpty(partyId)) {
        // recalculate all prices
        for(ShoppingCartItem cartItem : this) {
            cartItem.updatePrice(dispatcher, this);
        }

        // check all promo codes, remove on failed check
        Iterator<String> promoCodeIter = this.productPromoCodes.iterator();
        while (promoCodeIter.hasNext()) {
            String promoCode = promoCodeIter.next();
            String checkResult = ProductPromoWorker.checkCanUsePromoCode(promoCode, partyId, this.getDelegator(), locale);
            if (checkResult != null) {
                promoCodeIter.remove();
                Debug.logWarning(UtilProperties.getMessage(resource_error,"OrderOnUserChangePromoCodeWasRemovedBecause", UtilMisc.toMap("checkResult",checkResult), locale), module);
            }
        }

        // rerun promotions
        ProductPromoWorker.doPromotions(this, dispatcher);
    }
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:24,代码来源:ShoppingCart.java

示例4: getShipEstimate

import org.ofbiz.order.shoppingcart.product.ProductPromoWorker; //导入依赖的package包/类
public static String getShipEstimate(HttpServletRequest request, HttpServletResponse response) {
    ShoppingCart cart = (ShoppingCart) request.getSession().getAttribute("shoppingCart");
    LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
    Delegator delegator = (Delegator) request.getAttribute("delegator");

    int shipGroups = cart.getShipGroupSize();
    for (int i = 0; i < shipGroups; i++) {
        String shipmentMethodTypeId = cart.getShipmentMethodTypeId(i);
        if (UtilValidate.isEmpty(shipmentMethodTypeId)) {
            continue;
        }
        Map<String, Object> result = getShipGroupEstimate(dispatcher, delegator, cart, i);
        ServiceUtil.getMessages(request, result, null, "", "", "", "", null, null);
        if (result.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_ERROR)) {
            return "error";
        }

        BigDecimal shippingTotal = (BigDecimal) result.get("shippingTotal");
        if (shippingTotal == null) {
            shippingTotal = BigDecimal.ZERO;
        }
        cart.setItemShipGroupEstimate(shippingTotal, i);
    }

    ProductPromoWorker.doPromotions(cart, dispatcher);
    // all done
    return "success";
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:29,代码来源:ShippingEvents.java

示例5: doManualPromotions

import org.ofbiz.order.shoppingcart.product.ProductPromoWorker; //导入依赖的package包/类
public static String doManualPromotions(HttpServletRequest request, HttpServletResponse response) {
    LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
    Delegator delegator = (Delegator) request.getAttribute("delegator");
    ShoppingCart cart = getCartObject(request);
    List<GenericValue> manualPromotions = new LinkedList<GenericValue>();

    // iterate through the context and find all keys that start with "productPromoId_"
    Map<String, Object> context = UtilHttp.getParameterMap(request);
    String keyPrefix = "productPromoId_";
    for (int i = 1; i <= 50; i++) {
        String productPromoId = (String)context.get(keyPrefix + i);
        if (UtilValidate.isNotEmpty(productPromoId)) {
            try {
                GenericValue promo = EntityQuery.use(delegator).from("ProductPromo").where("productPromoId", productPromoId).queryOne();
                if (promo != null) {
                    manualPromotions.add(promo);
                }
            } catch (GenericEntityException gee) {
                request.setAttribute("_ERROR_MESSAGE_", gee.getMessage());
                return "error";
            }
        } else {
            break;
        }
    }
    ProductPromoWorker.doPromotions(cart, manualPromotions, dispatcher);
    return "success";
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:29,代码来源:ShoppingCartEvents.java

示例6: doManualPromotions

import org.ofbiz.order.shoppingcart.product.ProductPromoWorker; //导入依赖的package包/类
public static String doManualPromotions(HttpServletRequest request, HttpServletResponse response) {
    LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
    Delegator delegator = (Delegator) request.getAttribute("delegator");
    ShoppingCart cart = getCartObject(request);
    List<GenericValue> manualPromotions = new LinkedList<GenericValue>();

    // iterate through the context and find all keys that start with "productPromoId_"
    Map<String, Object> context = UtilHttp.getParameterMap(request);
    String keyPrefix = "productPromoId_";
    for (int i = 1; i <= 50; i++) {
        String productPromoId = (String)context.get(keyPrefix + i);
        if (UtilValidate.isNotEmpty(productPromoId)) {
            try {
                GenericValue promo = delegator.findOne("ProductPromo", UtilMisc.toMap("productPromoId", productPromoId), false);
                if (promo != null) {
                    manualPromotions.add(promo);
                }
            } catch (GenericEntityException gee) {
                request.setAttribute("_ERROR_MESSAGE_", gee.getMessage());
                return "error";
            }
        } else {
            break;
        }
    }
    ProductPromoWorker.doPromotions(cart, manualPromotions, dispatcher);
    return "success";
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:29,代码来源:ShoppingCartEvents.java

示例7: setDesiredAlternateGwpProductId

import org.ofbiz.order.shoppingcart.product.ProductPromoWorker; //导入依赖的package包/类
/** For GWP Promotions with multiple alternatives, selects an alternative to the current GWP */
public static String setDesiredAlternateGwpProductId(HttpServletRequest request, HttpServletResponse response) {
    ShoppingCart cart = getCartObject(request);
    Delegator delegator = (Delegator) request.getAttribute("delegator");
    LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
    String alternateGwpProductId = request.getParameter("alternateGwpProductId");
    String alternateGwpLineStr = request.getParameter("alternateGwpLine");
    Locale locale = UtilHttp.getLocale(request);

    if (UtilValidate.isEmpty(alternateGwpProductId)) {
        request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderCouldNotSelectAlternateGiftNoAlternateGwpProductIdPassed", locale));
        return "error";
    }
    if (UtilValidate.isEmpty(alternateGwpLineStr)) {
        request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderCouldNotSelectAlternateGiftNoAlternateGwpLinePassed", locale));
        return "error";
    }

    int alternateGwpLine = 0;
    try {
        alternateGwpLine = Integer.parseInt(alternateGwpLineStr);
    } catch (Exception e) {
        request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderCouldNotSelectAlternateGiftAlternateGwpLineIsNotAValidNumber", locale));
        return "error";
    }

    ShoppingCartItem cartLine = cart.findCartItem(alternateGwpLine);
    if (cartLine == null) {
        request.setAttribute("_ERROR_MESSAGE_", "Could not select alternate gift, no cart line item found for #" + alternateGwpLine + ".");
        return "error";
    }

    if (cartLine.getIsPromo()) {
        // note that there should just be one promo adjustment, the reversal of the GWP, so use that to get the promo action key
        Iterator<GenericValue> checkOrderAdjustments = UtilMisc.toIterator(cartLine.getAdjustments());
        while (checkOrderAdjustments != null && checkOrderAdjustments.hasNext()) {
            GenericValue checkOrderAdjustment = checkOrderAdjustments.next();
            if (UtilValidate.isNotEmpty(checkOrderAdjustment.getString("productPromoId")) &&
                    UtilValidate.isNotEmpty(checkOrderAdjustment.getString("productPromoRuleId")) &&
                    UtilValidate.isNotEmpty(checkOrderAdjustment.getString("productPromoActionSeqId"))) {
                GenericPK productPromoActionPk = delegator.makeValidValue("ProductPromoAction", checkOrderAdjustment).getPrimaryKey();
                cart.setDesiredAlternateGiftByAction(productPromoActionPk, alternateGwpProductId);
                if (cart.getOrderType().equals("SALES_ORDER")) {
                    org.ofbiz.order.shoppingcart.product.ProductPromoWorker.doPromotions(cart, dispatcher);
                }
                return "success";
            }
        }
    }

    request.setAttribute("_ERROR_MESSAGE_", "Could not select alternate gift, cart line item found for #" + alternateGwpLine + " does not appear to be a valid promotional gift.");
    return "error";
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:54,代码来源:ShoppingCartEvents.java

示例8: setCheckOutOptions

import org.ofbiz.order.shoppingcart.product.ProductPromoWorker; //导入依赖的package包/类
public Map<String, Object> setCheckOutOptions(String shippingMethod, String shippingContactMechId, Map<String, Map<String, Object>> selectedPaymentMethods,
        List<String> singleUsePayments, String billingAccountId, String shippingInstructions,
        String orderAdditionalEmails, String maySplit, String giftMessage, String isGift, String internalCode, String shipBeforeDate, String shipAfterDate) {
    List<String> errorMessages = new ArrayList<String>();
    Map<String, Object> result = null;
    String errMsg = null;


    if (UtilValidate.isNotEmpty(this.cart)) {
        // set the general shipping options and method
        errorMessages.addAll(setCheckOutShippingOptionsInternal(shippingMethod, shippingInstructions,
                orderAdditionalEmails, maySplit, giftMessage, isGift, internalCode, shipBeforeDate, shipAfterDate));

        // set the shipping address
        errorMessages.addAll(setCheckOutShippingAddressInternal(shippingContactMechId));

        // Recalc shipping costs before setting payment
        Map<String, Object> shipEstimateMap = ShippingEvents.getShipGroupEstimate(dispatcher, delegator, cart, 0);
        BigDecimal shippingTotal = (BigDecimal) shipEstimateMap.get("shippingTotal");
        if (shippingTotal == null) {
            shippingTotal = BigDecimal.ZERO;
        }
        cart.setItemShipGroupEstimate(shippingTotal, 0);
        ProductPromoWorker.doPromotions(cart, dispatcher);

        //Recalc tax before setting payment
        try {
            this.calcAndAddTax();
        } catch (GeneralException e) {
            Debug.logError(e, module);
        }
        // set the payment method(s) option
        errorMessages.addAll(setCheckOutPaymentInternal(selectedPaymentMethods, singleUsePayments, billingAccountId));

    } else {
        errMsg = UtilProperties.getMessage(resource_error,"checkhelper.no_items_in_cart", (cart != null ? cart.getLocale() : Locale.getDefault()));
        errorMessages.add(errMsg);
    }

    if (errorMessages.size() == 1) {
        result = ServiceUtil.returnError(errorMessages.get(0).toString());
    } else if (errorMessages.size() > 0) {
        result = ServiceUtil.returnError(errorMessages);
    } else {
        result = ServiceUtil.returnSuccess();
    }

    return result;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:50,代码来源:CheckOutHelper.java


注:本文中的org.ofbiz.order.shoppingcart.product.ProductPromoWorker类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。