vali 6 年 前
コミット
7289d87428
1 ファイル変更30 行追加1 行削除
  1. 30 1
      vendor/GatewayWorker_windows/Applications/whisper/Events.php

+ 30 - 1
vendor/GatewayWorker_windows/Applications/whisper/Events.php

@@ -71,7 +71,7 @@ class Events
         foreach ($group as $groupid => $gname) {
             $users = self::getUselistData($groupid);
             if (!empty($users)) {
-                Gateway::sendToGroup('group_' . $groupid, json_encode(['type' => 'lineupCount', count($users)], 256));
+                Gateway::sendToGroup('group_' . $groupid, json_encode(['type' => 'lineupCount', 'data' => ['count' => count($users)]], 256));
             }
         }
     }
@@ -509,6 +509,13 @@ class Events
             return;
         }
 
+        $groupMax = self::$global->systemconfig['maxWait'];
+        $noworders = self::getUselistData($group);
+        if ($noworders && count($noworders) > intval($groupMax['systemconfig_data'])) {
+            Gateway::sendToClient($client_id, json_encode(['message_type' => 'notice', 'content' => '组排队人数超过上限,请稍后在连线。'], 256));
+            return;
+        }
+
         self::$redis->hset('loginTmp:' . $uid, 'uid', time());
         self::$redis->expire('loginTmp:' . $uid, 5);
 
@@ -809,16 +816,21 @@ class Events
      */
     private static function userOnlineTask($group = 0, $uid = 0, $last = [], $client_id = '')
     {
+
         $allusergkarr = self::getUserListData();
         if (empty($allusergkarr)) {
             return;
         }
 
         $allkfgkarr = self::getWorkKfData();
+        ///做某个组的客户是还有人服务检测,如果此组没有客服在线了,要把对应排队的人kh踢掉
+        self::Kf_user_click($allkfgkarr, $allusergkarr);
+
         if (empty($allkfgkarr) && !$last) {
             return;
         }
 
+
         $maxset = intval((self::$global->systemconfig)['KFMaxServices']);
 
         if ($group && $uid) {
@@ -867,10 +879,27 @@ class Events
                 }
             }
         }
+
+
         return;
 
     }
 
+    //踢掉某个组没有客服的用户
+    private static function Kf_user_click($kfArrays, $userLIsts)
+    {
+        foreach ($userLIsts as $group => $groupusers) {
+            $haskf = isset($kfArrays[$group]) ? 1 : 0;
+            if (!$haskf) {
+                foreach ($groupusers as $user) {
+                    Gateway::sendToClient($user['client_id'], json_encode(['message_type' => 'notice', 'data' => ['msg' => "没有客服人员在线,请稍后再试。"]], 256));
+                    Gateway::closeClient($user['client_id']);
+                }
+            }
+        }
+        return true;
+    }
+
     //开启一个会话
     private static function BeginTalk($kfuid, $uid, $group, $serviceid = 0, $userInfo = false)
     {