From c847eff9fc7116b2df2ad9b925b16fcb2d1656ae Mon Sep 17 00:00:00 2001 From: wong <106998207@qq.com> Date: Tue, 12 Aug 2025 16:58:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=AF=9D=E8=AE=B0=E5=BD=95=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=B8=85=E6=B4=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../command/SyncWechatDataToCkbTask.php | 5 +++ .../Adapters/ChuKeBao/Adapter.php | 35 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/Server/application/command/SyncWechatDataToCkbTask.php b/Server/application/command/SyncWechatDataToCkbTask.php index 420040d9..688f4fd0 100644 --- a/Server/application/command/SyncWechatDataToCkbTask.php +++ b/Server/application/command/SyncWechatDataToCkbTask.php @@ -56,6 +56,7 @@ class SyncWechatDataToCkbTask extends Command $this->syncWechatFriendToTrafficPoolBatch($ChuKeBaoAdapter); $this->syncTrafficSourceUser($ChuKeBaoAdapter); $this->syncTrafficSourceGroup($ChuKeBaoAdapter); + $this->syncCallRecording($ChuKeBaoAdapter); $output->writeln("同步任务 sync_wechat_to_ckb 已结束"); return true; @@ -118,6 +119,10 @@ class SyncWechatDataToCkbTask extends Command { return $ChuKeBaoAdapter->syncWechatGroupCustomer(); } + protected function syncCallRecording(ChuKeBaoAdapter $ChuKeBaoAdapter) + { + return $ChuKeBaoAdapter->syncCallRecording(); + } } \ 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 03d7c51d..4879e277 100644 --- a/Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php +++ b/Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php @@ -1488,4 +1488,39 @@ class Adapter implements WeChatServiceInterface } + public function syncCallRecording() + { + $sql = "insert into ck_call_recording(`id`,`phone`,`isCallOut`,`companyId`,`callType`,`beginTime`,`endTime`,`createTime`) + SELECT + c.id id, + c.phone phone, + c.isCallOut isCallOut, + a.departmentId companyId, + c.callType callType, + c.beginTime beginTime, + c.endTime endTime, + c.callBeginTime createTime + FROM + s2_call_recording c + LEFT JOIN s2_company_account a ON c.deviceOwnerId = a.id + ORDER BY c.id DESC + LIMIT ?, ? + ON DUPLICATE KEY UPDATE + id=VALUES(id), + phone=VALUES(phone), + isCallOut=VALUES(isCallOut), + companyId=VALUES(companyId)"; + + $offset = 0; + $limit = 2000; + $usleepTime = 50000; + do { + $affected = Db::execute($sql, [$offset, $limit]); + $offset += $limit; + if ($affected > 0) { + usleep($usleepTime); + } + } while ($affected > 0); + } + }