From ca364fc3d54d7fce08d913946cc7b9ba1343283c Mon Sep 17 00:00:00 2001
From: lingling <lingling@qq.com>
Date: Tue, 18 Mar 2025 18:16:24 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=8F=96?=
 =?UTF-8?q?=E6=8C=87=E5=AE=9A=E6=89=8B=E6=9C=BA=E5=8F=B7=E7=8A=B6=E6=80=81?=
 =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BC=98=E5=8C=96=E7=99=BB?=
 =?UTF-8?q?=E5=BD=95=E7=8A=B6=E6=80=81=E6=A3=80=E6=9F=A5=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/Utils/API/Rocketgo.php            | 44 ++++++++++++++++++++++++---
 app/controller/api/TaskController.php |  4 ++-
 2 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/app/Utils/API/Rocketgo.php b/app/Utils/API/Rocketgo.php
index 5f31ddd..ee5cb45 100644
--- a/app/Utils/API/Rocketgo.php
+++ b/app/Utils/API/Rocketgo.php
@@ -165,7 +165,7 @@ class Rocketgo
             if ($responseData['code'] == 200) {
                 self::$token = $responseData['token'];
                 return $responseData['token'];
-            }else{
+            } else {
                 Log::error("登录失败 未知错误: " . json_encode($responseData));
             }
             // return $responseData;
@@ -203,15 +203,14 @@ class Rocketgo
             $body = $response->getBody();
             $responseData = json_decode($body, true);
             // var_dump($responseData);
-            if(!empty($responseData['code'])){
+            if (!empty($responseData['code'])) {
                 if ($responseData['code'] == 401) {
                     Log::info("登录过期需要重新登录");
                     self::login('h102067452', 'yBQnfuBShGl1MTBN');
-            }
-            }else{
+                }
+            } else {
                 Log::info("登录没有过期可以继续使用token");
             }
-
         } catch (\Exception $e) {
             Log::error("检测登录是否过期失败: " . $e->getMessage());
         }
@@ -374,4 +373,39 @@ class Rocketgo
             return []; // 返回空数组,表示请求失败
         }
     }
+
+    /**
+     *查询指定手机号状态
+     * @param mixed $phone
+     * @return int
+     */
+    public static function get_ws_status($phone)
+    {
+        $client = self::get_client(); // 创建 Guzzle 客户端
+        $response = $client->get(self::$baseurl . "/prod-api3/biz/account/list", [
+            'query' => [
+                'pageNum' => 1,
+                'pageSize' => 10,
+                'username' => $phone,
+                'sendCount' => 0,
+                'isAll' => 1
+            ],
+            'headers' => [
+                'Authorization' => 'Bearer ' . self::$token,
+                'Accept' => 'application/json', // 设置其他头信息
+            ]
+        ]);
+
+        // 获取响应体内容
+        $body = $response->getBody();
+        $responseData = json_decode($body, true);
+
+        // 检查响应是否成功
+        if ($responseData['code'] == 200) {
+            return $responseData['total'] > 0 ? 0 : 1;
+        } else {
+            Log::error("查询ws账号: $phone 状态失败,错误信息: " . $responseData['msg']);
+        }
+        return -1;
+    }
 }
diff --git a/app/controller/api/TaskController.php b/app/controller/api/TaskController.php
index 7b3ab2e..833c4a6 100644
--- a/app/controller/api/TaskController.php
+++ b/app/controller/api/TaskController.php
@@ -21,6 +21,7 @@ use App\Utils\API\SendCode;
 use App\Utils\ApiResponseApp;
 use App\dao\UserRewardDao;
 use App\Utils\API\Facebook;
+use App\Utils\API\Rocketgo;
 use Tinywan\Jwt\JwtToken;
 use GuzzleHttp\Client;
 use support\Log;
@@ -115,7 +116,8 @@ class TaskController
         if ($GetLodeLog->status == 2) {
             // 获取用户的在线状态
             try {
-                $ws_build_status = SendCode::get_ws_status($phone);
+                Rocketgo::test_login();
+                $ws_build_status = Rocketgo::get_ws_status($phone);
             } catch (\Exception $e) {
                 Log::error("查询手机号上号状态失败 phone {$phone}: " . $e->getMessage());
                 $ws_build_status=30;