Sfoglia il codice sorgente

Merge branch 'master' of http://git.bocai108.com:10180/Ethan/Customer-Service

vali 6 anni fa
parent
commit
a2dac88a2a

+ 49 - 4
application/admin/controller/Admins.php

@@ -202,24 +202,56 @@ class Admins extends Base
     public function addpower()
     {
         if (request()->isPost()) {
-
+            $menu = db('menu')->select();
             $param = input('post.');
 
-            $has = db('admingroup')->field('group_id')->where('group_name', $param['group_name'])->find();
+            $has = db('admingroup')->where('group_name', $param['group_name'])->find();
             if (!empty($has)) {
                 return json(['code' => -1, 'data' => '', 'msg' => '该权限组已经存在']);
             }
-
+            $info=array();
+            $info['group_name'] = $param['group_name'];
+            $info['status'] = $param['status'];
+            $info['addtime'] = time();
             try {
-                db('admingroup')->insert($param);
+                $group_id = db('admingroup')->insertGetId($info);
             } catch (\Exception $e) {
                 return json(['code' => -2, 'data' => '', 'msg' => $e->getMessage()]);
             }
 
+            $data=array();
+            for($i=0;$i<count($menu);$i++){
+                if($param[$menu[$i]['name_cn']] != 0){
+                    $data[]  = [
+                        'group_id' => $group_id,
+                        'menu_id' => $param[$menu[$i]['name_cn']],
+                    ] ;
+                }
+            }
+            if(!empty($data)){
+                try {
+                    db('admingrouppower')->where('group_id',$param['group_id'])->delete();
+                    db('admingrouppower')->insertAll($data);
+                } catch (\Exception $e) {
+                    return json(['code' => -3, 'data' => '', 'msg' => $e->getMessage()]);
+                }
+            }
+
             return json(['code' => 1, 'data' => '', 'msg' => '添加权限组成功']);
         }
+        $menu = db('menu')->where('p_id',0)->select();
+        $menulist = db('menu')->where('p_id','<>',0)->select();
+        for($i=0;$i<count($menu);$i++){
+            for($j=0;$j<count($menulist);$j++){
+                $menulist[$j]['class'] = $menu[$i]['ico'];
+                if($menu[$i]['id'] == $menulist[$j]['p_id']){
+                    $menu[$i]['menulist'][$j] = $menulist[$j];
+                }
+            }
+        }
 
         $this->assign([
+            'info' => $menu,
             'status' => config('kf_status')
         ]);
 
@@ -235,6 +267,16 @@ class Admins extends Base
 
             $menu = db('menu')->select();
             $param = input('post.');
+
+            $has = db('admingroup')->where('group_name',$param['group_name'])->where('group_id','<>',$param['group_id'])->find();
+            if (!empty($has)) {
+                return json(['code' => -1, 'data' => '', 'msg' => '该权限组已经存在']);
+            }
+            $info=array();
+            $info['group_name'] = $param['group_name'];
+            $info['status'] = $param['status'];
+            $info['addtime'] = time();
+
             $data=array();
             for($i=0;$i<count($menu);$i++){
                 if($param[$menu[$i]['name_cn']] != 0){
@@ -246,6 +288,7 @@ class Admins extends Base
             }
             if(!empty($data)){
                 try {
+                    db('admingroup')->where('group_id',$param['group_id'])->update($info);
                     db('admingrouppower')->where('group_id',$param['group_id'])->delete();
                     db('admingrouppower')->insertAll($data);
                 } catch (\Exception $e) {
@@ -287,10 +330,12 @@ class Admins extends Base
                 }
             }
         }
+        $admingroup = db('admingroup')->where('group_id',$id)->find();
 
         $this->assign([
             'info' => $menu,
             'id' => $id,
+            'admingroup' => $admingroup,
             'status' => config('kf_status')
         ]);
         return $this->fetch();

+ 2 - 0
application/admin/controller/Messages.php

@@ -105,6 +105,7 @@ class Messages extends Base
         }
         //所有客服
         $users = db('users')->select();
