Prechádzať zdrojové kódy

'修改workman配置,添加机器人问答'

Ethan 6 rokov pred
rodič
commit
461e0bffd4
28 zmenil súbory, kde vykonal 1117 pridanie a 283 odobranie
  1. 2 0
      .gitignore
  2. 7 1
      application/admin/config.php
  3. 175 0
      application/admin/controller/Robot.php
  4. 1 1
      application/admin/controller/Words.php
  5. 33 0
      application/admin/model/Groups.php
  6. 74 0
      application/admin/model/Robot.php
  7. 33 0
      application/admin/model/Robotgroups.php
  8. 6 6
      application/admin/view/menu.html
  9. 176 0
      application/admin/view/robot/addword.html
  10. 176 0
      application/admin/view/robot/editword.html
  11. 132 0
      application/admin/view/robot/index.html
  12. 1 1
      application/admin/view/words/editword.html
  13. 36 0
      application/index/controller/Common.php
  14. 35 0
      application/index/controller/Groups.php
  15. 69 0
      application/index/controller/Robot.php
  16. 33 0
      application/index/model/Groups.php
  17. 33 0
      application/index/model/Robot.php
  18. 33 0
      application/index/model/Robotgroups.php
  19. 2 1
      application/index/view/index/chat.html
  20. 9 2
      public/static/customer/js/whisper-cli.js
  21. 1 1
      public/static/customer/js/whisper-mobile.js
  22. 4 4
      public/static/service/js/whisper.js
  23. 3 2
      vendor/GatewayWorker_linux/GatewayWorker/vendor/workerman/workerman/Lib/Constants.php
  24. 27 0
      vendor/GatewayWorker_windows/Applications/whisper/Events.php
  25. 9 7
      vendor/GatewayWorker_windows/Applications/whisper/start_gateway.php
  26. 4 3
      vendor/GatewayWorker_windows/vendor/workerman/workerman-for-win/Lib/Constants.php
  27. 3 2
      vendor/GatewayWorker_windows/vendor/workerman/workerman/Lib/Constants.php
  28. 0 252
      whisper.sql

+ 2 - 0
.gitignore

@@ -1,2 +1,4 @@
 .idea
+composer.lock
+*.log
 runtime

+ 7 - 1
application/admin/config.php

@@ -15,9 +15,15 @@ return [
         2 => '禁用'
     ],
 
+    // 客服状态
+    'host' => [
+        1 => '是',
+        2 => '否'
+    ],
+
     // 是否在线
     'online' => [
         1 => '在线',
         2 => '离线'
     ]
-];
+];

+ 175 - 0
application/admin/controller/Robot.php

