Explorar el Código

兑换商品下单

wufeng hace 2 años
padre
commit
2d0636757d

+ 2 - 2
app/mobile/config/validate_rules.php

@@ -50,10 +50,10 @@ return [
     ],
 
     //【订单】
-    'orderAdd'=>[
+    'ExchangeOrderAdd'=>[
         'good_id|商品'=>'require|number|gt:0',
         'addr_id|收货地址'=>'require|number|gt:0',
-        'num|购买数量'=>'require|number|gt:0',
+        'num|购买数量'=>'require|number|gt:0|lt:999999999',
         'remark|'=>'max:255',
     ],
 

+ 1 - 1
app/mobile/controller/Exchange.php

@@ -34,7 +34,7 @@ class Exchange extends BaseController
 
         $param = $this->request->only(['good_id','addr_id','num','remark'],'post');
 
-        $val = Validate::rule(Config::get('validate_rules.orderAdd'));
+        $val = Validate::rule(Config::get('validate_rules.ExchangeOrderAdd'));
 
         if(!$val->check($param)) throw new ValidateException($val->getError());
 

+ 3 - 3
app/mobile/logic/ExchangeLogic.php

@@ -80,12 +80,12 @@ class ExchangeLogic extends BaseLogic
                 ->field('a.id,a.good_id,b.good_code,b.good_name,b.status,b.moq,c.id inventory_id,c.inventory')
                 ->leftJoin('good b', 'b.id=a.good_id AND b.is_del=' . CommonModel::$del_normal)
                 ->leftJoin('inventory_exchange c', 'c.account_id=' . self::$aid . ' AND c.good_id=a.good_id')
-                ->where(['a.is_del' => CommonModel::$del_normal, 'a.group_id' => self::$group_id, 'good_id' => $data['good_id']])
+                ->where(['a.is_del' => CommonModel::$del_normal, 'a.group_id' => self::$group_id, 'a.good_id' => $data['good_id']])
                 ->findOrEmpty();
 
             if ($rs->isEmpty()) throw new Exception('该商品不存在或不允许兑换');
-            if ($rs->status != CommonModel::$status_disable) throw new Exception('该商品已被禁用');
-            if ($rs->moq > $data['num']) throw new Exception('不满足该商品的起订量');
+            if ($rs->status != CommonModel::$status_normal) throw new Exception('该商品已被禁用');
+            if ($rs->moq > $data['num']) throw new Exception('不满足该商品的起订量,'.$rs->moq);
             if ($rs->inventory < $data['num']) throw new Exception('库存数不足');
 
             $date = date('Y-m-d H:i:s');

+ 1 - 0
app/mobile/route/app.php

@@ -24,5 +24,6 @@ Route::rule('serviceRead', 'Service/read');//读取
 //【兑换商品】
 Route::rule('exchangeGoodList', 'Exchange/goodList');//商品列表
 Route::rule('exchangeGoodInfo', 'Exchange/goodInfo');//商品详情
+Route::rule('exchangeOrderAdd', 'Exchange/orderAdd');//兑换商品下单