diff --git a/Server/application/command/SyncWechatDataToCkbTask.php b/Server/application/command/SyncWechatDataToCkbTask.php index 4e1bc482..fe95c1c0 100644 --- a/Server/application/command/SyncWechatDataToCkbTask.php +++ b/Server/application/command/SyncWechatDataToCkbTask.php @@ -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(); + } + } \ No newline at end of file diff --git a/Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php b/Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php index 2dbded4d..95358eeb 100644 --- a/Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php +++ b/Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php @@ -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); + } + + + }