@@ -0,0 +1,175 @@
+<?php
+namespace app\admin\controller;
+
+/**
+ * 智能问答类
+ */
+class Robot extends Base
+{
+
+
+    /**
+     * 智能问答列表
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function index()
+    {
+        if (request()->isAjax()) {
+            $param  = input('param.');
+            $limit  = $param['pageSize'];
+            $offset = (($param['pageNumber'] - 1) * $limit);
+            $where  = [];
+            if (empty($param['searchText']) === false) {
+                $where['robot_name'] = $param['searchText'];
+            }
+
+            $join   = [
+                'groups b'      => 'a.groups_id = b.id',
+                'robotgroups c' => 'a.robotgroups_id = c.robotgroups_id',
+            ];
+            $result = model('Robot')->selectJoin($join, $where, $offset, $limit);
+
+            foreach ($result as $key => $vo) {
+                // 优化显示状态.
+                if(1 === $vo['robot_status']) {
+                    $result[$key]['robot_status'] = '<span style="color: #2fbe1b">启用</span>';
+                } else {
+                    $result[$key]['robot_status'] = '<span style="color: red">禁用</span>';
+                }
+
+                // 优化显示热点问题.
+                if (1 === $vo['robot_host']) {
+                    $result[$key]['robot_host'] = '<span style="color: #2fbe1b">是</span>';
+                } else {
+                    $result[$key]['robot_host'] = '<span style="color: red">否</span>';
+                }
+
+                // 生成操作按钮.
+                $result[$key]['operate'] = $this->makeBtn($vo['robot_id']);
+            }
+
+            // 总数据.
+            $return['total'] = model('Robot')->count($where);
+            $return['rows'] = $result;
+
+            return json($return);
+
+        }
+
+        return $this->fetch();
+    }
+
+    // 添加智能问答
+    public function addWord()
+    {
+        if(request()->isPost()){
+
+            $param = input('post.');
+            $param['robot_content'] = trim($param['robot_content']);
+            $robotWhere = [
+                'robot_name' => $param['robot_name'],
+                'groups_id' => $param['groups_id'],
+                'robotgroups_id' => $param['robotgroups_id'],
+            ];
+
+            $has = db('robot')->field('robot_id')->where($robotWhere)->find();
+            if(!empty($has)){
+                return json(['code' => -1, 'data' => '', 'msg' => '该智能问答已经存在']);
+            }
+
+            $param['robot_addTime'] = date('Y-m-d H:i:s');
+            $param['robot_updateTime'] = date('Y-m-d H:i:s');
+            try{
+                db('robot')->insert($param);
+            }catch(\Exception $e){
+                return json(['code' => -2, 'data' => '', 'msg' => $e->getMessage()]);
+            }
+
+            return json(['code' => 1, 'data' => '', 'msg' => '添加智能问答成功']);
+        }
+        $groups = db('groups')->where('status', 1)->select();
+        $robotgroups = db('robotgroups')->where('robotgroups_status', 1)->select();
+        $this->assign([
+            'status' => config('kf_status'),
+            'host' => config('host'),
+            'groups' => $groups,
+            'robotgroups' => $robotgroups,
+        ]);
+
+        return $this->fetch();
+    }
+
+    // 编辑智能问答
+    public function editWord()
+    {
+        if(request()->isAjax()){
+
+            $param = input('post.');
+            $param['robot_content'] = trim($param['robot_content']);
+            $param['robot_updateTime'] = date('Y-m-d H:i:s');
+            $robotWhere = [
+                'robot_name' => $param['robot_name'],
+                'groups_id' => $param['groups_id'],
+                'robotgroups_id' => $param['robotgroups_id'],
+            ];
+
+            // 检测用户修改的智能问答是否重复
+            $has = db('robot')->where($robotWhere)->count();
+            if($has>1){
+                return json(['code' => -1, 'data' => '', 'msg' => '该智能问答已经存在']);
+            }
+
+            try{
+                db('robot')->where('robot_id', $param['robot_id'])->update($param);
+            }catch(\Exception $e){
+                return json(['code' => -2, 'data' => '', 'msg' => $e->getMessage()]);
+            }
+
+            return json(['code' => 1, 'data' => '', 'msg' => '编辑智能问答成功']);
+        }
+
+        $id = input('param.robot_id/d');
+        $info = db('robot')->where('robot_id', $id)->find();
+        $groups = db('groups')->where('status', 1)->select();
+        $robotgroups = db('robotgroups')->where('robotgroups_status', 1)->select();
+
+        $this->assign([
+            'info' => $info,
+            'host' => config('host'),
+            'groups' => $groups,
+            'robotgroups' => $robotgroups,
+            'status' => config('kf_status')
+        ]);
+        return $this->fetch();
+    }
+
+    // 删除智能问答
+    public function delWord()
+    {
+        if(request()->isAjax()){
+            $id = input('param.id/d');
+
+            try{
+                db('robot')->where('robot_id', $id)->delete();
+            }catch(\Exception $e){
+                return json(['code' => -1, 'data' => '', 'msg' => $e->getMessage()]);
+            }
+
+            return json(['code' => 1, 'data' => '', 'msg' => '删除智能问答成功']);
+        }
+    }
+
+    // 生成按钮
+    private function makeBtn($id)
+    {
+        $operate = '<a href="' . url('robot/editword', ['robot_id' => $id]) . '">';
+        $operate .= '<button type="button" class="btn btn-primary btn-sm"><i class="fa fa-paste"></i> 编辑</button></a> ';
+
+        $operate .= '<a href="javascript:userDel(' . $id . ')"><button type="button" class="btn btn-danger btn-sm">';
+        $operate .= '<i class="fa fa-trash-o"></i> 删除</button></a> ';
+
+        return $operate;
+    }
+}

+ 1 - 1
application/admin/controller/Words.php

@@ -136,4 +136,4 @@ class Words extends Base
 
         return $operate;
     }
-}
+}

+ 33 - 0
application/admin/model/Groups.php

@@ -0,0 +1,33 @@
+<?php
+namespace app\index\model;
+
+use think\Model;
+
+/**
+ * 分组模型
+ */
+class Groups extends Model
+{
+
+
+    /**
+     * select数据筛选
+     *
+     * @access public
+     * @param mixed $where 条件
+     * @return array 返回类型
+     */
+    public function select($where=[])
+    {
+        $result = $this;
+        if (empty($where) === false) {
+            $result = $result->where($where);
+        }
+
+        $result = $result->select();
+        return $result;
+
+    }//end select()
+
+
+}

+ 74 - 0
application/admin/model/Robot.php

@@ -0,0 +1,74 @@
+<?php
+namespace app\admin\model;
+
+use think\Model;
+
+/**
+ * 智能问答模型
+ */
+class Robot extends Model
+{
+
+
+    /**
+     * select数据筛选
+     *
+     * @access public
+     * @param mixed $join 关联
+     * @param mixed $where 条件
+     * @param mixed $offset 分页开始
+     * @param mixed $limit 分页大小
+     * @param mixed $order 排序
+     * @return array 返回类型
+     */
+    public function selectJoin($join, $where=[], $offset='', $limit='', $order=['robot_updateTime'=>'desc'])
+    {
+        $result = $this;
+        if (empty($join) === false) {
+            $result = $result->alias('a');
+            foreach ($join as $k => $v) {
+                $result = $result->join($k, $v);
+            }
+        }
+
+        if (empty($where) === false) {
+            $result = $result->where($where);
+        }
+
+        if (empty($offset) === false && empty($limit) === false) {
+            $result = $result->limit($offset, $limit);
+        }
+
+        if (empty($order) === false) {
+            foreach ($order as $k => $v) {
+                $result = $result->order($k, $v);
+            }
+        }
+
+        $result = $result->select();
+        return $result;
+
+    }//end selectJoin()
+
+
+    /**
+     * select数据筛选
+     *
+     * @access public
+     * @param mixed $where 条件
+     * @return array 返回类型
+     */
+    public function count($where=[])
+    {
+        $result = $this;
+        if (empty($where) === false) {
+            $result = $result->where($where);
+        }
+
+        $result = $result->count();
+        return $result;
+
+    }//end count()
+
+
+}

+ 33 - 0
application/admin/model/Robotgroups.php

@@ -0,0 +1,33 @@
+<?php
+namespace app\index\model;
+
+use think\Model;
+
+/**
+ * 智能问答分组模型
+ */
+class Robotgroups extends Model
+{
+
+
+    /**
+     * select数据筛选
+     *
+     * @access public
+     * @param mixed $where 条件
+     * @return array 返回类型
+     */
+    public function select($where=[])
+    {
+        $result = $this;
+        if (empty($where) === false) {
+            $result = $result->where($where);
+        }
+
+        $result = $result->select();
+        return $result;
+
+    }//end select()
+
+
+}

+ 6 - 6
application/admin/view/menu.html

@@ -58,21 +58,21 @@
         </li>
     </ul>
 </li>
-<!--<li class="menu">
+<li class="menu">
     <a href="#">
         <i class="fa fa-android"></i>
-        <span class="nav-label">机器应答管理</span>
+        <span class="nav-label">智能问答管理</span>
         <span class="fa arrow"></span>
     </a>
     <ul class="nav nav-second-level">
         <li>
-            <a class="J_menuItem" href="{:url('words/index')}">应答列表</a>
+            <a class="J_menuItem" href="{:url('robot/index')}">智能问答列表</a>
         </li>
         <li>
-            <a class="J_menuItem" href="{:url('words/addword')}">添加应答</a>
+            <a class="J_menuItem" href="{:url('robot/addword')}">添加智能问答</a>
         </li>
     </ul>
-</li>-->
+</li>
 <li class="menu">
     <a href="#">
         <i class="fa fa-gear"></i>
@@ -100,4 +100,4 @@
             <a class="J_menuItem" href="{:url('system/wordsLog')}">历史会话</a>
         </li>
     </ul>
-</li>
+</li>

+ 176 - 0
application/admin/view/robot/addword.html

@@ -0,0 +1,176 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>添加智能问答</title>
+    <link rel="shortcut icon" href="favicon.ico">
+    <link href="__CSS__/bootstrap.min.css?v=3.3.6" rel="stylesheet">
+    <link href="__CSS__/font-awesome.min.css?v=4.4.0" rel="stylesheet">
+    <link href="__CSS__/animate.min.css" rel="stylesheet">
+    <link href="__JS__/layui/css/layui.css" rel="stylesheet">
+    <link href="__CSS__/style.min.css?v=4.1.0" rel="stylesheet">
+</head>
+<body class="gray-bg">
+<div class="wrapper wrapper-content animated fadeInRight">
+    <div class="row">
+        <div class="col-sm-8">
+            <div class="ibox float-e-margins">
+                <div class="ibox-title">
+                    <h5>添加智能问答</h5>
+                </div>
+                <div class="ibox-content">
+                    <form class="form-horizontal m-t layui-form" id="commentForm" method="post" action="{:url('robot/addword')}">
+
+                        <div class="form-group">
+                            <label class="col-sm-3 control-label">问题:</label>
+                            <div class="input-group col-sm-4">
+                                <textarea class="form-control" name="robot_name" required="" aria-required="true" style="width: 400px;height: 38px;resize:none"></textarea>
+                            </div>
+                        </div>
+                        <div class="form-group">
+                            <label class="col-sm-3 control-label">答案:</label>
+                            <div class="input-group col-sm-4">
+                                <textarea class="form-control" name="robot_content" required="" aria-required="true" style="width: 400px;height: 150px;resize:none"></textarea>
+                            </div>
+                        </div>
+                        <div class="form-group">
+                            <label class="col-sm-3 control-label">选择分组:</label>
+                            <input type="hidden" id="groups_id" name="groups_id"/>
+                            <div class="input-group col-sm-4 layui-form">
+                                <select lay-verify="required" lay-filter="group">
+                                    <option value="">请选择</option>
+                                    {if !empty($groups)}
+                                    {foreach name="groups" item="vo"}
+                                    <option value="{$vo['id']}">{$vo['name']}</option>
+                                    {/foreach}
+                                    {/if}
+                                </select>
+                            </div>
+                        </div>
+                        <div class="form-group">
+                            <label class="col-sm-3 control-label">智能分组:</label>
+                            <input type="hidden" id="robotgroups_id" name="robotgroups_id"/>
+                            <div class="input-group col-sm-4 layui-form">
+                                <select lay-verify="required" lay-filter="robotgroups">
+                                    <option value="">请选择</option>
+                                    {if !empty($robotgroups)}
+                                    {foreach name="robotgroups" item="vo"}
+                                    <option value="{$vo['robotgroups_id']}">{$vo['robotgroups_name']}</option>
+                                    {/foreach}
+                                    {/if}
+                                </select>
+                            </div>
+                        </div>
+                        <div class="form-group layui-form-item">
+                            <label class="col-sm-3 control-label">是否为热点问题:</label>
+                            <div class="input-group col-sm-6">
+                                {if !empty($host)}
+                                {foreach name="host" item="vo" key="key"}
+                                <input type="radio" name="robot_host" value="{$key}" title="{$vo}" {if $key eq 2}checked{/if}>
+                                {/foreach}
+                                {/if}
+                            </div>
+                        </div>
+                        <div class="form-group layui-form-item">
+                            <label class="col-sm-3 control-label">是否启用:</label>
+                            <div class="input-group col-sm-6">
+                                {if !empty($status)}
+                                {foreach name="status" item="vo" key="key"}
+                                <input type="radio" name="robot_status" value="{$key}" title="{$vo}" {if $key eq 1}checked{/if}>
+                                {/foreach}
+                                {/if}
+                            </div>
+                        </div>
+                        <div class="form-group">
+                            <div class="col-sm-4 col-sm-offset-6">
+                                <button class="btn btn-primary" type="submit">提交</button>
+                            </div>
+                        </div>
+                    </form>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>
+<script src="__JS__/jquery.min.js?v=2.1.4"></script>
+<script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
+<script src="__JS__/content.min.js?v=1.0.0"></script>
+<script src="__JS__/plugins/validate/jquery.validate.min.js"></script>
+<script src="__JS__/plugins/validate/messages_zh.min.js"></script>
+<script src="__JS__/plugins/layer/layer.min.js"></script>
+<script src="__JS__/layui/layui.js"></script>
+<script src="__JS__/jquery.form.js"></script>
+<script type="text/javascript">
+    const myHost = "http://" + window.location.host;
+    layui.use(['form', 'upload'], function(){
+        var form = layui.form;
+
+        form.on('select(group)', function(value){
+            $("#groups_id").val(value.value);
+        });
+
+        form.on('select(robotgroups)', function(value){
+            $("#robotgroups_id").val(value.value);
+        });
+    });
+
+    layui.use(['form', 'upload'], function(){
+        var form = layui.form;
+    });
+
+    var index = '';
+    function showStart(){
+        index = layer.load(0, {shade: false});
+        return true;
+    }
+
+    function showSuccess(res){
+
+        layer.ready(function(){
+            layer.close(index);
+            if(1 == res.code){
+               layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
+                   window.location.href = myHost + '/admin/robot/index';
+               });
+            }else if(111 == res.code){
+                window.location.reload();
+            }else{
+                layer.msg(res.msg, {anim: 6});
+            }
+        });
+    }
+
+    $(document).ready(function(){
+        // 添加管理员
+        var options = {
+            beforeSubmit:showStart,
+            success:showSuccess
+        };
+
+        $('#commentForm').submit(function(){
+            $(this).ajaxSubmit(options);
+            return false;
+        });
+    });
+
+    // 表单验证
+    $.validator.setDefaults({
+        highlight: function(e) {
+            $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
+        },
+        success: function(e) {
+            e.closest(".form-group").removeClass("has-error").addClass("has-success")
+        },
+        errorElement: "span",
+        errorPlacement: function(e, r) {
+            e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
+        },
+        errorClass: "help-block m-b-none",
+        validClass: "help-block m-b-none"
+    });
+
+</script>
+</body>
+</html>

