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

📄 shoppingcartitem.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                }            }        }        // set the item ship group        if (resetShipGroup) {            cart.clearItemShipInfo(this);            cart.setItemShipGroupQty(this, quantity, 0);        }    }    public void updatePrice(LocalDispatcher dispatcher, ShoppingCart cart) throws CartItemModifyException {        // set basePrice using the calculateProductPrice service        if (_product != null && isModifiedPrice==false) {            try {                Map priceContext = FastMap.newInstance();                priceContext.put("currencyUomId", cart.getCurrency());                String partyId = cart.getPartyId();                if (partyId != null) {                    priceContext.put("partyId", partyId);                }                priceContext.put("quantity", new Double(this.getQuantity()));                priceContext.put("product", this.getProduct());                if (cart.getOrderType().equals("PURCHASE_ORDER")) {                    Map priceResult = dispatcher.runSync("calculatePurchasePrice", priceContext);                    if (ServiceUtil.isError(priceResult)) {                        throw new CartItemModifyException("There was an error while calculating the price: " + ServiceUtil.getErrorMessage(priceResult));                    }                    Boolean validPriceFound = (Boolean) priceResult.get("validPriceFound");                    if (!validPriceFound.booleanValue()) {                        throw new CartItemModifyException("Could not find a valid price for the product with ID [" + this.getProductId() + "] and supplier with ID [" + partyId + "], not adding to cart.");                    }                    this.setBasePrice(((Double) priceResult.get("price")).doubleValue());                    this.setDisplayPrice(this.basePrice);                    this.orderItemPriceInfos = (List) priceResult.get("orderItemPriceInfos");                } else {                    priceContext.put("prodCatalogId", this.getProdCatalogId());                    priceContext.put("webSiteId", cart.getWebSiteId());                    priceContext.put("productStoreId", cart.getProductStoreId());                    Map priceResult = dispatcher.runSync("calculateProductPrice", priceContext);                    if (ServiceUtil.isError(priceResult)) {                        throw new CartItemModifyException("There was an error while calculating the price: " + ServiceUtil.getErrorMessage(priceResult));                    }                    Boolean validPriceFound = (Boolean) priceResult.get("validPriceFound");                    if (!validPriceFound.booleanValue()) {                        throw new CartItemModifyException("Could not find a valid price for the product with ID [" + this.getProductId() + "], not adding to cart.");                    }                    if (priceResult.get("listPrice") != null) {                        this.listPrice = ((Double) priceResult.get("listPrice")).doubleValue();                    }                    if (priceResult.get("basePrice") != null) {                        this.setBasePrice(((Double) priceResult.get("basePrice")).doubleValue());                    }                    if (priceResult.get("price") != null) {                        this.setDisplayPrice(((Double) priceResult.get("price")).doubleValue());                    }                    this.setSpecialPromoPrice((Double) priceResult.get("specialPromoPrice"));                    this.orderItemPriceInfos = (List) priceResult.get("orderItemPriceInfos");                    // If product is configurable, the price is taken from the configWrapper.                    if (configWrapper != null) {                        // TODO: for configurable products need to do something to make them VAT aware... for now base and display prices are the same                        this.setBasePrice(configWrapper.getTotalPrice());                        this.setDisplayPrice(configWrapper.getTotalPrice());                    }                }            } catch (GenericServiceException e) {                throw new CartItemModifyException("There was an error while calculating the price", e);            }        }    }    /** Returns the quantity. */    public double getQuantity() {        return this.quantity;    }    /** Returns the reservation start date. */    public Timestamp getReservStart() {        return this.getReservStart(0);    }    /** Returns the reservation start date with a number of days added. */    public Timestamp getReservStart(double addDays) {        if (addDays == 0)                return this.reservStart;        else    {            if(this.reservStart != null)                return new Timestamp((long)(this.reservStart.getTime() + (addDays * 86400000.0)));            else                return null;        }    }    /** Returns the reservation length. */    public double getReservLength() {        return this.reservLength;    }    /** Returns the reservation number of persons. */    public double getReservPersons() {        return this.reservPersons;    }    public double getPromoQuantityUsed() {        if (this.getIsPromo()) {            return this.quantity;        } else {            return this.promoQuantityUsed;        }    }    public double getPromoQuantityAvailable() {        if (this.getIsPromo()) {            return 0;        } else {            return this.quantity - this.promoQuantityUsed;        }    }    public Iterator getQuantityUsedPerPromoActualIter() {        return this.quantityUsedPerPromoActual.entrySet().iterator();    }    public Iterator getQuantityUsedPerPromoCandidateIter() {        return this.quantityUsedPerPromoCandidate.entrySet().iterator();    }    public Iterator getQuantityUsedPerPromoFailedIter() {        return this.quantityUsedPerPromoFailed.entrySet().iterator();    }    public synchronized double addPromoQuantityCandidateUse(double quantityDesired, GenericValue productPromoCondAction, boolean checkAvailableOnly) {        if (quantityDesired == 0) return 0;        double promoQuantityAvailable = this.getPromoQuantityAvailable();        double promoQuantityToUse = quantityDesired;        if (promoQuantityAvailable > 0) {            if (promoQuantityToUse > promoQuantityAvailable) {                promoQuantityToUse = promoQuantityAvailable;            }            if (!checkAvailableOnly) {                // keep track of candidate promo uses on cartItem                GenericPK productPromoCondActionPK = productPromoCondAction.getPrimaryKey();                Double existingValue = (Double) this.quantityUsedPerPromoCandidate.get(productPromoCondActionPK);                if (existingValue == null) {                    this.quantityUsedPerPromoCandidate.put(productPromoCondActionPK, new Double(promoQuantityToUse));                } else {                    this.quantityUsedPerPromoCandidate.put(productPromoCondActionPK, new Double(promoQuantityToUse + existingValue.doubleValue()));                }                this.promoQuantityUsed += promoQuantityToUse;                //Debug.logInfo("promoQuantityToUse=" + promoQuantityToUse + ", quantityDesired=" + quantityDesired + ", for promoCondAction: " + productPromoCondAction, module);                //Debug.logInfo("promoQuantityUsed now=" + promoQuantityUsed, module);            }            return promoQuantityToUse;        } else {            return 0;        }    }    public double getPromoQuantityCandidateUse(GenericValue productPromoCondAction) {        GenericPK productPromoCondActionPK = productPromoCondAction.getPrimaryKey();        Double existingValue = (Double) this.quantityUsedPerPromoCandidate.get(productPromoCondActionPK);        if (existingValue == null) {            return 0;        } else {            return existingValue.doubleValue();        }    }    public double getPromoQuantityCandidateUseActionAndAllConds(GenericValue productPromoAction) {        double totalUse = 0;        String productPromoId = productPromoAction.getString("productPromoId");        String productPromoRuleId = productPromoAction.getString("productPromoRuleId");        GenericPK productPromoActionPK = productPromoAction.getPrimaryKey();        Double existingValue = (Double) this.quantityUsedPerPromoCandidate.get(productPromoActionPK);        if (existingValue != null) {            totalUse = existingValue.doubleValue();        }        Iterator entryIter = this.quantityUsedPerPromoCandidate.entrySet().iterator();        while (entryIter.hasNext()) {            Map.Entry entry = (Map.Entry) entryIter.next();            GenericPK productPromoCondActionPK = (GenericPK) entry.getKey();            Double quantityUsed = (Double) entry.getValue();            if (quantityUsed != null) {                // must be in the same rule and be a condition                if (productPromoId.equals(productPromoCondActionPK.getString("productPromoId")) &&                        productPromoRuleId.equals(productPromoCondActionPK.getString("productPromoRuleId")) &&                        productPromoCondActionPK.containsKey("productPromoCondSeqId")) {                    totalUse += quantityUsed.doubleValue();                }            }        }        return totalUse;    }    public synchronized void resetPromoRuleUse(String productPromoId, String productPromoRuleId) {        Iterator entryIter = this.quantityUsedPerPromoCandidate.entrySet().iterator();        while (entryIter.hasNext()) {            Map.Entry entry = (Map.Entry) entryIter.next();            GenericPK productPromoCondActionPK = (GenericPK) entry.getKey();            Double quantityUsed = (Double) entry.getValue();            if (productPromoId.equals(productPromoCondActionPK.getString("productPromoId")) && productPromoRuleId.equals(productPromoCondActionPK.getString("productPromoRuleId"))) {                entryIter.remove();                Double existingValue = (Double) this.quantityUsedPerPromoFailed.get(productPromoCondActionPK);                if (existingValue == null) {                    this.quantityUsedPerPromoFailed.put(productPromoCondActionPK, quantityUsed);                } else {                    this.quantityUsedPerPromoFailed.put(productPromoCondActionPK, new Double(quantityUsed.doubleValue() + existingValue.doubleValue()));                }                this.promoQuantityUsed -= quantityUsed.doubleValue();            }        }    }    public synchronized void confirmPromoRuleUse(String productPromoId, String productPromoRuleId) {        Iterator entryIter = this.quantityUsedPerPromoCandidate.entrySet().iterator();        while (entryIter.hasNext()) {            Map.Entry entry = (Map.Entry) entryIter.next();            GenericPK productPromoCondActionPK = (GenericPK) entry.getKey();            Double quantityUsed = (Double) entry.getValue();            if (productPromoId.equals(productPromoCondActionPK.getString("productPromoId")) && productPromoRuleId.equals(productPromoCondActionPK.getSt

⌨️ 快捷键说明

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