私域操盘手 - 微信号好友详情中的好友来源关联流量池
This commit is contained in:
@@ -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