mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-23 19:37:35 +08:00
refactor: 规范状态码、抛出异常的使用
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user