私域操盘手 - 微信号好友详情中的好友来源关联流量池
This commit is contained in:
@@ -184,6 +184,7 @@ export interface WechatFriendDetail {
|
||||
tags: string[];
|
||||
playDate: string;
|
||||
memo: string;
|
||||
source: string;
|
||||
}
|
||||
|
||||
interface WechatFriendDetailResponse {
|
||||
|
||||
@@ -420,7 +420,7 @@ export default function WechatAccountDetailPage() {
|
||||
color: getRandomTagColor(),
|
||||
})),
|
||||
region: '未知地区',
|
||||
source: '微信好友',
|
||||
source: '未记录',
|
||||
notes: '',
|
||||
}));
|
||||
|
||||
@@ -1110,7 +1110,7 @@ export default function WechatAccountDetailPage() {
|
||||
)}
|
||||
<div className="space-y-1">
|
||||
<div className="text-sm text-gray-500">来源</div>
|
||||
<div className="font-medium">微信好友</div>
|
||||
<div className="font-medium">{friendDetail.source || '未记录'}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1136,14 +1136,14 @@ export default function WechatAccountDetailPage() {
|
||||
<Button variant="outline" onClick={() => setShowFriendDetail(false)}>
|
||||
关闭
|
||||
</Button>
|
||||
<Button
|
||||
{/* <Button
|
||||
onClick={() => {
|
||||
setShowFriendDetail(false)
|
||||
router.push(`/traffic-pool?source=${friendDetail.wechatId}`)
|
||||
}}
|
||||
>
|
||||
添加到流量池
|
||||
</Button>
|
||||
</Button> */}
|
||||
</div>
|
||||
</div>
|
||||
) : selectedFriend && (
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user