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

📄 productpromoworker.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            Set productIds = ProductPromoWorker.getPromoRuleCondProductIds(productPromoCond, delegator, nowTimestamp);            List lineOrderedByBasePriceList = cart.getLineListOrderedByBasePrice(false);            Iterator lineOrderedByBasePriceIter = lineOrderedByBasePriceList.iterator();            while (quantityNeeded > 0 && lineOrderedByBasePriceIter.hasNext()) {                ShoppingCartItem cartItem = (ShoppingCartItem) lineOrderedByBasePriceIter.next();                // only include if it is in the productId Set for this check and if it is not a Promo (GWP) item                GenericValue product = cartItem.getProduct();                String parentProductId = cartItem.getParentProductId();                if (!cartItem.getIsPromo() &&                         (productIds.contains(cartItem.getProductId()) || (parentProductId != null && productIds.contains(parentProductId))) &&                         (product == null || !"N".equals(product.getString("includeInPromotions")))) {                    // reduce quantity still needed to qualify for promo (quantityNeeded)                    quantityNeeded -= cartItem.addPromoQuantityCandidateUse(quantityNeeded, productPromoCond, false);                }            }            // if quantityNeeded > 0 then the promo condition failed, so remove candidate promo uses and increment the promoQuantityUsed to restore it            if (quantityNeeded > 0) {                // failed, reset the entire rule, ie including all other conditions that might have been done before                cart.resetPromoRuleUse(productPromoCond.getString("productPromoId"), productPromoCond.getString("productPromoRuleId"));                compareBase = new Integer(-1);            } else {                // we got it, the conditions are in place...                compareBase = new Integer(0);                // NOTE: don't confirm rpomo rule use here, wait until actions are complete for the rule to do that            }        /* replaced by PPIP_PRODUCT_QUANT        } else if ("PPIP_PRODUCT_ID_IC".equals(inputParamEnumId)) {            String candidateProductId = condValue;            if (candidateProductId == null) {                // if null, then it's not in the cart                compareBase = new Integer(1);            } else {                // Debug.logInfo("Testing to see if productId \"" + candidateProductId + "\" is in the cart", module);                List productCartItems = cart.findAllCartItems(candidateProductId);                // don't count promotion items in this count...                Iterator pciIter = productCartItems.iterator();                while (pciIter.hasNext()) {                    ShoppingCartItem productCartItem = (ShoppingCartItem) pciIter.next();                    if (productCartItem.getIsPromo()) pciIter.remove();                }                if (productCartItems.size() > 0) {                    //Debug.logError("Item with productId \"" + candidateProductId + "\" IS in the cart", module);                    compareBase = new Integer(0);                } else {                    //Debug.logError("Item with productId \"" + candidateProductId + "\" IS NOT in the cart", module);                    compareBase = new Integer(1);                }            }        } else if ("PPIP_CATEGORY_ID_IC".equals(inputParamEnumId)) {            String productCategoryId = condValue;            Set productIds = new HashSet();            Iterator cartItemIter = cart.iterator();            while (cartItemIter.hasNext()) {                ShoppingCartItem cartItem = (ShoppingCartItem) cartItemIter.next();                if (!cartItem.getIsPromo()) {                    productIds.add(cartItem.getProductId());                }            }            compareBase = new Integer(1);            // NOTE: this technique is efficient for a smaller number of items in the cart, if there are a lot of lines            //in the cart then a non-cached query with a set of productIds using the IN operator would be better            Iterator productIdIter = productIds.iterator();            while (productIdIter.hasNext()) {                String productId = (String) productIdIter.next();                // if a ProductCategoryMember exists for this productId and the specified productCategoryId                List productCategoryMembers = delegator.findByAndCache("ProductCategoryMember", UtilMisc.toMap("productId", productId, "productCategoryId", productCategoryId));                // and from/thru date within range                productCategoryMembers = EntityUtil.filterByDate(productCategoryMembers, nowTimestamp);                if (productCategoryMembers != null && productCategoryMembers.size() > 0) {                    // if any product is in category, set true and break                    // then 0 (equals), otherwise 1 (not equals)                    compareBase = new Integer(0);                    break;                }            }        */        } else if ("PPIP_NEW_ACCT".equals(inputParamEnumId)) {            Double acctDays = cart.getPartyDaysSinceCreated(nowTimestamp);            if (acctDays == null) {                // condition always fails if we don't know how many days since account created                return false;            }            compareBase = new Integer(acctDays.compareTo(Double.valueOf(condValue)));        } else if ("PPIP_PARTY_ID".equals(inputParamEnumId)) {            if (partyId != null) {                compareBase = new Integer(partyId.compareTo(condValue));            } else {                compareBase = new Integer(1);            }        } else if ("PPIP_PARTY_GRP_MEM".equals(inputParamEnumId)) {            if (UtilValidate.isEmpty(partyId)) {                compareBase = new Integer(1);            } else {                String groupPartyId = condValue;                if (partyId.equals(groupPartyId)) {                    compareBase = new Integer(0);                } else {                    // look for PartyRelationship with partyRelationshipTypeId=GROUP_ROLLUP, the partyIdTo is the group member, so the partyIdFrom is the groupPartyId                    List partyRelationshipList = delegator.findByAndCache("PartyRelationship", UtilMisc.toMap("partyIdFrom", groupPartyId, "partyIdTo", partyId, "partyRelationshipTypeId", "GROUP_ROLLUP"));                    // and from/thru date within range                    partyRelationshipList = EntityUtil.filterByDate(partyRelationshipList, true);                    // then 0 (equals), otherwise 1 (not equals)                    if (partyRelationshipList != null && partyRelationshipList.size() > 0) {                        compareBase = new Integer(0);                    } else {                        compareBase = new Integer(1);                    }                }            }        } else if ("PPIP_PARTY_CLASS".equals(inputParamEnumId)) {            if (UtilValidate.isEmpty(partyId)) {                compareBase = new Integer(1);            } else {                String partyClassificationGroupId = condValue;                // find any PartyClassification                List partyClassificationList = delegator.findByAndCache("PartyClassification", UtilMisc.toMap("partyId", partyId, "partyClassificationGroupId", partyClassificationGroupId));                // and from/thru date within range                partyClassificationList = EntityUtil.filterByDate(partyClassificationList, true);                // then 0 (equals), otherwise 1 (not equals)                if (partyClassificationList != null && partyClassificationList.size() > 0) {                    compareBase = new Integer(0);                } else {                    compareBase = new Integer(1);                }            }        } else if ("PPIP_ROLE_TYPE".equals(inputParamEnumId)) {            if (partyId != null) {                // if a PartyRole exists for this partyId and the specified roleTypeId                GenericValue partyRole = delegator.findByPrimaryKeyCache("PartyRole",                        UtilMisc.toMap("partyId", partyId, "roleTypeId", condValue));                // then 0 (equals), otherwise 1 (not equals)                if (partyRole != null) {                    compareBase = new Integer(0);                } else {                    compareBase = new Integer(1);                }            } else {                compareBase = new Integer(1);            }        } else if ("PPIP_ORDER_TOTAL".equals(inputParamEnumId)) {            Double orderSubTotal = new Double(cart.getSubTotalForPromotions());            if (Debug.verboseOn()) Debug.logVerbose("Doing order total compare: orderSubTotal=" + orderSubTotal, module);            compareBase = new Integer(orderSubTotal.compareTo(Double.valueOf(condValue)));        } else if ("PPIP_ORST_HIST".equals(inputParamEnumId)) {            // description="Order sub-total X in last Y Months"            if (partyId != null && userLogin != null) {                // call the getOrderedSummaryInformation service to get the sub-total                int monthsToInclude = 12;                if (otherValue != null) {                    monthsToInclude = Integer.parseInt(condValue);                }                Map serviceIn = UtilMisc.toMap("partyId", partyId, "roleTypeId", "PLACING_CUSTOMER", "orderTypeId", "SALES_ORDER", "statusId", "ORDER_COMPLETED", "monthsToInclude", new Integer(monthsToInclude), "userLogin", userLogin);                try {                    Map result = dispatcher.runSync("getOrderedSummaryInformation", serviceIn);                    if (ServiceUtil.isError(result)) {                        Debug.logError("Error calling getOrderedSummaryInformation service for the PPIP_ORST_HIST ProductPromo condition input value: " + ServiceUtil.getErrorMessage(result), module);                        return false;                    } else {                        Double orderSubTotal = (Double) result.get("totalSubRemainingAmount");                        if (Debug.verboseOn()) Debug.logVerbose("Doing order history sub-total compare: orderSubTotal=" + orderSubTotal + ", for the last " + monthsToInclude + " months.", module);                        compareBase = new Integer(orderSubTotal.compareTo(Double.valueOf(condValue)));                    }                } catch (GenericServiceException e) {                    Debug.logError(e, "Error getting order history sub-total in the getOrderedSummaryInformation service, evaluating condition to false.", module);                    return false;                }            } else {                return false;            }        } else {            Debug.logWarning(UtilProperties.getMessage(resource_error,"OrderAnUnSupportedProductPromoCondInputParameterLhs", UtilMisc.toMap("inputParamEnumId",productPromoCond.getString("inputParamEnumId")), cart.getLocale()), module);            return false;        }        if (Debug.verboseOn()) Debug.logVerbose("Condition compare done, compareBase=" + compareBase, module);        if (compareBase != null) {            int compare = compareBase.intValue();            if ("PPC_EQ".equals(operatorEnumId)) {                if (compare == 0) return true;            } else if ("PPC_NEQ".equals(operatorEnumId)) {                if (compare != 0) return true;            } else if ("PPC_LT".equals(operatorEnumId)) {                if (compare < 0) return true;            } else if ("PPC_LTE".equals(operatorEnumId)) {                if (compare <= 0) return true;            } else if ("PPC_GT".equals(operatorEnumId)) {                if (compare > 0) return true;            } else if ("PPC_GTE".equals(operatorEnumId)) {                if (compare >= 0) return true;            } else {                Debug.logWarning(UtilProperties.getMessage(resource_error,"OrderAnUnSupportedProductPromoCondCondition", UtilMisc.toMap("operatorEnumId",operatorEnumId) , cart.getLocale()), module);                return false;            }        }        // defa

⌨️ 快捷键说明

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