|
@@ -91,22 +91,21 @@ class Events
|
|
|
public static function onConnect($client_id)
|
|
public static function onConnect($client_id)
|
|
|
{
|
|
{
|
|
|
// 检测是否开启自动应答
|
|
// 检测是否开启自动应答
|
|
|
- $sayHello = self::$db->query('select `word`,`status` from `ws_reply` where `id` = 1');
|
|
|
|
|
- if (!empty($sayHello) && 1 == $sayHello['0']['status']) {
|
|
|
|
|
|
|
+ $sayHello = self::$global->replay['1'];
|
|
|
|
|
+ if (!empty($sayHello) && 1 == $sayHello['status']) {
|
|
|
|
|
|
|
|
$hello = [
|
|
$hello = [
|
|
|
'message_type' => 'helloMessage',
|
|
'message_type' => 'helloMessage',
|
|
|
'data' => [
|
|
'data' => [
|
|
|
'name' => '智能助手',
|
|
'name' => '智能助手',
|
|
|
'time' => date('H:i'),
|
|
'time' => date('H:i'),
|
|
|
- 'content' => $sayHello['0']['word']
|
|
|
|
|
|
|
+ 'content' => $sayHello['word']
|
|
|
]
|
|
]
|
|
|
];
|
|
];
|
|
|
Gateway::sendToClient($client_id, json_encode($hello, 256));
|
|
Gateway::sendToClient($client_id, json_encode($hello, 256));
|
|
|
unset($hello);
|
|
unset($hello);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
unset($sayHello);
|
|
unset($sayHello);
|
|
|
// 检测是否开启广告
|
|
// 检测是否开启广告
|
|
|
$advertisement = self::$db->query('select * from `ws_advertisement` where `advertisement_status` = 1');
|
|
$advertisement = self::$db->query('select * from `ws_advertisement` where `advertisement_status` = 1');
|
|
@@ -496,8 +495,6 @@ class Events
|
|
|
|
|
|
|
|
// 写入接入值
|
|
// 写入接入值
|
|
|
$key = date('Ymd') . 'total_in';
|
|
$key = date('Ymd') . 'total_in';
|
|
|
- $oldKey = date('Ymd', strtotime('-1 day')); // 删除前一天的统计值
|
|
|
|
|
- unset(self::$global->$oldKey);
|
|
|
|
|
self::$global->increment($key);
|
|
self::$global->increment($key);
|
|
|
|
|
|
|
|
// 绑定 client_id 和 uid
|
|
// 绑定 client_id 和 uid
|
|
@@ -552,12 +549,14 @@ class Events
|
|
|
$now = time();
|
|
$now = time();
|
|
|
$starttime = $now - 86400 * 7;
|
|
$starttime = $now - 86400 * 7;
|
|
|
|
|
|
|
|
|
|
+ self::$redis->hset('loginTmp:' . $uid, 'uid', time());
|
|
|
|
|
+ self::$redis->expire('loginTmp:' . $uid, 5);
|
|
|
|
|
+
|
|
|
if (!empty($user_info)) {
|
|
if (!empty($user_info)) {
|
|
|
foreach ($user_info as $val => $serverid) {
|
|
foreach ($user_info as $val => $serverid) {
|
|
|
self::$redis->hdel(self::SERVICELOG, intval($serverid));
|
|
self::$redis->hdel(self::SERVICELOG, intval($serverid));
|
|
|
self::MySendMsg($val, json_encode(['message_type' => 'serviceoffline', 'msg' => '客户人员下线!'], 256));
|
|
self::MySendMsg($val, json_encode(['message_type' => 'serviceoffline', 'msg' => '客户人员下线!'], 256));
|
|
|
Gateway::closeClient($val);
|
|
Gateway::closeClient($val);
|
|
|
- sleep(1);
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -575,6 +574,9 @@ class Events
|
|
|
//用户下线了 系统调用,不能手动调用
|
|
//用户下线了 系统调用,不能手动调用
|
|
|
public static function guestOffline($client_id, $uid)
|
|
public static function guestOffline($client_id, $uid)
|
|
|
{
|
|
{
|
|
|
|
|
+ self::$redis->hset('loginTmp:' . $uid, 'uid', time());
|
|
|
|
|
+ self::$redis->expire('loginTmp:' . $uid, 3);
|
|
|
|
|
+
|
|
|
$uid = intval($uid);
|
|
$uid = intval($uid);
|
|
|
$krclient_id = 0;
|
|
$krclient_id = 0;
|
|
|
|
|
|
|
@@ -586,6 +588,7 @@ class Events
|
|
|
self::$redis->hdel(self::USERLIST, $uid);
|
|
self::$redis->hdel(self::USERLIST, $uid);
|
|
|
self::$redis->hdel(self::USERINFOKEY, $uid);
|
|
self::$redis->hdel(self::USERINFOKEY, $uid);
|
|
|
|
|
|
|
|
|
|
+
|
|
|
if (!empty($info['kfuid'])) {
|
|
if (!empty($info['kfuid'])) {
|
|
|
$kfinfo = self::$redis->hget(self::KFINFOKEY, $info['kfuid']);
|
|
$kfinfo = self::$redis->hget(self::KFINFOKEY, $info['kfuid']);
|
|
|
if (!empty($kfinfo)) {
|
|
if (!empty($kfinfo)) {
|
|
@@ -803,15 +806,15 @@ class Events
|
|
|
self::MySendMsg($userInfo['client_id'], json_encode($noticeUser, 256));
|
|
self::MySendMsg($userInfo['client_id'], json_encode($noticeUser, 256));
|
|
|
|
|
|
|
|
|
|
|
|
|
- $sayHello = self::$db->query('select `word`,`status` from `ws_reply` where `id` = 2');
|
|
|
|
|
- if (!empty($sayHello) && 1 == $sayHello['0']['status']) {
|
|
|
|
|
|
|
+ $sayHello = (self::$global->replay)['2'];
|
|
|
|
|
+ if (!empty($sayHello) && 1 == $sayHello['status']) {
|
|
|
$chat_message = [
|
|
$chat_message = [
|
|
|
'message_type' => 'chatMessage',
|
|
'message_type' => 'chatMessage',
|
|
|
'data' => [
|
|
'data' => [
|
|
|
'id' => self::getkfuid($kfinfo['id']),
|
|
'id' => self::getkfuid($kfinfo['id']),
|
|
|
'name' => $kfinfo['name'],
|
|
'name' => $kfinfo['name'],
|
|
|
'time' => date('H:i'),
|
|
'time' => date('H:i'),
|
|
|
- 'content' => $sayHello['0']['word']
|
|
|
|
|
|
|
+ 'content' => $sayHello['word']
|
|
|
]
|
|
]
|
|
|
];
|
|
];
|
|
|
self::MySendMsg($userInfo['client_id'], json_encode($chat_message, 256));
|
|
self::MySendMsg($userInfo['client_id'], json_encode($chat_message, 256));
|
|
@@ -1054,7 +1057,6 @@ class Events
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$group = self::$db->query("SELECT * FROM `ws_groups`");
|
|
$group = self::$db->query("SELECT * FROM `ws_groups`");
|
|
|
-
|
|
|
|
|
$arr = [];
|
|
$arr = [];
|
|
|
if ($group) {
|
|
if ($group) {
|
|
|
foreach ($group as $val) {
|
|
foreach ($group as $val) {
|
|
@@ -1063,8 +1065,14 @@ class Events
|
|
|
self::$global->groupmap = $arr;
|
|
self::$global->groupmap = $arr;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //$sayHello = self::$db->query('select `word`,`status` from `ws_reply` where `id` = 2');
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $arr = [];
|
|
|
|
|
+ $replay = self::$db->query('select * from `ws_reply`');
|
|
|
|
|
+ if ($replay) {
|
|
|
|
|
+ foreach ($replay as $val) {
|
|
|
|
|
+ $arr[$val['id']] = $val;
|
|
|
|
|
+ }
|
|
|
|
|
+ self::$global->replay = $arr;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1409,11 +1417,17 @@ class Events
|
|
|
|
|
|
|
|
//初始化.....
|
|
//初始化.....
|
|
|
self::upsystemconfig();
|
|
self::upsystemconfig();
|
|
|
- //每5分钟更新一次系统配置文件
|
|
|
|
|
|
|
+ //每3分钟更新一次系统配置文件
|
|
|
Timer::add(60 * 3, function () {
|
|
Timer::add(60 * 3, function () {
|
|
|
self::upsystemconfig();
|
|
self::upsystemconfig();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ // 删除前一天的统计值
|
|
|
|
|
+ Timer::add(60 * 60 * 12, function () {
|
|
|
|
|
+ $oldKey = date('Ymd', strtotime('-1 day'));
|
|
|
|
|
+ unset(self::$global->$oldKey);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
self::resetServiceLog();
|
|
self::resetServiceLog();
|
|
|
}
|
|
}
|
|
|
|
|
|