|
@@ -166,7 +166,7 @@ class Events
|
|
|
]
|
|
]
|
|
|
];
|
|
];
|
|
|
$found_key = array_search($v['servicelog_id'], array_column($serviceLog, 'servicelog_id'));
|
|
$found_key = array_search($v['servicelog_id'], array_column($serviceLog, 'servicelog_id'));
|
|
|
- Gateway::sendToClient($serviceLog[$found_key]['client_id'], json_encode($chat_message,256));
|
|
|
|
|
|
|
+ Gateway::sendToClient($serviceLog[$found_key]['client_id'], json_encode($chat_message, 256));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -256,8 +256,8 @@ class Events
|
|
|
//Gateway::sendToCurrentClient('{"type":"pong"}');
|
|
//Gateway::sendToCurrentClient('{"type":"pong"}');
|
|
|
return;
|
|
return;
|
|
|
} else {
|
|
} else {
|
|
|
- //echo "onMessage: " . $message . "\r\n";
|
|
|
|
|
- //print_r([self::$global->kfList, self::$global->userList, self::$global->uidSimpleList, self::$global->userToKf]);
|
|
|
|
|
|
|
+ echo "onMessage: " . $message . "\r\n";
|
|
|
|
|
+ print_r([self::$global->kfList, self::$global->userList, self::$global->uidSimpleList, self::$global->userToKf]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$message = json_decode($message, true);
|
|
$message = json_decode($message, true);
|
|
@@ -271,6 +271,9 @@ class Events
|
|
|
self::userInitEnt($client_id, $message);
|
|
self::userInitEnt($client_id, $message);
|
|
|
break;
|
|
break;
|
|
|
// 聊天
|
|
// 聊天
|
|
|
|
|
+ case 'getkfonlines':
|
|
|
|
|
+ self::getkfonlines($client_id, $message);
|
|
|
|
|
+ break;
|
|
|
case 'chatMessage':
|
|
case 'chatMessage':
|
|
|
$client = Gateway::getClientIdByUid($message['data']['to_id']);
|
|
$client = Gateway::getClientIdByUid($message['data']['to_id']);
|
|
|
if (!empty($client)) {
|
|
if (!empty($client)) {
|
|
@@ -442,6 +445,32 @@ class Events
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static function getkfonlines($client_id, $message)
|
|
|
|
|
+ {
|
|
|
|
|
+ $return = [
|
|
|
|
|
+ 'message_type' => 'onlinekfs',
|
|
|
|
|
+ 'data' => [],
|
|
|
|
|
+ ];
|
|
|
|
|
+ $kfs = self::$global->kfList;
|
|
|
|
|
+ if (!$kfs) {
|
|
|
|
|
+ Gateway::sendToCurrentClient(json_encode($return, 256));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $ret = [];
|
|
|
|
|
+ foreach ($kfs as $gruop => $fs) {
|
|
|
|
|
+ foreach ($fs as $kfid => $kfdata) {
|
|
|
|
|
+ if ($kfdata['status'] == 1) {
|
|
|
|
|
+ $ret[$gruop][] = ['id' => $kfid, 'name' => $kfdata['name'], 'job_member' => $kfdata['job_name']];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $return['data'] = $ret;
|
|
|
|
|
+
|
|
|
|
|
+ Gateway::sendToCurrentClient(json_encode($return, 256));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
//客户工单内部组转接
|
|
//客户工单内部组转接
|
|
|
public static function changeOtherhKeFu($client_id, $smessage)
|
|
public static function changeOtherhKeFu($client_id, $smessage)
|
|
@@ -518,7 +547,7 @@ class Events
|
|
|
'message_type' => 'connect',
|
|
'message_type' => 'connect',
|
|
|
'data' => [
|
|
'data' => [
|
|
|
'kf_id' => $toukfid,
|
|
'kf_id' => $toukfid,
|
|
|
- 'kf_name' => Gateway::getSession( Gateway::getClientIdByUid($toukfid)['0'])['name'],
|
|
|
|
|
|
|
+ 'kf_name' => Gateway::getSession(Gateway::getClientIdByUid($toukfid)['0'])['name'],
|
|
|
]
|
|
]
|
|
|
];
|
|
];
|
|
|
Gateway::sendToClient($uidclientid, json_encode($noticeUser, 256));
|
|
Gateway::sendToClient($uidclientid, json_encode($noticeUser, 256));
|
|
@@ -544,9 +573,10 @@ class Events
|
|
|
{
|
|
{
|
|
|
$kfList = self::$global->kfList;
|
|
$kfList = self::$global->kfList;
|
|
|
//客服登陆验证 不符合的直接断掉
|
|
//客服登陆验证 不符合的直接断掉
|
|
|
- $logcheck = true; //开发时使用
|
|
|
|
|
- //$logcheck = self::KfloginChedk($client_id, $message);
|
|
|
|
|
- if (!$logcheck) {
|
|
|
|
|
|
|
+ //$logcheck = true; //开发时使用
|
|
|
|
|
+ $kfinfo = self::KfloginChedk($client_id, $message);
|
|
|
|
|
+ if (empty($kfinfo)) {
|
|
|
|
|
+ Gateway::sendToClient($client_id, json_encode(["message_type" => 'checkfalse', 'data' => "验证失败"], 256));
|
|
|
Gateway::closeCurrentClient();
|
|
Gateway::closeCurrentClient();
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -556,9 +586,10 @@ class Events
|
|
|
do {
|
|
do {
|
|
|
$newKfList = $kfList;
|
|
$newKfList = $kfList;
|
|
|
$newKfList[$message['group']][$message['uid']] = [
|
|
$newKfList[$message['group']][$message['uid']] = [
|
|
|
- 'id' => $message['uid'],
|
|
|
|
|
- 'name' => $message['name'],
|
|
|
|
|
- 'avatar' => $message['avatar'],
|
|
|
|
|
|
|
+ 'id' => 'KF' . $kfinfo['id'],
|
|
|
|
|
+ 'name' => $kfinfo['user_name'],
|
|
|
|
|
+ 'job_name' => $kfinfo['user_job_number'],
|
|
|
|
|
+ 'avatar' => $kfinfo['user_avatar'],
|
|
|
'client_id' => $client_id,
|
|
'client_id' => $client_id,
|
|
|
'task' => 0,
|
|
'task' => 0,
|
|
|
'status' => 2,// 1为在线(接收分配、接收消息)2为隐身(不接收分配、只接收消息)
|
|
'status' => 2,// 1为在线(接收分配、接收消息)2为隐身(不接收分配、只接收消息)
|
|
@@ -589,8 +620,8 @@ class Events
|
|
|
//客服登陆验证
|
|
//客服登陆验证
|
|
|
public static function KfloginChedk($client, $messageArray)
|
|
public static function KfloginChedk($client, $messageArray)
|
|
|
{
|
|
{
|
|
|
- $uid = isset($messageArray['uid']) ? ($messageArray['uid']) : '';
|
|
|
|
|
- $token = isset($messageArray['token']) ? ($messageArray['token']) : '';
|
|
|
|
|
|
|
+ $uid = isset($messageArray['uid']) ? $messageArray['uid'] : '';
|
|
|
|
|
+ $token = isset($messageArray['token']) ? $messageArray['token'] : '';
|
|
|
if (empty($uid) || empty($token)) {
|
|
if (empty($uid) || empty($token)) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|