From 60f3d0ce0a1459b5b702b22b035614fd9195154e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=B8=85=E7=88=BD?= Date: Tue, 13 May 2025 10:32:18 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=81=E5=9F=9F=E6=93=8D=E7=9B=98=E6=89=8B?= =?UTF-8?q?=20-=20=E5=BE=AE=E4=BF=A1=E5=8F=B7=E5=A5=BD=E5=8F=8B=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E4=B8=AD=E7=9A=84=E5=A5=BD=E5=8F=8B=E6=9D=A5=E6=BA=90?= =?UTF-8?q?=E5=85=B3=E8=81=94=E6=B5=81=E9=87=8F=E6=B1=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cunkebao/api/wechat-accounts.ts | 1 + Cunkebao/app/wechat-accounts/[id]/page.tsx | 8 ++-- ...echatOnDeviceFriendProfileV1Controller.php | 45 +++++++++++++++++-- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/Cunkebao/api/wechat-accounts.ts b/Cunkebao/api/wechat-accounts.ts index cbbd6f84..3db64f75 100644 --- a/Cunkebao/api/wechat-accounts.ts +++ b/Cunkebao/api/wechat-accounts.ts @@ -184,6 +184,7 @@ export interface WechatFriendDetail { tags: string[]; playDate: string; memo: string; + source: string; } interface WechatFriendDetailResponse { diff --git a/Cunkebao/app/wechat-accounts/[id]/page.tsx b/Cunkebao/app/wechat-accounts/[id]/page.tsx index 88da5874..7569aa58 100644 --- a/Cunkebao/app/wechat-accounts/[id]/page.tsx +++ b/Cunkebao/app/wechat-accounts/[id]/page.tsx @@ -420,7 +420,7 @@ export default function WechatAccountDetailPage() { color: getRandomTagColor(), })), region: '未知地区', - source: '微信好友', + source: '未记录', notes: '', })); @@ -1110,7 +1110,7 @@ export default function WechatAccountDetailPage() { )}
来源
-
微信好友
+
{friendDetail.source || '未记录'}
@@ -1136,14 +1136,14 @@ export default function WechatAccountDetailPage() { - + */} ) : selectedFriend && ( diff --git a/Server/application/cunkebao/controller/wechat/GetWechatOnDeviceFriendProfileV1Controller.php b/Server/application/cunkebao/controller/wechat/GetWechatOnDeviceFriendProfileV1Controller.php index 95274bc1..fb4f7abc 100644 --- a/Server/application/cunkebao/controller/wechat/GetWechatOnDeviceFriendProfileV1Controller.php +++ b/Server/application/cunkebao/controller/wechat/GetWechatOnDeviceFriendProfileV1Controller.php @@ -2,6 +2,7 @@ namespace app\cunkebao\controller\wechat; +use app\common\model\TrafficPool as TrafficPoolModel; use app\cunkebao\controller\BaseController; use app\cunkebao\model\WechatAccount as WechatAccountModel; use library\ResponseHelper; @@ -22,6 +23,43 @@ class GetWechatOnDeviceFriendProfileV1Controller extends BaseController return date('Y-m-d', strtotime('-1 day')); } + /** + * 获取好友标签 + * + * @param string $tags + * @return array + */ + protected function getWechatTags(string $tags): array + { + return json_decode($tags, true); + } + + /** + * 获取添加时间 + * + * @param int $timestamp + * @return string + */ + protected function getAddShipDate(int $timestamp): string + { + return date('Y-m-d', $timestamp); + } + + /** + * 获取流量来源 + * + * @param string $wechatId + * @return string|null + */ + protected function getTrafficSource(string $wechatId): string + { + return (string)TrafficPoolModel::alias('p') + ->field('t.id') + ->join('traffic_source s', 's.identifier = p.identifier') + ->where('p.wechatId', $wechatId) + ->value('fromd'); + } + /** * 获取微信账号 * @@ -36,7 +74,7 @@ class GetWechatOnDeviceFriendProfileV1Controller extends BaseController [ 'w.id', 'w.avatar', 'w.nickname', 'w.region', 'w.wechatId', 'CASE WHEN w.alias IS NULL OR w.alias = "" THEN w.wechatId ELSE w.alias END AS wechatId', - 'f.createTime addTime', 'f.tags', 'f.memo' + 'f.createTime', 'f.tags', 'f.memo' ] ) ->join('wechat_friendship f', 'w.wechatId=f.wechatId') @@ -64,8 +102,9 @@ class GetWechatOnDeviceFriendProfileV1Controller extends BaseController return ResponseHelper::success( array_merge($results, [ 'playDate' => $this->getLastPlayTime($results['wechatId']), - 'tags' => json_decode($results['tags'], true), - 'addDate' => date('Y-m-d', $results['addTime']), + 'source' => $this->getTrafficSource($results['wechatId']), + 'tags' => $this->getWechatTags($results['tags']), + 'addDate' => $this->getAddShipDate($results['createTime']), ]) ); } catch (\Exception $e) {