vali 6 lat temu
rodzic
commit
a499341161

+ 31 - 2
vendor/GatewayWorker_windows/Applications/whisper/Events.php

@@ -518,15 +518,16 @@ class Events
 
         $groupMax = self::$global->systemconfig['maxWait'];
         $noworders = self::getUselistData($group);
-        if ($noworders && count($noworders) > intval($groupMax['systemconfig_data'])) {
+        if ($noworders && count($noworders) >= intval($groupMax['systemconfig_data'])) {
             Gateway::sendToClient($client_id, json_encode(['message_type' => 'notice', 'content' => '组排队人数超过上限,请稍后在连线。'], 256));
             return;
         }
 
-        if (!$last && $noworders) {
+        if (!$last && self::HasInqueue($group)) {
             Gateway::sendToClient($client_id, json_encode(['message_type' => 'inqueue', 'content' => '当前咨询人数繁多,正在排队中,请耐心等待。'], 256));
         }
 
+
         self::$redis->hset('loginTmp:' . $uid, 'uid', time());
         self::$redis->expire('loginTmp:' . $uid, 5);
 
@@ -1980,6 +1981,34 @@ class Events
         return $date;
     }
 
+    //检查一个新人是否需要排队
+    public static function HasInqueue($group)
+    {
+        $group = intval($group);
+        $allserveric = self::$redis->hgetall(self::SERVICELOG);
+        if (empty($allserveric)) {
+            return false;
+        }
+        $count = 0;
+        foreach ($allserveric as $serv) {
+            $tmp = json_decode($serv, true);
+            if (isset($tmp['group_id']) && $tmp['group_id'] == $group) {
+                $count++;
+            }
+        }
+
+        $gkf = self::getOnlineKfData($group, 1);
+        $max = intval(self::$global->systemconfig['KFMaxServices']['systemconfig_data']);
+
+        if ($gkf) {
+            $cc = count($gkf) * $max;
+            if ($cc >= $count) {
+                return true;
+            }
+        }
+
+        return false;
+    }
 
 }