diff --git a/application/index/controller/Index.php b/application/index/controller/Index.php index c0e44f9..879deac 100644 --- a/application/index/controller/Index.php +++ b/application/index/controller/Index.php @@ -38,7 +38,7 @@ class Index extends Controller if (!$uid || !$kefu_code ) { 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); if (empty($list)) return json($list); foreach ($list as $key => $item) { diff --git a/application/index/controller/Kefu.php b/application/index/controller/Kefu.php index 85fceae..b2bb828 100644 --- a/application/index/controller/Kefu.php +++ b/application/index/controller/Kefu.php @@ -40,7 +40,7 @@ class Kefu extends Base if (!$uid || !$kefu_code ) { 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); if (empty($list)) return json(['code'=>200,'data'=>$list,'msg'=>'操作成功']); foreach ($list as $key => $item) { diff --git a/application/swoole/service/Event.php b/application/swoole/service/Event.php index 773575d..5fbbbbb 100644 --- a/application/swoole/service/Event.php +++ b/application/swoole/service/Event.php @@ -14,6 +14,7 @@ use think\Exception; use think\facade\Log; use Logic\KefuLogic; use exception\LogicException; +use Logic\ServiceLogic; use exception\BaseException; use Logic\QueueLogic; use Logic\Visitor; @@ -54,7 +55,7 @@ class Event * @param $fd 客户端标识 * @param $data 请求数据 */ - public static function kefuLogin($fd, $data, $server) + public static function kefuConnection($fd, $data, $server) { try { @@ -71,7 +72,6 @@ class Event self::$kefu[$data['uid']]['visitor_fds'][$item['visitor_id']] = $item['client_id']; } } - Log::record('WebSocket请求开始,数据信息[' . json_encode($frame) . ']'); QueueLogic::updateQueueingkefuClientid($kefu_code, $fd); return self::reposon($fd, 200, '客服上线成功', [], 'kefu_online'); } catch (BaseException $e) { @@ -178,7 +178,7 @@ class Event return self::reposon($fd, 200, $kefu_info['msg'], $kefu_info['data'], 'visitorToKefu'); } catch (Exception $e) { Db::rollback(); - Log::error('分配客服数据错误信息:' . $e->getMessage()); + Log::info('分配客服数据错误信息:' . $e->getMessage()); //取消客服在线状态 KefuLogic::setKefuOnlineStatus(ltrim($kefu_info['data']['kefu_code'], 'KF_'), '', 0); return self::reposon($fd, 401, '请重新尝试分配客服1', [], 'visitorToKefu'); @@ -190,7 +190,7 @@ class Event Db::commit(); } catch (BaseException $e) { Db::rollback(); - Log::error('分配客服数据错误信息:' . $e->getMessage()); + Log::record('分配客服数据错误信息:' . $e->getMessage()); return self::reposon($fd, 402, '请重新尝试分配客服2', [], 'visitorToKefu'); } unset($customer, $kefu_info); diff --git a/config/swoole_server.php b/config/swoole_server.php index e3eac62..c8a96a8 100644 --- a/config/swoole_server.php +++ b/config/swoole_server.php @@ -17,7 +17,7 @@ use think\facade\Env; return [ // 扩展自身配置 'host' => '0.0.0.0', // 监听地址 - 'port' => 9510, // 监听端口 + 'port' => 9111, // 监听端口 'type' => 'socket', // 服务类型 支持 socket http server 'mode' => '', // 运行模式 默认为SWOOLE_PROCESS 'sock_type' => '', // sock type 默认为SWOOLE_SOCK_TCP @@ -27,7 +27,7 @@ return [ 'daemonize' => false, 'pid_file' => Env::get('runtime_path') . 'swoole_server.pid', 'log_file' => Env::get('runtime_path') . 'swoole_server.log', - + 'worker_num'=>1, // 事件回调定义 'onOpen' => [new app\swoole\service\Service(),'onOpen'], 'onMessage' => [new app\swoole\service\Service(),'onMessage'],