input('type'); if (in_array($type, [SmsCode::TYPE_SET_WALLET_PASSWORD])) { if (is_null($user = $request->user())) { throw new AuthenticationException('请先登录', ['api']); } $phone = $user->phone; } else { $request->validate([ 'phone' => ['bail', 'required', new PhoneNumber()], ]); $phone = $request->input('phone'); } $code = app()->isProduction() ? mt_rand(100000, 999999) : '666666'; try { $smsCodeService->send($phone, $type, $code); } catch (BizException $e) { throw $e; } catch (Throwable $e) { report($e); } return response()->noContent(); } }