+ 176 - 0
application/admin/view/robot/editword.html

@@ -0,0 +1,176 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>编辑智能问答</title>
+    <link rel="shortcut icon" href="favicon.ico">
+    <link href="__CSS__/bootstrap.min.css?v=3.3.6" rel="stylesheet">
+    <link href="__CSS__/font-awesome.min.css?v=4.4.0" rel="stylesheet">
+    <link href="__CSS__/animate.min.css" rel="stylesheet">
+    <link href="__JS__/layui/css/layui.css" rel="stylesheet">
+    <link href="__CSS__/style.min.css?v=4.1.0" rel="stylesheet">
+</head>
+<body class="gray-bg">
+<div class="wrapper wrapper-content animated fadeInRight">
+    <div class="row">
+        <div class="col-sm-8">
+            <div class="ibox float-e-margins">
+                <div class="ibox-title">
+                    <h5>编辑智能问答</h5>
+                </div>
+                <div class="ibox-content">
+                    <form class="form-horizontal m-t layui-form" id="commentForm" method="post" action="{:url('robot/editWord')}">
+                        <input type="hidden" name="robot_id" value="{$info['robot_id']}"/>
+                        <div class="form-group">
+                            <label class="col-sm-3 control-label">问题:</label>
+                            <div class="input-group col-sm-4">
+                                <textarea class="form-control" name="robot_name" required="" aria-required="true" style="width: 400px;height: 38px;resize:none">{$info['robot_name']}</textarea>
+                            </div>
+                        </div>
+                        <div class="form-group">
+                            <label class="col-sm-3 control-label">答案:</label>
+                            <div class="input-group col-sm-4">
+                                <textarea class="form-control" name="robot_content" required="" aria-required="true" style="width: 400px;height: 150px;resize:none">{$info['robot_content']}</textarea>
+                            </div>
+                        </div>
+                        <div class="form-group">
+                            <label class="col-sm-3 control-label">选择分组:</label>
+                            <input type="hidden" id="groups_id" name="groups_id" value="{$info['groups_id']}"/>
+                            <div class="input-group col-sm-4 layui-form">
+                                <select lay-verify="required" lay-filter="group">
+                                    <option value="">请选择</option>
+                                    {if !empty($groups)}
+                                    {foreach name="groups" item="vo"}
+                                    <option value="{$vo['id']}" {if $vo['id'] eq $info['groups_id']}selected{/if}>{$vo['name']}</option>
+                                    {/foreach}
+                                    {/if}
+                                </select>
+                            </div>
+                        </div>
+                        <div class="form-group">
+                            <label class="col-sm-3 control-label">智能分组:</label>
+                            <input type="hidden" id="robotgroups_id" name="robotgroups_id" value="{$info['robotgroups_id']}"/>
+                            <div class="input-group col-sm-4 layui-form">
+                                <select lay-verify="required" lay-filter="robotgroups">
+                                    <option value="">请选择</option>
+                                    {if !empty($robotgroups)}
+                                    {foreach name="robotgroups" item="vo"}
+                                    <option value="{$vo['robotgroups_id']}" {if $vo['robotgroups_id'] eq $info['robotgroups_id']}selected{/if}>{$vo['robotgroups_name']}</option>
+                                    {/foreach}
+                                    {/if}
+                                </select>
+                            </div>
+                        </div>
+                        <div class="form-group layui-form-item">
+                            <label class="col-sm-3 control-label">是否为热点问题:</label>
+                            <div class="input-group col-sm-6">
+                                {if !empty($host)}
+                                {foreach name="host" item="vo" key="key"}
+                                <input type="radio" name="robot_host" value="{$key}" title="{$vo}" {if $key eq $info['robot_host']}checked{/if}>
+                                {/foreach}
+                                {/if}
+                            </div>
+                        </div>
+                        <div class="form-group layui-form-item">
+                            <label class="col-sm-3 control-label">是否启用:</label>
+                            <div class="input-group col-sm-6">
+                                {if !empty($status)}
+                                {foreach name="status" item="vo" key="key"}
+                                <input type="radio" name="robot_status" value="{$key}" title="{$vo}" {if $key eq $info['robot_status']}checked{/if}>
+                                {/foreach}
+                                {/if}
+                            </div>
+                        </div>
+                        <div class="form-group">
+                            <div class="col-sm-4 col-sm-offset-6">
+                                <button class="btn btn-primary" type="submit">提交</button>
+                            </div>
+                        </div>
+                    </form>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>
+<script src="__JS__/jquery.min.js?v=2.1.4"></script>
+<script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
+<script src="__JS__/content.min.js?v=1.0.0"></script>
+<script src="__JS__/plugins/validate/jquery.validate.min.js"></script>
+<script src="__JS__/plugins/validate/messages_zh.min.js"></script>
+<script src="__JS__/plugins/layer/layer.min.js"></script>
+<script src="__JS__/layui/layui.js"></script>
+<script src="__JS__/jquery.form.js"></script>
+<script type="text/javascript">
+    const myHost = "http://" + window.location.host;
+
+    layui.use(['form', 'upload'], function(){
+        var form = layui.form;
+    });
+
+    var index = '';
+    function showStart(){
+        index = layer.load(0, {shade: false});
+        return true;
+    }
+
+    function showSuccess(res){
+
+        layer.ready(function(){
+            layer.close(index);
+            if(1 == res.code){
+                layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
+                    window.location.href = myHost + '/admin/robot/index';
+                });
+            }else if(111 == res.code){
+                window.location.reload();
+            }else{
+                layer.msg(res.msg, {anim: 6});
+            }
+        });
+    }
+
+    $(document).ready(function(){
+        // 添加管理员
+        var options = {
+            beforeSubmit:showStart,
+            success:showSuccess
+        };
+
+        $('#commentForm').submit(function(){
+            $(this).ajaxSubmit(options);
+            return false;
+        });
+    });
+
+    // 表单验证
+    $.validator.setDefaults({
+        highlight: function(e) {
+            $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
+        },
+        success: function(e) {
+            e.closest(".form-group").removeClass("has-error").addClass("has-success")
+        },
+        errorElement: "span",
+        errorPlacement: function(e, r) {
+            e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
+        },
+        errorClass: "help-block m-b-none",
+        validClass: "help-block m-b-none"
+    });
+
+    layui.use(['form', 'upload'], function(){
+        var form = layui.form;
+
+        form.on('select(group)', function(value){
+            $("#groups_id").val(value.value);
+        });
+
+        form.on('select(robotgroups)', function(value){
+            $("#robotgroups_id").val(value.value);
+        });
+    });
+</script>
+</body>
+</html>

+ 132 - 0
application/admin/view/robot/index.html

@@ -0,0 +1,132 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>智能问答列表</title>
+    <link rel="shortcut icon" href="favicon.ico">
+    <link href="__CSS__/bootstrap.min.css?v=3.3.6" rel="stylesheet">
+    <link href="__CSS__/font-awesome.min.css?v=4.4.0" rel="stylesheet">
+    <link href="__CSS__/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
+    <link href="__CSS__/animate.min.css" rel="stylesheet">
+    <link href="__CSS__/style.min.css?v=4.1.0" rel="stylesheet">
+</head>
+<body class="gray-bg">
+<div class="wrapper wrapper-content animated fadeInRight">
+    <!-- Panel Other -->
+    <div class="ibox float-e-margins">
+        <div class="ibox-title">
+            <h5>智能问答列表</h5>
+        </div>
+        <div class="ibox-content">
+            <!--搜索框开始-->
+            <form id='commentForm' role="form" method="post" class="form-inline pull-right">
+                <div class="content clearfix m-b">
+                    <div class="form-group">
+                        <label>问题关键字:</label>
+                        <input type="text" class="form-control" id="content" name="content">
+                    </div>
+                    <div class="form-group">
+                        <button class="btn btn-primary" type="button" style="margin-top:5px" id="search"><strong>搜 索</strong>
+                        </button>
+                    </div>
+                </div>
+            </form>
+            <!--搜索框结束-->
+            <div class="example-wrap">
+                <div class="example">
+                    <table id="cusTable">
+                        <thead>
+                        <th data-field="robot_id">问题ID</th>
+                        <th data-field="robot_name">问题</th>
+                        <th data-field="robot_content">答案</th>
+                        <th data-field="robotgroups_name">智能分组</th>
+                        <th data-field="name">所属</th>
+                        <th data-field="robot_host">是否为热点问题</th>
+                        <th data-field="robot_status">状态</th>
+                        <th data-field="operate">操作</th>
+                        </thead>
+                    </table>
+                </div>
+            </div>
+            <!-- End Example Pagination -->
+        </div>
+    </div>
+</div>
+<!-- End Panel Other -->
+<script src="__JS__/jquery.min.js?v=2.1.4"></script>
+<script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
+<script src="__JS__/content.min.js?v=1.0.0"></script>
+<script src="__JS__/plugins/bootstrap-table/bootstrap-table.min.js"></script>
+<script src="__JS__/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
+<script src="__JS__/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
+<script src="__JS__/plugins/layer/layer.min.js"></script>
+<script type="text/javascript">
+    function initTable() {
+        //先销毁表格
+        $('#cusTable').bootstrapTable('destroy');
+        //初始化表格,动态从服务器加载数据
+        $("#cusTable").bootstrapTable({
+            method: "get",  //使用get请求到服务器获取数据
+            url: "{:url('robot/index')}", //获取数据的地址
+            striped: true,  //表格显示条纹
+            pagination: true, //启动分页
+            pageSize: 10,  //每页显示的记录数
+            pageNumber:1, //当前第几页
+            pageList: [5, 10, 15, 20, 25],  //记录数可选列表
+            sidePagination: "server", //表示服务端请求
+            paginationFirstText: "首页",
+            paginationPreText: "上一页",
+            paginationNextText: "下一页",
+            paginationLastText: "尾页",
+            queryParamsType : "undefined",
+            queryParams: function queryParams(params) {   //设置查询参数
+                var param = {
+                    pageNumber: params.pageNumber,
+                    pageSize: params.pageSize,
+                    searchText:$('#content').val()
+                };
+                return param;
+            },
+            onLoadSuccess: function(res){  //加载成功时执行
+                if(111 == res.code){
+                    window.location.reload();
+                }
+                layer.msg("加载成功", {time : 1000});
+            },
+            onLoadError: function(){  //加载失败时执行
+                layer.msg("加载数据失败");
+            }
+        });
+    }
+
+    $(document).ready(function () {
+        //调用函数,初始化表格
+        initTable();
+
+        //当点击查询按钮的时候执行
+        $("#search").bind("click", initTable);
+    });
+
+    function userDel(id){
+        layer.confirm('确认删除此智能问答?', {icon: 3, title:'提示'}, function(index){
+            //do something
+            $.getJSON("{:url('robot/delWord')}", {'id' : id}, function(res){
+                if(1 == res.code){
+                    layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
+                        initTable();
+                    });
+                }else if(111 == res.code){
+                    window.location.reload();
+                }else{
+                    layer.alert(res.msg, {title: '友情提示', icon: 2});
+                }
+            });
+
+            layer.close(index);
+        })
+
+    }
+</script>
+</body>
+</html>

+ 1 - 1
application/admin/view/words/editword.html

@@ -117,4 +117,4 @@
 
 </script>
 </body>
-</html>
+</html>

+ 36 - 0
application/index/controller/Common.php

@@ -0,0 +1,36 @@
+<?php
+namespace app\index\controller;
+
+use think\Controller;
+
+/**
+ * 分组类
+ */
+class Common extends Controller
+{
+
+
+    /**
+     * 构造函数
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function __construct()
+    {
+        $request     = \think\Request::instance();
+        $getApiToken = input('server.HTTP_apiToken');
+        $action      = $request->action();
+        $controller  = $request->controller();
+        $module      = $request->module();
+        $apiToken    = md5($action.'Customer-Service'.$controller.strtotime(date('Y-m-d')).$module);
+        if ($getApiToken !== $apiToken) {
+            $code = -2;
+            $msg  = 'token错误';
+            return json(['code' => $code, 'data' => [], 'msg' => $msg]);
+        }
+
+    }//end __construct()
+
+
+}

+ 35 - 0
application/index/controller/Groups.php

@@ -0,0 +1,35 @@
+<?php
+namespace app\index\controller;
+
+
+/**
+ * 分组类
+ */
+class Groups extends Common
+{
+
+
+    /**
+     * 分组
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function index()
+    {
+        $code = -2;
+        $msg  = '错误';
+        try {
+            $groupsWhere['status'] = 1;
+            // 获取符合条件数据.
+            $groups = model('Groups')->select($groupsWhere);
+
+            return json(['code' => 200, 'data' => $groups, 'msg' => '成功']);
+        } catch (\Exception $e) {
+            return json(['code' => $code, 'data' => [], 'msg' => $msg]);
+        }
+
+    }//end index()
+
+
+}

+ 69 - 0
application/index/controller/Robot.php

@@ -0,0 +1,69 @@
+<?php
+namespace app\index\controller;
+
+/**
+ * 智能问答类
+ */
+class Robot extends Common
+{
+
+
+    /**
+     * 热点智能问答筛选
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function index()
+    {
+        $code = -2;
+        $msg  = '错误';
+        try {
+            // 获取查询条件.
+            $groupsId       = input('get.groups_id');
+            $robotgroups_id = input('get.robotgroups_id');
+            if ($groupsId) {
+                $robotWhere['groups_id'] = $groupsId;
+            }
+
+            if ($robotgroups_id) {
+                $robotWhere['robotgroups_id'] = $robotgroups_id;
+            }
+
+            $robotWhere['robot_status'] = 1;
+            $robotWhere['robot_host']   = 1;
+            // 获取符合条件数据.
+            $robot = model('Robot')->select($robotWhere);
+
+            return json(['code' => 200, 'data' => $robot, 'msg' => '成功']);
+        } catch (\Exception $e) {
+            return json(['code' => $code, 'data' => [], 'msg' => $msg]);
+        }//end try
+
+    }//end index()
+
+
+    /**
+     * 智能问答分组
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function getRobotGroups()
+    {
+        $code = -2;
+        $msg  = '错误';
+        try {
+            $robotGroupsWhere['robotgroups_status'] = 1;
+            // 获取符合条件数据.
+            $robotGroups = model('Robotgroups')->select($robotGroupsWhere);
+
+            return json(['code' => 200, 'data' => $robotGroups, 'msg' => '成功']);
+        } catch (\Exception $e) {
+            return json(['code' => $code, 'data' => [], 'msg' => $msg]);
+        }
+
+    }//end getRobotGroups()
+
+
+}

+ 33 - 0
application/index/model/Groups.php

@@ -0,0 +1,33 @@
+<?php
+namespace app\index\model;
+
+use think\Model;
+
+/**
+ * 分组模型
+ */
+class Groups extends Model
+{
+
+
+    /**
+     * select数据筛选
+     *
+     * @access public
+     * @param mixed $where 条件
+     * @return array 返回类型
+     */
+    public function select($where=[])
+    {
+        $result = $this;
+        if (empty($where) === false) {
+            $result = $result->where($where);
+        }
+
+        $result = $result->select();
+        return $result;
+
+    }//end select()
+
+
+}

+ 33 - 0
application/index/model/Robot.php

@@ -0,0 +1,33 @@
+<?php
+namespace app\index\model;
+
+use think\Model;
+
+/**
+ * 智能问答模型
+ */
+class Robot extends Model
+{
+
+
+    /**
+     * select数据筛选
+     *
+     * @access public
+     * @param mixed $where 条件
+     * @return array 返回类型
+     */
+    public function select($where=[])
+    {
+        $result = $this;
+        if (empty($where) === false) {
+            $result = $result->where($where);
+        }
+
+        $result = $result->select();
+        return $result;
+
+    }//end select()
+
+
+}

+ 33 - 0
application/index/model/Robotgroups.php

@@ -0,0 +1,33 @@
+<?php
+namespace app\index\model;
+
+use think\Model;
+
+/**
+ * 智能问答分组模型
+ */
+class Robotgroups extends Model
+{
+
+
+    /**
+     * select数据筛选
+     *
+     * @access public
+     * @param mixed $where 条件
+     * @return array 返回类型
+     */
+    public function select($where=[])
+    {
+        $result = $this;
+        if (empty($where) === false) {
+            $result = $result->where($where);
+        }
+
+        $result = $result->select();
+        return $result;
+
+    }//end select()
+
+
+}

+ 2 - 1
application/index/view/index/chat.html

@@ -29,6 +29,7 @@
         <div class="input-group" style="margin-top: 5px;width: 100%">
             <span class="input-group-btn" style="float: right;">
                 <button class="btn btn-primary" type="button" id="send">发送</button>
+                <button class="btn btn-primary" type="button" onclick="aa()">发送</button>
             </span>
         </div>
     </div>
@@ -51,4 +52,4 @@
 <script src="/static/customer/js/whisper-cli.js"></script>
 
 </body>
-</html>
+</html>

+ 9 - 2
public/static/customer/js/whisper-cli.js

@@ -14,7 +14,7 @@ var commChat = 1;
 if(config != undefined && config.socket != undefined){
 
     // 创建一个Socket实例
-    var socket = new WebSocket('ws://' + config.socket);
+    var socket = new WebSocket('ws://' + config.socket+'?apiToken=72fb0848e7bf20e052362bac4a86164c');
 
     // 加锁
     lockTextarea();
@@ -170,6 +170,13 @@ function showSystem(msg){
 }
 
 
+function aa() {
+    socket.send(JSON.stringify({
+        type: 'toRobot',
+        data: {groups_id: 1, robot_name: '范德萨1', robotgroups_id: 1,
+            from_id: config.uid, from_avatar: 333}
+    }));
+}
 // 发送信息
 function sendMsg(sendMsg){
 
@@ -359,4 +366,4 @@ function showBigPic(){
 function wordBottom(){
     var ex = document.getElementById("chat-list");
     ex.scrollTop = ex.scrollHeight;
-}
+}

+ 1 - 1
public/static/customer/js/whisper-mobile.js

@@ -339,4 +339,4 @@ function showChatLog(){
 // 退出
 function loginOut(){
     window.history.go(-1);
-}
+}

+ 4 - 4
public/static/service/js/whisper.js

@@ -6,9 +6,9 @@ var uinfo = {
 };
 
 // 创建一个Socket实例
-var socket = new WebSocket('ws://' + socket_server);
+var socket = new WebSocket('ws://' + socket_server+'?apiToken=72fb0848e7bf20e052362bac4a86164c');
 
-// 打开Socket 
+// 打开Socket
 socket.onopen = function (res) {
     layui.use(['layer'], function () {
         var layer = layui.layer;
@@ -25,7 +25,7 @@ socket.onopen = function (res) {
 // 监听消息
 socket.onmessage = function (res) {
     var data = eval("(" + res.data + ")");
-	
+
     switch (data['message_type']) {
         // 服务端ping客户端
         case 'ping':
@@ -584,4 +584,4 @@ function loginOut(){
             }, 1500); // 此处等待用户真的退出了
         }
     });
-}
+}

+ 3 - 2
vendor/GatewayWorker_linux/GatewayWorker/vendor/workerman/workerman/Lib/Constants.php

@@ -13,9 +13,10 @@
  */
 
 // Date.timezone
-if (!ini_get('date.timezone')) {
+/*if (!ini_get('date.timezone')) {
     date_default_timezone_set('Asia/Shanghai');
-}
+}*/
+date_default_timezone_set('Asia/Shanghai');
 // Display errors.
 ini_set('display_errors', 'on');
 // Reporting all.

+ 27 - 0
vendor/GatewayWorker_windows/Applications/whisper/Events.php

@@ -316,6 +316,10 @@ class Events
                 }
                 unset($userInfo);
                 break;
+            // 机器人问答.
+            case 'toRobot':
+                self::toRobot($client_id, $message);
+                break;
         }
     }
 
@@ -798,4 +802,27 @@ class Events
         }
         unset($kfList, $nowTalking, $inQueue, $onlineKf, $key, $key2, $param);
     }
+
+    /**
+     * 机器人问答
+     * @param $client_id 服务ID
+     * @param $message 数据
+     */
+    private static function toRobot($client_id, $message)
+    {
+        $groups_id = $message['data']['groups_id'];
+        $robot_name = $message['data']['robot_name'];
+        $robotgroups_id = $message['data']['robotgroups_id'];
+        // 查询问题.
+        $getRobot = self::$db->query("select `robot_content` from `ws_robot` where `robot_status`= 1 and `groups_id`= '" . $groups_id . "' and `robot_name`= '" . $robot_name . "' and `robotgroups_id`= '" . $robotgroups_id . "'");
+        $chat_message = [
+            'message_type' => 'chatMessage',
+            'data' => [
+                'name' => '智能助手',
+                'time' => date('H:i'),
+                'content' => $getRobot ? htmlspecialchars($getRobot[0]['robot_content']) : 'error',
+            ]
+        ];
+        Gateway::sendToClient($client_id, json_encode($chat_message));
+    }
 }

+ 9 - 7
vendor/GatewayWorker_windows/Applications/whisper/start_gateway.php

@@ -1,4 +1,4 @@
-<?php 
+<?php
 /**
  * This file is part of workerman.
  *
@@ -29,7 +29,7 @@ $gateway->count = 4;
 // 本机ip,分布式部署时使用内网ip
 $gateway->lanIp = '127.0.0.1';
 // 内部通讯起始端口,假如$gateway->count=4,起始端口为4000
-// 则一般会使用4000 4001 4002 4003 4个端口作为内部通讯端口 
+// 则一般会使用4000 4001 4002 4003 4个端口作为内部通讯端口
 $gateway->startPort = 2900;
 // 服务注册地址
 $gateway->registerAddress = '127.0.0.1:1238';
@@ -39,23 +39,25 @@ $gateway->pingInterval = 10;
 // 心跳数据
 $gateway->pingData = '{"message_type":"ping"}';
 
-/* 
 // 当客户端连接上来时,设置连接的onWebSocketConnect,即在websocket握手时的回调
 $gateway->onConnect = function($connection)
 {
     $connection->onWebSocketConnect = function($connection , $http_header)
     {
+        $apiToken = md5('Customer-Service'.strtotime(date('Y-m-d')).$_SERVER['HTTP_ORIGIN']);
+        if ($_GET['apiToken'] !== $apiToken) {
+            $connection->close();
+        }
         // 可以在这里判断连接来源是否合法,不合法就关掉连接
         // $_SERVER['HTTP_ORIGIN']标识来自哪个站点的页面发起的websocket链接
-        if($_SERVER['HTTP_ORIGIN'] != 'http://kedou.workerman.net')
+        /*if($_SERVER['HTTP_ORIGIN'] != 'http://kedou.workerman.net')
         {
             $connection->close();
-        }
+        }*/
         // onWebSocketConnect 里面$_GET $_SERVER是可用的
         // var_dump($_GET, $_SERVER);
     };
-}; 
-*/
+};
 
 // 如果不是在根目录启动,则运行runAll方法
 if(!defined('GLOBAL_START'))

+ 4 - 3
vendor/GatewayWorker_windows/vendor/workerman/workerman-for-win/Lib/Constants.php

@@ -13,9 +13,10 @@
  */
 
 // Date.timezone
-if (!ini_get('date.timezone')) {
+/*if (!ini_get('date.timezone')) {
     date_default_timezone_set('Asia/Shanghai');
-}
+}*/
+date_default_timezone_set('Asia/Shanghai');
 // Display errors.
 ini_set('display_errors', 'on');
 // Reporting all.
@@ -32,4 +33,4 @@ if(!class_exists('Error'))
     class Error extends Exception
     {
     }
-}
+}

+ 3 - 2
vendor/GatewayWorker_windows/vendor/workerman/workerman/Lib/Constants.php

@@ -13,9 +13,10 @@
  */
 
 // Date.timezone
-if (!ini_get('date.timezone')) {
+/*if (!ini_get('date.timezone')) {
     date_default_timezone_set('Asia/Shanghai');
-}
+}*/
+date_default_timezone_set('Asia/Shanghai');
 // Display errors.
 ini_set('display_errors', 'on');
 // Reporting all.

+ 0 - 252
whisper.sql

@@ -1,252 +0,0 @@
-/*
-Navicat MySQL Data Transfer
-
-Source Server         : localhost
-Source Server Version : 50553
-Source Host           : 127.0.0.1:3306
-Source Database       : whisper
-
-Target Server Type    : MYSQL
-Target Server Version : 50553
-File Encoding         : 65001
-
-Date: 2018-03-17 15:03:51
-*/
-
-SET FOREIGN_KEY_CHECKS=0;
-
--- ----------------------------
--- Table structure for ws_admins
--- ----------------------------
-DROP TABLE IF EXISTS `ws_admins`;
-CREATE TABLE `ws_admins` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `user_name` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '用户名',
-  `password` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '密码',
-  `last_login_ip` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '最后登录IP',
-  `last_login_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后登录时间',
-  `status` int(1) NOT NULL DEFAULT '1' COMMENT '状态',
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-
--- ----------------------------
--- Records of ws_admins
--- ----------------------------
-INSERT INTO `ws_admins` VALUES ('1', 'admin', 'cbb2fc826b6cbb2305cca827529b739b', '127.0.0.1', '1521187852', '1');
-INSERT INTO `ws_admins` VALUES ('2', '小白', 'cb78913de44f5a36ab63e8ffacde44b0', '', '0', '1');
-
--- ----------------------------
--- Table structure for ws_chat_log
--- ----------------------------
-DROP TABLE IF EXISTS `ws_chat_log`;
-CREATE TABLE `ws_chat_log` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `from_id` varchar(55) NOT NULL COMMENT '网页用户随机编号(仅为记录参考记录)',
-  `from_name` varchar(255) NOT NULL COMMENT '发送者名称',
-  `from_avatar` varchar(255) NOT NULL COMMENT '发送者头像',
-  `to_id` varchar(55) NOT NULL COMMENT '接收方',
-  `to_name` varchar(255) NOT NULL COMMENT '接受者名称',
-  `content` text NOT NULL COMMENT '发送的内容',
-  `time_line` int(10) NOT NULL COMMENT '记录时间',
-  PRIMARY KEY (`id`),
-  KEY `fromid` (`from_id`(4)) USING BTREE,
-  KEY `toid` (`to_id`) USING BTREE
-) ENGINE=MyISAM AUTO_INCREMENT=24 DEFAULT CHARSET=utf8;
-
--- ----------------------------
--- Records of ws_chat_log
--- ----------------------------
-INSERT INTO `ws_chat_log` VALUES ('1', '2', '会员2', 'http://wx2.sinaimg.cn/mw690/5db11ff4gy1flxmew7edlj203d03wt8n.jpg', 'KF1', '客服', '你在干嘛呢?', '1521177459');
-INSERT INTO `ws_chat_log` VALUES ('2', '2', '会员2', 'http://wx2.sinaimg.cn/mw690/5db11ff4gy1flxmew7edlj203d03wt8n.jpg', 'KF1', '客服', '啊大大啊阿达是', '1521177463');
-INSERT INTO `ws_chat_log` VALUES ('3', 'KF1', '客服', '/uploads/20171024/902b5294f41f6a7d1e1451c7c0969a21.jpg', '2', '会员2', '嗯嗯嗯', '1521177471');
-INSERT INTO `ws_chat_log` VALUES ('4', 'KF1', '客服', '/uploads/20171024/902b5294f41f6a7d1e1451c7c0969a21.jpg', '2', '会员2', '其味无穷二群翁群翁', '1521177480');
-INSERT INTO `ws_chat_log` VALUES ('5', '2', '会员2', 'http://wx2.sinaimg.cn/mw690/5db11ff4gy1flxmew7edlj203d03wt8n.jpg', 'KF1', '客服', '怎么解释', '1521177488');
-INSERT INTO `ws_chat_log` VALUES ('6', 'KF1', '客服', '/uploads/20171024/902b5294f41f6a7d1e1451c7c0969a21.jpg', '2', '会员2', '驱蚊器二', '1521179009');
-INSERT INTO `ws_chat_log` VALUES ('7', '2', '会员2', 'http://wx2.sinaimg.cn/mw690/5db11ff4gy1flxmew7edlj203d03wt8n.jpg', 'KF1', '客服', '说话没法关闭', '1521179074');
-INSERT INTO `ws_chat_log` VALUES ('8', '2', '会员2', 'http://wx2.sinaimg.cn/mw690/5db11ff4gy1flxmew7edlj203d03wt8n.jpg', 'KF1', '客服', ' face[猪头] ', '1521179109');
-INSERT INTO `ws_chat_log` VALUES ('9', 'KF1', '客服', '/uploads/20171024/902b5294f41f6a7d1e1451c7c0969a21.jpg', '2', '会员2', ' face[黑线] ', '1521179115');
-INSERT INTO `ws_chat_log` VALUES ('10', '2', '会员2', 'http://wx2.sinaimg.cn/mw690/5db11ff4gy1flxmew7edlj203d03wt8n.jpg', 'KF1', '客服', '你们干嘛呢?', '1521179267');
-INSERT INTO `ws_chat_log` VALUES ('11', '2', '会员2', 'http://wx2.sinaimg.cn/mw690/5db11ff4gy1flxmew7edlj203d03wt8n.jpg', 'KF1', '客服', '阿萨德', '1521179419');
-INSERT INTO `ws_chat_log` VALUES ('12', '2', '会员2', 'http://wx2.sinaimg.cn/mw690/5db11ff4gy1flxmew7edlj203d03wt8n.jpg', 'KF1', '客服', ' face[猪头] ', '1521179862');
-INSERT INTO `ws_chat_log` VALUES ('13', '2', '会员2', 'http://wx2.sinaimg.cn/mw690/5db11ff4gy1flxmew7edlj203d03wt8n.jpg', 'KF1', '客服', '好朋友', '1521187501');
-INSERT INTO `ws_chat_log` VALUES ('14', '2', '会员2', 'http://wx2.sinaimg.cn/mw690/5db11ff4gy1flxmew7edlj203d03wt8n.jpg', 'KF1', '客服', 'qwewq ', '1521188657');
-INSERT INTO `ws_chat_log` VALUES ('15', '2', '会员2', 'http://wx2.sinaimg.cn/mw690/5db11ff4gy1flxmew7edlj203d03wt8n.jpg', 'KF1', '客服', 'sdasd ', '1521188837');
-INSERT INTO `ws_chat_log` VALUES ('16', 'KF1', '客服', '/uploads/20171024/902b5294f41f6a7d1e1451c7c0969a21.jpg', '2', '会员2', 'asda ', '1521188849');
-INSERT INTO `ws_chat_log` VALUES ('17', '2', '会员2', 'http://wx2.sinaimg.cn/mw690/5db11ff4gy1flxmew7edlj203d03wt8n.jpg', 'KF1', '客服', 'asdas ', '1521188868');
-INSERT INTO `ws_chat_log` VALUES ('18', 'KF1', '客服', '/uploads/20171024/902b5294f41f6a7d1e1451c7c0969a21.jpg', '2', '会员2', '干么的', '1521188880');
-INSERT INTO `ws_chat_log` VALUES ('19', '2', '会员2', 'http://wx2.sinaimg.cn/mw690/5db11ff4gy1flxmew7edlj203d03wt8n.jpg', 'KF1', '客服', '阿达', '1521189214');
-INSERT INTO `ws_chat_log` VALUES ('20', '2', '会员2', 'http://wx2.sinaimg.cn/mw690/5db11ff4gy1flxmew7edlj203d03wt8n.jpg', 'KF1', '客服', '请问', '1521189860');
-INSERT INTO `ws_chat_log` VALUES ('21', 'KF1', '客服', '/uploads/20171024/902b5294f41f6a7d1e1451c7c0969a21.jpg', '2', '会员2', 'AS ', '1521190128');
-INSERT INTO `ws_chat_log` VALUES ('22', 'KF1', '客服', '/uploads/20171024/902b5294f41f6a7d1e1451c7c0969a21.jpg', '1', '会员1', '驱蚊器无', '1521194101');
-INSERT INTO `ws_chat_log` VALUES ('23', '1', '会员1', 'http://wx2.sinaimg.cn/mw690/5db11ff4gy1flxmew7edlj203d03wt8n.jpg', 'KF1', '客服', '请问', '1521194123');
-
--- ----------------------------
--- Table structure for ws_groups
--- ----------------------------
-DROP TABLE IF EXISTS `ws_groups`;
-CREATE TABLE `ws_groups` (
-  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '分组id',
-  `name` varchar(255) NOT NULL COMMENT '分组名称',
-  `status` tinyint(1) NOT NULL COMMENT '分组状态',
-  PRIMARY KEY (`id`)
-) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
-
--- ----------------------------
--- Records of ws_groups
--- ----------------------------
-INSERT INTO `ws_groups` VALUES ('1', '售前组', '1');
-INSERT INTO `ws_groups` VALUES ('2', '售后组', '1');
-
--- ----------------------------
--- Table structure for ws_kf_config
--- ----------------------------
-DROP TABLE IF EXISTS `ws_kf_config`;
-CREATE TABLE `ws_kf_config` (
-  `id` int(11) NOT NULL,
-  `max_service` int(11) NOT NULL COMMENT '每个客服最大服务的客户数',
-  `change_status` tinyint(1) NOT NULL COMMENT '是否启用转接',
-  PRIMARY KEY (`id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-
--- ----------------------------
--- Records of ws_kf_config
--- ----------------------------
-INSERT INTO `ws_kf_config` VALUES ('1', '5', '1');
-
--- ----------------------------
--- Table structure for ws_now_data
--- ----------------------------
-DROP TABLE IF EXISTS `ws_now_data`;
-CREATE TABLE `ws_now_data` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `is_talking` int(5) NOT NULL DEFAULT '0' COMMENT '正在咨询的人数',
-  `in_queue` int(5) NOT NULL DEFAULT '0' COMMENT '排队等待的人数',
-  `online_kf` int(5) NOT NULL COMMENT '在线客服数',
-  `success_in` int(5) NOT NULL COMMENT '成功接入用户',
-  `total_in` int(5) NOT NULL COMMENT '今日累积接入的用户',
-  `now_date` varchar(10) NOT NULL COMMENT '当前日期',
-  PRIMARY KEY (`id`),
-  KEY `now_date` (`now_date`) USING BTREE
-) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-
--- ----------------------------
--- Records of ws_now_data
--- ----------------------------
-INSERT INTO `ws_now_data` VALUES ('1', '1', '0', '1', '14', '14', '2018-03-16');
-
--- ----------------------------
--- Table structure for ws_reply
--- ----------------------------
-DROP TABLE IF EXISTS `ws_reply`;
-CREATE TABLE `ws_reply` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `word` varchar(255) NOT NULL COMMENT '自动回复的内容',
-  `status` tinyint(1) NOT NULL DEFAULT '2' COMMENT '是否自动回复',
-  PRIMARY KEY (`id`)
-) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
-
--- ----------------------------
--- Records of ws_reply
--- ----------------------------
-INSERT INTO `ws_reply` VALUES ('1', '欢迎使用whisper', '2');
-
--- ----------------------------
--- Table structure for ws_service_data
--- ----------------------------
-DROP TABLE IF EXISTS `ws_service_data`;
-CREATE TABLE `ws_service_data` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `is_talking` int(5) NOT NULL DEFAULT '0' COMMENT '正在咨询的人数',
-  `in_queue` int(5) NOT NULL DEFAULT '0' COMMENT '排队等待的人数',
-  `online_kf` int(5) NOT NULL COMMENT '在线客服数',
-  `success_in` int(5) NOT NULL COMMENT '成功接入用户',
-  `total_in` int(5) NOT NULL COMMENT '今日累积接入的用户',
-  `add_date` varchar(10) NOT NULL COMMENT '写入的日期',
-  `add_hour` varchar(2) NOT NULL COMMENT '写入的小时数',
-  `add_minute` varchar(2) NOT NULL COMMENT '写入的分钟数',
-  PRIMARY KEY (`id`),
-  KEY `add_date,add_hour` (`add_date`,`add_hour`) USING BTREE
-) ENGINE=MyISAM AUTO_INCREMENT=20 DEFAULT CHARSET=utf8;
-
--- ----------------------------
--- Records of ws_service_data
--- ----------------------------
-INSERT INTO `ws_service_data` VALUES ('1', '2', '1', '1', '2', '4', '2018-03-15', '09', '10');
-INSERT INTO `ws_service_data` VALUES ('2', '0', '0', '0', '3', '4', '2018-03-15', '10', '15');
-INSERT INTO `ws_service_data` VALUES ('3', '3', '4', '1', '4', '6', '2018-03-15', '11', '20');
-INSERT INTO `ws_service_data` VALUES ('4', '0', '0', '0', '0', '2', '2018-03-15', '12', '25');
-INSERT INTO `ws_service_data` VALUES ('5', '0', '0', '0', '0', '2', '2018-03-15', '13', '30');
-INSERT INTO `ws_service_data` VALUES ('6', '0', '1', '0', '0', '3', '2018-03-15', '14', '35');
-INSERT INTO `ws_service_data` VALUES ('7', '0', '0', '0', '0', '4', '2018-03-15', '15', '40');
-INSERT INTO `ws_service_data` VALUES ('8', '0', '0', '0', '0', '4', '2018-03-15', '16', '45');
-INSERT INTO `ws_service_data` VALUES ('9', '0', '0', '0', '0', '4', '2018-03-15', '17', '50');
-INSERT INTO `ws_service_data` VALUES ('10', '0', '0', '0', '0', '4', '2018-03-15', '18', '55');
-INSERT INTO `ws_service_data` VALUES ('11', '0', '0', '0', '1', '4', '2018-03-15', '08', '05');
-INSERT INTO `ws_service_data` VALUES ('12', '0', '0', '1', '99', '100', '2018-03-16', '11', '35');
-INSERT INTO `ws_service_data` VALUES ('13', '0', '0', '1', '102', '103', '2018-03-16', '12', '15');
-INSERT INTO `ws_service_data` VALUES ('14', '0', '0', '1', '102', '103', '2018-03-16', '12', '55');
-INSERT INTO `ws_service_data` VALUES ('15', '0', '0', '1', '1', '1', '2018-03-16', '14', '37');
-INSERT INTO `ws_service_data` VALUES ('16', '0', '0', '1', '1', '1', '2018-03-16', '15', '17');
-INSERT INTO `ws_service_data` VALUES ('17', '0', '0', '1', '1', '1', '2018-03-16', '15', '57');
-INSERT INTO `ws_service_data` VALUES ('18', '1', '0', '1', '3', '3', '2018-03-16', '17', '31');
-INSERT INTO `ws_service_data` VALUES ('19', '2', '0', '1', '14', '14', '2018-03-16', '18', '11');
-
--- ----------------------------
--- Table structure for ws_service_log
--- ----------------------------
-DROP TABLE IF EXISTS `ws_service_log`;
-CREATE TABLE `ws_service_log` (
-  `user_id` varchar(55) NOT NULL COMMENT '会员的id',
-  `client_id` varchar(20) NOT NULL COMMENT '会员的客户端标识',
-  `user_name` varchar(255) DEFAULT NULL COMMENT '会员名称',
-  `user_avatar` varchar(155) NOT NULL COMMENT '会员头像',
-  `user_ip` varchar(15) NOT NULL COMMENT '会员的ip',
-  `kf_id` varchar(55) NOT NULL COMMENT '服务的客服id',
-  `start_time` int(10) NOT NULL COMMENT '开始服务时间',
-  `end_time` int(10) DEFAULT '0' COMMENT '结束服务时间',
-  `group_id` int(11) NOT NULL COMMENT '服务的客服的分组id',
-  KEY `user_id,client_id` (`user_id`,`client_id`) USING BTREE,
-  KEY `kf_id,start_time,end_time` (`kf_id`,`start_time`,`end_time`) USING BTREE
-) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-
--- ----------------------------
--- Records of ws_service_log
--- ----------------------------
-
--- ----------------------------
--- Table structure for ws_users
--- ----------------------------
-DROP TABLE IF EXISTS `ws_users`;
-CREATE TABLE `ws_users` (
-  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '客服id',
-  `user_name` varchar(255) NOT NULL COMMENT '客服名称',
-  `user_pwd` varchar(32) NOT NULL COMMENT '客服登录密码',
-  `user_avatar` varchar(255) NOT NULL COMMENT '客服头像',
-  `status` tinyint(1) NOT NULL COMMENT '用户状态',
-  `online` tinyint(1) NOT NULL DEFAULT '2' COMMENT '是否在线',
-  `group_id` int(11) DEFAULT '0' COMMENT '所属分组id',
-  PRIMARY KEY (`id`)
-) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
-
--- ----------------------------
--- Records of ws_users
--- ----------------------------
-INSERT INTO `ws_users` VALUES ('1', '客服小白', 'cb78913de44f5a36ab63e8ffacde44b0', '/uploads/20171024/902b5294f41f6a7d1e1451c7c0969a21.jpg', '1', '2', '1');
-INSERT INTO `ws_users` VALUES ('2', '客服小美', 'cb78913de44f5a36ab63e8ffacde44b0', '/uploads/20171024/43cb54a995b89d0926e1de31af0074fc.jpg', '1', '2', '1');
-
--- ----------------------------
--- Table structure for ws_words
--- ----------------------------
-DROP TABLE IF EXISTS `ws_words`;
-CREATE TABLE `ws_words` (
-  `id` int(11) NOT NULL AUTO_INCREMENT,
-  `content` varchar(255) NOT NULL COMMENT '常用语内容',
-  `add_time` datetime NOT NULL COMMENT '添加时间',
-  `status` tinyint(1) NOT NULL COMMENT '是否启用',
-  PRIMARY KEY (`id`)
-) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
-
--- ----------------------------
--- Records of ws_words
--- ----------------------------
-INSERT INTO `ws_words` VALUES ('1', '欢迎来到whisper v1.0.0', '2017-10-25 12:51:09', '1');