流量池服务端

This commit is contained in:
wong
2026-02-02 11:00:26 +08:00
parent f0c278a35f
commit 519a9b1d1b
22 changed files with 7239 additions and 2252 deletions

View File

@@ -379,10 +379,50 @@ class MomentsController extends BaseController
$total = KfMoments::where(['companyId' => $companyId, 'userId' => $userId, 'isDel' => 0])->count();
// 收集所有需要查询的微信账号ID
$allWechatAccountIds = [];
foreach ($list as $item) {
$sendData = json_decode($item->sendData, true);
$items = $sendData['jobPublishWechatMomentsItems'] ?? [];
foreach ($items as $accountItem) {
if (!empty($accountItem['wechatAccountId'])) {
$allWechatAccountIds[] = $accountItem['wechatAccountId'];
}
}
}
// 批量查询微信账号信息
$wechatAccountsMap = [];
if (!empty($allWechatAccountIds)) {
$wechatAccounts = Db::table('s2_wechat_account')
->whereIn('id', array_unique($allWechatAccountIds))
->field('id, wechatId, nickName, avatar')
->select();
foreach ($wechatAccounts as $account) {
$wechatAccountsMap[$account['id']] = $account;
}
}
// 处理数据
$data = [];
foreach ($list as $item) {
$sendData = json_decode($item->sendData,true);
$sendData = json_decode($item->sendData, true);
$momentsItems = $sendData['jobPublishWechatMomentsItems'] ?? [];
// 构建账号详情列表
$accounts = [];
foreach ($momentsItems as $accountItem) {
$wechatAccountId = $accountItem['wechatAccountId'] ?? 0;
$accountInfo = $wechatAccountsMap[$wechatAccountId] ?? null;
$accounts[] = [
'wechatAccountId' => $wechatAccountId,
'wechatId' => $accountInfo['wechatId'] ?? '',
'nickName' => $accountInfo['nickName'] ?? '',
'avatar' => $accountInfo['avatar'] ?? '',
'labels' => $accountItem['labels'] ?? []
];
}
$data[] = [
'id' => $item->id,
'content' => $sendData['text'] ?? '',
@@ -392,8 +432,9 @@ class MomentsController extends BaseController
'link' => $sendData['link'] ?? [],
'publicMode' => $sendData['publicMode'] ?? 2,
'isSend' => $item->isSend,
'sendTime' => date('Y-m-d H:i:s',$item->sendTime),
'accountCount' => count($sendData['jobPublishWechatMomentsItems'] ?? [])
'sendTime' => date('Y-m-d H:i:s', $item->sendTime),
'accountCount' => count($accounts),
'accounts' => $accounts
];
}