wesmiler 1 year ago
parent
commit
7f23fc44c1
1 changed files with 15 additions and 10 deletions
  1. 15 10
      app/Http/Controllers/Api/v1/OrderController.php

+ 15 - 10
app/Http/Controllers/Api/v1/OrderController.php

@@ -64,18 +64,23 @@ class OrderController extends webApp
      */
     public function buySubmit(OrderValidator $validator)
     {
-        $params = request()->all();
-        $params = $validator->check($params, 'buy');
-        if (!is_array($params)) {
-            return showJson($params, false);
+        try{
+            $params = request()->all();
+            $params = $validator->check($params, 'buy');
+            if (!is_array($params)) {
+                return showJson($params, false);
+            }
+
+            if(!$result = OrderService::make()->buySubmit($this->userId, $params)){
+                $error = OrderService::make()->getError();
+                return showJson($error, false, '',$error==2304?405:($error == 1040?401:-1));
+            }else{
+                return showJson(OrderService::make()->getError(), true, $result);
+            }
+        } catch (\Exception $exception){
+            return showJson(1018, false,['error'=> $exception->getMessage(),'trace'=>$exception->getTrace()]);
         }
 
-        if(!$result = OrderService::make()->buySubmit($this->userId, $params)){
-            $error = OrderService::make()->getError();
-            return showJson($error, false, '',$error==2304?405:($error == 1040?401:-1));
-        }else{
-            return showJson(OrderService::make()->getError(), true, $result);
-        }
     }