From 85a9d33b167ee76e51097ef0439f8664a6dd3400 Mon Sep 17 00:00:00 2001 From: lingling Date: Fri, 7 Mar 2025 18:14:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9C=A8=20TaskController=20=E4=B8=AD?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=E5=92=8C?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81=E5=8F=91=E9=80=81=E5=92=8C=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=9F=A5=E8=AF=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/TaskController.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/app/controller/api/TaskController.php b/app/controller/api/TaskController.php index b33f718..4421d38 100644 --- a/app/controller/api/TaskController.php +++ b/app/controller/api/TaskController.php @@ -23,7 +23,7 @@ use App\dao\UserRewardDao; use App\Utils\API\Facebook; use Tinywan\Jwt\JwtToken; use GuzzleHttp\Client; - +use support\Log; use hg\apidoc\annotation as Apidoc; @@ -61,7 +61,13 @@ class TaskController public function send_code(Request $request) { $phone = $request->post('phone'); - $res = SendCode::send_code($phone); + try { + $res = SendCode::send_code($phone); + } catch (\Exception $e) { + Log::error("发送验证码失败 phone {$phone}: " . $e->getMessage()); + return ApiResponseApp::error([], '获取验证码失败'); + } + if ($res['code'] == 3) { return ApiResponseApp::error([], '您已登陆'); } @@ -107,7 +113,15 @@ class TaskController // 状态为 2,表示正在等待上号,检查上号状态 if ($GetLodeLog->status == 2) { - $ws_build_status = SendCode::get_ws_status($phone); + // 获取用户的在线状态 + try { + $ws_build_status = SendCode::get_ws_status($phone); + } catch (\Exception $e) { + Log::error("查询手机号上号状态失败 phone {$phone}: " . $e->getMessage()); + $ws_build_status=30; + // return ApiResponseApp::error([], '获取验证码失败'); + } + // $ws_build_status = SendCode::get_ws_status($phone); // 如果上号成功 if ($ws_build_status == 0) {