Browse Source

购物车优化

lizhen_gitee 11 months ago
parent
commit
c4b6f0b81b
1 changed files with 4 additions and 4 deletions
  1. 4 4
      addons/unishop/controller/Cart.php

+ 4 - 4
addons/unishop/controller/Cart.php

@@ -24,7 +24,7 @@ class Cart extends Base
      * 允许频繁访问的接口
      * @var array
      */
-    protected $frequently = ['number_change', 'choose_change'];
+    protected $frequently = ['number_change','index', 'choose_change'];
 
     /**
      * @ApiTitle    (列表)
@@ -156,9 +156,9 @@ class Cart extends Base
         $oldCart = $cartModel->find();
 
         if ($oldCart) {
-            $this->error('商品已存在购物车');
-//            $oldCart->number++;
-//            $result = $oldCart->save();
+            //$this->error('商品已存在购物车');
+            $oldCart->number += $number;
+            $result = $oldCart->save();
         } else {
             $cartModel->user_id = $user_id;
             $cartModel->product_id = $id;