diff --git a/app/common/logic/PaymentLogic.php b/app/common/logic/PaymentLogic.php index 2ae9d5f8b..6ae8af3c0 100644 --- a/app/common/logic/PaymentLogic.php +++ b/app/common/logic/PaymentLogic.php @@ -40,6 +40,7 @@ class PaymentLogic extends BaseLogic PayNotifyLogic::handle($from, $order['order_id']); return ['pay_way' => PayEnum::BALANCE_PAY]; } + try { switch ($payWay) { case PayEnum::WECHAT_PAY: $auth = UserAuth::where(['user_id' => $order['uid'], 'terminal' => $terminal])->findOrEmpty(); @@ -56,19 +57,20 @@ class PaymentLogic extends BaseLogic 'attach' => $from ]; $wechat = new PayService(1); - try { + // 尝试执行可能会抛出异常的代码 $result = $wechat->wechat->mini($order)->toArray(); - } catch (\Exception $e) { - \support\Log::info($e->getMessage()); - throw new \Exception($e->getMessage()); - } + break; default: self::$error = '订单异常'; $result = false; } + } catch (\Exception $e) { + \support\Log::info($e->getMessage()); + throw new \Exception($e->getMessage()); + } return $result; }