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) {