From 798b0d7854a54fd1162b05dda4e16e6f312eca86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=B8=85=E7=88=BD?= Date: Wed, 14 May 2025 14:17:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=81=E5=9F=9F=E6=8A=84=E7=9B=98=E6=89=8B?= =?UTF-8?q?=20-=20=E4=BF=AE=E6=94=B9=E5=BE=AE=E4=BF=A1=E5=8F=B7=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E8=B7=AF=E7=94=B1=E8=A7=84=E5=88=99=20=E5=8F=8A=20?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=BE=AE=E4=BF=A1=E5=8F=B7=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cunkebao/api/wechat-accounts.ts | 8 +- Cunkebao/app/traffic-pool/page.tsx | 242 +++++++++--------- Cunkebao/app/wechat-accounts/[id]/page.tsx | 14 +- Cunkebao/app/wechat-accounts/page.tsx | 4 +- Cunkebao/types/wechat-account.ts | 1 + Server/application/cunkebao/config/route.php | 2 +- .../GetWechatOnDeviceFriendsV1Controller.php | 25 +- ...GetWechatOnDeviceSummarizeV1Controller.php | 21 +- ...r.php => GetWechatProfileV1Controller.php} | 13 +- .../GetWechatsOnDevicesV1Controller.php | 4 +- 10 files changed, 152 insertions(+), 182 deletions(-) rename Server/application/cunkebao/controller/wechat/{GetWechatOnDeviceFriendProfileV1Controller.php => GetWechatProfileV1Controller.php} (88%) diff --git a/Cunkebao/api/wechat-accounts.ts b/Cunkebao/api/wechat-accounts.ts index 3db64f75..393e1d8b 100644 --- a/Cunkebao/api/wechat-accounts.ts +++ b/Cunkebao/api/wechat-accounts.ts @@ -159,9 +159,9 @@ export const fetchWechatFriends = async (wechatId: string, page: number = 1, pag * @param id 微信账号ID * @returns 微信账号概览信息 */ -export const fetchWechatAccountSummary = async (id: string): Promise => { +export const fetchWechatAccountSummary = async (wechatIdid: string): Promise => { try { - return api.get(`/v1/wechats/${id}/summary`); + return api.get(`/v1/wechats/${wechatIdid}/summary`); } catch (error) { console.error("获取账号概览失败:", error); throw error; @@ -193,9 +193,9 @@ interface WechatFriendDetailResponse { data: WechatFriendDetail; } -export const fetchWechatFriendDetail = async (wechatId: string, friendId: string): Promise => { +export const fetchWechatFriendDetail = async (wechatId: string): Promise => { try { - return api.get(`/v1/wechats/${wechatId}/friend/${friendId}`); + return api.get(`/v1/wechats/${wechatId}`); } catch (error) { console.error("获取好友详情失败:", error); throw error; diff --git a/Cunkebao/app/traffic-pool/page.tsx b/Cunkebao/app/traffic-pool/page.tsx index 10cc5910..62f6fde7 100644 --- a/Cunkebao/app/traffic-pool/page.tsx +++ b/Cunkebao/app/traffic-pool/page.tsx @@ -413,136 +413,136 @@ export default function TrafficPoolPage() {
-
- {/* 搜索和筛选区域 */} -
-
- - { - setSearchQuery(e.target.value) - setCurrentPage(1) - }} - className="pl-9" - /> -
- +
+ {/* 搜索和筛选区域 */} +
+
+ + { + setSearchQuery(e.target.value) + setCurrentPage(1) + }} + className="pl-9" + />
+ +
- {/* 统计卡片 */} -
- -
流量池总数
+ {/* 统计卡片 */} +
+ +
流量池总数
{stats.totalCount}
-
- -
今日新增
+
+ +
今日新增
{stats.todayAddCount}
-
-
+
+
{/* 分类标签页 */} - { + setActiveCategory(value) + setCurrentPage(1) + }} + > + + 潜在客户 + 已转化 + + + + {/* 筛选器 */} +
+ { - setSourceFilter(value) - setCurrentPage(1) - }} - > - - - + + + - 全部来源 + 全部来源 {sourceTypes.map((source) => ( {source.name} ))} - - + + {activeCategory === "potential" && ( - { + setStatusFilter(value) + setCurrentPage(1) + }} + > + + + + + 全部状态 {statusTypes.map((status) => ( {status.name} ))} - - + + )} -
+
{/* 用户列表 */} -
+
{loading && users.length === 0 ? ( -
- -
加载中...
-
- ) : users.length === 0 ? ( -
-
暂无数据
+
+ +
加载中...
+
+ ) : users.length === 0 ? ( +
+
暂无数据
-
- ) : ( + 刷新 + +
+ ) : ( <> {users.map((user) => ( - handleUserClick(user)} - > -
- -
-
-
{user.nickname}
-
handleUserClick(user)} + > +
+ +
+
+
{user.nickname}
+
+ ? "bg-yellow-100 text-yellow-800" + : "bg-red-100 text-red-800" + }`} + > {activeCategory === "customer" ? "已通过" : user.status === 2 @@ -550,28 +550,28 @@ export default function TrafficPoolPage() { : user.status === 1 ? "待处理" : "已失败"} -
-
-
微信号: {user.wechatId}
-
来源: {user.source}
-
添加时间: {user.addTime}
- - {/* 标签展示 */} -
- {user.tags.slice(0, 2).map((tag) => ( - - {tag.name} - - ))} - {user.tags.length > 2 && ( - - +{user.tags.length - 2} - - )} -
- +
微信号: {user.wechatId}
+
来源: {user.source}
+
添加时间: {user.addTime}
+ + {/* 标签展示 */} +
+ {user.tags.slice(0, 2).map((tag) => ( + + {tag.name} + + ))} + {user.tags.length > 2 && ( + + +{user.tags.length - 2} + + )} +
+
+
+ ))} {/* 加载状态显示 */} @@ -618,17 +618,17 @@ export default function TrafficPoolPage() { : selectedUser.status === 2 ? "bg-green-100 text-green-800" : selectedUser.status === 1 - ? "bg-yellow-100 text-yellow-800" - : "bg-red-100 text-red-800" + ? "bg-yellow-100 text-yellow-800" + : "bg-red-100 text-red-800" }`} > {activeCategory === "customer" ? "已通过" : selectedUser.status === 2 - ? "已添加" + ? "已添加" : selectedUser.status === 1 - ? "待处理" - : "已失败"} + ? "待处理" + : "已失败"}
diff --git a/Cunkebao/app/wechat-accounts/[id]/page.tsx b/Cunkebao/app/wechat-accounts/[id]/page.tsx index 5837e6cb..fac8dd48 100644 --- a/Cunkebao/app/wechat-accounts/[id]/page.tsx +++ b/Cunkebao/app/wechat-accounts/[id]/page.tsx @@ -103,6 +103,7 @@ interface WechatAccountDetail { avatar: string nickname: string wechatId: string + wechatAccount: string deviceId: string deviceName: string friendCount: number @@ -199,6 +200,7 @@ export default function WechatAccountDetailPage() { nickname: string; status: "normal" | "abnormal"; wechatId: string; + wechatAccount: string; deviceName: string; deviceId?: string | number; } | null>(null) @@ -219,6 +221,7 @@ export default function WechatAccountDetailPage() { mockData.status = decodedData.status; mockData.wechatId = decodedData.wechatId; mockData.deviceName = decodedData.deviceName; + mockData.wechatAccount = decodedData.wechatAccount; } setAccount(mockData); setFriendsTotal(mockData.friendCount); @@ -328,6 +331,7 @@ export default function WechatAccountDetailPage() { "https://hebbkx1anhila5yf.public.blob.vercel-storage.com/img_v3_02jn_e7fcc2a4-3560-478d-911a-4ccd69c6392g.jpg-a8zVtwxMuSrPWN9dfWH93EBY0yM3Dh.jpeg", nickname: "卡若-25vig", wechatId: `wxid_${Math.random().toString(36).substr(2, 8)}`, + wechatAccount: initialData?.wechatAccount || "wxid_default", deviceId: "device-1", deviceName: "设备1", friendCount: friends.length, @@ -398,7 +402,7 @@ export default function WechatAccountDetailPage() { setIsFetchingFriends(true); setHasFriendLoadError(false); - const data = await api.get>(`/v1/wechats/${id}/friends?page=${page}&limit=30`, true); + const data = await api.get>(`/v1/wechats/${account?.wechatId}/friends?page=${page}&limit=30`, true); if (data && data.code === 200) { // 更新总数计数 @@ -526,7 +530,7 @@ export default function WechatAccountDetailPage() { const fetchSummaryData = useCallback(async () => { try { setIsLoading(true); - const response = await fetchWechatAccountSummary(id); + const response = await fetchWechatAccountSummary(account?.wechatId || ''); if (response.code === 200) { setAccountSummary(response.data); } else { @@ -546,7 +550,7 @@ export default function WechatAccountDetailPage() { } finally { setIsLoading(false); } - }, [id]); + }, [account]); // 在页面加载和切换到概览标签时获取数据 useEffect(() => { @@ -623,7 +627,7 @@ export default function WechatAccountDetailPage() { setFriendDetailError(null) try { - const response = await fetchWechatFriendDetail(account?.wechatId || id, friend.id) + const response = await fetchWechatFriendDetail(friend.wechatId) if (response.code === 200) { setFriendDetail(response.data) } else { @@ -699,7 +703,7 @@ export default function WechatAccountDetailPage() { {account.status === "normal" ? "正常" : "异常"}
-

微信号:{account.wechatId}

+

微信号:{account.wechatAccount}

-
微信号:{account.wechatId}
+
微信号:{account.wechatAccount}
好友数量:{account.friendCount}
今日新增:+{account.todayAdded}
diff --git a/Cunkebao/types/wechat-account.ts b/Cunkebao/types/wechat-account.ts index 15ae51cc..9e3909f6 100644 --- a/Cunkebao/types/wechat-account.ts +++ b/Cunkebao/types/wechat-account.ts @@ -2,6 +2,7 @@ export interface ServerWechatAccount { id: number; wechatId: string; + wechatAccount: string; nickname: string; accountNickname: string; avatar: string; diff --git a/Server/application/cunkebao/config/route.php b/Server/application/cunkebao/config/route.php index 4f983ec5..52306a13 100644 --- a/Server/application/cunkebao/config/route.php +++ b/Server/application/cunkebao/config/route.php @@ -25,7 +25,7 @@ Route::group('v1/', function () { Route::get('', 'app\cunkebao\controller\wechat\GetWechatsOnDevicesV1Controller@index'); Route::get(':id/summary', 'app\cunkebao\controller\wechat\GetWechatOnDeviceSummarizeV1Controller@index'); Route::get(':id/friends', 'app\cunkebao\controller\wechat\GetWechatOnDeviceFriendsV1Controller@index'); - Route::get(':id/friend/:aId', 'app\cunkebao\controller\wechat\GetWechatOnDeviceFriendProfileV1Controller@index'); + Route::get(':wechatId', 'app\cunkebao\controller\wechat\GetWechatProfileV1Controller@index'); Route::get('count', 'app\cunkebao\controller\DeviceWechat@count'); Route::get('device-count', 'app\cunkebao\controller\DeviceWechat@deviceCount'); // 获取有登录微信的设备数量 diff --git a/Server/application/cunkebao/controller/wechat/GetWechatOnDeviceFriendsV1Controller.php b/Server/application/cunkebao/controller/wechat/GetWechatOnDeviceFriendsV1Controller.php index 5ad9a002..9a95e862 100644 --- a/Server/application/cunkebao/controller/wechat/GetWechatOnDeviceFriendsV1Controller.php +++ b/Server/application/cunkebao/controller/wechat/GetWechatOnDeviceFriendsV1Controller.php @@ -41,8 +41,8 @@ class GetWechatOnDeviceFriendsV1Controller extends BaseController $query = WechatFriendShipModel::alias('f') ->field( [ - 'w.id', 'w.nickname', 'w.avatar', - 'CASE WHEN w.alias IS NULL OR w.alias = "" THEN w.wechatId ELSE w.alias END AS wechatId', + 'w.id', 'w.nickname', 'w.avatar', 'w.wechatId', + 'CASE WHEN w.alias IS NULL OR w.alias = "" THEN w.wechatId ELSE w.alias END AS wechatAccount', 'f.memo', 'f.tags' ] ) @@ -60,25 +60,6 @@ class GetWechatOnDeviceFriendsV1Controller extends BaseController return $query->paginate($this->request->param('limit/d', 10), false, ['page' => $this->request->param('page/d', 1)]); } - /** - * 获取原始的64位的微信id - * - * @return string - * @throws \Exception - */ - protected function getStringWechatIdByNumberId(): string - { - $account = WechatAccountModel::find( - $this->request->param('id/d') - ); - - if (is_null($account)) { - throw new \Exception('微信账号不存在', 404); - } - - return $account->wechatId; - } - /** * 构建查询条件 * @@ -92,7 +73,7 @@ class GetWechatOnDeviceFriendsV1Controller extends BaseController $where[] = ['exp', "f.memo LIKE '%{$keyword}%' OR f.tags LIKE '%{$keyword}%'"]; } - $where['f.ownerWechatId'] = $this->getStringWechatIdByNumberId(); + $where['f.ownerWechatId'] = $this->request->param('id/s') ?: 'x_x'; return array_merge($where, $params); } diff --git a/Server/application/cunkebao/controller/wechat/GetWechatOnDeviceSummarizeV1Controller.php b/Server/application/cunkebao/controller/wechat/GetWechatOnDeviceSummarizeV1Controller.php index 0a086942..f195cb6f 100644 --- a/Server/application/cunkebao/controller/wechat/GetWechatOnDeviceSummarizeV1Controller.php +++ b/Server/application/cunkebao/controller/wechat/GetWechatOnDeviceSummarizeV1Controller.php @@ -233,25 +233,6 @@ class GetWechatOnDeviceSummarizeV1Controller extends BaseController ]; } - /** - * 获取原始的64位的微信id - * - * @return string - * @throws \Exception - */ - protected function getStringWechatIdByNumberId(): string - { - $account = WechatAccountModel::find( - $this->request->param('id/d') - ); - - if (is_null($account)) { - throw new \Exception('微信账号不存在', 404); - } - - return $account->wechatId; - } - /** * 获取微信号详情 * @@ -260,7 +241,7 @@ class GetWechatOnDeviceSummarizeV1Controller extends BaseController public function index() { try { - $wechatId = $this->getStringWechatIdByNumberId(); + $wechatId = $this->request->param('id/s'); // 以下内容依次加工数据 $accountAge = $this->getRegisterDate($wechatId); diff --git a/Server/application/cunkebao/controller/wechat/GetWechatOnDeviceFriendProfileV1Controller.php b/Server/application/cunkebao/controller/wechat/GetWechatProfileV1Controller.php similarity index 88% rename from Server/application/cunkebao/controller/wechat/GetWechatOnDeviceFriendProfileV1Controller.php rename to Server/application/cunkebao/controller/wechat/GetWechatProfileV1Controller.php index 72a3a869..ad7a7f5d 100644 --- a/Server/application/cunkebao/controller/wechat/GetWechatOnDeviceFriendProfileV1Controller.php +++ b/Server/application/cunkebao/controller/wechat/GetWechatProfileV1Controller.php @@ -10,7 +10,7 @@ use library\ResponseHelper; /** * 设备微信控制器 */ -class GetWechatOnDeviceFriendProfileV1Controller extends BaseController +class GetWechatProfileV1Controller extends BaseController { /** * 获取最近互动时间 @@ -63,11 +63,11 @@ class GetWechatOnDeviceFriendProfileV1Controller extends BaseController /** * 获取微信账号 * - * @param int $id + * @param string $wechatId * @return array * @throws \Exception */ - protected function getWechatAccountProfileById(int $id): array + protected function getWechatAccountProfileByWechatId(string $wechatId): array { $account = WechatAccountModel::alias('w') ->field( @@ -78,7 +78,8 @@ class GetWechatOnDeviceFriendProfileV1Controller extends BaseController ] ) ->join('wechat_friendship f', 'w.wechatId=f.wechatId') - ->find($id); + ->where('w.wechatId', $wechatId) + ->find(); if (is_null($account)) { throw new \Exception('未获取到微信账号数据', 404); @@ -95,8 +96,8 @@ class GetWechatOnDeviceFriendProfileV1Controller extends BaseController public function index() { try { - $results = $this->getWechatAccountProfileById( - $this->request->param('aId/d') + $results = $this->getWechatAccountProfileByWechatId( + $this->request->param('wechatId/s') ); return ResponseHelper::success( diff --git a/Server/application/cunkebao/controller/wechat/GetWechatsOnDevicesV1Controller.php b/Server/application/cunkebao/controller/wechat/GetWechatsOnDevicesV1Controller.php index 68fde3ae..3deb2a7f 100644 --- a/Server/application/cunkebao/controller/wechat/GetWechatsOnDevicesV1Controller.php +++ b/Server/application/cunkebao/controller/wechat/GetWechatsOnDevicesV1Controller.php @@ -198,8 +198,8 @@ class GetWechatsOnDevicesV1Controller extends BaseController $query = WechatAccountModel::alias('w') ->field( [ - 'w.id', 'w.nickname', 'w.avatar', - 'CASE WHEN w.alias IS NULL OR w.alias = "" THEN w.wechatId ELSE w.alias END AS wechatId', + 'w.id', 'w.nickname', 'w.avatar', 'w.wechatId', + 'CASE WHEN w.alias IS NULL OR w.alias = "" THEN w.wechatId ELSE w.alias END AS wechatAccount', 'l.deviceId' ] )