From adc3cf660f08e0e64d3dfc1e8d2651613b137dc5 Mon Sep 17 00:00:00 2001 From: wong <106998207@qq.com> Date: Fri, 27 Jun 2025 16:43:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Server/application/common/TaskServer.php | 4 ++++ .../WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php | 13 +++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Server/application/common/TaskServer.php b/Server/application/common/TaskServer.php index 254d1091..fb3b57d2 100644 --- a/Server/application/common/TaskServer.php +++ b/Server/application/common/TaskServer.php @@ -46,6 +46,10 @@ class TaskServer extends Server $adapter = new ChuKeBaoAdapter(); + + Log::info('Workerman进程:' . $current_worker_id); + + // 在一个进程里处理获客任务添加后的相关逻辑 if ($current_worker_id == self::PROCESS_COUNT - 1) { Timer::add(60, function () use($adapter) { diff --git a/Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php b/Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php index 71d09115..4fe7d07a 100644 --- a/Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php +++ b/Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php @@ -156,8 +156,10 @@ class Adapter implements WeChatServiceInterface ->where('status', 0) ->whereRaw("id % $process_count_for_status_0 = {$current_worker_id}") ->limit(50) + ->order('id DESC') ->select(); + if ($tasks) { foreach ($tasks as $task) { @@ -171,7 +173,6 @@ class Adapter implements WeChatServiceInterface } $wechatIdAccountIdMap = $this->getWeChatIdsAccountIdsMapByDeviceIds($task_info['reqConf']['device']); - if (empty($wechatIdAccountIdMap)) { continue; } @@ -181,10 +182,10 @@ class Adapter implements WeChatServiceInterface // 是否已经是好友的判断,如果已经是好友,直接break; 但状态还是维持1,让另外一个进程处理发消息的逻辑 $isFriend = $this->checkIfIsWeChatFriendByPhone($wechatId, $task['phone']); - if ($isFriend) { - $task['processed_wechat_ids'] = $task['processed_wechat_ids'] . ',' . $wechatId; // 处理失败任务用,用于过滤已处理的微信号 - break; - } +// if ($isFriend) { +// $task['processed_wechat_ids'] = $task['processed_wechat_ids'] . ',' . $wechatId; // 处理失败任务用,用于过滤已处理的微信号 +// break; +// } // 判断时间间隔\时间段和最后一次的状态 $canCreateFriendAddTask = $this->checkIfCanCreateFriendAddTask($wechatId, $task_info['reqConf']); @@ -428,7 +429,7 @@ class Adapter implements WeChatServiceInterface // 先读取缓存 $task_info = cache('task_info_' . $id); - if (!empty($task_info)) { + if (empty($task_info)) { $task_info = Db::name('customer_acquisition_task') ->where('id', $id) ->find();