同步群列表

This commit is contained in:
wong
2025-08-05 10:28:28 +08:00
parent ebff15fbed
commit 982b2c024b
2 changed files with 45 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ class SyncWechatDataToCkbTask extends Command
$this->syncWechatDeviceLoginLog($ChuKeBaoAdapter);
$this->syncWechatDevice($ChuKeBaoAdapter);
$this->syncWechatCustomer($ChuKeBaoAdapter);
$this->syncWechatGroup($ChuKeBaoAdapter);
$this->syncWechatFriendToTrafficPoolBatch($ChuKeBaoAdapter);
$this->syncTrafficSourceUser($ChuKeBaoAdapter);
$this->syncTrafficSourceGroup($ChuKeBaoAdapter);
@@ -108,5 +109,10 @@ class SyncWechatDataToCkbTask extends Command
return $ChuKeBaoAdapter->syncTrafficSourceGroup();
}
protected function syncWechatGroup(ChuKeBaoAdapter $ChuKeBaoAdapter)
{
return $ChuKeBaoAdapter->syncWechatGroup();
}
}

View File

@@ -1318,4 +1318,43 @@ class Adapter implements WeChatServiceInterface
}
} while ($affected > 0);
}
public function syncWechatGroup()
{
$sql = "insert into ck_wechat_group(`id`,`chatroomId`,`name`,`avatar`,`companyId`,`ownerWechatId`,`createTime`,`updateTime`,`deleteTime`)
SELECT
g.id id,
g.chatroomId chatroomId,
g.nickname name,
g.chatroomAvatar avatar,
c.departmentId companyId,
g.wechatAccountWechatId ownerWechatId,
g.createTime createTime,
g.updateTime updateTime,
g.deleteTime deleteTime
FROM
s2_wechat_chatroom g
LEFT JOIN s2_company_account c ON g.accountId = c.id
ORDER BY g.id DESC
LIMIT ?, ?
ON DUPLICATE KEY UPDATE
chatroomId=VALUES(chatroomId),
companyId=VALUES(companyId),
ownerWechatId=VALUES(ownerWechatId)";
$offset = 0;
$limit = 2000;
$usleepTime = 50000;
do {
$affected = Db::execute($sql, [$offset, $limit]);
$offset += $limit;
if ($affected > 0) {
usleep($usleepTime);
}
} while ($affected > 0);
}
}