refactor: 规范状态码、抛出异常的使用

This commit is contained in:
xboard committed 2023-12-07 04:01:32 +08:00
1 parent bfb8bf2201
commit 8f049f72f8
71 files changed
+663 -910

No files matched your search

@@ -17,13 +17,13 @@ class PaymentController extends Controller
try {
$paymentService = new PaymentService($method, null, $uuid);
$verify = $paymentService->notify($request->input());
if (!$verify) throw new ApiException(500, 'verify error');
if (!$verify) return $this->fail([422,'verify error']);
if (!$this->handle($verify['trade_no'], $verify['callback_no'])) {
throw new ApiException(500, 'handle error');
return $this->fail([400,'handle error']);
}
return(isset($verify['custom_result']) ? $verify['custom_result'] : 'success');
} catch (\Exception $e) {
throw new ApiException(500, 'fail');
return $this->fail([500,'fail']);
}
}
@@ -31,7 +31,7 @@ class PaymentController extends Controller
{
$order = Order::where('trade_no', $tradeNo)->first();
if (!$order) {
throw new ApiException(500, 'order is not found');
return $this->fail([400202,'order is not found']);
}
if ($order->status !== 0) return true;
$orderService = new OrderService($order);