From c08b9b0b26c842968f7af9adcae31e0cdfa8f6cb Mon Sep 17 00:00:00 2001 From: wong <106998207@qq.com> Date: Tue, 15 Jul 2025 11:06:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E9=87=8F=E5=88=86=E5=8F=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../job/WorkbenchTrafficDistributeJob.php | 56 +++++++++---------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/Server/application/job/WorkbenchTrafficDistributeJob.php b/Server/application/job/WorkbenchTrafficDistributeJob.php index de457812..53e26d54 100644 --- a/Server/application/job/WorkbenchTrafficDistributeJob.php +++ b/Server/application/job/WorkbenchTrafficDistributeJob.php @@ -58,7 +58,7 @@ class WorkbenchTrafficDistributeJob protected function processSingleWorkbench($workbench) { $page = 1; - $pageSize = 100; + $pageSize = 20; $config = WorkbenchTrafficConfig::where('workbenchId', $workbench->id)->find(); if (!$config) { @@ -89,8 +89,6 @@ class WorkbenchTrafficDistributeJob ->group('a.id') ->having('todayCount <= ' . $config['maxPerDay']) ->select(); - - $accountNum = count($accounts); if ($accountNum < 1) { Log::info("流量分发工作台 {$workbench->id} 可分配账号少于1个"); @@ -134,29 +132,33 @@ class WorkbenchTrafficDistributeJob } // 执行切换好友命令 - $automaticAssign->allotWechatFriend([ + $res = $automaticAssign->allotWechatFriend([ 'wechatFriendId' => $friend['id'], 'toAccountId' => $account['id'] ], true); - Db::table('s2_wechat_friend') - ->where('id',$friend['id']) - ->update([ - 'accountId' => $account['id'], - 'accountUserName' => $account['userName'], - 'accountRealName' => $account['realName'], - 'accountNickname' => $account['nickname'], + + $res = json_decode($res,true); + if ($res['code'] == 200){ + Db::table('s2_wechat_friend') + ->where('id',$friend['id']) + ->update([ + 'accountId' => $account['id'], + 'accountUserName' => $account['userName'], + 'accountRealName' => $account['realName'], + 'accountNickname' => $account['nickname'], ]); - // 写入分配记录表 - Db::name('workbench_traffic_config_item')->insert([ - 'workbenchId' => $workbench->id, - 'deviceId' => $friend['deviceId'], - 'wechatFriendId' => $friend['id'], - 'wechatAccountId' => $account['id'], - 'createTime' => time(), - 'exp' => $config['exp'], - 'expTime' => time() + 86400 * $config['exp'], - ]); - Log::info("流量分发工作台 {$workbench->id} 好友[{$friend['id']}]分配给客服[{$account['id']}] 成功"); + // 写入分配记录表 + Db::name('workbench_traffic_config_item')->insert([ + 'workbenchId' => $workbench->id, + 'deviceId' => $friend['deviceId'], + 'wechatFriendId' => $friend['id'], + 'wechatAccountId' => $account['id'], + 'createTime' => time(), + 'exp' => $config['exp'], + 'expTime' => time() + 86400 * $config['exp'], + ]); + Log::info("流量分发工作台 {$workbench->id} 好友[{$friend['id']}]分配给客服[{$account['id']}] 成功"); + } $i++; } break; @@ -206,24 +208,16 @@ class WorkbenchTrafficDistributeJob $query = Db::table('s2_wechat_friend')->alias('wf') ->join(['s2_company_account' => 'sa'], 'sa.id = wf.accountId', 'left') ->join(['s2_wechat_account' => 'wa'], 'wa.id = wf.wechatAccountId', 'left') - ->join('workbench_traffic_config_item wtci', 'wtci.wechatFriendId = wf.id AND wtci.workbenchId = ' . $config['workbenchId'], 'left') + ->join('workbench_traffic_config_item wtci', 'wtci.isRecycle = 0 and wtci.wechatFriendId = wf.id AND wtci.workbenchId = ' . $config['workbenchId'], 'left') ->where([ - ['wf.isDeleted', '=', 0], ['wf.isDeleted', '=', 0], ['wf.isPassed', '=', 1], //['sa.departmentId', '=', $workbench->companyId], - ['wtci.expTime', '>', time()], ['wtci.id', 'null', null] ]) ->whereIn('wa.currentDeviceId', $devices) ->field('wf.id,wf.wechatAccountId,wf.wechatId,wf.labels,sa.userName,wa.currentDeviceId as deviceId'); - //lllll - if($workbench->id == 65){ - $query->where('wf.accountId',1602); - } - - if(!empty($labels)){ $query->where(function ($q) use ($labels) {