diff --git a/Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php b/Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php index 2db45e6b4..e40abd607 100644 --- a/Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php +++ b/Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php @@ -154,18 +154,29 @@ class Adapter implements WeChatServiceInterface public function handleCustomerTaskWithStatusIsNew(int $current_worker_id, int $process_count_for_status_0) { - $tasks = Db::name('customer_acquisition_task')->alias('task') - ->join('task_customer customer','task.id=customer.task_id') - ->where(['task.status' => 1,'customer.status'=>0,'task.deleteTime' => 0]) - ->whereRaw("customer.id % $process_count_for_status_0 = {$current_worker_id}") - ->order('id DESC') + $task = Db::name('customer_acquisition_task') + ->where(['status' => 1,'deleteTime' => 0]) ->select(); + if (empty($task)) { + return false; + } + + $taskData = []; + foreach ($task as $item) { + $tasks = Db::name('task_customer') + ->where(['status'=> 0,'task_id'=>$item['id']]) + ->whereRaw("id % $process_count_for_status_0 = {$current_worker_id}") + ->order('id DESC') + ->limit(20) + ->select(); + $taskData = array_merge($taskData, $tasks); + } - if ($tasks) { + if ($taskData) { - foreach ($tasks as $task) { + foreach ($taskData as $task) { $task_id = $task['task_id'];