同步群列表
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user