📄 shoppingcart.java
字号:
} else { i++; } } return false; } public boolean containAllWorkEffortCartItems() { // Check for existing cart item. for (int i = 0; i < this.cartLines.size();) { ShoppingCartItem cartItem = (ShoppingCartItem) cartLines.get(i); if (!cartItem.getItemType().equals("RENTAL_ORDER_ITEM")) { // not a item to create workefforts? return false; } else { i++; } } return true; } /** Returns this item's index. */ public int getItemIndex(ShoppingCartItem item) { return cartLines.indexOf(item); } /** Get a ShoppingCartItem from the cart object. */ public ShoppingCartItem findCartItem(int index) { if (cartLines.size() <= index) return null; return (ShoppingCartItem) cartLines.get(index); } public ShoppingCartItem findCartItem(String orderItemSeqId) { if (orderItemSeqId != null) { for (int i = 0; i < this.cartLines.size(); i++) { ShoppingCartItem cartItem = (ShoppingCartItem) cartLines.get(i); String itemSeqId = cartItem.getOrderItemSeqId(); if (itemSeqId != null && orderItemSeqId.equals(itemSeqId)) { return cartItem; } } } return null; } /** Remove an item from the cart object. */ public void removeCartItem(int index, LocalDispatcher dispatcher) throws CartItemModifyException { if (isReadOnlyCart()) { throw new CartItemModifyException("Cart items cannot be changed"); } if (index < 0) return; if (cartLines.size() <= index) return; ShoppingCartItem item = (ShoppingCartItem) cartLines.remove(index); // set quantity to 0 to trigger necessary events item.setQuantity(0.0, dispatcher, this); } /** Moves a line item to a differnt index. */ public void moveCartItem(int fromIndex, int toIndex) { if (toIndex < fromIndex) { cartLines.add(toIndex, cartLines.remove(fromIndex)); } else if (toIndex > fromIndex) { cartLines.add(toIndex - 1, cartLines.remove(fromIndex)); } } /** Returns the number of items in the cart object. */ public int size() { return cartLines.size(); } /** Returns a Collection of items in the cart object. */ public List items() { return cartLines; } /** Returns an iterator of cart items. */ public Iterator iterator() { return cartLines.iterator(); } /** Gets the userLogin associated with the cart; may be null */ public GenericValue getUserLogin() { return this.userLogin; } public void setUserLogin(GenericValue userLogin, LocalDispatcher dispatcher) throws CartItemModifyException { this.userLogin = userLogin; this.handleNewUser(dispatcher); } protected void setUserLogin(GenericValue userLogin) { if (this.userLogin == null) { this.userLogin = userLogin; } else { throw new IllegalArgumentException("Cannot change UserLogin object with this method"); } } public GenericValue getAutoUserLogin() { return this.autoUserLogin; } public void setAutoUserLogin(GenericValue autoUserLogin, LocalDispatcher dispatcher) throws CartItemModifyException { this.autoUserLogin = autoUserLogin; if (getUserLogin() == null) { this.handleNewUser(dispatcher); } } protected void setAutoUserLogin(GenericValue autoUserLogin) { if (this.autoUserLogin == null) { this.autoUserLogin = autoUserLogin; } else { throw new IllegalArgumentException("Cannot change AutoUserLogin object with this method"); } } public void handleNewUser(LocalDispatcher dispatcher) throws CartItemModifyException { String partyId = this.getPartyId(); if (UtilValidate.isNotEmpty(partyId)) { // recalculate all prices Iterator cartItemIter = this.iterator(); while (cartItemIter.hasNext()) { ShoppingCartItem cartItem = (ShoppingCartItem) cartItemIter.next(); cartItem.updatePrice(dispatcher, this); } // check all promo codes, remove on failed check Iterator promoCodeIter = this.productPromoCodes.iterator(); while (promoCodeIter.hasNext()) { String promoCode = (String) promoCodeIter.next(); String checkResult = ProductPromoWorker.checkCanUsePromoCode(promoCode, partyId, this.getDelegator()); if (checkResult != null) { promoCodeIter.remove(); Debug.logWarning(UtilProperties.getMessage(resource_error,"OrderOnUserChangePromoCodeWasRemovedBecause", UtilMisc.toMap("checkResult",checkResult), locale), module); } } // rerun promotions ProductPromoWorker.doPromotions(this, dispatcher); } } public String getExternalId() { return this.externalId; } public void setExternalId(String externalId) { this.externalId = externalId; } public String getInternalCode() { return this.internalCode; } public void setInternalCode(String internalCode) { this.internalCode = internalCode; } public String getWebSiteId() { return this.webSiteId; } public void setWebSiteId(String webSiteId) { this.webSiteId = webSiteId; } /** * Set ship before date for a particular ship group * @param idx * @param shipBeforeDate */ public void setShipBeforeDate(int idx, Timestamp shipBeforeDate) { CartShipInfo csi = this.getShipInfo(idx); csi.shipBeforeDate = shipBeforeDate; } /** * Set ship before date for ship group 0 * @param shipBeforeDate */ public void setShipBeforeDate(Timestamp shipBeforeDate) { this.setShipBeforeDate(0, shipBeforeDate); } /** * Get ship before date for a particular ship group * @param idx * @return */ public Timestamp getShipBeforeDate(int idx) { CartShipInfo csi = this.getShipInfo(idx); return csi.shipBeforeDate; } /** * Get ship before date for ship group 0 * @return */ public Timestamp getShipBeforeDate() { return this.getShipBeforeDate(0); } /** * Set ship after date for a particular ship group * @param idx * @param shipAfterDate */ public void setShipAfterDate(int idx, Timestamp shipAfterDate) { CartShipInfo csi = this.getShipInfo(idx); csi.shipAfterDate = shipAfterDate; } /** * Set ship after date for a particular ship group * @param shipAfterDate */ public void setShipAfterDate(Timestamp shipAfterDate) { this.setShipAfterDate(0, shipAfterDate); } /** * Get ship after date for a particular ship group * @param idx * @return */ public Timestamp getShipAfterDate(int idx) { CartShipInfo csi = this.getShipInfo(idx); return csi.shipAfterDate; } /** * Get ship after date for ship group 0 * @return */ public Timestamp getShipAfterDate() { return this.getShipAfterDate(0); } public void setDefaultShipBeforeDate(Timestamp defaultShipBeforeDate) { this.defaultShipBeforeDate = defaultShipBeforeDate; } public Timestamp getDefaultShipBeforeDate() { return this.defaultShipBeforeDate; } public void setDefaultShipAfterDate(Timestamp defaultShipAfterDate) { this.defaultShipAfterDate = defaultShipAfterDate; } public Timestamp getDefaultShipAfterDate() { return this.defaultShipAfterDate; } public String getOrderPartyId() { return this.orderPartyId != null ? this.orderPartyId : this.getPartyId(); } public void setOrderPartyId(String orderPartyId) { this.orderPartyId = orderPartyId; } public String getPlacingCustomerPartyId() { return this.placingCustomerPartyId != null ? this.placingCustomerPartyId : this.getPartyId(); } public void setPlacingCustomerPartyId(String placingCustomerPartyId) { this.placingCustomerPartyId = placingCustomerPartyId; if (UtilValidate.isEmpty(this.orderPartyId)) this.orderPartyId = placingCustomerPartyId; } public String getBillToCustomerPartyId() { return this.billToCustomerPartyId != null ? this.billToCustomerPartyId : this.getPartyId(); } public void setBillToCustomerPartyId(String billToCustomerPartyId) { this.billToCustomerPartyId = billToCustomerPartyId; if ((UtilValidate.isEmpty(this.orderPartyId)) && !(orderType.equals("PURCHASE_ORDER"))) { this.orderPartyId = billToCustomerPartyId; // orderPartyId should be bill-to-customer when it is not a purchase order } } public String getShipToCustomerPartyId() { return this.shipToCustomerPartyId != null ? this.shipToCustomerPartyId : this.getPartyId(); } public void setShipToCustomerPartyId(String shipToCustomerPartyId) { this.shipToCustomerPartyId = shipToCustomerPartyId; if (UtilValidate.isEmpty(this.orderPartyId)) this.orderPartyId = shipToCustomerPartyId; } public String getEndUserCustomerPartyId() { return this.endUserCustomerPartyId != null ? this.endUserCustomerPartyId : this.getPartyId(); } public void setEndUserCustomerPartyId(String endUserCustomerPartyId) { this.endUserCustomerPartyId = endUserCustomerPartyId; if (UtilValidate.isEmpty(this.orderPartyId)) this.orderPartyId = endUserCustomerPartyId; }// protected String billFromVendorPartyId = null; // protected String shipFromVendorPartyId = null; //protected String supplierAgentPartyId = null; public String getBillFromVendorPartyId() { return this.billFromVendorPartyId != null ? this.billFromVendorPartyId : this.getPartyId(); } public void setBillFromVendorPartyId(String billFromVendorPartyId) { this.billFromVendorPartyId = billFromVendorPartyId; if ((UtilValidate.isEmpty(this.orderPartyId)) && (orderType.equals("PURCHASE_ORDER"))) { this.orderPartyId = billFromVendorPartyId; // orderPartyId should be bill-from-vendor when it is a purchase order } } public String getShipFromVendorPartyId() { return this.shipFromVendorPartyId != null ? this.shipFromVendorPartyId : this.getPartyId(); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -