代码提交

This commit is contained in:
wong
2025-08-07 11:56:04 +08:00
parent f592784c11
commit b33231b3b4
7 changed files with 462 additions and 7 deletions

View File

@@ -1356,6 +1356,39 @@ class Adapter implements WeChatServiceInterface
} while ($affected > 0);
}
public function syncWechatGroupCustomer()
{
$sql = "insert into ck_wechat_group_member(`identifier`,`chatroomId`,`companyId`,`groupId`,`createTime`)
SELECT
m.wechatId identifier,
g.chatroomId chatroomId,
c.departmentId companyId,
g.id groupId,
m.createTime createTime
FROM
s2_wechat_chatroom_member m
LEFT JOIN s2_wechat_chatroom g ON g.chatroomId = m.chatroomId
LEFT JOIN s2_company_account c ON g.accountId = c.id
ORDER BY m.id DESC
LIMIT ?, ?
ON DUPLICATE KEY UPDATE
identifier=VALUES(identifier),
chatroomId=VALUES(chatroomId),
companyId=VALUES(companyId),
groupId=VALUES(groupId)";
$offset = 0;
$limit = 2000;
$usleepTime = 50000;
do {
$affected = Db::execute($sql, [$offset, $limit]);
$offset += $limit;
if ($affected > 0) {
usleep($usleepTime);
}
} while ($affected > 0);
}
}