Przeglądaj źródła

加入异常补货

family 1 rok temu
rodzic
commit
b4e123c59c
1 zmienionych plików z 21 dodań i 15 usunięć
  1. 21 15
      app/controller/api/movie/Movie.php

+ 21 - 15
app/controller/api/movie/Movie.php

@@ -180,22 +180,24 @@ class Movie extends BaseController
180 180
      */
181 181
     public function submitOrder()
182 182
     {
183
-        $params = $this->request->params(
184
-            ['relation_id', ''], // 场次ID
185
-            ['sched_sign', ''], // 场次编码
186
-            ['sched_seat', ''], // 座位编码
187
-            ['channel_sn', ''], // 实际价格
188
-            ['phone', ''] // 联系电话
189
-        );
190
-
191
-        if (empty($params['relation_id']) || empty($params['sched_sign']) || $params['channel_sn']) return app('json')->fail('请选择观影场次');
183
+        $params['relation_id'] = $this->request->param('relation_id', '');// 场次ID
184
+        $params['sched_sign'] = $this->request->param('sched_sign', '');// 场次编码
185
+        $params['sched_seat'] = $this->request->param('sched_seat', '');// 座位编码
186
+        $params['channel_sn'] = $this->request->param('channel_sn', '');// 实际价格
187
+        $params['phone'] = $this->request->param('phone', '');// 联系电话
188
+
189
+        if (empty($params['relation_id']) || empty($params['sched_sign']) || empty($params['channel_sn'])) return app('json')->fail('请选择观影场次');
192 190
         if (empty($params['sched_seat'])) return app('json')->fail('请选择观影座位');
193 191
 
194
-        $result = $this->repository->submitOrder($this->request->userInfo(), $params);
195
-        if (!empty($result)) {
196
-            return app('json')->success(['order_sn' => $result]);
197
-        } else {
198
-            return app('json')->fail('锁座下单失败');
192
+        try {
193
+            $result = $this->repository->submitOrder($this->request->userInfo(), $params);
194
+            if (!empty($result)) {
195
+                return app('json')->success(['order_sn' => $result]);
196
+            } else {
197
+                return app('json')->fail('锁座下单失败');
198
+            }
199
+        } catch (\Exception $exception) {
200
+            return app('json')->fail($exception->getMessage());
199 201
         }
200 202
     }
201 203
 
@@ -211,7 +213,11 @@ class Movie extends BaseController
211 213
         $pay_type = $this->request->param('pay_type', '');
212 214
         if (empty($pay_type) || !in_array($pay_type, ['wx', 'ali'])) return app('json')->fail('请选择支付方式');
213 215
 
214
-        return app('json')->success($this->repository->confirmOrder($this->request->userInfo(), $order_sn, $pay_type));
216
+        try {
217
+            return app('json')->success($this->repository->confirmOrder($this->request->userInfo(), $order_sn, $pay_type));
218
+        } catch (\Exception $exception) {
219
+            return app('json')->fail($exception->getMessage());
220
+        }
215 221
     }
216 222
 
217 223
     /**