Browse Source

地区购买

afa 9 months ago
parent
commit
143a14641f
2 changed files with 2 additions and 5 deletions
  1. 1 3
      application/api/controller/Order.php
  2. 1 2
      application/api/validate/Order.php

+ 1 - 3
application/api/controller/Order.php

@@ -36,7 +36,6 @@ class Order extends Api
         $areaArr = ($params['type'] == 1)? explode(',', $params['area_id']): '';
         $areaNum = ($params['type'] == 1)? count($areaArr): $params['num'];
         if(($order_info->num +$order_info->init_num+ $areaNum) > $order_info->stock) $this->error(__("库存不足"));
-    
         // 启动事务
         Db::startTrans();
         try {
@@ -46,14 +45,13 @@ class Order extends Api
             if(bccomp($totalPrice, $amount, 2) > 0) throw new Exception(__("余额不足请前往充值"), 15001);
             if($order_info->start_time > time()) throw new Exception(__("抢购未开始"));
             if($order_info->stock == 0 || time() >= $order_info->end_time) throw new Exception(__("抢购已结束"));
-
+            
             //批量地区添加 1选择地区 2未选择地区
             if($params['type'] == 1)
                 $productOrder::setPopularAreaOrder($areaArr, $params['order_id'], $order_info->price, $params['product_id'], $this->auth->id);
             else
                 $productOrder::setPopularNoAreaOrder($areaNum, $params['order_id'], $order_info->price, $params['product_id'], $this->auth->id);
             
-
             //余额记录
             $ledgerWalletModel->changeWalletAccount($this->auth->id, Asset::TOKEN, -$totalPrice, $ledgerWalletModel::Popular, $this->auth->id);
 

+ 1 - 2
application/api/validate/Order.php

@@ -10,11 +10,10 @@ class Order extends Validate
      * 验证规则
      */
     protected $rule = [
-  
       'order_id'   => 'require',
       'product_id' => 'require',
       'area_id'    => 'requireIf:type,1',
-      'num'        => 'requireIf:type,2',
+      'num'        => 'requireIf:type,2|gt:0',
       'name'       => 'require',
       'type'       => 'require|in:1,2',
       'phone'      => 'require|mobile',