📄 orderreadhelper.java
字号:
return UtilFormatOut.checkNull(shipmentMethodType.getString("shipmentMethodTypeId")) + "@" + UtilFormatOut.checkNull(shipGroup.getString("carrierPartyId")); } } return UtilFormatOut.checkNull(shipGroup.getString("carrierPartyId")); } } catch (GenericEntityException e) { Debug.logWarning(e, module); } return ""; } public boolean hasShippingAddress() { if (UtilValidate.isNotEmpty(this.getShippingLocations())) { return true; } return false; } public GenericValue getOrderItemShipGroup(String shipGroupSeqId) { try { return orderHeader.getDelegator().findByPrimaryKey("OrderItemShipGroup", UtilMisc.toMap("orderId", orderHeader.getString("orderId"), "shipGroupSeqId", shipGroupSeqId)); } catch (GenericEntityException e) { Debug.logWarning(e, module); } return null; } public List getOrderItemShipGroups() { try { return orderHeader.getRelated("OrderItemShipGroup", UtilMisc.toList("shipGroupSeqId")); } catch (GenericEntityException e) { Debug.logWarning(e, module); } return null; } public List getShippingLocations() { List shippingLocations = new LinkedList(); List shippingCms = this.getOrderContactMechs("SHIPPING_LOCATION"); if (shippingCms != null) { Iterator i = shippingCms.iterator(); while (i.hasNext()) { GenericValue ocm = (GenericValue) i.next(); if (ocm != null) { try { GenericValue addr = ocm.getDelegator().findByPrimaryKey("PostalAddress", UtilMisc.toMap("contactMechId", ocm.getString("contactMechId"))); if (addr != null) { shippingLocations.add(addr); } } catch (GenericEntityException e) { Debug.logWarning(e, module); } } } } return shippingLocations; } public GenericValue getShippingAddress(String shipGroupSeqId) { try { GenericValue shipGroup = orderHeader.getDelegator().findByPrimaryKey("OrderItemShipGroup", UtilMisc.toMap("orderId", orderHeader.getString("orderId"), "shipGroupSeqId", shipGroupSeqId)); if (shipGroup != null) { return shipGroup.getRelatedOne("PostalAddress"); } } catch (GenericEntityException e) { Debug.logWarning(e, module); } return null; } /** @deprecated */ public GenericValue getShippingAddress() { try { GenericValue orderContactMech = EntityUtil.getFirst(orderHeader.getRelatedByAnd("OrderContactMech", UtilMisc.toMap( "contactMechPurposeTypeId", "SHIPPING_LOCATION"))); if (orderContactMech != null) { GenericValue contactMech = orderContactMech.getRelatedOne("ContactMech"); if (contactMech != null) { return contactMech.getRelatedOne("PostalAddress"); } } } catch (GenericEntityException e) { Debug.logWarning(e, module); } return null; } public List getBillingLocations() { List billingLocations = new LinkedList(); List billingCms = this.getOrderContactMechs("BILLING_LOCATION"); if (billingCms != null) { Iterator i = billingCms.iterator(); while (i.hasNext()) { GenericValue ocm = (GenericValue) i.next(); if (ocm != null) { try { GenericValue addr = ocm.getDelegator().findByPrimaryKey("PostalAddress", UtilMisc.toMap("contactMechId", ocm.getString("contactMechId"))); if (addr != null) { billingLocations.add(addr); } } catch (GenericEntityException e) { Debug.logWarning(e, module); } } } } return billingLocations; } /** @deprecated */ public GenericValue getBillingAddress() { GenericValue billingAddress = null; try { GenericValue orderContactMech = EntityUtil.getFirst(orderHeader.getRelatedByAnd("OrderContactMech", UtilMisc.toMap("contactMechPurposeTypeId", "BILLING_LOCATION"))); if (orderContactMech != null) { GenericValue contactMech = orderContactMech.getRelatedOne("ContactMech"); if (contactMech != null) { billingAddress = contactMech.getRelatedOne("PostalAddress"); } } } catch (GenericEntityException e) { Debug.logWarning(e, module); } if (billingAddress == null) { // get the address from the billing account GenericValue billingAccount = getBillingAccount(); if (billingAccount != null) { try { billingAddress = billingAccount.getRelatedOne("PostalAddress"); } catch (GenericEntityException e) { Debug.logWarning(e, module); } } else { // get the address from the first payment method GenericValue paymentPreference = EntityUtil.getFirst(getPaymentPreferences()); if (paymentPreference != null) { try { GenericValue paymentMethod = paymentPreference.getRelatedOne("PaymentMethod"); if (paymentMethod != null) { GenericValue creditCard = paymentMethod.getRelatedOne("CreditCard"); if (creditCard != null) { billingAddress = creditCard.getRelatedOne("PostalAddress"); } else { GenericValue eftAccount = paymentMethod.getRelatedOne("EftAccount"); if (eftAccount != null) { billingAddress = eftAccount.getRelatedOne("PostalAddress"); } } } } catch (GenericEntityException e) { Debug.logWarning(e, module); } } } } return billingAddress; } public List getOrderContactMechs(String purposeTypeId) { try { return orderHeader.getRelatedByAnd("OrderContactMech", UtilMisc.toMap("contactMechPurposeTypeId", purposeTypeId)); } catch (GenericEntityException e) { Debug.logWarning(e, module); } return null; } public Timestamp getEarliestShipByDate() { try { List groups = orderHeader.getRelated("OrderItemShipGroup", UtilMisc.toList("shipByDate DESC")); if (groups.size() > 0) { GenericValue group = (GenericValue) groups.get(0); return group.getTimestamp("shipByDate"); } } catch (GenericEntityException e) { Debug.logWarning(e, module); } return null; } public Timestamp getEarliestShipAfterDate() { try { List groups = orderHeader.getRelated("OrderItemShipGroup", UtilMisc.toList("shipAfterDate DESC")); if (groups.size() > 0) { GenericValue group = (GenericValue) groups.get(0); return group.getTimestamp("shipAfterDate"); } } catch (GenericEntityException e) { Debug.logWarning(e, module); } return null; } public String getCurrentStatusString() { GenericValue statusItem = null; try { statusItem = orderHeader.getRelatedOneCache("StatusItem"); } catch (GenericEntityException e) { Debug.logError(e, module); } if (statusItem != null) { return statusItem.getString("description"); } else { return orderHeader.getString("statusId"); } } public String getStatusString() { List orderStatusList = this.getOrderHeaderStatuses(); if (orderStatusList == null || orderStatusList.size() == 0) return ""; Iterator orderStatusIter = orderStatusList.iterator(); StringBuffer orderStatusString = new StringBuffer(50); try { boolean isCurrent = true; while (orderStatusIter.hasNext()) { GenericValue orderStatus = (GenericValue) orderStatusIter.next(); GenericValue statusItem = orderStatus.getRelatedOneCache("StatusItem"); if (statusItem != null) { orderStatusString.append(statusItem.getString("description")); } else { orderStatusString.append(orderStatus.getString("statusId")); } if (isCurrent && orderStatusIter.hasNext()) { orderStatusString.append(" ("); isCurrent = false; } else { if (orderStatusIter.hasNext()) { orderStatusString.append("/"); } else { if (!isCurrent) { orderStatusString.append(")"); } } } } } catch (GenericEntityException e) { Debug.logError(e, "Error getting Order Status information: " + e.toString(), module); } return orderStatusString.toString(); } public GenericValue getBillingAccount() { GenericValue billingAccount = null; try { billingAccount = orderHeader.getRelatedOne("BillingAccount"); } catch (GenericEntityException e) { Debug.logError(e, module); } return billingAccount; } /** * Returns the OrderPaymentPreference.maxAmount for the billing account associated with the order, or 0 if there is no * billing account or no max amount set */ public double getBillingAccountMaxAmount() { if (getBillingAccount() == null) { return 0.0; } else { List paymentPreferences = getPaymentPreferences(); GenericValue billingAccountPaymentPreference = EntityUtil.getFirst(EntityUtil.filterByAnd(paymentPreferences, UtilMisc.toMap("paymentMethodTypeId", "EXT_BILLACT"))); if ((billingAccountPaymentPreference != null) && (billingAccountPaymentPreference.getDouble("maxAmount") != null)) { return billingAccountPaymentPreference.getDouble("maxAmount").doubleValue(); } else { return 0.0; } } } /** * Returns party from OrderRole of BILL_TO_CUSTOMER */ public GenericValue getBillToParty() { return this.getPartyFromRole("BILL_TO_CUSTOMER"); } /** * Returns bill from party based on BILL_FROM_VENDOR in OrderRole. If not found, then use the Order's ProductStore payToPartyId */ public GenericValue getBillFromParty() { GenericValue billFromParty = this.getPartyFromRole("BILL_FROM_VENDOR"); if (billFromParty == null) { GenericValue productStore = getProductStore(); if (productStore != null) { try { return productStore.getRelatedOneCache("Party"); } catch (GenericEntityException ex) { Debug.logError("Failed to get Pay to Party of ProductStore for OrderHeader [" + orderHeader +" ] due to exception " + ex.getMessage(), module); return null; } } else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -