コード例 #1
0
ファイル: Cart.java プロジェクト: YuxingXie/daba_mall
 public int getTotalAmount() {
   if (productSelectedList == null) return 0;
   int totalAmount = 0;
   for (ProductSelected productSelected : productSelectedList) {
     totalAmount += productSelected.getAmount();
   }
   return totalAmount;
 }
コード例 #2
0
ファイル: Cart.java プロジェクト: YuxingXie/daba_mall
 public double getTotalPrice() {
   if (productSelectedList == null) return 0d;
   double totalPrice = 0d;
   for (ProductSelected productSelected : productSelectedList) {
     Assert.notNull(productSelected.getProductSeries());
     if (productSelected.getProductSeries().getCurrentPrice() == null) totalPrice += 0;
     else
       totalPrice +=
           productSelected.getAmount()
               * productSelected.getProductSeries().getCurrentPrice().getPrice();
   }
   return totalPrice;
 }
コード例 #3
0
ファイル: Cart.java プロジェクト: YuxingXie/daba_mall
 public void merge(ProductSelected anotherProductSelected) {
   List<ProductSelected> productSelectedList = this.getProductSelectedList();
   if (productSelectedList == null) {
     productSelectedList = new ArrayList<ProductSelected>();
     productSelectedList.add(anotherProductSelected);
     this.setProductSelectedList(productSelectedList);
     return;
   }
   for (ProductSelected thisProductSelected : this.getProductSelectedList()) {
     if (thisProductSelected.equals(anotherProductSelected)) {
       int amount = thisProductSelected.getAmount() == null ? 0 : thisProductSelected.getAmount();
       thisProductSelected.setAmount(amount + anotherProductSelected.getAmount());
       return;
     }
   }
   productSelectedList.add(anotherProductSelected);
   //        setProductSelectedList(productSelectedList);
 }
コード例 #4
0
ファイル: Cart.java プロジェクト: YuxingXie/daba_mall
 public void merge(Cart anotherCart) {
   if (anotherCart == null) return;
   if (anotherCart.getProductSelectedList() == null) return;
   List<ProductSelected> thisProductSelectedList = this.getProductSelectedList();
   if (thisProductSelectedList == null) {
     this.setProductSelectedList(anotherCart.getProductSelectedList());
     return;
   }
   outer:
   for (ProductSelected anotherProductSelected : anotherCart.getProductSelectedList()) {
     inner:
     for (ProductSelected thisProductSelected : this.getProductSelectedList()) {
       if (thisProductSelected.equals(anotherProductSelected)) {
         thisProductSelected.setAmount(
             thisProductSelected.getAmount() + anotherProductSelected.getAmount());
         break outer;
       }
     }
     thisProductSelectedList.add(anotherProductSelected);
     //            setProductSelectedList(thisProductSelectedList);
   }
 }