dever 3 years ago
parent
commit
d0a7fb4427
1 changed files with 30 additions and 25 deletions
  1. 30 25
      app/shop/src/Buy.php

+ 30 - 25
app/shop/src/Buy.php

@@ -98,34 +98,39 @@ class Buy extends Core
 		$where['uid'] = $this->uid;
 		$where['shop_id'] = $this->shop_id;
 
-		$this->data['cart'] = Dever::db('shop/cart')->select($where);
-
-		if ($this->data['cart']) {
-			foreach ($this->data['cart'] as $k => $v) {
-				$this->data['cart'][$k]['goods'] = Dever::load('goods/lib/info')->getPayInfo($v['goods_id'], $v['sku_id']);
-
-				$w = array();
-	            $w['goods_id'] = $v['goods_id'];
-	            $w['sku_id'] = $v['sku_id'];
-	            $w['shop_id'] = $this->shop_id;
-	            $goods_sku = Dever::db('shop/goods_sku')->find($w);
-	            if ($goods_sku) {
-	                if (isset($goods_sku['price_id']) && $goods_sku['price_id'] > 0) {
-	                    $price_template = Dever::load('price/lib/data')->get($v['goods_id'], $v['sku_id'], $goods_sku['price_id']);
-	                    if ($price_template) {
-	                        if ($price_template['price_sell'] && $price_template['price_sell'] > 0) {
-	                            $this->data['cart'][$k]['goods']['price'] = $price_template['price_sell'];
-	                        }
-	                    }
-	                }
-	            }
-
-				if (isset($this->data['cart'][$k]['goods']['sku_id'])) {
-					$this->data['cart'][$k]['price_id'] = $this->data['cart'][$k]['goods']['sku_id'];
+		$cart = Dever::db('shop/cart')->select($where);
+
+		$this->data['cart'] = array();
+		$i = 0;
+		if ($cart) {
+			foreach ($cart as $k => $v) {
+				$goods = Dever::load('goods/lib/info')->getPayInfo($v['goods_id'], $v['sku_id']);
+				if ($goods['status'] == 1) {
+					$this->data['cart'][$i]['goods'] = $goods;
+
+					$w = array();
+		            $w['goods_id'] = $v['goods_id'];
+		            $w['sku_id'] = $v['sku_id'];
+		            $w['shop_id'] = $this->shop_id;
+		            $goods_sku = Dever::db('shop/goods_sku')->find($w);
+		            if ($goods_sku) {
+		                if (isset($goods_sku['price_id']) && $goods_sku['price_id'] > 0) {
+		                    $price_template = Dever::load('price/lib/data')->get($v['goods_id'], $v['sku_id'], $goods_sku['price_id']);
+		                    if ($price_template) {
+		                        if ($price_template['price_sell'] && $price_template['price_sell'] > 0) {
+		                            $this->data['cart'][$i]['goods']['price'] = $price_template['price_sell'];
+		                        }
+		                    }
+		                }
+		            }
+
+					if (isset($this->data['cart'][$i]['goods']['sku_id'])) {
+						$this->data['cart'][$i]['price_id'] = $this->data['cart'][$i]['goods']['sku_id'];
+					}
+					$i++;
 				}
 			}
 		}
-
 		return $this->data['cart'];
 	}