wupengfei 2 years ago
parent
commit
5cfae096b8
1 changed files with 2 additions and 5 deletions
  1. 2 5
      application/api/controller/Order.php

+ 2 - 5
application/api/controller/Order.php

@@ -215,12 +215,8 @@ class Order extends Base
         if(!$goods_id || !$spec_id)  $this->error('请选择商品');
         if($num <=0 ) $this->error('数量有误');
         if(!$add_id ) $this->error('请选择收货地址');
-
-
-
+        Db::startTrans();
         try {
-
-            Db::startTrans();
             $add_info = DeliveryAddress::find($add_id)->toArray();
             $order_insert = [
                 'user_id' => $this->user_id,
@@ -286,6 +282,7 @@ class Order extends Base
                 $redis_prefix = 'GROUP_'.$act_id.'_';
                 $redis = new Redis();
                 $redis_stock = $redis->get($redis_prefix.$item['id'].'_stock',0);
+                var_dump($redis_stock);
                 if($redis_stock <= 0 || $redis_stock < $num || $item['stock'] < $num) $this->exception('库存不足');
                 if($leader_id){
                     if($redis->get($redis_prefix.$leader_id,0)) $this->exception('该团已有团员参与');