소스 검색

add to local

stanley-king 8 년 전
부모
커밋
b4dececc30
2개의 변경된 파일8개의 추가작업 그리고 4개의 파일을 삭제
  1. 2 2
      data/model/cart.model.php
  2. 6 2
      mobile/control/cart.php

+ 2 - 2
data/model/cart.model.php

@@ -250,7 +250,7 @@ class cartModel extends Model
         }
         else
         {
-            if(is_array($condition) && array_key_exists('cart_id')) {
+            if(is_array($condition) && array_key_exists('cart_id',$condition)) {
                 $cart_id = $condition['cart_id'];
             }
 
@@ -263,7 +263,7 @@ class cartModel extends Model
                     foreach($data as $key => $val) {
                         $cart[$key] = $val;
                     }
-                    $this->getCartNum('session');
+                    $this->getCartNum('Session');
                     return true;
                 }
             }

+ 6 - 2
mobile/control/cart.php

@@ -452,12 +452,14 @@ class cartControl extends mobileControl
         }
     }
 
-    public function do_edit($cart_id,$quantity)
+    public function do_edit($cart_id,$quantity_in)
     {
         $model_cart = Model('cart');
         $model_goods= Model('goods');
         $logic_buy_1 = logic('buy_1');
 
+        $quantity = $quantity_in;
+
         //存放返回信息
         $cart_info = $model_cart->getCartInfo(array('cart_id'=>$cart_id,'buyer_id'=>$_SESSION['member_id']));
         if ($cart_info['bl_id'] == '0')
@@ -477,8 +479,10 @@ class cartControl extends mobileControl
             $logic_buy_1->getGroupbuyInfo($goods_info);
             //限时折扣
             $logic_buy_1->getXianshiInfo($goods_info,$quantity);
-
             $quantity = $goods_info['goods_num'];
+            if($quantity == $cart_info['goods_num']) {
+                return array('cart_id' => $cart_id, 'quantity' => $quantity, 'err_info' => "该商品只允许抢购{$quantity}件~");
+            }
             if(intval($goods_info['goods_storage']) < $quantity) {
                 $model_cart->editCart(array('goods_num'=>$goods_info['goods_storage']),array('cart_id'=>$cart_id,'buyer_id'=>$_SESSION['member_id']));
                 return array('cart_id' => $cart_id, 'quantity' => $goods_info['goods_storage'], 'err_info' => '库存不足,已将您购物车更新为库存数量.');