afa 6 ماه پیش
والد
کامیت
026f783d92
2فایلهای تغییر یافته به همراه6 افزوده شده و 4 حذف شده
  1. 4 1
      application/api/controller/Pledge.php
  2. 2 3
      application/api/logic/PledgeLogic.php

+ 4 - 1
application/api/controller/Pledge.php

@@ -96,7 +96,7 @@ class Pledge extends Api
         try {
 
             // 质抵押订单 
-            $pledgeLogic::setPledgeOrder($pledge, $order_no, $this->auth->id, $count, $this->pay[$pay_type], $pledge[$this->pay[$pay_type]]);
+            $res = $pledgeLogic::setPledgeOrder($pledge, $order_no, $this->auth->id, $count, $this->pay[$pay_type], $pledge[$this->pay[$pay_type]]);
             // 提交事务
             Db::commit();
         } catch (Exception $e) {
@@ -104,6 +104,9 @@ class Pledge extends Api
             Db::rollback();
             $this->error($e->getMessage(), null, $e->getCode());
         }
+        if ($res === false)    {
+            $this->error(__("订单创建失败"));
+        }
         $this->success('ok');
       }
 

+ 2 - 3
application/api/logic/PledgeLogic.php

@@ -42,9 +42,8 @@ class PledgeLogic
     //添加质抵押订单
     public static function setPledgeOrder(object $pledge, array $order_no, int $user_id, int $count, string $pay_type, float $price)
     {
-        $model  = Loader::model('ProductOrder');
         $product=  self::getOrderProductList($user_id, $order_no, $count);
-        
+
         if(empty($product) || count($product) < $count)  throw new Exception('订单不存在');
         $pledge_num = 1;
         if($pledge->type_id == ProductPledges::Single) $pledge_num = $count;
@@ -59,6 +58,7 @@ class PledgeLogic
         (new LedgerWalletModel())->changeWalletAccount($user_id, $pay_type, -$price, $action, 0);
   
         //修改状态
+        $model  = Loader::model('ProductOrder');
         return $model->whereIn('order_no', $order_no)->setField('status', $model::Freeze);
     }
 
@@ -191,7 +191,6 @@ class PledgeLogic
     //添加用户存储产品
     public static function setPledgeProductAdd(object $pledge, int $user_id, int $count, array $order_no)
     {
-
         $product = self::getOrderProductList($user_id, $order_no, $count);
         if(empty($product) || count($product) < $count)  throw new Exception('订单不存在');