Browse Source

Merge branch 'dev' of http://git.bocai108.com:10180/Ethan/Customer-Service into dev

# Conflicts:
#	vendor/GatewayWorker_windows/Applications/whisper/Events.php
vali 6 years ago
parent
commit
11225aaeda
1 changed files with 43 additions and 0 deletions
  1. 43 0
      vendor/GatewayWorker_windows/Applications/whisper/Events.php

+ 43 - 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':
@@ -208,6 +212,10 @@ class Events
                 case 'updateusercache':
                     //更新用户缓存信息
                     self::updateusercache($client_id, $message['data']);
+                // 客服更改状态.
+                case 'joinServiceGroup':
+                    //后台更改了数据,sock里的缓存强制更新一下,做到即时更新的效果
+                    self::joinServiceGroup($client_id, $message['data']);
                     break;
                 case  'tickkf':
                     //将某个kf踢下线
@@ -241,6 +249,22 @@ class Events
         return self::$redis->sismember(self::ADMINLIST, $client_id);
     }
 
+    //更新用户缓存信息
+//    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)
@@ -249,6 +273,25 @@ class Events
         self::getUserInfoCache($uid, 180, 0);
     }
 
+    //加入工单群组(未完)
+    public static function joinServiceGroup($client_id, $message) {
+        $uid = $message['uid'];
+        $serviceLogId = $message['conversationId'];
+        $userInfo = self::$db->select('user_overview')->from('ws_users')->where('id=:id')->bindValues(['id' => $uid])->row();
+        if ($userInfo[0]['user_overview'] !== 1) {
+            $chat_message = [
+                'message_type' => 'error',
+                'data' => [
+                    'flag' => 1,
+                    'msg' => '取消排队成功!'
+                ]
+            ];
+            Gateway::sendToCurrentClient(json_encode($chat_message, 256));
+            return;
+        }
+        Gateway::joinGroup($client_id, $serviceLogId);
+    }
+
     //强制更新缓存信息
     public static function updatecache($client_id, $dataArray)
     {