|
|
@@ -55,21 +55,6 @@ class Events
|
|
|
self::$global = self::$logic->getGlbData();
|
|
|
|
|
|
self::TimerThing($worker);
|
|
|
- // 管理员实时监控.
|
|
|
- /*Timer::add(6, function () {
|
|
|
- // 获取在线管理员总数.
|
|
|
- $adminListCount = self::$redis->lLen('adminList');
|
|
|
- // 获取在线管理员
|
|
|
- $adminList = self::$redis->lrange('adminList', 0, $adminListCount);
|
|
|
- if ($adminList) {
|
|
|
- self::systemMonitoring($adminList);
|
|
|
- }
|
|
|
- });*/
|
|
|
-
|
|
|
- // 检查对话时效给出.
|
|
|
- Timer::add(6, function () {
|
|
|
- self::overTime();
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -179,7 +164,7 @@ class Events
|
|
|
break;
|
|
|
// 评价.
|
|
|
case 'evaluate':
|
|
|
- self::evaluate($client_id, $message);
|
|
|
+ self::evaluate($message['data']);
|
|
|
break;
|
|
|
// 客服关闭会话.
|
|
|
case 'kfCloseUser':
|
|
|
@@ -194,11 +179,28 @@ class Events
|
|
|
break;
|
|
|
// 弹出评价.
|
|
|
case 'getEvaluate';
|
|
|
+ self::getEvaluate($message['data']);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 弹出评价.
|
|
|
+ public static function getEvaluate($message) {
|
|
|
+ // 获取当前会话工单.
|
|
|
+ $data = json_decode(self::$redis->HGET('SERVICELOG', $message['conversationId']), true);
|
|
|
+ if (empty($data)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $chat_message = [
|
|
|
+ 'message_type' => 'getEvaluate',
|
|
|
+ 'data' => [
|
|
|
+ 'content' => '欢迎你的咨询,请对我们的服务做出评价',
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ Gateway::sendToClient($data['client_id'], json_encode($chat_message, 256));
|
|
|
+ }
|
|
|
+
|
|
|
//客服聊天
|
|
|
public static function chatMessage($message)
|
|
|
{
|
|
|
@@ -414,7 +416,7 @@ class Events
|
|
|
// 查询token是否存在.
|
|
|
$systemConfigData = self::$db->query("SELECT `id` FROM `ws_admins` where `token`= '$token'");
|
|
|
if ($systemConfigData) {
|
|
|
- $adminList = self::$redis->lpush('adminList', $client_id);
|
|
|
+ self::$redis->sadd('adminList', $client_id);
|
|
|
self::systemMonitoring([$client_id]);
|
|
|
} else {
|
|
|
$chat_message = [
|
|
|
@@ -527,11 +529,9 @@ class Events
|
|
|
|
|
|
echo "下线:uid: $uid - cid: $client_id - iskf: $isKefuoff \n";
|
|
|
|
|
|
- $adminList = self::$global->adminList ?? [];
|
|
|
- $key = array_search($client_id, $adminList);
|
|
|
- if (strlen($key)) {
|
|
|
- array_splice($adminList, $key, 1);
|
|
|
- self::$global->adminList = $adminList;
|
|
|
+ $isAdmin = self::$redis->sismember('adminList', $client_id);
|
|
|
+ if ($isAdmin) {
|
|
|
+ self::$redis->srem('adminList', $client_id);
|
|
|
}
|
|
|
if (empty($uid)) {
|
|
|
return;
|
|
|
@@ -1077,7 +1077,7 @@ class Events
|
|
|
* @param $client_id 服务ID
|
|
|
* @param $message 数据
|
|
|
*/
|
|
|
- private static function toRobot($client_id, $message)
|
|
|
+ private static function toRobot($message)
|
|
|
{
|
|
|
$groups_id = $message['data']['groups_id'];
|
|
|
$robot_name = $message['data']['robot_name'];
|
|
|
@@ -1101,29 +1101,24 @@ class Events
|
|
|
* @param $client_id 服务ID
|
|
|
* @param $message 数据
|
|
|
*/
|
|
|
- private static function evaluate($client_id, $message)
|
|
|
+ private static function evaluate($message)
|
|
|
{
|
|
|
- // 修改数据库.
|
|
|
- $evaluate_id = $message['data']['evaluate_id'];
|
|
|
- $result = self::$db->query("UPDATE `ws_service_log` SET `evaluate_id` = '" . $evaluate_id . "' WHERE `client_id`='" . $client_id . "'");
|
|
|
- if ($result) {
|
|
|
- $chat_message = [
|
|
|
- 'message_type' => 'evaluate',
|
|
|
- 'data' => [
|
|
|
- 'status' => 1,
|
|
|
- 'time' => date('H:i'),
|
|
|
- ]
|
|
|
- ];
|
|
|
- } else {
|
|
|
- $chat_message = [
|
|
|
- 'message_type' => 'evaluate',
|
|
|
- 'data' => [
|
|
|
- 'status' => 2,
|
|
|
- 'time' => date('H:i'),
|
|
|
- ]
|
|
|
- ];
|
|
|
+ // 获取当前会话工单.
|
|
|
+ $data = json_decode(self::$redis->HGET('SERVICELOG', $message['conversationId']), true);
|
|
|
+ if (empty($data)) {
|
|
|
+ return;
|
|
|
}
|
|
|
- Gateway::sendToClient($client_id, json_encode($chat_message, 256));
|
|
|
+ $data['evaluate_id'] = $message['evaluate_id'];
|
|
|
+ $data['evaluate_content'] = $message['evaluate_content'];
|
|
|
+ self::$redis->HSET('SERVICELOG', $data['client_id'], json_encode($data, 256));
|
|
|
+ $chat_message = [
|
|
|
+ 'message_type' => 'evaluate',
|
|
|
+ 'data' => [
|
|
|
+ 'status' => 1,
|
|
|
+ 'time' => date('H:i'),
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ Gateway::sendToClient($message['client_id'], json_encode($chat_message, 256));
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1285,6 +1280,7 @@ class Events
|
|
|
'evaluateCount' => $evaluateCount,
|
|
|
]
|
|
|
];
|
|
|
+ print_r($chat_message);
|
|
|
Gateway::sendToClient($v, json_encode($chat_message, 256));
|
|
|
}
|
|
|
}
|
|
|
@@ -1526,6 +1522,20 @@ class Events
|
|
|
unset(self::$global->$oldKey);
|
|
|
});
|
|
|
|
|
|
+ // 管理员实时监控.
|
|
|
+ Timer::add(6, function () {
|
|
|
+ // 获取在线管理员
|
|
|
+ $adminList = self::$redis->smembers('adminList');
|
|
|
+ if ($adminList) {
|
|
|
+ self::systemMonitoring($adminList);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 检查对话时效给出.
|
|
|
+ Timer::add(6, function () {
|
|
|
+ self::overTime();
|
|
|
+ });
|
|
|
+
|
|
|
self::resetServiceLog();
|
|
|
}
|
|
|
|