|
|
@@ -252,8 +252,8 @@ class Events
|
|
|
*/
|
|
|
public static function onMessage($client_id, $message)
|
|
|
{
|
|
|
- if ($message == '{"type":"ping"}' || $message == '{"message_type":"ping"}' ) {
|
|
|
- Gateway::sendToCurrentClient('{"type":"pong"}');
|
|
|
+ if ($message == '{"type":"ping"}' || $message == '{"type":"pong"}') {
|
|
|
+ //Gateway::sendToCurrentClient('{"type":"pong"}');
|
|
|
return;
|
|
|
} else {
|
|
|
echo "onMessage: " . $message . "\r\n";
|
|
|
@@ -444,13 +444,16 @@ class Events
|
|
|
|
|
|
|
|
|
//客户工单内部组转接
|
|
|
- public static function changeOtherhKeFu($client_id, $message)
|
|
|
+ public static function changeOtherhKeFu($client_id, $smessage)
|
|
|
{
|
|
|
+ $message = $smessage['data'];
|
|
|
+
|
|
|
$groupid = isset($message['group']) ? intval($message['group']) : 0;
|
|
|
- $toukfid = isset($message['toukfuid']) ? intval($message['toukfuid']) : 0;
|
|
|
+ $toukfid = isset($message['toukfuid']) ? $message['toukfuid'] : 0;
|
|
|
$fromkfuid = isset($message['fromkfuid']) ? $message['fromkfuid'] : 0;
|
|
|
$uid = isset($message['uid']) ? $message['uid'] : 0;
|
|
|
$word = isset($message['word']) ? $message['word'] : '';
|
|
|
+
|
|
|
if (empty($groupid) || empty($toukfid) || empty($fromkfuid) || empty($uid) || empty($word) || ($toukfid == $fromkfuid)) {
|
|
|
return false;
|
|
|
}
|
|
|
@@ -458,6 +461,7 @@ class Events
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
$tokfidclientid = Gateway::getClientIdByUid($toukfid);
|
|
|
$tokfidclientid = $tokfidclientid['0'];
|
|
|
$uidclientid = Gateway::getClientIdByUid($uid);
|
|
|
@@ -493,15 +497,14 @@ class Events
|
|
|
do {
|
|
|
} while (!self::$global->cas('userToKf', $userToKf, $userToKf_new));
|
|
|
|
|
|
-
|
|
|
/////////取消原有会话,开启新会话
|
|
|
$histarttimelimit = time() - 3600 * 24;
|
|
|
- $bindval = ['user_id' => $uid, 'kf_id' => intval(trim($toukfid, 'KF')), 'histime' => $histarttimelimit];
|
|
|
- $oldlog = self::$db->select('*')->from('ws_service_log')->where('user_id= :user_id and client_id=:client_id and kf_id=:kf_id and status=2 and start_time>=:histime ')->bindValues($bindval)->row();
|
|
|
+ $bindval = ['user_id' => $uid, 'client_id' => $uidclientid, 'kf_id' => intval(trim($fromkfuid, 'KF')), 'histime' => $histarttimelimit];
|
|
|
+ $oldlog = self::$db->select('*')->from('ws_service_log')->where('user_id= :user_id and client_id=:client_id and kf_id=:kf_id and status!=2 and start_time>=:histime ')->bindValues($bindval)->row();
|
|
|
if (!$oldlog) {
|
|
|
return false;
|
|
|
}
|
|
|
- self::$db->update('ws_service_log')->cols(['status' => 2, 'endtime' => time()])->where('servicelog_id=' . $oldlog['servicelog_id'])->query();
|
|
|
+ self::$db->update('ws_service_log')->cols(['status' => 2, 'end_time' => time()])->where('servicelog_id=' . $oldlog['servicelog_id'])->query();
|
|
|
unset($oldlog['servicelog_id']);
|
|
|
$oldlog = array_merge($oldlog, ['kf_id' => intval(trim($toukfid, 'KF')), 'start_time' => time(), 'end_time' => 0, 'status' => 1, 'evaluate_id' => 0]);
|
|
|
$new_id = self::$db->insert('ws_service_log')->cols($oldlog)->query();
|
|
|
@@ -515,7 +518,7 @@ class Events
|
|
|
'message_type' => 'connect',
|
|
|
'data' => [
|
|
|
'kf_id' => $toukfid,
|
|
|
- 'kf_name' => Gateway::getSession($toukfid)['name'],
|
|
|
+ 'kf_name' => Gateway::getSession( Gateway::getClientIdByUid($toukfid)['0'])['name'],
|
|
|
]
|
|
|
];
|
|
|
Gateway::sendToClient($uidclientid, json_encode($noticeUser, 256));
|
|
|
@@ -525,7 +528,7 @@ class Events
|
|
|
$noticeKf = [
|
|
|
'message_type' => 'connect',
|
|
|
'data' => [
|
|
|
- 'user_info' => $uidclientid
|
|
|
+ 'user_info' => $uid
|
|
|
]
|
|
|
];
|
|
|
Gateway::sendToClient($tokfidclientid, json_encode($noticeKf, 256));
|
|
|
@@ -540,7 +543,6 @@ class Events
|
|
|
public static function Kfinit($client_id, $message)
|
|
|
{
|
|
|
$kfList = self::$global->kfList;
|
|
|
-
|
|
|
//客服登陆验证 不符合的直接断掉
|
|
|
$logcheck = true; //开发时使用
|
|
|
//$logcheck = self::KfloginChedk($client_id, $message);
|
|
|
@@ -551,7 +553,6 @@ class Events
|
|
|
|
|
|
// 如果该客服未在内存中记录则记录
|
|
|
if (!isset($kfList[$message['group']]) || !array_key_exists($message['uid'], $kfList[$message['group']])) {
|
|
|
-
|
|
|
do {
|
|
|
$newKfList = $kfList;
|
|
|
$newKfList[$message['group']][$message['uid']] = [
|
|
|
@@ -1099,7 +1100,7 @@ class Events
|
|
|
'system' => $res['data']['3']['system'],
|
|
|
'browse' => $res['data']['3']['browse'],
|
|
|
'status' => 1,
|
|
|
- 'intime'=>$res['data']['3']['intime'],
|
|
|
+ 'intime' => $res['data']['3']['intime'],
|
|
|
'end_time' => 0
|
|
|
];
|
|
|
$hisSession = self::$db->select('*')->from('ws_service_log')->where('user_id=:user_id and kf_id=:kf_id and group_id=:group_id and status in (1,3)')->bindValues(array('user_id' => $res['data']['3']['id'], 'kf_id' => intval(ltrim($res['data']['0'], 'KF')), 'group_id' => $group))->row();
|