⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shoppingcartevents.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        }    }    /** Assign agreement **/    public static String selectAgreement(HttpServletRequest request, HttpServletResponse response) {        GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");        ShoppingCart cart = getCartObject(request);        ShoppingCartHelper cartHelper = new ShoppingCartHelper(delegator, dispatcher, cart);        String agreementId = request.getParameter("agreementId");        Map result = cartHelper.selectAgreement(agreementId);        if (ServiceUtil.isError(result)) {           request.setAttribute("_ERROR_MESSAGE_", ServiceUtil.getErrorMessage(result));           return "error";        }        return "success";    }    /** Assign currency **/    public static String setCurrency(HttpServletRequest request, HttpServletResponse response) {        GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");        ShoppingCart cart = getCartObject(request);        ShoppingCartHelper cartHelper = new ShoppingCartHelper(delegator, dispatcher, cart);        String currencyUomId = request.getParameter("currencyUomId");        Map result = cartHelper.setCurrency(currencyUomId);        if (ServiceUtil.isError(result)) {           request.setAttribute("_ERROR_MESSAGE_", ServiceUtil.getErrorMessage(result));           return "error";        }        return "success";    }    /** Add order term **/    public static String addOrderTerm(HttpServletRequest request, HttpServletResponse response) {        GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");        ShoppingCart cart = getCartObject(request);        ShoppingCartHelper cartHelper = new ShoppingCartHelper(delegator, dispatcher, cart);        String termTypeId = request.getParameter("termTypeId");        String termValue = request.getParameter("termValue");        String termDays = request.getParameter("termDays");        String termIndex = request.getParameter("termIndex");        Locale locale = UtilHttp.getLocale(request);        Double dTermValue = null;        Long lTermDays = null;        if (termValue.trim().equals("")) {            termValue = null;        }        if (termDays.trim().equals("")) {            termDays = null;        }        if (UtilValidate.isEmpty(termTypeId)) {            request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderOrderTermTypeIsRequired", locale));            return "error";        }        if (!UtilValidate.isSignedDouble(termValue)) {            request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderOrderTermValue", UtilMisc.toMap("orderTermValue",UtilValidate.isSignedFloatMsg), locale));            return "error";        }        if (termValue != null) {            dTermValue =new Double(termValue);        }        if (!UtilValidate.isInteger(termDays)) {            request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderOrderTermDays", UtilMisc.toMap("orderTermDays",UtilValidate.isLongMsg), locale));            return "error";        }        if (termDays != null) {            lTermDays = new Long(termDays);        }        if ((termIndex != null) && (termIndex != "-1") && (UtilValidate.isInteger(termIndex))) {            cartHelper.removeOrderTerm(Integer.parseInt(termIndex));        }        Map result = cartHelper.addOrderTerm(termTypeId, dTermValue, lTermDays);        if (ServiceUtil.isError(result)) {            request.setAttribute("_ERROR_MESSAGE_", ServiceUtil.getErrorMessage(result));            return "error";        }        return "success";    }   /** Add order term **/   public static String removeOrderTerm(HttpServletRequest request, HttpServletResponse response) {       GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");       LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");       ShoppingCart cart = getCartObject(request);       ShoppingCartHelper cartHelper = new ShoppingCartHelper(delegator, dispatcher, cart);       String index = request.getParameter("termIndex");       Map result = cartHelper.removeOrderTerm(Integer.parseInt(index));       if (ServiceUtil.isError(result)) {           request.setAttribute("_ERROR_MESSAGE_", ServiceUtil.getErrorMessage(result));           return "error";       }       return "success";   }    /** Initialize order entry from a shopping list **/    public static String loadCartFromShoppingList(HttpServletRequest request, HttpServletResponse response) {        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");        HttpSession session = request.getSession();        GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");        Locale locale = UtilHttp.getLocale(request);        String shoppingListId = request.getParameter("shoppingListId");        ShoppingCart cart = null;        try {            Map outMap = dispatcher.runSync("loadCartFromShoppingList",                    UtilMisc.toMap("shoppingListId", shoppingListId,                    "userLogin", userLogin));            cart = (ShoppingCart)outMap.get("shoppingCart");        } catch(GenericServiceException exc) {            request.setAttribute("_ERROR_MESSAGE_", exc.getMessage());            return "error";        }        session.setAttribute("shoppingCart", cart);        session.setAttribute("productStoreId", cart.getProductStoreId());        session.setAttribute("orderMode", cart.getOrderType());        session.setAttribute("orderPartyId", cart.getOrderPartyId());        return "success";    }    /** Initialize order entry from a quote **/    public static String loadCartFromQuote(HttpServletRequest request, HttpServletResponse response) {        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");        HttpSession session = request.getSession();        GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");        Locale locale = UtilHttp.getLocale(request);        String quoteId = request.getParameter("quoteId");        ShoppingCart cart = null;        try {            Map outMap = dispatcher.runSync("loadCartFromQuote",                    UtilMisc.toMap("quoteId", quoteId,                            "applyQuoteAdjustments", "true",                            "userLogin", userLogin));            cart = (ShoppingCart) outMap.get("shoppingCart");        } catch (GenericServiceException exc) {            request.setAttribute("_ERROR_MESSAGE_", exc.getMessage());            return "error";        }        // Set the cart's default checkout options for a quick checkout        cart.setDefaultCheckoutOptions(dispatcher);        // Make the cart read-only        cart.setReadOnlyCart(true);        session.setAttribute("shoppingCart", cart);        session.setAttribute("productStoreId", cart.getProductStoreId());        session.setAttribute("orderMode", cart.getOrderType());        session.setAttribute("orderPartyId", cart.getOrderPartyId());        return "success";    }    public static String createQuoteFromCart(HttpServletRequest request, HttpServletResponse response) {        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");        HttpSession session = request.getSession();        GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");        String destroyCart = request.getParameter("destroyCart");        ShoppingCart cart = getCartObject(request);        Map result = null;        String quoteId = null;        try {            result = dispatcher.runSync("createQuoteFromCart",                    UtilMisc.toMap("cart", cart,                            "userLogin", userLogin));            quoteId = (String) result.get("quoteId");        } catch (GenericServiceException exc) {            request.setAttribute("_ERROR_MESSAGE_", exc.getMessage());            return "error";        }        if (ServiceUtil.isError(result)) {           request.setAttribute("_ERROR_MESSAGE_", ServiceUtil.getErrorMessage(result));           return "error";        }        request.setAttribute("quoteId", quoteId);        if (destroyCart != null && destroyCart.equals("Y")) {            ShoppingCartEvents.destroyCart(request, response);        }        return "success";    }    public static String createCustRequestFromCart(HttpServletRequest request, HttpServletResponse response) {        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");        HttpSession session = request.getSession();        GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");        String destroyCart = request.getParameter("destroyCart");        ShoppingCart cart = getCartObject(request);        Map result = null;        String custRequestId = null;        try {            result = dispatcher.runSync("createCustRequestFromCart",                    UtilMisc.toMap("cart", cart,                            "userLogin", userLogin));            custRequestId = (String) result.get("custRequestId");        } catch (GenericServiceException exc) {            request.setAttribute("_ERROR_MESSAGE_", exc.getMessage());            return "error";        }        if (ServiceUtil.isError(result)) {           request.setAttribute("_ERROR_MESSAGE_", ServiceUtil.getErrorMessage(result));           return "error";        }        request.setAttribute("custRequestId", custRequestId);        if (destroyCart != null && destroyCart.equals("Y")) {            ShoppingCartEvents.destroyCart(request, response);        }        return "success";    }    /** Initialize order entry **/    public static String initializeOrderEntry(HttpServletRequest request, HttpServletResponse response) {        GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");        HttpSession session = request.getSession();        Security security = (Security) request.getAttribute("security");        GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");        String finalizeMode = (String)session.getAttribute("finalizeMode");        Locale locale = UtilHttp.getLocale(request);        String productStoreId = request.getParameter("productStoreId");        if (UtilValidate.isNotEmpty(productStoreId)) {            session.setAttribute("productStoreId", productStoreId);        }        ShoppingCart cart = getCartObject(request);        // TODO: re-factor and move this inside the ShoppingCart constructor        String orderMode = request.getParameter("orderMode");        if (orderMode != null) {            cart.setOrderType(orderMode);            session.setAttribute("orderMode", orderMode);        } else {            request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderPleaseSelectEitherSaleOrPurchaseOrder", locale));            return "error";        }        // check the selected product store        GenericValue productStore = null;        if (UtilValidate.isNotEmpty(productStoreId)) {            productStore = ProductStoreWorker.getProductStore(productStoreId, delegator);            if (productStore != null) {                // check permission for taking the order                boolean hasPermission = false;                if ((cart.getOrderType().equals("PURCHASE_ORDER")) && (security.hasEntityPermission("ORDERMGR", "_PURCHASE_CREATE", session))) {                    hasPermission = true;                } else if (cart.getOrderType().equals("SALES_ORDER")) {                    if (security.hasEntityPermission("ORDERMGR", "_SALES_CREATE", session)) {                        hasPermission = true;                    } else {                        // if the user is a rep of the store, then he also has permission                        List storeReps = null;                        try {                            storeReps = delegator.findByAnd("ProductStoreRole", UtilMisc.toMap("productStoreId", productStore.getString("productStoreId"),                                                            "partyId", userLogin.getString("partyId"), "roleTypeId", "SALES_REP"));                        } catch(GenericEntityException gee) {                            //                        }                        storeReps = EntityUtil.filterByDate(storeReps);                        if (storeReps != null && storeReps.size() > 0) {                            hasPermission = true;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -