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

📄 orderreadhelper.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    public BigDecimal getShippableWeightBd(String shipGroupSeqId) {        BigDecimal shippableWeight = ZERO;        List validItems = getValidOrderItems(shipGroupSeqId);        if (validItems != null) {            Iterator i = validItems.iterator();            while (i.hasNext()) {                GenericValue item = (GenericValue) i.next();                shippableWeight = shippableWeight.add(this.getItemWeightBd(item).multiply( getOrderItemQuantityBd(item))).setScale(scale, rounding);            }        }        return shippableWeight.setScale(scale, rounding);    }    /** @deprecated Use getShippableWeightBd() instead */    public double getShippableWeight(String shipGroupSeqId) {        return getShippableWeightBd(shipGroupSeqId).doubleValue();    }    public BigDecimal getItemWeightBd(GenericValue item) {        GenericDelegator delegator = orderHeader.getDelegator();        BigDecimal itemWeight = ZERO;        GenericValue product = null;        try {            product = item.getRelatedOne("Product");        } catch (GenericEntityException e) {            Debug.logError(e, "Problem getting Product from OrderItem; returning 0", module);            return new BigDecimal ("0.00");        }        if (product != null) {            if (ProductWorker.shippingApplies(product)) {                BigDecimal weight = product.getBigDecimal("weight");                String isVariant = product.getString("isVariant");                if (weight == null && "Y".equals(isVariant)) {                    // get the virtual product and check its weight                    try {                        String virtualId = ProductWorker.getVariantVirtualId(product);                        if (UtilValidate.isNotEmpty(virtualId)) {                            GenericValue virtual = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", virtualId));                            if (virtual != null) {                                weight = virtual.getBigDecimal("weight");                            }                        }                    } catch (GenericEntityException e) {                        Debug.logError(e, "Problem getting virtual product");                    }                }                if (weight != null) {                    itemWeight = weight;                }            }        }        return itemWeight;    }    /** @deprecated Use getItemWeightBd() instead */    public double getItemWeight(GenericValue item) {        return getItemWeightBd(item).doubleValue();    }    public List getShippableSizes() {        List shippableSizes = new LinkedList();        List validItems = getValidOrderItems();        if (validItems != null) {            Iterator i = validItems.iterator();            while (i.hasNext()) {                GenericValue item = (GenericValue) i.next();                shippableSizes.add(new Double(this.getItemSize(item)));            }        }        return shippableSizes;    }    // TODO: Might want to use BigDecimal here if precision matters    public double getItemSize(GenericValue item) {        GenericDelegator delegator = orderHeader.getDelegator();        double size = 0;        GenericValue product = null;        try {            product = item.getRelatedOne("Product");        } catch (GenericEntityException e) {            Debug.logError(e, "Problem getting Product from OrderItem", module);            return 0;        }        if (product != null) {            if (ProductWorker.shippingApplies(product)) {                Double height = product.getDouble("shippingHeight");                Double width = product.getDouble("shippingWidth");                Double depth = product.getDouble("shippingDepth");                String isVariant = product.getString("isVariant");                if ((height == null || width == null || depth == null) && "Y".equals(isVariant)) {                    // get the virtual product and check its values                    try {                        String virtualId = ProductWorker.getVariantVirtualId(product);                        if (UtilValidate.isNotEmpty(virtualId)) {                            GenericValue virtual = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", virtualId));                            if (virtual != null) {                                if (height == null) height = virtual.getDouble("shippingHeight");                                if (width == null) width = virtual.getDouble("shippingWidth");                                if (depth == null) depth = virtual.getDouble("shippingDepth");                            }                        }                    } catch (GenericEntityException e) {                        Debug.logError(e, "Problem getting virtual product");                    }                }                if (height == null) height = new Double(0);                if (width == null) width = new Double(0);                if (depth == null) depth = new Double(0);                // determine girth (longest field is length)                double[] sizeInfo = { height.doubleValue(), width.doubleValue(), depth.doubleValue() };                Arrays.sort(sizeInfo);                size = (sizeInfo[0] * 2) + (sizeInfo[1] * 2) + sizeInfo[2];            }        }        return size;    }    public long getItemPiecesIncluded(GenericValue item) {        GenericDelegator delegator = orderHeader.getDelegator();        long piecesIncluded = 1;        GenericValue product = null;        try {            product = item.getRelatedOne("Product");        } catch (GenericEntityException e) {            Debug.logError(e, "Problem getting Product from OrderItem; returning 1", module);            return 1;        }        if (product != null) {            if (ProductWorker.shippingApplies(product)) {                Long pieces = product.getLong("piecesIncluded");                String isVariant = product.getString("isVariant");                if (pieces == null && isVariant != null && "Y".equals(isVariant)) {                    // get the virtual product and check its weight                    GenericValue virtual = null;                    try {                        List virtuals = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productIdTo", product.getString("productId"), "productAssocTypeId", "PRODUCT_VARIENT"), UtilMisc.toList("-fromDate"));                        if (virtuals != null) {                            virtuals = EntityUtil.filterByDate(virtuals);                        }                        virtual = EntityUtil.getFirst(virtuals);                    } catch (GenericEntityException e) {                        Debug.logError(e, "Problem getting virtual product");                    }                    if (virtual != null) {                        pieces = virtual.getLong("piecesIncluded");                    }                }                if (pieces != null) {                    piecesIncluded = pieces.longValue();                }            }        }        return piecesIncluded;    }   public List getShippableItemInfo(String shipGroupSeqId) {        List shippableInfo = new LinkedList();        List validItems = getValidOrderItems(shipGroupSeqId);        if (validItems != null) {            Iterator i = validItems.iterator();            while (i.hasNext()) {                GenericValue item = (GenericValue) i.next();                shippableInfo.add(this.getItemInfoMap(item));            }        }        return shippableInfo;    }    public Map getItemInfoMap(GenericValue item) {        Map itemInfo = new HashMap();        itemInfo.put("productId", item.getString("productId"));        itemInfo.put("quantity", getOrderItemQuantity(item));        itemInfo.put("weight", new Double(this.getItemWeight(item)));        itemInfo.put("size",  new Double(this.getItemSize(item)));        itemInfo.put("piecesIncluded", new Long(this.getItemPiecesIncluded(item)));        itemInfo.put("featureSet", this.getItemFeatureSet(item));        return itemInfo;    }    public String getOrderEmailString() {        GenericDelegator delegator = orderHeader.getDelegator();        // get the email addresses from the order contact mech(s)        List orderContactMechs = null;        try {            Map ocFields = UtilMisc.toMap("orderId", orderHeader.get("orderId"), "contactMechPurposeTypeId", "ORDER_EMAIL");            orderContactMechs = delegator.findByAnd("OrderContactMech", ocFields);        } catch (GenericEntityException e) {            Debug.logWarning(e, "Problems getting order contact mechs", module);        }        StringBuffer emails = new StringBuffer();        if (orderContactMechs != null) {            Iterator oci = orderContactMechs.iterator();            while (oci.hasNext()) {                try {                    GenericValue orderContactMech = (GenericValue) oci.next();                    GenericValue contactMech = orderContactMech.getRelatedOne("ContactMech");                    emails.append(emails.length() > 0 ? "," : "").append(contactMech.getString("infoString"));                } catch (GenericEntityException e) {                    Debug.logWarning(e, "Problems getting contact mech from order contact mech", module);                }            }        }        return emails.toString();    }    public BigDecimal getOrderGrandTotalBd() {        if (totalPrice == null) {            totalPrice = getOrderGrandTotalBd(getValidOrderItems(), getAdjustments());        }// else already set        return totalPrice;    }    /** @deprecated Use getOrderGrandTotalBd() instead */    public double getOrderGrandTotal() {        return getOrderGrandTotalBd().doubleValue();    }    public List getOrderHeaderAdjustments() {        return getOrderHeaderAdjustments(getAdjustments(), null);    }    public List getOrderHeaderAdjustments(String shipGroupSeqId) {        return getOrderHeaderAdjustments(getAdjustments(), shipGroupSeqId);    }    public List getOrderHeaderAdjustmentsToShow() {        return filterOrderAdjustments(getOrderHeaderAdjustments(), true, false, false, false, false);    }    public List getOrderHeaderStatuses() {        return getOrderHeaderStatuses(getOrderStatuses());    }    public BigDecimal getOrderAdjustmentsTotalBd() {        return getOrderAdjustmentsTotalBd(getValidOrderItems(), getAdjustments());    }    /** @deprecated Use getOrderAdjustmentsTotalBd() instead */    public double getOrderAdjustmentsTotal() {        return getOrderAdjustmentsTotalBd().doubleValue();    }    public BigDecimal getOrderAdjustmentTotalBd(GenericValue adjustment) {        return calcOrderAdjustmentBd(adjustment, getOrderItemsSubTotalBd());    }    /** @deprecated Use getOrderAdjustmentsTotalBd() instead */    public double getOrderAdjustmentTotal(GenericValue adjustment) {        return getOrderAdjustmentTotalBd(adjustment).doubleValue();    }    public int hasSurvey() {        GenericDelegator delegator = orderHeader.getDelegator();        List surveys = null;        try {            surveys = delegator.findByAnd("SurveyResponse", UtilMisc.toMap("orderId", orderHeader.getString("orderId")));        } catch (GenericEntityException e) {            Debug.logError(e, module);        }        int size = 0;        if (surveys != null) {            size = surveys.size();        }        return size;    }    // ========================================    // ========== Order Item Methods ==========    // ========================================    public List getOrderItems() {        if (orderItems == null) {            try {                orderItems = orderHeader.getRelated("OrderItem", UtilMisc.toList("orderItemSeqId"));            } catch (GenericEntityException e) {                Debug.logWarning(e, module);            }        }        return orderItems;    }    public List getOrderItemAndShipGroupAssoc() {        if (orderItemAndShipGrp == null) {            try {                orderItemAndShipGrp = orderHeader.getDelegator().findByAnd("OrderItemAndShipGroupAssoc",                        UtilMisc.toMap("orderId", orderHeader.getString("orderId")));            } catch (GenericEntityException e) {                Debug.logWarning(e, module);            }        }        return orderItemAndShipGrp;

⌨️ 快捷键说明

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