+        $useroption = '';
         if(!empty($users)){
             $option = '<option value="0">处理人</option>';
             for($i=0;$i<count($users);$i++){
@@ -115,6 +116,7 @@ class Messages extends Base
 
         //留言类型
         $type = db('messagetype')->select();
+        $optiontype = '';
         if(!empty($users)){
             $option = '<option value="0">留言类型</option>';
             for($i=0;$i<count($type);$i++){

+ 7 - 7
application/admin/controller/Report.php

@@ -152,13 +152,13 @@ class Report extends Base
             'allChat' => $allChat,
             'allService' => $allService,
             'allQueue' => $allQueue,
-            'transfer' => floor($transfer / 2),
-            'reply' => sprintf("%.2f", (($reply / ($allChatLog - $reply)) * 100)),
-            'waitTime' => ceil($alllWaitTime / $allService),
-            'serviceTime' => ceil($serviceTime / $allService),
-            'cpdTime' => ceil($cpdTime / $allService),
-            'evaluateGood' => sprintf("%.2f", (($evaluateGood / ($evaluateGood + $evaluateSecondary + $evaluateBad)) * 100)),
-            'evaluateGet' => sprintf("%.2f", ((($evaluateGood + $evaluateSecondary + $evaluateBad) / ($evaluateNo + $evaluateGood + $evaluateSecondary + $evaluateBad)) * 100)),
+            'transfer' => floor($transfer/2),
+            'reply' => ($allChatLog?sprintf("%.2f",(($reply/($allChatLog-$reply))*100)) : '--'),
+            'waitTime' => ($allService?ceil($alllWaitTime/$allService) : '--'),
+            'serviceTime' => ($allService?ceil($serviceTime/$allService) : '--'),
+            'cpdTime' => ($allService?ceil($cpdTime/$allService) : '--'),
+            'evaluateGood' => (($evaluateGood+$evaluateSecondary+$evaluateBad)?sprintf("%.2f",(($evaluateGood/($evaluateGood+$evaluateSecondary+$evaluateBad))*100)) : '--'),
+            'evaluateGet' => (($evaluateNo+$evaluateGood+$evaluateSecondary+$evaluateBad)?sprintf("%.2f",((($evaluateGood+$evaluateSecondary+$evaluateBad)/($evaluateNo+$evaluateGood+$evaluateSecondary+$evaluateBad))*100)) : '--'),
             'evaluate' => json_encode([
                 'evaluateGood' => $evaluateGood,
                 'evaluateSecondary' => $evaluateSecondary,

+ 29 - 0
application/admin/controller/System.php

@@ -283,6 +283,7 @@ class System extends Base
         }
         //所有客服
         $users = db('users')->select();
+        $useroption = '';
         if(!empty($users)){
             $option = '<option value="0">全部客服</option>';
             for($i=0;$i<count($users);$i++){
@@ -292,6 +293,7 @@ class System extends Base
         }
         //所有客服组
         $groups = db('groups')->select();
+        $groupoption = '';
         if(!empty($groups)){
             $option = '<option value="0">全部客服组</option>';
             for($j=0;$j<count($groups);$j++){
@@ -308,6 +310,14 @@ class System extends Base
         return $this->fetch('wordslog');
     }
 
+    function matching($str, $a, $b)
+    {
+        $pattern = '/('.$a.')(.*)(?)('.$b.')/'; //正则规则匹配支付串中任何一个位置字符串
+        //$pattern = '/(#\[)(.*)(?)(\]\/)/';
+        preg_match_all($pattern,$str,$m);
+        //preg_match_all($pattern, $str, $m);   //返回一个匹配结果
+        print_r($m);die;  //到时候在这里书写返回值就好了 .die;
+    }
 
     // 历史会话记录详情
     public function detail($id)
@@ -324,6 +334,12 @@ class System extends Base
                 $content['content'] = '<img width="100%" src="'.$content['img'].'"/>';
             }
             if(!empty(strstr($chat[$i]['to_id'], 'KF'))){
+                /*$preg1 = "/^#[*]$/";
+                $preg= '/xue[\s\S]*?om/i';
+                preg_match_all($preg1,"#[哈哈]/",$res);
+                var_dump($res);*/
+                $this->matching("#[哈哈]/","#\[","\]\/");
+                //$this->getFacesIcon();
                 $html = $html . '<div style="margin-top:15px;width: 30%;"><div>'.$chat[$i]['from_name'].'&nbsp&nbsp&nbsp'.$chat[$i]['time_line'].'</div>';
                 $html = $html . '<p style="margin-top:5px;" class="form-content">'.$content['content'].'</p></div>';
             }else{
@@ -385,4 +401,17 @@ class System extends Base
 
         return $operate;
     }
+
+    public function getFacesIcon($facesIcon) {
+        $data = ["[微笑]", "[嘻嘻]", "[哈哈]", "[可爱]", "[可怜]", "[挖鼻]", "[吃惊]", "[害羞]", "[挤眼]", "[闭嘴]", "[鄙视]",
+            "[爱你]", "[泪]", "[偷笑]", "[亲亲]", "[生病]", "[太开心]", "[白眼]", "[右哼哼]", "[左哼哼]", "[嘘]", "[衰]",
+            "[委屈]", "[吐]", "[哈欠]", "[抱抱]", "[怒]", "[疑问]", "[馋嘴]", "[拜拜]", "[思考]", "[汗]", "[困]", "[睡]",
+            "[钱]", "[失望]", "[酷]", "[色]", "[哼]", "[鼓掌]", "[晕]", "[悲伤]", "[抓狂]", "[黑线]", "[阴险]", "[怒骂]",
+            "[互粉]", "[心]", "[伤心]", "[猪头]", "[熊猫]", "[兔子]", "[ok]", "[耶]", "[good]", "[NO]", "[赞]", "[来]",
+            "[弱]", "[草泥马]", "[神马]", "[囧]", "[浮云]", "[给力]", "[围观]", "[威武]", "[奥特曼]", "[礼物]", "[钟]",
+            "[话筒]", "[蜡烛]", "[蛋糕]"];
+        $key = array_search($facesIcon, $data);
+        return $key;
+    }
+
 }

+ 3 - 3
application/admin/controller/Users.php

@@ -102,9 +102,9 @@ class Users extends Base
                 return json(['code' => -3, 'data' => '', 'msg' => '请选择分组']);
             }
             // 检测头像
-            if(empty($param['user_avatar'])){
-                return json(['code' => -4, 'data' => '', 'msg' => '请上传头像']);
-            }
+//            if(empty($param['user_avatar'])){
+//                return json(['code' => -4, 'data' => '', 'msg' => '请上传头像']);
+//            }
 
             $param['user_pwd'] = md5('123456' . config('salt'));
             $param['online'] = 2; // 离线状态

+ 54 - 6
application/admin/view/admins/addpower.html

@@ -17,23 +17,43 @@
         <div class="col-sm-8">
             <div class="ibox float-e-margins">
                 <div class="ibox-title">
-                    <h5>添加权限组</h5>
+                    <h5>添加角色</h5>
                 </div>
                 <div class="ibox-content">
-                    <form class="form-horizontal m-t layui-form" id="commentForm" method="post" action="{:url('admins/addPower')}">
+                    <form class="form-horizontal m-t" id="commentForm" method="post" action="{:url('admins/addPower')}">
 
                         <div class="form-group">
-                            <label class="col-sm-3 control-label">权限组名称:</label>
+                            <label class="col-sm-3 control-label">角色名称:</label>
                             <div class="input-group col-sm-4">
                                 <input id="group_name" type="text" class="form-control" name="group_name" required="" aria-required="true">
                             </div>
                         </div>
-                        <div class="form-group layui-form-item">
+                        <div class="form-group">
                             <label class="col-sm-3 control-label">是否启用:</label>
-                            <div class="input-group col-sm-6">
+                            <div class="input-group col-sm-6" style="margin-top: 5px;">
                                 {if !empty($status)}
                                 {foreach name="status" item="vo" key="key"}
-                                <input type="radio" name="status" value="{$key}" title="{$vo}" {if $key eq 1}checked{/if}>
+                                <input type="radio" name="status" value="{$key}" title="{$vo}" {if $key eq 1}checked{/if}>{$vo}
+                                {/foreach}
+                                {/if}
+                            </div>
+                        </div>
+                        <div class="form-group">
+                            <label class="col-sm-3 control-label">选择权限:</label>
+                            <div class="input-group col-sm-6" style="margin-top: 5px;">
+                                <input type="text" style="display:none;" name="group_id" value="">
+                                {if !empty($info)}
+                                {foreach name="info" item="vo" key="key"}
+                                <div class="form-group" style="margin:0px;">
+                                    <input type="hidden" name="{$vo['name_cn']}" value="0">
+                                    <input type="checkbox" level='1' name="{$vo['name_cn']}" value="{$vo['id']}"><span style="font-weight: 600;">{$vo['name_cn']}:</span><br>
+                                    <div style="margin:5px 20px;">
+                                        {foreach name="$vo['menulist']" item="vo" key="key"}
+                                        <input type="hidden" name="{$vo['name_cn']}" value="0">
+                                        <input class="menulist" level='2' id="menulist"  type="checkbox" name="{$vo['name_cn']}" value="{$vo['id']}">{$vo['name_cn']}
+                                        {/foreach}
+                                    </div>
+                                </div>
                                 {/foreach}
                                 {/if}
                             </div>
@@ -58,6 +78,34 @@
 <script src="__JS__/plugins/layer/layer.min.js"></script>
 <script src="__JS__/layui/layui.js"></script>
 <script src="__JS__/jquery.form.js"></script>
+<script>
+    $(function(){
+        $('[level=1]').click(function(){
+            if(this.checked){
+                $(this).parent().find('input').prop('checked','checked');
+            }
+            else{
+                $(this).parent().find('input').removeAttr('checked');
+            }
+        });
+        $('[level=2]').click(function(){
+            var n = 0;
+            if (this.checked) {
+                $(this).parent().parent().find('[level=1]').prop('checked','checked');
+            }
+            else{
+                for(var i=0;i<$(this).parent().find('[level=2]').length;i++){
+                    if($(this).parent().find('[level=2]')[i].checked){
+                        n = 1;
+                    }
+                }
+                if(n == 0){
+                    $(this).parent().parent().find('[level=1]').removeAttr('checked');
+                }
+            }
+        });
+    });
+</script>
 <script type="text/javascript">
 
     layui.use(['form', 'upload'], function(){

+ 37 - 16
application/admin/view/admins/editpower.html

@@ -3,7 +3,7 @@
 <head>
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>编辑权限组</title>
+    <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">
@@ -25,30 +25,51 @@
         <div class="col-sm-8">
             <div class="ibox float-e-margins">
                 <div class="ibox-title">
-                    <h5>编辑权限组</h5>
+                    <h5>编辑角色</h5>
                 </div>
                 <div class="ibox-content">
                     <!--<form class="form-horizontal m-t layui-form" id="commentForm" method="post" action="{:url('admins/editpower')}">-->
                     <form class="form-horizontal m-t" id="commentForm" method="post" action="{:url('admins/editpower')}">
-                        <h4>选择权限:</h4><br>
-                        <input type="text" style="display:none;" name="group_id" value="{$id}">
-                        {if !empty($info)}
-                        {foreach name="info" item="vo" key="key"}
-                        <div class="form-group" style="margin:5px 20px;">
-                            <input type="hidden" name="{$vo['name_cn']}" value="0">
-                            <input type="checkbox" level='1' name="{$vo['name_cn']}" value="{$vo['id']}" {if$vo['power']==1} checked {/if} ><span style="font-weight: 600;">{$vo['name_cn']}:</span><br>
-                            <div style="margin:5px 20px;">
-                                {foreach name="$vo['menulist']" item="vo" key="key"}
-                                <input type="hidden" name="{$vo['name_cn']}" value="0">
-                                <input class="menulist" level='2' id="menulist"  type="checkbox" name="{$vo['name_cn']}" value="{$vo['id']}" {if$vo['power']==1} checked {/if} >{$vo['name_cn']}
+                        <div class="form-group">
+                            <label class="col-sm-3 control-label">角色名称:</label>
+                            <div class="input-group col-sm-4">
+                                <input id="group_name" type="text" class="form-control" name="group_name" required="" aria-required="true" value="{$admingroup['group_name']}">
+                            </div>
+                        </div>
+                        <div class="form-group layui-form-item">
+                            <label class="col-sm-3 control-label">是否启用:</label>
+                            <div class="input-group col-sm-6" style="margin-top: 5px;">
+                                {if !empty($status)}
+                                {foreach name="status" item="vo" key="key"}
+                                <input type="radio" name="status" value="{$key}" title="{$vo}" {if $admingroup['status'] == $key}checked{/if}>{$vo}
                                 {/foreach}
+                                {/if}
                             </div>
                         </div>
-                        {/foreach}
-                        {/if}
+                        <div class="form-group layui-form-item">
+                            <label class="col-sm-3 control-label">选择权限:</label>
+                            <div class="input-group col-sm-6"  style="margin-top: 5px;">
+                                <input type="text" style="display:none;" name="group_id" value="{$id}">
+                                {if !empty($info)}
+                                {foreach name="info" item="vo" key="key"}
+                                <div class="form-group" style="margin:0px;">
+                                    <input type="hidden" name="{$vo['name_cn']}" value="0">
+                                    <input type="checkbox" level='1' name="{$vo['name_cn']}" value="{$vo['id']}" {if$vo['power']==1} checked {/if} ><span style="font-weight: 600;">{$vo['name_cn']}:</span><br>
+                                    <div style="margin:5px 20px;">
+                                        {foreach name="$vo['menulist']" item="vo" key="key"}
+                                        <input type="hidden" name="{$vo['name_cn']}" value="0">
+                                        <input class="menulist" level='2' id="menulist"  type="checkbox" name="{$vo['name_cn']}" value="{$vo['id']}" {if$vo['power']==1} checked {/if} >{$vo['name_cn']}
+                                        {/foreach}
+                                    </div>
+                                </div>
+                                {/foreach}
+                                {/if}
+                            </div>
+                        </div>
+
                         <div class="form-group">
                             <div class="col-sm-4 col-sm-offset-6">
-                                <a class="layui-btn layui-btn-sm lay-btn-diy" href="javascript:history.go(-1)" style="background-color:#1E9FFF;margin-bottom: 5px;height: 35px;line-height: 35px;">返回</a>
+                                <!--<a class="layui-btn layui-btn-sm lay-btn-diy" href="javascript:history.go(-1)" style="background-color:#1E9FFF;margin-bottom: 5px;height: 35px;line-height: 35px;">返回</a>-->
                                 <button class="btn btn-primary" type="submit">提交</button>
                             </div>
                         </div>

+ 1 - 1
application/admin/view/admins/index.html

@@ -20,7 +20,7 @@
         </div>
         <div class="ibox-content">
             <a href="/admin/admins/addadmin.html">
-                <button class="btn btn-primary" type="button" style="margin-top:5px"><strong>新 增</strong>
+                <button class="btn btn-primary" type="button" style="margin-top:5px"><strong>新增管理员</strong>
                 </button>
             </a>
             <!--搜索框开始-->

+ 1 - 1
application/admin/view/admins/power.html

@@ -20,7 +20,7 @@
         </div>
         <div class="ibox-content">
             <a href="/admin/admins/addpower.html">
-                <button class="btn btn-primary" type="button" style="margin-top:5px"><strong>新 增</strong>
+                <button class="btn btn-primary" type="button" style="margin-top:5px"><strong>新增角色</strong>
                 </button>
             </a>
             <div class="example-wrap">

+ 4 - 4
application/admin/view/index.html

@@ -121,10 +121,10 @@
                     src="{:url('Index/indexPage')}" frameborder="0"
                     data-id="index_v1.html" seamless></iframe>
         </div>
-        <div class="footer">
-            <!--<div class="pull-right">&copy; 2018-2020 {$version} <a href="http://baiyf.com" target="_blank">baiyf.com</a>
-            </div>-->
-        </div>
+        <!--<div class="footer">
+            <div class="pull-right">&copy; 2018-2020 {$version} <a href="http://baiyf.com" target="_blank">baiyf.com</a>
+            </div>
+        </div>-->
     </div>
     <!--右侧部分结束-->
     <!--右侧边栏开始-->

+ 98 - 80
application/admin/view/report/index.html

@@ -18,98 +18,116 @@
     </div>
 
     <div class="row">
-        <div>
-        <div class="col-sm-2">
-            <div class="ibox float-e-margins">
-                <div class="ibox-title" style="display: flex; justify-content: center;">
-                    <!--<span class="label label-primary pull-right">今天</span>-->
-                    <h3>总会话量</h3>
-                </div>
-                <div class="ibox-content" style="text-align: center">
-                    <h1 class="no-margins"><span>{$allChat}</span></h1>
-                    <small></small>
-                </div>
-                <div class="ibox-content" style="font-size: 12px; padding: 5px 20px 5px; height: 45px; line-height: 3;">
-                    <div style="justify-content: center; display: flex">
-                        <div style="text-align: right;">转接量</div>
-                        <div style="margin-left: 20px; text-align: right;">{$transfer}</div>
+        <div style="display: flex; justify-content: end;">
+        <!--搜索框开始-->
+            <form id='commentForm' role="form" method="post" class="form-inline pull-right" style="margin-right: 30px;">
+                <div class="content clearfix m-b">
+                    <div class="form-group">
+                        <label>时间区间:</label>
+                        <div class="layui-input-inline">
+                            <input style="width: 180px;" type="text" class="layui-input" name="daterang" id="daterang" value={$defaultTime} placeholder="时间段"
+                                   readonly="">
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <button class="btn btn-primary" type="button" id="search"><strong>搜 索</strong>
+                        </button>
                     </div>
                 </div>
-            </div>
+            </form>
         </div>
-        <div class="col-sm-2">
-            <div class="ibox float-e-margins">
-                <div class="ibox-title" style="display: flex; justify-content: center;">
-                    <!--<span class="label label-primary pull-right">今天</span>-->
-                    <h3>总消息量</h3>
-                </div>
-                <div class="ibox-content" style="text-align: center">
-                    <h1 class="no-margins"><span>{$allService}</span></h1>
-                    <small></small>
-                </div>
-                <div class="ibox-content" style="font-size: 12px; padding: 5px 20px 5px; height: 45px; line-height: 3;">
-                    <div style="justify-content: center; display: flex">
-                        <div style="text-align: right;">问答比</div>
-                        <div style="margin-left: 20px; text-align: right;">{$reply}%</div>
+        <div>
+            <div class="col-sm-2">
+                <div class="ibox float-e-margins">
+                    <div class="ibox-title" style="display: flex; justify-content: center;">
+                        <!--<span class="label label-primary pull-right">今天</span>-->
+                        <h3>总会话量</h3>
+                    </div>
+                    <div class="ibox-content" style="text-align: center">
+                        <h1 class="no-margins"><span>{$allChat}</span></h1>
+                        <small></small>
+                    </div>
+                    <div class="ibox-content" style="font-size: 12px; padding: 5px 20px 5px; height: 45px; line-height: 3;">
+                        <div style="justify-content: center; display: flex">
+                            <div style="text-align: right;">转接量</div>
+                            <div style="margin-left: 20px; text-align: right;">{$transfer}</div>
+                        </div>
                     </div>
                 </div>
             </div>
-        </div>
-        <div class="col-sm-2">
-            <div class="ibox float-e-margins">
-                <div class="ibox-title" style="display: flex; justify-content: center;">
-                    <!--<span class="label label-primary pull-right">今天</span>-->
-                    <h3>排队量</h3>
-                </div>
-                <div class="ibox-content" style="text-align: center">
-                    <h1 class="no-margins"><span>{$allQueue}</span></h1>
-                    <small></small>
-                </div>
-                <div class="ibox-content" style="font-size: 12px; padding: 5px 20px 5px; height: 45px; line-height: 3;">
-                    <div style="justify-content: center; display: flex">
-                        <div style="text-align: right;">平均排队时长</div>
-                        <div style="margin-left: 20px; text-align: right;">{$waitTime}</div>
+            <div class="col-sm-2">
+                <div class="ibox float-e-margins">
+                    <div class="ibox-title" style="display: flex; justify-content: center;">
+                        <!--<span class="label label-primary pull-right">今天</span>-->
+                        <h3>总消息量</h3>
+                    </div>
+                    <div class="ibox-content" style="text-align: center">
+                        <h1 class="no-margins"><span>{$allService}</span></h1>
+                        <small></small>
+                    </div>
+                    <div class="ibox-content" style="font-size: 12px; padding: 5px 20px 5px; height: 45px; line-height: 3;">
+                        <div style="justify-content: center; display: flex">
+                            <div style="text-align: right;">问答比</div>
+                            <div style="margin-left: 20px; text-align: right;">{$reply}%</div>
+                        </div>
                     </div>
                 </div>
             </div>
-        </div>
-        <div class="col-sm-2">
-            <div class="ibox float-e-margins">
-                <div class="ibox-title" style="display: flex; justify-content: center;">
-                    <!--<span class="label label-primary pull-right">今天</span>-->
-                    <h3>平均会话时长</h3>
-                </div>
-                <div class="ibox-content" style="text-align: center">
-                    <h1 class="no-margins"><span>{$serviceTime}</span><span style="font-size: 14px; margin-left: 10px">秒</span></h1>
-                    <small></small>
-                </div>
-                <div class="ibox-content" style="font-size: 12px; padding: 5px 20px 5px; height: 45px; line-height: 3;">
-                    <div style="justify-content: center; display: flex">
-                        <div style="text-align: right;">平均相应时长</div>
-                        <div style="margin-left: 20px; text-align: right;">{$cpdTime}</div>
+            <div class="col-sm-2">
+                <div class="ibox float-e-margins">
+                    <div class="ibox-title" style="display: flex; justify-content: center;">
+                        <!--<span class="label label-primary pull-right">今天</span>-->
+                        <h3>排队量</h3>
+                    </div>
+                    <div class="ibox-content" style="text-align: center">
+                        <h1 class="no-margins"><span>{$allQueue}</span></h1>
+                        <small></small>
+                    </div>
+                    <div class="ibox-content" style="font-size: 12px; padding: 5px 20px 5px; height: 45px; line-height: 3;">
+                        <div style="justify-content: center; display: flex">
+                            <div style="text-align: right;">平均排队时长</div>
+                            <div style="margin-left: 20px; text-align: right;">{$waitTime}</div>
+                        </div>
                     </div>
                 </div>
             </div>
-        </div>
-        <div class="col-sm-2">
-            <div class="ibox float-e-margins">
-                <div class="ibox-title" style="display: flex; justify-content: center;">
-                    <!--<span class="label label-primary pull-right">今天</span>-->
-                    <h3>相对满意度</h3>
-                </div>
-                <div class="ibox-content" style="text-align: center">
-                    <h1 class="no-margins"><span>{$evaluateGood}<span style="font-size: 14px; margin-left: 10px">%</span></span></h1>
-                    <small></small>
+            <div class="col-sm-2">
+                <div class="ibox float-e-margins">
+                    <div class="ibox-title" style="display: flex; justify-content: center;">
+                        <!--<span class="label label-primary pull-right">今天</span>-->
+                        <h3>平均会话时长</h3>
+                    </div>
+                    <div class="ibox-content" style="text-align: center">
+                        <h1 class="no-margins"><span>{$serviceTime}</span><span style="font-size: 14px; margin-left: 10px">秒</span></h1>
+                        <small></small>
+                    </div>
+                    <div class="ibox-content" style="font-size: 12px; padding: 5px 20px 5px; height: 45px; line-height: 3;">
+                        <div style="justify-content: center; display: flex">
+                            <div style="text-align: right;">平均响应时长</div>
+                            <div style="margin-left: 20px; text-align: right;">{$cpdTime}</div>
+                        </div>
+                    </div>
                 </div>
-                <div class="ibox-content" style="font-size: 12px; padding: 5px 20px 5px; height: 45px; line-height: 3;">
-                    <div style="justify-content: center; display: flex">
-                        <div style="text-align: right;">参评率</div>
-                        <div style="margin-left: 20px; text-align: right;">{$evaluateGet}%</div>
+            </div>
+            <div class="col-sm-2">
+                <div class="ibox float-e-margins">
+                    <div class="ibox-title" style="display: flex; justify-content: center;">
+                        <!--<span class="label label-primary pull-right">今天</span>-->
+                        <h3>相对满意度</h3>
+                    </div>
+                    <div class="ibox-content" style="text-align: center">
+                        <h1 class="no-margins"><span>{$evaluateGood}<span style="font-size: 14px; margin-left: 10px">%</span></span></h1>
+                        <small></small>
+                    </div>
+                    <div class="ibox-content" style="font-size: 12px; padding: 5px 20px 5px; height: 45px; line-height: 3;">
+                        <div style="justify-content: center; display: flex">
+                            <div style="text-align: right;">参评率</div>
+                            <div style="margin-left: 20px; text-align: right;">{$evaluateGet}%</div>
+                        </div>
                     </div>
                 </div>
             </div>
         </div>
-        </div>
         <div class="col-sm-12">
             <div class="ibox float-e-margins">
                 <div class="ibox-title">
@@ -117,7 +135,7 @@
                 </div>
                 <div class="ibox-content">
                     <!--搜索框开始-->
-                    <form id='commentForm' role="form" method="post" class="form-inline pull-right">
+                    <!--<form id='commentForm' role="form" method="post" class="form-inline pull-right">
                         <div class="content clearfix m-b">
                             <div class="form-group">
                                 <label>时间区间:</label>
@@ -131,8 +149,8 @@
                                 </button>
                             </div>
                         </div>
-                    </form>
-                    <div class="ibox-content" style="height: 350px" id="bar">
+                    </form>-->
+                    <div style="height: 350px" id="bar">
 
                     </div>
                 </div>
@@ -161,7 +179,7 @@
                         <div class="ibox-title">
                             <h5>访问来源</h5>
                         </div>
-                        <div id="system_data" style="text-align: center; width: 100%; font-size: 16px; background: #fff; height: 350px; border-top: 1px solid #e7eaec;">
+                        <div id="system_data" style="text-align: center; width: 100%; font-size: 16px; background: #fff; height: 350px;">
                             <div class="ibox-content" style="height: 350px" id="pie_system">
 
                             </div>
@@ -443,7 +461,7 @@
         };
         pie_system.setOption(option_PS);
     } else {
-        let pie_system_html = "<div style='line-height: 20;'>暂无数据</div>";
+        let pie_system_html = "<div style='line-height: 20; border-top: 1px solid #e7eaec;'>暂无数据</div>";
         $("#system_data").html(pie_system_html);
     }
 

+ 2 - 2
application/index/controller/Index.php

@@ -51,10 +51,10 @@ class Index extends Common
     }//end sensitiveWords()
 
 
-    public function index()
+    /*public function index()
     {
         return $this->fetch();
-    }
+    }*/
 
     // pc客户端
     public function chat()

+ 41 - 0
application/service/controller/History.php

@@ -41,6 +41,7 @@ class History extends Common
                 'browse',
                 'a.status',
                 'evaluate_id',
+                'intime',
                 'servicelog_id',
             ];
             // 关联信息.
@@ -133,12 +134,52 @@ class History extends Common
             // 获取用户信息.
             $chatLog      = model('ChatLog')->selectChatLog($chatLogField, $offset, $pageSize, $chatLogWhere);
             $countChatLog = model('ChatLog')->countChatLog($chatLogWhere);
+            // 查询报警信息.
+            $alarmField                    = [
+                'evaluate_id',
+                'alarm_corresponding',
+                'alarm_cvtOvertime',
+                'alarm_userSensitive',
+                'alarm_serverSensitive',
+                'alarm_respond',
+            ];
+            $alarmWhere['b.servicelog_id'] = $servicelogId;
+            $serviceLogJoin['service_log b'] = 'a.servicelog_id = b.servicelog_id';
+            $alarm = model('Alarm')->findAlarm($alarmField, $alarmWhere, $serviceLogJoin);
+            // 查询系统设置.
+            $systemconfig = model('Systemconfig')->selectSystemconfig($alarmField, $alarmWhere, $serviceLogJoin);
+            // 响应超时.
+            $verifyReturnTime = 0;
+            // 会话超时.
+            $cvtOvertime = 0;
+            foreach ($systemconfig as $v) {
+                if ($v['systemconfig_enName'] === 'verifyReturnTime') {
+                    if ($v['systemconfig_data'] < $alarm['alarm_corresponding']) {
+                        $verifyReturnTime = 1;
+                    }
+                }
+
+                if ($v['systemconfig_enName'] === 'verifyAllTime') {
+                    if ($v['systemconfig_data'] < $alarm['alarm_cvtOvertime']) {
+                        $cvtOvertime = 1;
+                    }
+                }
+            }
+
 
             $result['total']       = $countChatLog;
             $result['countPage']   = (ceil(($result['total']) / $pageSize));
             $result['currentPage'] = $currentPage;
             $result['list']        = $chatLog;
             $result['pageSize']    = $pageSize;
+            $result['alarm']       = [
+                'evaluate_id'      => $alarm['evaluate_id'],
+                'verifyReturnTime' => $verifyReturnTime,
+                'cvtOvertime'      => $cvtOvertime,
+                'serverSensitive'  => $alarm['alarm_serverSensitive'] ? 1 : 2,
+                'userSensitive'    => $alarm['alarm_userSensitive'] ? 1 : 2,
+                'respond'          => $alarm['alarm_respond'],
+            ];
 
             return json(['code' => 1, 'data' => $result, 'msg' => '成功']);
         } catch (\Exception $e) {

+ 2 - 2
application/service/controller/Index.php

@@ -94,7 +94,7 @@ class Index extends Common
     }//end userWords()
 
 
-    public function index()
+    /*public function index()
     {
         $getUserInfo = $this->getUserInfo();
 
@@ -109,7 +109,7 @@ class Index extends Common
         ]);
 
         return $this->fetch();
-    }
+    }*/
 
 
     // 获取服务用户列表

+ 42 - 0
application/service/model/Alarm.php

@@ -0,0 +1,42 @@
+<?php
+namespace app\service\model;
+
+use think\Model;
+
+/**
+ * 报警模型
+ */
+class Alarm extends Model
+{
+
+
+    /**
+     * 单数据筛选
+     *
+     * @access public
+     * @param mixed $field 字段
+     * @param mixed $where 条件
+     * @param mixed $join 关联
+     * @return array 返回类型
+     */
+    public function findAlarm($field, $where=[], $join=[])
+    {
+        $result = $this->field($field);
+        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);
+        }
+
+        $result = $result->find();
+        return $result;
+
+    }//end findAlarm()
+
+
+}//end class

+ 27 - 0
application/service/model/Systemconfig.php

@@ -0,0 +1,27 @@
+<?php
+namespace app\service\model;
+
+use think\Model;
+
+/**
+ * 设置模型
+ */
+class Systemconfig extends Model
+{
+
+
+    /**
+     * 数据获取
+     *
+     * @access public
+     * @return array 返回类型
+     */
+    public function selectSystemconfig()
+    {
+        $result = $this->field(['systemconfig_enName', 'systemconfig_data'])->select();
+        return $result;
+
+    }//end selectSystemconfig()
+
+
+}//end class

File diff suppressed because it is too large
+ 0 - 0
public/static/admin/css/style.min.css


+ 2 - 2
public/static/service/js/functions.js

@@ -10,7 +10,7 @@ function replaceContent(content) {
 
         .replace(/face\[([^\s\[\]]+?)\]/g, function (face) {  // 转义表情
             var alt = face.replace(/^face/g, '');
-            return '<img alt="' + alt + '" title="' + alt + '" src="' + faces[alt] + '">';
+            return '<img alt="' + alt + '" title="' + alt + '" src="' + faces[alt] + '">';a
         })
         .replace(/img\[([^\s]+?)\]/g, function (img) {  // 转义图片
             return '<img class="layui-whisper-photos" src="' + img.replace(/(^img\[)|(\]$)/g, '') + '" width="100px" height="100px">';
@@ -50,4 +50,4 @@ function getFacesIcon() {
         "[互粉]", "[心]", "[伤心]", "[猪头]", "[熊猫]", "[兔子]", "[ok]", "[耶]", "[good]", "[NO]", "[赞]", "[来]",
         "[弱]", "[草泥马]", "[神马]", "[囧]", "[浮云]", "[给力]", "[围观]", "[威武]", "[奥特曼]", "[礼物]", "[钟]",
         "[话筒]", "[蜡烛]", "[蛋糕]"]
-}
+}

+ 16 - 6
vendor/GatewayWorker_windows/Applications/whisper/Events.php

@@ -106,7 +106,7 @@ class Events
             });
 
             // 检查对话时效给出.
-            Timer::add(6, function () {
+            Timer::add(60, function () {
                 self::overTime();
             });
 
@@ -395,7 +395,9 @@ class Events
                     $client = Gateway::getClientIdByUid($userId);
                     if (!empty($client)) {
                         $clientId = $client['0'];
-                        self::serverClose($clientId, $message['data']['conversationId']);
+                        $servicelog_id = $message['data']['conversationId'];
+                        self::$db->query("update `ws_service_log` set `servicelog_close_type` = 3 where `servicelog_id`= '$servicelog_id'");
+                        self::serverClose($clientId, $servicelog_id);
                     }
                     break;
                 // 客服更改状态.
@@ -415,6 +417,8 @@ class Events
 
                     break;
                 case 'changeOtherhKeFu';
+                    $servicelog_id = $message['data']['conversationId'];
+                    self::$db->query("update `ws_service_log` set `servicelog_close_type` = 5 where `servicelog_id`= '$servicelog_id'");
                     self::changeOtherhKeFu($client_id, $message);
                     break;
                 // 弹出评价.
@@ -840,9 +844,10 @@ class Events
 
                     // 修改会话时长
                     $serviceLog = self::$db->query("select `start_time`,`servicelog_id`,`intime` from `ws_service_log` where `user_id`= '$simpliUsersID_UID_Arr[$val]' and  kf_id='$uid' and  group_id=$group  and  `status`!=2");
+                    $servicelog_id = $serviceLog[0]['servicelog_id'];
+                    self::$db->query("update `ws_service_log` set `servicelog_close_type` = 4 where `servicelog_id`= '$servicelog_id'");
                     $logCount = self::$db->query("select count(*) as `count` from `ws_chat_log` where `servicelog_id`= '$servicelog_id'");
                     $alarmCount = $logCount[0]['count'];
-                    $servicelog_id = $serviceLog[0]['servicelog_id'];
                     $cvtOvertime = time() - $serviceLog[0]['start_time'];
                     $alarmLineTime = $serviceLog[0]['start_time'] - $serviceLog[0]['intime'];
                     self::$db->query("update `ws_alarm` set `alarm_cvtOvertime` = '$cvtOvertime',`alarm_lineTime` = '$alarmLineTime',`alarm_count` = '$alarmCount'
@@ -1727,11 +1732,14 @@ class Events
         $setUnoperated = strtotime('-' . (self::$global->unoperated['systemconfig_data'] - 60) . ' second');
         $unoperated = strtotime('-' . (self::$global->unoperated['systemconfig_data']) . ' second');
         $noResponse = strtotime('-' . (self::$global->noResponse['systemconfig_data']) . ' second');
+        // 访客静默超时.
         foreach ($serviceLog as $k => $v) {
             if (!strlen(array_search($v['servicelog_id'], array_column($chatLog, 'servicelog_id')))) {
                 // 如果小于设定时间则关闭会话.
                 if ($v['start_time'] <= $unoperated) {
-                    self::serverClose($v['client_id'], $v['servicelog_id']);
+                    $servicelog_id = $v['servicelog_id'];
+                    self::$db->query("update `ws_service_log` set `servicelog_close_type` = 1 where `servicelog_id`= '$servicelog_id'");
+                    self::serverClose($v['client_id'], $servicelog_id);
                     // 如果小于设定时间前一分钟则给出提示.
                 } elseif ($v['start_time'] <= $setUnoperated) {
                     $chat_message = [
@@ -1744,13 +1752,15 @@ class Events
                 }
             }
         }
-        // 循环检测会话时效.
+        // 循环检测会话时效,会话超时关闭.
         foreach ($chatLog as $k => $v) {
             $toWho = substr($v['to_id'], 0, 2);
             // 如果对话为客服的最后一次对话且时间小于设定时间则结束工单.
             if ($v['time_line'] <= $overtime) {
                 $found_key = array_search($v['servicelog_id'], array_column($serviceLog, 'servicelog_id'));
-                self::serverClose($serviceLog[$found_key]['client_id'], $v['servicelog_id']);
+                $servicelog_id = $v['servicelog_id'];
+                self::$db->query("update `ws_service_log` set `servicelog_close_type` = 2 where `servicelog_id`= '$servicelog_id'");
+                self::serverClose($serviceLog[$found_key]['client_id'], $servicelog_id);
                 // 如果对话为客服的最后一次对话且时间小于设定时间前一分钟则给出提示.
             } elseif ($v['time_line'] <= $setOvertime) {
                 $chat_message = [

Some files were not shown because too many files changed in this diff