mirror of
https://gitee.com/zhc02/timely_service.git
synced 2025-08-02 12:34:48 +08:00
core
This commit is contained in:
parent
d30b63abc2
commit
681e925f7e
@ -38,7 +38,7 @@ class Index extends Controller
|
|||||||
if (!$uid || !$kefu_code ) {
|
if (!$uid || !$kefu_code ) {
|
||||||
return '参数错误';
|
return '参数错误';
|
||||||
}
|
}
|
||||||
$sql = "SELECT * FROM chat_log WHERE ( from_id = '{$uid}' and to_id ='{$kefu_code}') or (from_id = '{$kefu_code}' and to_id ='{$uid}') order by create_time";
|
$sql = "SELECT * FROM ty_chat_log WHERE ( from_id = '{$uid}' and to_id ='{$kefu_code}') or (from_id = '{$kefu_code}' and to_id ='{$uid}') order by create_time";
|
||||||
$list = Db::query($sql);
|
$list = Db::query($sql);
|
||||||
if (empty($list)) return json($list);
|
if (empty($list)) return json($list);
|
||||||
foreach ($list as $key => $item) {
|
foreach ($list as $key => $item) {
|
||||||
|
@ -40,7 +40,7 @@ class Kefu extends Base
|
|||||||
if (!$uid || !$kefu_code ) {
|
if (!$uid || !$kefu_code ) {
|
||||||
return '参数错误';
|
return '参数错误';
|
||||||
}
|
}
|
||||||
$sql = "SELECT * FROM chat_log WHERE ( from_id = '{$kefu_code}' and to_id ='{$uid}') or (from_id = '{$uid}' and to_id ='{$kefu_code}') order by create_time";
|
$sql = "SELECT * FROM ty_chat_log WHERE ( from_id = '{$kefu_code}' and to_id ='{$uid}') or (from_id = '{$uid}' and to_id ='{$kefu_code}') order by create_time";
|
||||||
$list = Db::query($sql);
|
$list = Db::query($sql);
|
||||||
if (empty($list)) return json(['code'=>200,'data'=>$list,'msg'=>'操作成功']);
|
if (empty($list)) return json(['code'=>200,'data'=>$list,'msg'=>'操作成功']);
|
||||||
foreach ($list as $key => $item) {
|
foreach ($list as $key => $item) {
|
||||||
|
@ -14,6 +14,7 @@ use think\Exception;
|
|||||||
use think\facade\Log;
|
use think\facade\Log;
|
||||||
use Logic\KefuLogic;
|
use Logic\KefuLogic;
|
||||||
use exception\LogicException;
|
use exception\LogicException;
|
||||||
|
use Logic\ServiceLogic;
|
||||||
use exception\BaseException;
|
use exception\BaseException;
|
||||||
use Logic\QueueLogic;
|
use Logic\QueueLogic;
|
||||||
use Logic\Visitor;
|
use Logic\Visitor;
|
||||||
@ -54,7 +55,7 @@ class Event
|
|||||||
* @param $fd 客户端标识
|
* @param $fd 客户端标识
|
||||||
* @param $data 请求数据
|
* @param $data 请求数据
|
||||||
*/
|
*/
|
||||||
public static function kefuLogin($fd, $data, $server)
|
public static function kefuConnection($fd, $data, $server)
|
||||||
{
|
{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -71,7 +72,6 @@ class Event
|
|||||||
self::$kefu[$data['uid']]['visitor_fds'][$item['visitor_id']] = $item['client_id'];
|
self::$kefu[$data['uid']]['visitor_fds'][$item['visitor_id']] = $item['client_id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log::record('WebSocket请求开始,数据信息[' . json_encode($frame) . ']');
|
|
||||||
QueueLogic::updateQueueingkefuClientid($kefu_code, $fd);
|
QueueLogic::updateQueueingkefuClientid($kefu_code, $fd);
|
||||||
return self::reposon($fd, 200, '客服上线成功', [], 'kefu_online');
|
return self::reposon($fd, 200, '客服上线成功', [], 'kefu_online');
|
||||||
} catch (BaseException $e) {
|
} catch (BaseException $e) {
|
||||||
@ -178,7 +178,7 @@ class Event
|
|||||||
return self::reposon($fd, 200, $kefu_info['msg'], $kefu_info['data'], 'visitorToKefu');
|
return self::reposon($fd, 200, $kefu_info['msg'], $kefu_info['data'], 'visitorToKefu');
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
Log::error('分配客服数据错误信息:' . $e->getMessage());
|
Log::info('分配客服数据错误信息:' . $e->getMessage());
|
||||||
//取消客服在线状态
|
//取消客服在线状态
|
||||||
KefuLogic::setKefuOnlineStatus(ltrim($kefu_info['data']['kefu_code'], 'KF_'), '', 0);
|
KefuLogic::setKefuOnlineStatus(ltrim($kefu_info['data']['kefu_code'], 'KF_'), '', 0);
|
||||||
return self::reposon($fd, 401, '请重新尝试分配客服1', [], 'visitorToKefu');
|
return self::reposon($fd, 401, '请重新尝试分配客服1', [], 'visitorToKefu');
|
||||||
@ -190,7 +190,7 @@ class Event
|
|||||||
Db::commit();
|
Db::commit();
|
||||||
} catch (BaseException $e) {
|
} catch (BaseException $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
Log::error('分配客服数据错误信息:' . $e->getMessage());
|
Log::record('分配客服数据错误信息:' . $e->getMessage());
|
||||||
return self::reposon($fd, 402, '请重新尝试分配客服2', [], 'visitorToKefu');
|
return self::reposon($fd, 402, '请重新尝试分配客服2', [], 'visitorToKefu');
|
||||||
}
|
}
|
||||||
unset($customer, $kefu_info);
|
unset($customer, $kefu_info);
|
||||||
|
@ -17,7 +17,7 @@ use think\facade\Env;
|
|||||||
return [
|
return [
|
||||||
// 扩展自身配置
|
// 扩展自身配置
|
||||||
'host' => '0.0.0.0', // 监听地址
|
'host' => '0.0.0.0', // 监听地址
|
||||||
'port' => 9510, // 监听端口
|
'port' => 9111, // 监听端口
|
||||||
'type' => 'socket', // 服务类型 支持 socket http server
|
'type' => 'socket', // 服务类型 支持 socket http server
|
||||||
'mode' => '', // 运行模式 默认为SWOOLE_PROCESS
|
'mode' => '', // 运行模式 默认为SWOOLE_PROCESS
|
||||||
'sock_type' => '', // sock type 默认为SWOOLE_SOCK_TCP
|
'sock_type' => '', // sock type 默认为SWOOLE_SOCK_TCP
|
||||||
@ -27,7 +27,7 @@ return [
|
|||||||
'daemonize' => false,
|
'daemonize' => false,
|
||||||
'pid_file' => Env::get('runtime_path') . 'swoole_server.pid',
|
'pid_file' => Env::get('runtime_path') . 'swoole_server.pid',
|
||||||
'log_file' => Env::get('runtime_path') . 'swoole_server.log',
|
'log_file' => Env::get('runtime_path') . 'swoole_server.log',
|
||||||
|
'worker_num'=>1,
|
||||||
// 事件回调定义
|
// 事件回调定义
|
||||||
'onOpen' => [new app\swoole\service\Service(),'onOpen'],
|
'onOpen' => [new app\swoole\service\Service(),'onOpen'],
|
||||||
'onMessage' => [new app\swoole\service\Service(),'onMessage'],
|
'onMessage' => [new app\swoole\service\Service(),'onMessage'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user