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

📄 webshoppingcart.java

📁 国外的一套开源CRM
💻 JAVA
字号:
/*
 * $Id: WebShoppingCart.java,v 1.5 2003/11/08 20:54:17 ajzeneski Exp $
 *
 *  Copyright (c) 2001, 2002 The Open For Business Project - www.ofbiz.org
 *
 *  Permission is hereby granted, free of charge, to any person obtaining a
 *  copy of this software and associated documentation files (the "Software"),
 *  to deal in the Software without restriction, including without limitation
 *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
 *  and/or sell copies of the Software, and to permit persons to whom the
 *  Software is furnished to do so, subject to the following conditions:
 *
 *  The above copyright notice and this permission notice shall be included
 *  in all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
 *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
 *  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
package org.ofbiz.order.shoppingcart;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.product.catalog.CatalogWorker;
import org.ofbiz.product.store.ProductStoreWorker;
import org.ofbiz.base.util.UtilHttp;

/**
 * <p><b>Title:</b> WebShoppingCart.java
 * <p><b>Description:</b> This is a very basic
 * extension of the 
 * {@link org.ofbiz.order.shoppingcart.ShoppingCart ShoppingCart}
 * class which provides web presentation layer specific functionality
 * related specifically to user session information. 
 *
 * @author     <a href="mailto:jaz@ofbiz.org">Andy Zeneski</a>
 * @author     <a href="mailto:cnelson@einnovation.com">Chris Nelson</a>
 * @author     <a href="mailto:jonesde@ofbiz.org">David E. Jones</a>
 * @author     <a href="mailto:tristana@twibble.org">Tristan Austin</a>
 * @version    $Revision: 1.5 $
 * @since      2.0
 */
public class WebShoppingCart extends ShoppingCart {
    private HttpSession session = null;

    /** Creates a new cloned ShoppingCart Object. */
    public WebShoppingCart(ShoppingCart cart, HttpSession session) {
        super(cart);
        this.session = session;
    }    

    /** Creates new empty ShoppingCart object. */
    public WebShoppingCart(HttpServletRequest request) {
        super((GenericDelegator)request.getAttribute("delegator"), ProductStoreWorker.getProductStoreId(request), CatalogWorker.getWebSiteId(request), UtilHttp.getCurrencyUom(request));
        super.setLocale(UtilHttp.getLocale(request));
        this.session = request.getSession();
    }

    /** Gets the userLogin from the session; may be null */
    public GenericValue getUserLogin() {
        return (GenericValue) this.session.getAttribute("userLogin");
    }

    public GenericValue getAutoUserLogin() {
        return (GenericValue) this.session.getAttribute("autoUserLogin");
    }
    
    public String getWebSiteId() {
        return (String) session.getAttribute("webSiteId");
    }
    
    public String getPartyId() {
        String partyId = (String) session.getAttribute("orderPartyId");
        if (partyId == null && getUserLogin() != null)
            partyId = getUserLogin().getString("partyId");
        if (partyId == null && getAutoUserLogin() != null)
            partyId = getAutoUserLogin().getString("partyId");
        return partyId;
    }
}

⌨️ 快捷键说明

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