📄 shoppingcart.java
字号:
public void setShipFromVendorPartyId(String shipFromVendorPartyId) { this.shipFromVendorPartyId = shipFromVendorPartyId; if (UtilValidate.isEmpty(this.orderPartyId)) this.orderPartyId = shipFromVendorPartyId; } public String getSupplierAgentPartyId() { return this.supplierAgentPartyId != null ? this.supplierAgentPartyId : this.getPartyId(); } public void setSupplierAgentPartyId(String supplierAgentPartyId) { this.supplierAgentPartyId = supplierAgentPartyId; if (UtilValidate.isEmpty(this.orderPartyId)) this.orderPartyId = supplierAgentPartyId; } public String getPartyId() { String partyId = this.orderPartyId; if (partyId == null && getUserLogin() != null) { partyId = getUserLogin().getString("partyId"); } if (partyId == null && getAutoUserLogin() != null) { partyId = getAutoUserLogin().getString("partyId"); } return partyId; } public void setAutoSaveListId(String id) { this.autoSaveListId = id; } public String getAutoSaveListId() { return this.autoSaveListId; } public void setLastListRestore(Timestamp time) { this.lastListRestore = time; } public Timestamp getLastListRestore() { return this.lastListRestore; } public Double getPartyDaysSinceCreated(Timestamp nowTimestamp) { String partyId = this.getPartyId(); if (UtilValidate.isEmpty(partyId)) { return null; } try { GenericValue party = this.getDelegator().findByPrimaryKeyCache("Party", UtilMisc.toMap("partyId", partyId)); if (party == null) { return null; } Timestamp createdDate = party.getTimestamp("createdDate"); if (createdDate == null) { return null; } double diffMillis = nowTimestamp.getTime() - createdDate.getTime(); // millis per day: 1000.0 * 60.0 * 60.0 * 24.0 = 86400000.0 return new Double((diffMillis) / 86400000.0); } catch (GenericEntityException e) { Debug.logError(e, "Error looking up party when getting createdDate", module); return null; } } // ======================================================================= // Methods for cart fields // ======================================================================= /** Clears out the cart. */ public void clear() { this.poNumber = null; this.orderId = null; this.firstAttemptOrderId = null; this.billingAccountId = null; this.billingAccountAmt = 0.00; this.nextItemSeq = 1; this.agreementId = null; this.quoteId = null; this.defaultItemDeliveryDate = null; this.defaultItemComment = null; this.orderAdditionalEmails = null; //this.viewCartOnAdd = false; this.readOnlyCart = false; this.lastListRestore = null; this.autoSaveListId = null; this.orderTermSet = false; this.orderTerms.clear(); this.adjustments.clear(); this.expireSingleUsePayments(); this.cartLines.clear(); this.clearPayments(); this.shipInfo.clear(); this.contactMechIdsMap.clear(); // clear the additionalPartyRole Map Iterator it = this.additionalPartyRole.entrySet().iterator(); while (it.hasNext()) { Map.Entry me = (Map.Entry) it.next(); ((LinkedList) me.getValue()).clear(); } this.additionalPartyRole.clear(); this.freeShippingProductPromoActions.clear(); this.desiredAlternateGiftByAction.clear(); this.productPromoUseInfoList.clear(); this.productPromoCodes.clear(); // clear the auto-save info if (ProductStoreWorker.autoSaveCart(this.getDelegator(), this.getProductStoreId())) { GenericValue ul = this.getUserLogin(); if (ul == null) { ul = this.getAutoUserLogin(); } // load the auto-save list ID if (autoSaveListId == null) { try { autoSaveListId = ShoppingListEvents.getAutoSaveListId(this.getDelegator(), null, null, ul, this.getProductStoreId()); } catch (GeneralException e) { Debug.logError(e, module); } } // clear the list if (autoSaveListId != null) { try { org.ofbiz.order.shoppinglist.ShoppingListEvents.clearListInfo(this.getDelegator(), autoSaveListId); } catch (GenericEntityException e) { Debug.logError(e, module); } } this.lastListRestore = null; this.autoSaveListId = null; } } /** Sets the order type. */ public void setOrderType(String orderType) { this.orderType = orderType; } /** Returns the order type. */ public String getOrderType() { return this.orderType; } public void setChannelType(String channelType) { this.channel = channelType; } public String getChannelType() { return this.channel; } public boolean isPurchaseOrder() { return "PURCHASE_ORDER".equals(this.orderType); } public boolean isSalesOrder() { return "SALES_ORDER".equals(this.orderType); } /** Sets the PO Number in the cart. */ public void setPoNumber(String poNumber) { this.poNumber = poNumber; } /** Returns the po number. */ public String getPoNumber() { return poNumber; } public void setDefaultItemDeliveryDate(String date) { this.defaultItemDeliveryDate = date; } public String getDefaultItemDeliveryDate() { return this.defaultItemDeliveryDate; } public void setDefaultItemComment(String comment) { this.defaultItemComment = comment; } public String getDefaultItemComment() { return this.defaultItemComment; } public void setAgreementId(String agreementId) { this.agreementId = agreementId; } public String getAgreementId() { return this.agreementId; } public void setQuoteId(String quoteId) { this.quoteId = quoteId; } public String getQuoteId() { return this.quoteId; } // ======================================================================= // Payment Method // ======================================================================= public String getPaymentMethodTypeId(String paymentMethodId) { try { GenericValue pm = this.getDelegator().findByPrimaryKey("PaymentMethod", UtilMisc.toMap("paymentMethodId", paymentMethodId)); if (pm != null) { return pm.getString("paymentMethodTypeId"); } } catch (GenericEntityException e) { Debug.logError(e, module); } return null; } /** Creates a CartPaymentInfo object */ public CartPaymentInfo makePaymentInfo(String id, String refNum, Double amount) { CartPaymentInfo inf = new CartPaymentInfo(); inf.refNum[0] = refNum; inf.amount = amount; if (!isPaymentMethodType(id)) { inf.paymentMethodTypeId = this.getPaymentMethodTypeId(id); inf.paymentMethodId = id; } else { inf.paymentMethodTypeId = id; } return inf; } /** Locates the index of an existing CartPaymentInfo object or -1 if none found */ public int getPaymentInfoIndex(String id, String refNum) { CartPaymentInfo thisInf = this.makePaymentInfo(id, refNum, null); for (int i = 0; i < paymentInfo.size(); i++) { CartPaymentInfo inf = (CartPaymentInfo) paymentInfo.get(i); if (inf.compareTo(thisInf) == 0) { return i; } } return -1; } /** Returns the CartPaymentInfo objects which have matching fields */ public List getPaymentInfos(boolean isPaymentMethod, boolean isPaymentMethodType, boolean hasRefNum) { List foundRecords = new LinkedList(); Iterator i = paymentInfo.iterator(); while (i.hasNext()) { CartPaymentInfo inf = (CartPaymentInfo) i.next(); if (isPaymentMethod && inf.paymentMethodId != null) { if (hasRefNum && inf.refNum != null) { foundRecords.add(inf); } else if (!hasRefNum && inf.refNum == null) { foundRecords.add(inf); } } else if (isPaymentMethodType && inf.paymentMethodTypeId != null) { if (hasRefNum && inf.refNum != null) { foundRecords.add(inf); } else if (!hasRefNum && inf.refNum == null) { foundRecords.add(inf); } } } return foundRecords; } /** Locates an existing CartPaymentInfo object by index */ public CartPaymentInfo getPaymentInfo(int index) { return (CartPaymentInfo) paymentInfo.get(index); } /** Locates an existing (or creates a new) CartPaymentInfo object */ public CartPaymentInfo getPaymentInfo(String id, String refNum, String authCode, Double amount, boolean update) { CartPaymentInfo thisInf = this.makePaymentInfo(id, refNum, amount); Iterator i = paymentInfo.iterator(); while (i.hasNext()) { CartPaymentInfo inf = (CartPaymentInfo) i.next(); if (inf.compareTo(thisInf) == 0) { // update the info if (update) { inf.refNum[0] = refNum; inf.refNum[1] = authCode; inf.amount = amount; } Debug.logInfo("Returned existing PaymentInfo - " + inf.toString(), module); return inf; } } Debug.logInfo("Returned new PaymentInfo - " + thisInf.toString(), module); return thisInf; } /** Locates an existing (or creates a new) CartPaymentInfo object */ public CartPaymentInfo getPaymentInfo(String id, String refNum, String authCode, Double amount) { return this.getPaymentInfo(id, refNum, authCode, amount, false); } /** Locates an existing (or creates a new) CartPaymentInfo object */ public CartPaymentInfo getPaymentInfo(String id) { return this.getPaymentInfo(id, null, null, null, false); } /** adds a payment method/payment method type */ public void addPaymentAmount(String id, Double amount, String refNum, String authCode, boolean isSingleUse, boolean isPresent, boolean replace) { CartPaymentInfo inf = this.getPaymentInfo(id, refNum, authCode, amount, true); inf.singleUse = isSingleUse; if (replace) { p
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -