|
|
@@ -124,6 +124,33 @@ class Cart
|
|
|
return $supplierData;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取购物车中所有商品列表
|
|
|
+ * @return array|mixed
|
|
|
+ */
|
|
|
+ public function getCartProductList(){
|
|
|
+ $carts = Cache::get('cart_products_' . $this->user_id)? : [];
|
|
|
+ if($carts){
|
|
|
+ return $carts;
|
|
|
+ }
|
|
|
+
|
|
|
+ $cartList = $this->getList([]);
|
|
|
+ $carts = [];
|
|
|
+ if($cartList){
|
|
|
+ foreach ($cartList as $item){
|
|
|
+ if($item['productList']){
|
|
|
+ foreach ($item['productList'] as $v){
|
|
|
+ $carts[$v['product_id']] = $v;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if($carts){
|
|
|
+ Cache::set('cart_products_' . $this->user_id, $carts, rand(10, 30));
|
|
|
+ }
|
|
|
+ return $carts;
|
|
|
+ }
|
|
|
+
|
|
|
private function getProductBySupplier($supplierId, $productList){
|
|
|
$result = [];
|
|
|
foreach ($productList as $product){
|