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

📄 productstoreworker.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                Double maxSize = method.getDouble("maxSize");                if (minSize != null && minSize.doubleValue() > 0) {                    boolean allMatch = false;                    if (itemSizes != null) {                        allMatch = true;                        Iterator isi = itemSizes.iterator();                        while (isi.hasNext()) {                            Double size = (Double) isi.next();                            if (size.doubleValue() < minSize.doubleValue()) {                                allMatch = false;                            }                        }                    }                    if (!allMatch) {                        returnShippingMethods.remove(method);                        //Debug.logInfo("Removed shipping method because not all products are less then min size", module);                        continue;                    }                }                if (maxSize != null && maxSize.doubleValue() > 0) {                    boolean allMatch = false;                    if (itemSizes != null) {                        allMatch = true;                        Iterator isi = itemSizes.iterator();                        while (isi.hasNext()) {                            Double size = (Double) isi.next();                            if (size.doubleValue() > maxSize.doubleValue()) {                                allMatch = false;                            }                        }                    }                    if (!allMatch) {                        returnShippingMethods.remove(method);                        //Debug.logInfo("Removed shipping method because one or more products were more then max size", module);                        continue;                    }                }                // check USPS address                String allowUspsAddr = method.getString("allowUspsAddr");                String requireUspsAddr = method.getString("requireUspsAddr");                boolean isUspsAddress = ContactMechWorker.isUspsAddress(shippingAddress);                if ("N".equals(allowUspsAddr) && isUspsAddress) {                    returnShippingMethods.remove(method);                    //Debug.logInfo("Remove shipping method due to USPS address", module);                    continue;                }                if ("Y".equals(requireUspsAddr) && !isUspsAddress) {                    returnShippingMethods.remove(method);                    //Debug.logInfo("Removed shipping method due to NON-USPS address", module);                    continue;                }                // check company address                String companyPartyId = method.getString("companyPartyId");                String allowCompanyAddr = method.getString("allowCompanyAddr");                String requireCompanyAddr = method.getString("requireCompanyAddr");                boolean isCompanyAddress = ContactMechWorker.isCompanyAddress(shippingAddress, companyPartyId);                if ("N".equals(allowCompanyAddr) && isCompanyAddress) {                    returnShippingMethods.remove(method);                    //Debug.logInfo("Removed shipping method due to Company address", module);                    continue;                }                if ("Y".equals(requireCompanyAddr) && !isCompanyAddress) {                    returnShippingMethods.remove(method);                    //Debug.logInfo("Removed shipping method due to NON-Company address", module);                    continue;                }                // check the items excluded from shipping                String includeFreeShipping = method.getString("includeNoChargeItems");                if (includeFreeShipping != null && "N".equalsIgnoreCase(includeFreeShipping)) {                    if ((itemSizes == null || itemSizes.size() == 0) && orderTotal == 0) {                        returnShippingMethods.remove(method);                        //Debug.logInfo("Removed shipping method due to all items being exempt from shipping", module);                        continue;                    }                }                // check the geos                String includeGeoId = method.getString("includeGeoId");                String excludeGeoId = method.getString("excludeGeoId");                if ((includeGeoId != null && includeGeoId.length() > 0) || (excludeGeoId != null && excludeGeoId.length() > 0)) {                    if (shippingAddress == null) {                        returnShippingMethods.remove(method);                        //Debug.logInfo("Removed shipping method due to empty shipping adresss (may not have been selected yet)", module);                        continue;                    }                }                if (includeGeoId != null && includeGeoId.length() > 0) {                    List includeGeoGroup = GeoWorker.expandGeoGroup(includeGeoId, delegator);                    if (!GeoWorker.containsGeo(includeGeoGroup, shippingAddress.getString("countryGeoId"), delegator) &&                            !GeoWorker.containsGeo(includeGeoGroup, shippingAddress.getString("stateProvinceGeoId"), delegator) &&                            !GeoWorker.containsGeo(includeGeoGroup, shippingAddress.getString("postalCodeGeoId"), delegator)) {                        // not in required included geos                        returnShippingMethods.remove(method);                        //Debug.logInfo("Removed shipping method due to being outside the included GEO", module);                        continue;                    }                }                if (excludeGeoId != null && excludeGeoId.length() > 0) {                    List excludeGeoGroup = GeoWorker.expandGeoGroup(excludeGeoId, delegator);                    if (GeoWorker.containsGeo(excludeGeoGroup, shippingAddress.getString("countryGeoId"), delegator) ||                            GeoWorker.containsGeo(excludeGeoGroup, shippingAddress.getString("stateProvinceGeoId"), delegator) ||                            GeoWorker.containsGeo(excludeGeoGroup, shippingAddress.getString("postalCodeGeoId"), delegator)) {                        // in excluded geos                        returnShippingMethods.remove(method);                        //Debug.logInfo("Removed shipping method due to being inside the excluded GEO", module);                        continue;                    }                }                // check the features                String includeFeatures = method.getString("includeFeatureGroup");                String excludeFeatures = method.getString("excludeFeatureGroup");                if (includeFeatures != null && includeFeatures.length() > 0) {                    List includedFeatures = null;                    try {                        includedFeatures = delegator.findByAndCache("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", includeFeatures));                    } catch (GenericEntityException e) {                        Debug.logError(e, "Unable to lookup ProductFeatureGroupAppl records for group : " + includeFeatures, module);                    }                    if (includedFeatures != null) {                        boolean foundOne = false;                        Iterator ifet = includedFeatures.iterator();                        while (ifet.hasNext()) {                            GenericValue appl = (GenericValue) ifet.next();                            if (featureIdMap.containsKey(appl.getString("productFeatureId"))) {                                foundOne = true;                                break;                            }                        }                        if (!foundOne) {                            returnShippingMethods.remove(method);                            //Debug.logInfo("Removed shipping method due to no required features found", module);                            continue;                        }                    }                }                if (excludeFeatures != null && excludeFeatures.length() > 0) {                    List excludedFeatures = null;                    try {                        excludedFeatures = delegator.findByAndCache("ProductFeatureGroupAppl", UtilMisc.toMap("productFeatureGroupId", excludeFeatures));                    } catch (GenericEntityException e) {                        Debug.logError(e, "Unable to lookup ProductFeatureGroupAppl records for group : " + excludeFeatures, module);                    }                    if (excludedFeatures != null) {                        Iterator ifet = excludedFeatures.iterator();                        while (ifet.hasNext()) {                            GenericValue appl = (GenericValue) ifet.next();                            if (featureIdMap.containsKey(appl.getString("productFeatureId"))) {                                returnShippingMethods.remove(method);                                //Debug.logInfo("Removed shipping method due to an exluded feature being found : " + appl.getString("productFeatureId"), module);                                continue;                            }                        }                    }                }            }        }        return returnShippingMethods;    }    public static ProductStoreSurveyWrapper getRandomSurveyWrapper(ServletRequest request, String groupName) {        GenericValue productStore = getProductStore(request);        HttpSession session = ((HttpServletRequest)request).getSession();        if (productStore == null) {            return null;        }        GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");        if (userLogin == null) {            userLogin = (GenericValue) session.getAttribute("autoUserLogin");        }        String partyId = userLogin != null ? userLogin.getString("partyId") : null;        Map passThruFields = UtilHttp.getParameterMap(((HttpServletRequest)request));        return getRandomSurveyWrapper(productStore.getDelegator(), productStore.getString("productStoreId"), groupName, partyId, passThruFields);    }    public static ProductStoreSurveyWrapper getRandomSurveyWrapper(GenericDelegator delegator, String productStoreId, String groupName, String partyId, Map passThruFields) {        List randomSurveys = getSurveys(delegator, productStoreId, groupName, null, "RANDOM_POLL");        if (!UtilValidate.isEmpty(randomSurveys)) {            Random rand = new Random();            int index = rand.nextInt(randomSurveys.size());            GenericValue appl = (GenericValue) randomSurveys.get(index);            return new ProductStoreSurveyWrapper(appl, partyId, passThruFields);        } else {            return null;        }    }    public static List getProductSurveys(GenericDelegator delegator, String productStoreId, String productId, String surveyApplTypeId) {        return getSurveys(delegator, productStoreId, null, productId, surveyApplTypeId);    }    public static List getSurveys(GenericDelegator delegator, String productStoreId, String groupName, String productId, String surveyApplTypeId) {        List surveys = new LinkedList();        List storeSurveys = null;        try {            storeSurveys = delegator.findByAndCache("ProductStoreSurveyAppl", UtilMisc.toMap("productStoreId", productStoreId, "surveyApplTypeId", surveyApplTypeId), UtilMisc.toList("sequenceNum"));        } catch (GenericEntityException e) {            Debug.logError(e, "Unable to get ProductStoreSurveyAppl for store : " + productStoreId, module);            return surveys;        }        // limit by date        storeSurveys = EntityUtil.filterByDate(storeSurveys);        // limit based on group name        if (!UtilValidate.isEmpty(groupName)) {            storeSurveys = EntityUtil.filterByAnd(storeSurveys, UtilMisc.toMap("groupName", groupName));        }        // limit by product        if (!UtilValidate.isEmpty(productId) && !UtilValidate.isEmpty(storeSurveys)) {            Iterator ssi = storeSurveys.iterator();            while (ssi.hasNext()) {                GenericValue surveyAppl = (GenericValue) ssi.next();                GenericValue product = null;                String virtualProductId = null;                // if the item is a variant, get its virtual productId                 try {                    product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", productId));                    if ((product != null) && ("Y".equals(product.get("isVariant")))) {                        virtualProductId = ProductWorker.getVariantVirtualId(product);                    }                } catch (GenericEntityException e) {                    Debug.logError(e, "Problem finding product from productId " + productId, module);                }                // use survey if productId or virtualProductId of the variant product is in the ProductStoreSurveyAppl                if (surveyAppl.get("productId") != null) {                    if (surveyAppl.get("productId").equals(productId)) {

⌨️ 快捷键说明

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