Ethan преди 6 години
родител
ревизия
4d56347118
променени са 2 файла, в които са добавени 22 реда и са изтрити 0 реда
  1. 1 0
      application/service/controller/Common.php
  2. 21 0
      vendor/GatewayWorker_windows/Applications/whisper/Events.php

+ 1 - 0
application/service/controller/Common.php

@@ -31,6 +31,7 @@ class Common extends Base
                 'expire_time',
             ];
             $usersWhere['token'] = $getUserToken;
+            $usersWhere['status'] = 1;
             // 验证用户token.
             $users         = model('users')->findUsers($usersField, $usersWhere);
             $effectiveTime = strtotime(date('Y-m-d H:i:s').'-1 hours');

+ 21 - 0
vendor/GatewayWorker_windows/Applications/whisper/Events.php

@@ -136,6 +136,10 @@ class Events
         }
 
         $message = json_decode($message, true);
+        // 验证客服是否被删除或禁用.
+        if (isset($message['data']['conversationId'])) {
+            self::prohibitServer($message['data']['conversationId']);
+        }
         if (isset($message['type'])) {
             switch ($message['type']) {
                 case 'mydebug':
@@ -218,6 +222,23 @@ class Events
         return true;
     }
 
+    //更新用户缓存信息
+    public static function prohibitServer($serviceLogId)
+    {
+        $data = json_decode(self::$redis->HGET('SERVICELOG', $serviceLogId), true);
+        $userInfo = self::$db->select('status')->from('ws_users')->where('id=:id')->bindValues(['id' => $data['kf_id']])->row();
+        if (!$userInfo || $userInfo['status'] != 1) {
+            $chat_message = [
+                'message_type' => 'error',
+                'data' => [
+                    'msg' => '账号异常!'
+                ]
+            ];
+            Gateway::sendToClient($data['kf_client_id'], json_encode($chat_message, 256));
+            Gateway::closeClient($data['kf_client_id']);
+        }
+    }
+
     //更新用户缓存信息
     public static function updateusercache($client_id, $dataArray)
     {