添加好友优化

This commit is contained in:
wong
2025-07-14 11:59:32 +08:00
parent acdaa78258
commit d21db1c6a6

View File

@@ -153,9 +153,10 @@ class Adapter implements WeChatServiceInterface
public function handleCustomerTaskWithStatusIsNew(int $current_worker_id, int $process_count_for_status_0) public function handleCustomerTaskWithStatusIsNew(int $current_worker_id, int $process_count_for_status_0)
{ {
$task = Db::name('customer_acquisition_task') $task = Db::name('customer_acquisition_task')
->where(['status' => 1,'deleteTime' => 0]) ->where(['status' => 1,'deleteTime' => 0])
->whereRaw("id % $process_count_for_status_0 = {$current_worker_id}")
->order('id desc')
->select(); ->select();
if (empty($task)) { if (empty($task)) {
@@ -164,11 +165,16 @@ class Adapter implements WeChatServiceInterface
$taskData = []; $taskData = [];
foreach ($task as $item) { foreach ($task as $item) {
$reqConf = json_decode($item['reqConf'], true);
$device = $reqConf['device'] ?? [];
$deviceCount = count($device);
if ($deviceCount <= 0){
continue;
}
$tasks = Db::name('task_customer') $tasks = Db::name('task_customer')
->where(['status'=> 0,'task_id'=>$item['id']]) ->where(['status'=> 0,'task_id'=>$item['id']])
->whereRaw("id % $process_count_for_status_0 = {$current_worker_id}")
->order('id DESC') ->order('id DESC')
->limit(5) ->limit($deviceCount)
->select(); ->select();
$taskData = array_merge($taskData, $tasks); $taskData = array_merge($taskData, $tasks);
} }