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

📄 productconfigwrapper.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        GenericValue configItemAssoc = null;        ProductConfigItemContentWrapper content = null;        List options = null;        boolean first = true;                public ConfigItem(GenericValue questionAssoc) throws Exception {            configItemAssoc = questionAssoc;            configItem = configItemAssoc.getRelatedOne("ConfigItemProductConfigItem");            options = new ArrayList();        }                public ConfigItem(ConfigItem ci) {            configItem = GenericValue.create(ci.configItem);            configItemAssoc = GenericValue.create(ci.configItemAssoc);            options = new ArrayList();            for (int i = 0; i < ci.options.size(); i++) {                options.add(new ConfigOption((ConfigOption)ci.options.get(i)));            }            first = ci.first;            content = ci.content; // FIXME: this should be cloned        }        public void setContent(Locale locale, String mimeTypeId) {            content = new ProductConfigItemContentWrapper(configItem, locale, mimeTypeId);        }                public ProductConfigItemContentWrapper getContent() {            return content;        }                public GenericValue getConfigItem() {            return configItem;        }                public GenericValue getConfigItemAssoc() {            return configItemAssoc;        }        public boolean isStandard() {            return configItemAssoc.getString("configTypeId").equals("STANDARD");        }                public boolean isSingleChoice() {            return configItem.getString("configItemTypeId").equals("SINGLE");        }                public boolean isMandatory() {            return configItemAssoc.getString("isMandatory") != null && configItemAssoc.getString("isMandatory").equals("Y");        }                public boolean isFirst() {            return first;        }                public void setFirst(boolean newValue) {            first = newValue;        }                public void addOption(ConfigOption option) {            options.add(option);        }                public List getOptions() {            return options;        }                public String getQuestion() {            String question = "";            if (UtilValidate.isNotEmpty(configItemAssoc.getString("description"))) {                question = configItemAssoc.getString("description");            } else {                if (content != null) {                    question = content.get("DESCRIPTION");                } else {                    question = (configItem.getString("description") != null? configItem.getString("description"): "");                }            }            return question;        }        public String getDescription() {            String description = "";            if (UtilValidate.isNotEmpty(configItemAssoc.getString("longDescription"))) {                description = configItemAssoc.getString("longDescription");            } else {                if (content != null) {                    description = content.get("LONG_DESCRIPTION");                } else {                    description = (configItem.getString("longDescription") != null? configItem.getString("longDescription"): "");                }            }            return description;        }        public boolean isSelected() {            if (isStandard()) return true;            Iterator availOptions = getOptions().iterator();            while (availOptions.hasNext()) {                ConfigOption oneOption = (ConfigOption)availOptions.next();                if (oneOption.isSelected()) {                    return true;                }            }            return false;        }                public ConfigOption getSelected() {            Iterator availOptions = getOptions().iterator();            while (availOptions.hasNext()) {                ConfigOption oneOption = (ConfigOption)availOptions.next();                if (oneOption.isSelected()) {                    return oneOption;                }            }            return null;        }                public boolean equals(Object obj) {            if (obj == null || !(obj instanceof ConfigItem)) {                return false;            }            ConfigItem ci = (ConfigItem)obj;            if (!configItem.getString("configItemId").equals(ci.getConfigItem().getString("configItemId"))) {                return false;            }            List opts = ci.getOptions();            if (options.size() != opts.size()) {                return false;            }            for (int i = 0; i < options.size(); i++) {                ConfigOption co = (ConfigOption)options.get(i);                if (!co.equals(opts.get(i))) {                    return false;                }            }            return true;        }        public String toString() {            return configItem.getString("configItemId");        }    }        public class ConfigOption implements java.io.Serializable {        double optionPrice = 0;        Date availabilityDate = null;        List componentList = null; // lists of ProductConfigProduct        GenericValue configOption = null;        boolean selected = false;        boolean available = true;                public ConfigOption(GenericDelegator delegator, LocalDispatcher dispatcher, GenericValue option, String catalogId, String webSiteId, String currencyUomId, GenericValue autoUserLogin) throws Exception {            configOption = option;            componentList = option.getRelated("ConfigOptionProductConfigProduct");            Iterator componentsIt = componentList.iterator();            while (componentsIt.hasNext()) {                double price = 0;                GenericValue oneComponent = (GenericValue)componentsIt.next();                // Get the component's price                Map fieldMap = UtilMisc.toMap("product", oneComponent.getRelatedOne("ProductProduct"), "prodCatalogId", catalogId, "webSiteId", webSiteId,                        "currencyUomId", currencyUomId, "productPricePurposeId", "COMPONENT_PRICE", "autoUserLogin", autoUserLogin);                Map priceMap = dispatcher.runSync("calculateProductPrice", fieldMap);                Double componentPrice = (Double) priceMap.get("price");                double mult = 1;                if (oneComponent.getDouble("quantity") != null) {                    mult = oneComponent.getDouble("quantity").doubleValue();                }                if (mult == 0) {                    mult = 1;                }                if (componentPrice != null) {                    price = componentPrice.doubleValue();                } else {                    fieldMap.put("productPricePurposeId", "PURCHASE");                    Map purchasePriceResultMap = dispatcher.runSync("calculateProductPrice", fieldMap);                    Double purchasePrice = (Double) purchasePriceResultMap.get("price");                    if (purchasePrice != null) {                        price = purchasePrice.doubleValue();                    }                }                optionPrice += (price * mult);                // TODO: get the component's availability date            }        }                public ConfigOption(ConfigOption co) {            configOption = GenericValue.create(co.configOption);            componentList = new ArrayList();            for (int i = 0; i < co.componentList.size(); i++) {                componentList.add(GenericValue.create((GenericValue)co.componentList.get(i)));            }            optionPrice = co.optionPrice;            available = co.available;            selected = co.selected;        }        public String getDescription() {            return (configOption.getString("description") != null? configOption.getString("description"): "no description");        }                public double getPrice() {            return optionPrice;        }                public boolean isSelected() {            return selected;        }                public void setSelected(boolean newValue) {            selected = newValue;        }                public boolean isAvailable() {            return available;        }                public void setAvailable(boolean newValue) {            available = newValue;        }        public List getComponents() {            return componentList;        }                public boolean equals(Object obj) {            if (obj == null || !(obj instanceof ConfigOption)) {                return false;            }            ConfigOption co = (ConfigOption)obj;            // TODO: we should compare also the GenericValues                        return isSelected() == co.isSelected();        }                public String toString() {            return configOption.getString("configItemId") + "/" + configOption.getString("configOptionId") + (isSelected()? "*": "");        }    }    }

⌨️ 快捷键说明

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