|
|
@@ -81,6 +81,7 @@ class Events
|
|
|
|
|
|
// 定时统计数据
|
|
|
if (0 === $worker->id) {
|
|
|
+
|
|
|
self::writeLogKfStatus(0, 0, 0);
|
|
|
|
|
|
// 1分钟统计一次实时数据
|
|
|
@@ -92,9 +93,6 @@ class Events
|
|
|
self::writeLog(2);
|
|
|
});
|
|
|
|
|
|
- }
|
|
|
- if (1 == $worker->id) {
|
|
|
-
|
|
|
//每1分钟发一次本组排队数
|
|
|
Timer::add(60 * 1, function () {
|
|
|
self::lineup();
|
|
|
@@ -106,17 +104,12 @@ class Events
|
|
|
Timer::add(60 * 10, function () {
|
|
|
self::upsystemconfig();
|
|
|
});
|
|
|
- }
|
|
|
-
|
|
|
- if (2 == $worker->id) {
|
|
|
|
|
|
// 检查对话时效给出.
|
|
|
Timer::add(6, function () {
|
|
|
self::overTime();
|
|
|
});
|
|
|
- }
|
|
|
|
|
|
- if (3 == $worker->id) {
|
|
|
// 实时监控.
|
|
|
Timer::add(60, function () {
|
|
|
$adminList = self::$global->adminList ?? [];
|
|
|
@@ -210,8 +203,8 @@ class Events
|
|
|
//Gateway::sendToCurrentClient('{"type":"pong"}');
|
|
|
return;
|
|
|
} 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);
|
|
|
@@ -261,12 +254,15 @@ class Events
|
|
|
'servicelog_id' => $message['data']['conversationId'],
|
|
|
'time_line' => time()
|
|
|
];
|
|
|
-
|
|
|
self::$db->insert('ws_chat_log')->cols($serviceLog)->query();
|
|
|
+
|
|
|
+ /*
|
|
|
if ($message['data']['sensitiveNumber']) {
|
|
|
|
|
|
}
|
|
|
self::$db->query("update `ws_alarm` set `alarm_corresponding` = '$corresponding',alarm_respond=2 where `servicelog_id`= '$servicelog_id'");
|
|
|
+ */
|
|
|
+
|
|
|
unset($serviceLog);
|
|
|
}
|
|
|
if (isset($message['data']['isFirst']) && $message['data']['isFirst']) {
|
|
|
@@ -573,6 +569,10 @@ class Events
|
|
|
];
|
|
|
Gateway::sendToClient($tokfidclientid, json_encode($noticeKf, 256));
|
|
|
unset($noticeKf);
|
|
|
+
|
|
|
+ self::servicetrutoother('OUT', $fromkfuid, $toukfid, $oldlog['servicelog_id'], $uid);
|
|
|
+ self::servicetrutoother('IN', $toukfid, $fromkfuid, $new_id, $uid);
|
|
|
+
|
|
|
//回转接人,转接成功
|
|
|
Gateway::sendToCurrentClient(json_encode(['message_type' => 'trunconnect', 'data' => ['status' => 1], 256]));
|
|
|
|
|
|
@@ -1338,6 +1338,9 @@ class Events
|
|
|
|
|
|
case -1:
|
|
|
$waitMsg = '暂时没有客服上班,请稍后再咨询。';
|
|
|
+ Gateway::sendToClient($client_id, json_encode(['message_type' => "noservice", 'data' => ['content' => $waitMsg]], 256));
|
|
|
+ Gateway::closeClient($client_id);
|
|
|
+ return;
|
|
|
break;
|
|
|
case -2:
|
|
|
break;
|
|
|
@@ -1369,10 +1372,41 @@ class Events
|
|
|
}
|
|
|
}
|
|
|
Gateway::sendToGroup('group_' . $group, json_encode(['message_type' => 'kfqueuelength', 'leng' => $waitcount], 256));
|
|
|
+ self::todayqueuelength();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //今天排序累加
|
|
|
+ private static function todayqueuelength()
|
|
|
+ {
|
|
|
+ $dtype = 'user.queue.day.length';
|
|
|
+ $today = date("Y-m-d");
|
|
|
+
|
|
|
+ $sret = self::$db->select('*')->from('ws_countmidtable')->where('dtype=:dtype and mdate=:mdate')->bindValues(array('dtype' => $dtype, 'mdate' => $today))->row();
|
|
|
+ if ($ret) {
|
|
|
+ $db->update('ws_countmidtable')->cols(array('dcontent' => intval($sret['dcontent']) + 1))->where('id=' . $sret['id'])->query();
|
|
|
+ } else {
|
|
|
+ $db->insert('ws_countmidtable')->cols(array(
|
|
|
+ 'dtype' => $dtype,
|
|
|
+ 'mdate' => $today,
|
|
|
+ 'datatype' => 1,
|
|
|
+ 'dcontent' => 1))->query();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //客服工单转单
|
|
|
+ private static function servicetrutoother($type, $owen, $otherkfid, $serverid, $clientuid)
|
|
|
+ {
|
|
|
+ $db->insert('ws_serviceturn_log')->cols(array(
|
|
|
+ 'stype' => $type,
|
|
|
+ 'uid' => $owen,
|
|
|
+ 'tuid' => $otherkfid,
|
|
|
+ 'serverid' => $serverid,
|
|
|
+ 'guestuid' => $clientuid
|
|
|
+ ))->query();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 给客服分配会员【均分策略】
|