From 982b2c024bbb4e5b074cc4c8f1a7ce08c3180933 Mon Sep 17 00:00:00 2001 From: wong <106998207@qq.com> Date: Tue, 5 Aug 2025 10:28:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E7=BE=A4=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/SyncWechatDataToCkbTask.php | 6 +++ .../Adapters/ChuKeBao/Adapter.php | 39 +++++++++++++++++++ 2 files changed, 45 insertions(+) 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); + } + + + }