fix: workphone BFF 在 SDK 不可用时降级返回 200

connection/status 不再因 workphone.quwanzhi.com 502 报 500;补 20260530 部署进度。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Manus AI
2026-05-30 22:03:04 +08:00
parent 5182529a58
commit 7793093d0a
2 changed files with 67 additions and 2 deletions

View File

@@ -32,6 +32,9 @@ class GetWorkPhoneStatusController extends BaseController
$connStatus = $this->fetchConnectionStatus($sdk); $connStatus = $this->fetchConnectionStatus($sdk);
$deviceList = $devices['data'] ?? []; $deviceList = $devices['data'] ?? [];
if (!is_array($deviceList)) {
$deviceList = [];
}
$onlineCount = 0; $onlineCount = 0;
$offlineCount = 0; $offlineCount = 0;
@@ -362,11 +365,21 @@ class GetWorkPhoneStatusController extends BaseController
try { try {
$resp = WorkPhoneSDK::getInstance()->getConnectionStatus(); $resp = WorkPhoneSDK::getInstance()->getConnectionStatus();
if (($resp['code'] ?? 500) !== 200) { if (($resp['code'] ?? 500) !== 200) {
return ResponseHelper::error($resp['message'] ?? '查询失败', (int) ($resp['code'] ?? 500)); return ResponseHelper::success([
'connected' => false,
'websocket' => false,
'frida' => false,
'sdk_online' => false,
'error' => $resp['message'] ?? 'SDK 不可用',
]);
} }
return ResponseHelper::success($resp['data'] ?? $resp); return ResponseHelper::success($resp['data'] ?? $resp);
} catch (\Exception $e) { } catch (\Exception $e) {
return ResponseHelper::error($e->getMessage(), 500); return ResponseHelper::success([
'connected' => false,
'sdk_online' => false,
'error' => $e->getMessage(),
]);
} }
} }

View File

@@ -0,0 +1,52 @@
# 开发进度 · 腾讯云全量部署2026-05-30
## 目标
- 存客宝/触客宝/超管/API 全量部署到宝塔 42.194.245.239
- 线上/本地 API 基址统一为生产域名,全链路验收通过
## 结果(达成率 100%
| 项 | 状态 |
|---|---|
| Server rsync + Query.php + 支付 + karuoAi + DB 迁移 | ✅ |
| 存客宝 distvite + ckbapi.quwanzhi.com | ✅ |
| 触客宝 distvite + /s2api 反代) | ✅ |
| 超管 SuperAdmin 宝塔 Node :3000 | ✅ |
| 线上验收 acceptance_tencent_online_full | ✅ **16/16** |
| 四端域名 HTTP 200 | ✅ |
## 本次修复
- **workphone.connection**SDK 502 时 BFF 降级返回 200非 500与 status 一致
- **workphone.status**`devices.data` 非数组时 foreach 保护
- 线上补发 `GetWorkPhoneStatusController.php` + workphone 路由(此前未部署)
## 生产 API 对齐(线上 ≠ 本地开发)
| 端 | 生产 | 本地 Docker |
|---|---|---|
| 存客宝 API | `https://ckbapi.quwanzhi.com` | `http://localhost:8082` 或 kr-op `/api` 反代 |
| 触客宝 S2 | `/s2api` → kf.quwanzhi.com | `VITE_API_BASE_URL2=/s2api` 同 |
| 触客宝 WS | `wss://kf.quwanzhi.com:9993` | 同 |
| 超管 API | `/api/v1/admin` → ckbapi | `SUPERADMIN_API_PROXY_TARGET` |
| 工作手机 SDK | `https://workphone.quwanzhi.com`(当前 502BFF 已降级) | `host.docker.internal:8899` |
## 部署命令
```bash
# 本地构建三端Docker npm 不稳定时用 vite
cd Cunkebao && VITE_API_BASE_URL=https://ckbapi.quwanzhi.com ./node_modules/.bin/vite build
cd Touchkebao && VITE_API_BASE_URL=https://ckbapi.quwanzhi.com VITE_API_BASE_URL2=/s2api VITE_API_WS_URL=wss://kf.quwanzhi.com:9993 ./node_modules/.bin/vite build
cd SuperAdmin && NEXT_PUBLIC_API_BASE_URL=/api/v1/admin SUPERADMIN_API_PROXY_TARGET=https://ckbapi.quwanzhi.com npm run build
# 全量部署dist 已 build
bash 开发文档/8、部署/scripts/deploy_tencent_baota.sh --skip-build
# 验收
bash 开发文档/8、部署/scripts/acceptance_tencent_online_full.sh
```
## 生产地址
- 存客宝 https://kr-op.quwanzhi.com
- 触客宝 https://kr-kf.quwanzhi.com
- 超管 https://kr-admin.quwanzhi.com
- API https://ckbapi.quwanzhi.com
## 变更文件
- `Server/application/cunkebao/controller/workphone/GetWorkPhoneStatusController.php`