本文整理汇总了Java中org.ofbiz.product.product.ProductWorker类的典型用法代码示例。如果您正苦于以下问题:Java ProductWorker类的具体用法?Java ProductWorker怎么用?Java ProductWorker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProductWorker类属于org.ofbiz.product.product包,在下文中一共展示了ProductWorker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPackedQuantity
import org.ofbiz.product.product.ProductWorker; //导入依赖的package包/类
public BigDecimal getPackedQuantity(String productId, int packageSeq) {
if (productId != null) {
try {
productId = ProductWorker.findProductId(this.getDelegator(), productId);
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
}
BigDecimal total = BigDecimal.ZERO;
if (productId != null) {
for (PackingSessionLine line: this.getLines()) {
if (productId.equals(line.getProductId())) {
if (packageSeq == -1 || packageSeq == line.getPackageSeq()) {
total = total.add(line.getQuantity());
}
}
}
}
return total;
}
示例2: getShippableTotal
import org.ofbiz.product.product.ProductWorker; //导入依赖的package包/类
public BigDecimal getShippableTotal(String shipGroupSeqId) {
BigDecimal shippableTotal = ZERO;
List<GenericValue> validItems = getValidOrderItems(shipGroupSeqId);
if (validItems != null) {
for (GenericValue item : validItems) {
GenericValue product = null;
try {
product = item.getRelatedOne("Product", false);
} catch (GenericEntityException e) {
Debug.logError(e, "Problem getting Product from OrderItem; returning 0", module);
return ZERO;
}
if (product != null) {
if (ProductWorker.shippingApplies(product)) {
shippableTotal = shippableTotal.add(OrderReadHelper.getOrderItemSubTotal(item, getAdjustments(), false, true)).setScale(scale,
rounding);
}
}
}
}
return shippableTotal.setScale(scale, rounding);
}
示例3: getShippableQuantity
import org.ofbiz.product.product.ProductWorker; //导入依赖的package包/类
public BigDecimal getShippableQuantity(String shipGroupSeqId) {
BigDecimal shippableQuantity = ZERO;
List<GenericValue> validItems = getValidOrderItems(shipGroupSeqId);
if (validItems != null) {
for (GenericValue item : validItems) {
GenericValue product = null;
try {
product = item.getRelatedOne("Product", false);
} catch (GenericEntityException e) {
Debug.logError(e, "Problem getting Product from OrderItem; returning 0", module);
return ZERO;
}
if (product != null) {
if (ProductWorker.shippingApplies(product)) {
shippableQuantity = shippableQuantity.add(getOrderItemQuantity(item)).setScale(scale, rounding);
}
}
}
}
return shippableQuantity.setScale(scale, rounding);
}
示例4: addItem
import org.ofbiz.product.product.ProductWorker; //导入依赖的package包/类
/** Add an item to the shopping cart. */
public int addItem(int index, ShoppingCartItem item) throws CartItemModifyException {
if (isReadOnlyCart()) {
throw new CartItemModifyException("Cart items cannot be changed");
}
if (!cartLines.contains(item)) {
// If the billing address is already set, verify if the new product
// is available in the address' geo
GenericValue product = item.getProduct();
if (product != null && isSalesOrder()) {
GenericValue billingAddress = this.getBillingAddress();
if (billingAddress != null) {
if (!ProductWorker.isBillableToAddress(product, billingAddress)) {
throw new CartItemModifyException("The billing address is not compatible with ProductGeos rules of this product.");
}
}
}
cartLines.add(index, item);
return index;
} else {
return this.getItemIndex(item);
}
}
示例5: addPaymentAmount
import org.ofbiz.product.product.ProductWorker; //导入依赖的package包/类
/** adds a payment method/payment method type */
public CartPaymentInfo addPaymentAmount(String id, BigDecimal amount, String refNum, String authCode, boolean isSingleUse, boolean isPresent, boolean replace) {
CartPaymentInfo inf = this.getPaymentInfo(id, refNum, authCode, amount, replace);
if (isSalesOrder()) {
GenericValue billingAddress = inf.getBillingAddress(this.getDelegator());
if (billingAddress != null) {
// this payment method will set the billing address for the order;
// before it is set we have to verify if the billing address is
// compatible with the ProductGeos
for (GenericValue product : ShoppingCart.getItemsProducts(this.cartLines)) {
if (!ProductWorker.isBillableToAddress(product, billingAddress)) {
throw new IllegalArgumentException("The billing address is not compatible with ProductGeos rules.");
}
}
}
}
inf.singleUse = isSingleUse;
inf.isPresent = isPresent;
if (replace) {
paymentInfo.remove(inf);
}
paymentInfo.add(inf);
return inf;
}
示例6: isShippableToAddress
import org.ofbiz.product.product.ProductWorker; //导入依赖的package包/类
private boolean isShippableToAddress(ShoppingCartItem item) {
if ("SALES_ORDER".equals(getOrderTypeId())) {
// Verify if the new address is compatible with the ProductGeos rules of
// the products already in the cart
GenericValue shippingAddress = null;
try {
shippingAddress = item.getDelegator().findOne("PostalAddress", UtilMisc.toMap("contactMechId", this.internalContactMechId), false);
} catch (GenericEntityException gee) {
Debug.logError(gee, "Error retrieving the shipping address for contactMechId [" + this.internalContactMechId + "].", module);
}
if (shippingAddress != null) {
GenericValue product = item.getProduct();
if (UtilValidate.isNotEmpty(product)) {
return ProductWorker.isShippableToAddress(product, shippingAddress);
}
}
}
return true;
}
示例7: isProductInCategory
import org.ofbiz.product.product.ProductWorker; //导入依赖的package包/类
public static boolean isProductInCategory(Delegator delegator, String productId, String productCategoryId) throws GenericEntityException {
if (productCategoryId == null) return false;
if (UtilValidate.isEmpty(productId)) return false;
List<GenericValue> productCategoryMembers = EntityUtil.filterByDate(delegator.findByAnd("ProductCategoryMember",
UtilMisc.toMap("productCategoryId", productCategoryId, "productId", productId), null, true), true);
if (UtilValidate.isEmpty(productCategoryMembers)) {
//before giving up see if this is a variant product, and if so look up the virtual product and check it...
GenericValue product = delegator.findOne("Product", UtilMisc.toMap("productId", productId), true);
List<GenericValue> productAssocs = ProductWorker.getVariantVirtualAssocs(product);
//this does take into account that a product could be a variant of multiple products, but this shouldn't ever really happen...
if (productAssocs != null) {
for (GenericValue productAssoc: productAssocs) {
if (isProductInCategory(delegator, productAssoc.getString("productId"), productCategoryId)) {
return true;
}
}
}
return false;
} else {
return true;
}
}
示例8: getShippableTotal
import org.ofbiz.product.product.ProductWorker; //导入依赖的package包/类
public BigDecimal getShippableTotal(String shipGroupSeqId) {
BigDecimal shippableTotal = ZERO;
List<GenericValue> validItems = getValidOrderItems(shipGroupSeqId);
if (validItems != null) {
for(GenericValue item : validItems) {
GenericValue product = null;
try {
product = item.getRelatedOne("Product", false);
} catch (GenericEntityException e) {
Debug.logError(e, "Problem getting Product from OrderItem; returning 0", module);
return ZERO;
}
if (product != null) {
if (ProductWorker.shippingApplies(product)) {
shippableTotal = shippableTotal.add(OrderReadHelper.getOrderItemSubTotal(item, getAdjustments(), false, true)).setScale(scale, rounding);
}
}
}
}
return shippableTotal.setScale(scale, rounding);
}
示例9: getShippableQuantity
import org.ofbiz.product.product.ProductWorker; //导入依赖的package包/类
public BigDecimal getShippableQuantity(String shipGroupSeqId) {
BigDecimal shippableQuantity = ZERO;
List<GenericValue> validItems = getValidOrderItems(shipGroupSeqId);
if (validItems != null) {
for(GenericValue item : validItems) {
GenericValue product = null;
try {
product = item.getRelatedOne("Product", false);
} catch (GenericEntityException e) {
Debug.logError(e, "Problem getting Product from OrderItem; returning 0", module);
return ZERO;
}
if (product != null) {
if (ProductWorker.shippingApplies(product)) {
shippableQuantity = shippableQuantity.add(getOrderItemQuantity(item)).setScale(scale, rounding);
}
}
}
}
return shippableQuantity.setScale(scale, rounding);
}
示例10: addPaymentAmount
import org.ofbiz.product.product.ProductWorker; //导入依赖的package包/类
/** adds a payment method/payment method type */
public CartPaymentInfo addPaymentAmount(String id, BigDecimal amount, String refNum, String authCode, boolean isSingleUse, boolean isPresent, boolean replace) {
CartPaymentInfo inf = this.getPaymentInfo(id, refNum, authCode, amount, replace);
if (isSalesOrder()) {
GenericValue billingAddress = inf.getBillingAddress(this.getDelegator());
if (billingAddress != null) {
// this payment method will set the billing address for the order;
// before it is set we have to verify if the billing address is
// compatible with the ProductGeos
for(GenericValue product : ShoppingCart.getItemsProducts(this.cartLines)) {
if (!ProductWorker.isBillableToAddress(product, billingAddress)) {
throw new IllegalArgumentException("The billing address is not compatible with ProductGeos rules.");
}
}
}
}
inf.singleUse = isSingleUse;
inf.isPresent = isPresent;
if (replace) {
paymentInfo.remove(inf);
}
paymentInfo.add(inf);
return inf;
}
示例11: isProductInCategory
import org.ofbiz.product.product.ProductWorker; //导入依赖的package包/类
public static boolean isProductInCategory(Delegator delegator, String productId, String productCategoryId) throws GenericEntityException {
if (productCategoryId == null)
return false;
if (UtilValidate.isEmpty(productId))
return false;
List<GenericValue> productCategoryMembers = EntityQuery.use(delegator).from("ProductCategoryMember")
.where("productCategoryId", productCategoryId, "productId", productId).cache(true).filterByDate().queryList();
if (UtilValidate.isEmpty(productCategoryMembers)) {
// before giving up see if this is a variant product, and if so look
// up the virtual product and check it...
GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).cache().queryOne();
List<GenericValue> productAssocs = ProductWorker.getVariantVirtualAssocs(product);
// this does take into account that a product could be a variant of
// multiple products, but this shouldn't ever really happen...
if (productAssocs != null) {
for (GenericValue productAssoc : productAssocs) {
if (isProductInCategory(delegator, productAssoc.getString("productId"), productCategoryId)) {
return true;
}
}
}
return false;
} else {
return true;
}
}
示例12: shippingApplies
import org.ofbiz.product.product.ProductWorker; //导入依赖的package包/类
/** Returns true if shipping charges apply to this item. */
public boolean shippingApplies() {
GenericValue product = getProduct();
if (product != null) {
return ProductWorker.shippingApplies(product);
} else {
// we don't ship non-product items
return false;
}
}
示例13: taxApplies
import org.ofbiz.product.product.ProductWorker; //导入依赖的package包/类
/** Returns true if tax charges apply to this item. */
public boolean taxApplies() {
GenericValue product = getProduct();
if (product != null) {
return ProductWorker.taxApplies(product);
} else {
// we do tax non-product items
return true;
}
}
示例14: getParentProduct
import org.ofbiz.product.product.ProductWorker; //导入依赖的package包/类
public GenericValue getParentProduct() {
if (this._parentProduct != null) {
return this._parentProduct;
}
if (this.productId == null) {
throw new IllegalStateException("Bad product id");
}
this._parentProduct = ProductWorker.getParentProduct(productId, this.getDelegator());
return this._parentProduct;
}
示例15: getOptionalProductFeatures
import org.ofbiz.product.product.ProductWorker; //导入依赖的package包/类
public Map<String, List<GenericValue>> getOptionalProductFeatures() {
if (_product != null) {
return ProductWorker.getOptionalProductFeatures(getDelegator(), this.productId);
} else {
// non-product items do not have features
return FastMap.newInstance();
}
}