📄 shoppingcartitem.java
字号:
/* * $Id: ShoppingCartItem.java 7275 2006-04-11 08:59:24Z jonesde $ * * Copyright (c) 2001-2005 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 java.math.BigDecimal;import java.sql.Timestamp;import java.util.ArrayList;import java.util.Arrays;import java.util.HashMap;import java.util.Iterator;import java.util.LinkedList;import java.util.List;import java.util.Locale;import java.util.Map;import java.util.Set;import org.apache.commons.collections.set.ListOrderedSet;import org.ofbiz.base.util.Debug;import org.ofbiz.base.util.GeneralException;import org.ofbiz.base.util.UtilDateTime;import org.ofbiz.base.util.UtilFormatOut;import org.ofbiz.base.util.UtilMisc;import org.ofbiz.base.util.UtilProperties;import org.ofbiz.base.util.UtilValidate;import org.ofbiz.entity.GenericDelegator;import org.ofbiz.entity.GenericEntityException;import org.ofbiz.entity.GenericPK;import org.ofbiz.entity.GenericValue;import org.ofbiz.entity.condition.EntityExpr;import org.ofbiz.entity.condition.EntityOperator;import org.ofbiz.entity.util.EntityUtil;import org.ofbiz.order.order.OrderReadHelper;import org.ofbiz.order.shoppingcart.product.ProductPromoWorker;import org.ofbiz.order.shoppinglist.ShoppingListEvents;import org.ofbiz.product.catalog.CatalogWorker;import org.ofbiz.product.category.CategoryWorker;import org.ofbiz.product.config.ProductConfigWrapper;import org.ofbiz.product.product.ProductContentWrapper;import org.ofbiz.product.product.ProductWorker;import org.ofbiz.product.store.ProductStoreWorker;import org.ofbiz.service.GenericServiceException;import org.ofbiz.service.LocalDispatcher;import org.ofbiz.service.ModelService;import org.ofbiz.service.ServiceUtil;import javolution.util.FastMap;/** * <p><b>Title:</b> ShoppingCartItem.java * <p><b>Description:</b> Shopping cart item object. * * @author <a href="mailto:jaz@ofbiz.org.com">Andy Zeneski</a> * @author <a href="mailto:jonesde@ofbiz.org">David E. Jones</a> * @version $Rev: 7275 $ * @since 2.0 */public class ShoppingCartItem implements java.io.Serializable { public static String module = ShoppingCartItem.class.getName(); public static final String resource = "OrderUiLabels"; public static final String resource_error = "OrderErrorUiLabels"; public static String[] attributeNames = { "shoppingListId", "shoppingListItemSeqId", "surveyResponses", "itemDesiredDeliveryDate", "itemComment"}; private transient GenericDelegator delegator = null; private transient GenericValue _product = null; // the actual product private transient GenericValue _parentProduct = null; // the virtual product private String delegatorName = null; private String prodCatalogId = null; private String productId = null; private String itemType = null; // ends up in orderItemTypeId private String productCategoryId = null; private String itemDescription = null; private Timestamp reservStart = null; // for reservations: date start private double reservLength = 0; // for reservations: length private double reservPersons = 0; // for reservations: number of persons using private double quantity = 0.0; private double basePrice = 0.0; private Double displayPrice = null; private Double specialPromoPrice = null; // comes from price calc, used for special promo price promotion action private double reserv2ndPPPerc = 0.0; // for reservations: extra % 2nd person private double reservNthPPPerc = 0.0; // for reservations: extra % Nth person private double listPrice = 0.0; private boolean isModifiedPrice = false; // flag to know if the price have been modified private double selectedAmount = 0.0; private String requirementId = null; private String quoteId = null; private String quoteItemSeqId = null; private String statusId = null; private Map orderItemAttributes = null; private Map attributes = null; private String orderItemSeqId = null; private Locale locale = null; private Timestamp shipBeforeDate = null; private Timestamp shipAfterDate = null; private Map contactMechIdsMap = FastMap.newInstance(); private List orderItemPriceInfos = null; private List itemAdjustments = new LinkedList(); private boolean isPromo = false; private double promoQuantityUsed = 0; private Map quantityUsedPerPromoCandidate = new HashMap(); private Map quantityUsedPerPromoFailed = new HashMap(); private Map quantityUsedPerPromoActual = new HashMap(); private Map additionalProductFeatureAndAppls = new HashMap(); private List alternativeOptionProductIds = null; private ProductConfigWrapper configWrapper = null; private List featuresForSupplier = new LinkedList(); /** * Makes a ShoppingCartItem and adds it to the cart. * NOTE: This method will get the product entity and check to make sure it can be purchased. * * @param cartLocation The location to place this item; null will place at the end * @param productId The primary key of the product being added * @param quantity The quantity to add * @param additionalProductFeatureAndAppls Product feature/appls map * @param attributes All unique attributes for this item (NOT features) * @param prodCatalogId The catalog this item was added from * @param dispatcher LocalDispatcher object for doing promotions, etc * @param cart The parent shopping cart object this item will belong to * @return a new ShoppingCartItem object * @throws CartItemModifyException */ public static ShoppingCartItem makeItem(Integer cartLocation, String productId, double selectedAmount, double quantity, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, LocalDispatcher dispatcher, ShoppingCart cart) throws CartItemModifyException, ItemNotFoundException { return ShoppingCartItem.makeItem(cartLocation, productId, selectedAmount, quantity, additionalProductFeatureAndAppls, attributes, prodCatalogId, null, dispatcher, cart); } /** * Makes a ShoppingCartItem and adds it to the cart. * NOTE: This method will get the product entity and check to make sure it can be purchased. * * @param cartLocation The location to place this item; null will place at the end * @param productId The primary key of the product being added * @param selectedAmount ? * @param quantity The quantity to add * @param additionalProductFeatureAndAppls Product feature/appls map * @param attributes All unique attributes for this item (NOT features) * @param prodCatalogId The catalog this item was added from * @param configWrapper The product configuration wrapper (null if the product is not configurable) * @param dispatcher LocalDispatcher object for doing promotions, etc * @param cart The parent shopping cart object this item will belong to * @return a new ShoppingCartItem object * @throws CartItemModifyException */ public static ShoppingCartItem makeItem(Integer cartLocation, String productId, double selectedAmount, double quantity, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, LocalDispatcher dispatcher, ShoppingCart cart) throws CartItemModifyException, ItemNotFoundException { return ShoppingCartItem.makeItem(cartLocation, productId, selectedAmount, quantity, null, 0.00, 0.00, null, null, additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, dispatcher, cart); } /** * Makes a ShoppingCartItem and adds it to the cart. * NOTE: This method will get the product entity and check to make sure it can be purchased. * * @param cartLocation The location to place this item; null will place at the end * @param productId The primary key of the product being added * @param selectedAmount ? * @param quantity The quantity to add * @param additionalProductFeatureAndAppls Product feature/appls map * @param attributes All unique attributes for this item (NOT features) * @param prodCatalogId The catalog this item was added from * @param configWrapper The product configuration wrapper (null if the product is not configurable) * @param dispatcher LocalDispatcher object for doing promotions, etc * @param cart The parent shopping cart object this item will belong to * @return a new ShoppingCartItem object * @throws CartItemModifyException */ public static ShoppingCartItem makeItem(Integer cartLocation, String productId, double selectedAmount, double quantity, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, LocalDispatcher dispatcher, ShoppingCart cart, boolean triggerExternalOps) throws CartItemModifyException, ItemNotFoundException { return ShoppingCartItem.makeItem(cartLocation, productId, selectedAmount, quantity, null, 0.00, 0.00, null, null, additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, dispatcher, cart, triggerExternalOps); } /** * Makes a ShoppingCartItem and adds it to the cart. * NOTE: This method will get the product entity and check to make sure it can be purchased. * * @param cartLocation The location to place this item; null will place at the end * @param productId The primary key of the product being added * @param selectedAmount ? * @param quantity The quantity to add * @param reservStart start of the reservation * @param reservLength length of the reservation * @param reservPersons nbr of persons taking advantage of the reservation * @param shipBeforeDate The date to ship the order by * @param shipAfterDate Wait until this date to ship * @param additionalProductFeatureAndAppls Product feature/appls map * @param attributes All unique attributes for this item (NOT features) * @param prodCatalogId The catalog this item was added from * @param configWrapper The product configuration wrapper (null if the product is not configurable) * @param dispatcher LocalDispatcher object for doing promotions, etc * @param cart The parent shopping cart object this item will belong to * @return a new ShoppingCartItem object * @throws CartItemModifyException */ public static ShoppingCartItem makeItem(Integer cartLocation, String productId, double selectedAmount, double quantity, Timestamp reservStart, double reservLength, double reservPersons, Timestamp shipBeforeDate, Timestamp shipAfterDate, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, LocalDispatcher dispatcher, ShoppingCart cart) throws CartItemModifyException, ItemNotFoundException { return ShoppingCartItem.makeItem(cartLocation, productId, selectedAmount, quantity, reservStart, reservLength, reservPersons, shipBeforeDate, shipAfterDate, additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, dispatcher, cart, true); } public static ShoppingCartItem makeItem(Integer cartLocation, String productId, double selectedAmount, double quantity, Timestamp reservStart, double reservLength, double reservPersons, Timestamp shipBeforeDate, Timestamp shipAfterDate, Map additionalProductFeatureAndAppls, Map attributes, String prodCatalogId, ProductConfigWrapper configWrapper, LocalDispatcher dispatcher, ShoppingCart cart, boolean triggerExternalOps) throws CartItemModifyException, ItemNotFoundException { return ShoppingCartItem.makeItem(cartLocation, productId, selectedAmount, quantity, 0.00, reservStart, reservLength, reservPersons, shipBeforeDate, shipAfterDate, additionalProductFeatureAndAppls, attributes, prodCatalogId, configWrapper, dispatcher, cart, triggerExternalOps, true); } /** * Makes a ShoppingCartItem and adds it to the cart. * NOTE: This method will get the product entity and check to make sure it can be purchased. * * @param cartLocation The location to place this item; null will place at the end * @param productId The primary key of the product being added * @param selectedAmount ? * @param quantity The quantity to add * @param reservStart start of the reservation * @param reservLength length of the reservation * @param reservPersons nbr of persons taking advantage of the reservation * @param shipBeforeDate The date to ship the order by * @param shipAfterDate Wait until this date to ship
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -