Pārlūkot izejas kodu

'新增客服查看所有会话'

Ethan 6 gadi atpakaļ
vecāks
revīzija
f418097b49

+ 9 - 1
application/admin/controller/Users.php

@@ -43,6 +43,13 @@ class Users extends Base
                     $result[$key]['status'] = '<span style="color: red">禁用</span>';
                 }
 
+                // 优化显示状态
+                if(1 == $vo['user_overview']){
+                    $result[$key]['user_overview'] = '<span class="label label-primary">启用</span>';
+                }else{
+                    $result[$key]['user_overview'] = '<span class="label label-danger">禁用</span>';
+                }
+
                 // 查询分组
                 $result[$key]['group'] = '-';
                 $groups = db('groups')->field('name')->where('id', $vo['group_id'])->find();
@@ -182,10 +189,11 @@ class Users extends Base
             $addar['signature'] = $param['signature'];
             $addar['group_id'] = $param['group_id'];
             $addar['status'] = $param['status'];
+            $addar['user_overview'] = $param['user_overview'];
             if(!empty($param['user_avatar'])){
                 $addar['user_avatar'] = $param['user_avatar'];
             }
-          
+
             try{
                 db('users')->where('id', $param['id'])->update($addar);
             }catch(\Exception $e){

+ 7 - 6
application/admin/view/settings/demo.html

@@ -7,10 +7,11 @@
 </head>
 <body class="gray-bg">
 <script type="text/javascript">
+
   var xmlhttp=new XMLHttpRequest();
   var data = [];//配置信息
   var appip_source = '';
-  var appuip_user = '999';
+  var appuip_user = '';
   var isIE=!!window.ActiveXObject;    //是否IE浏览器
   var isIE6=isIE&&!window.XMLHttpRequest;  //是否IE6浏览器
   var isIE7=isIE&&!isIE6&&!isIE8;  //是否IE7浏览器
@@ -19,7 +20,7 @@
   var hostname = location.protocol+'//'+location.host;
   var adminDomain = 'http://kfadmin.bocai186.com';   //服务器域名
   var serverDomain = 'http://kefu.bocai186.com';   //客服域名
-  var userDomain = 'http://kf.bocai186.com';   //用户域名
+  var userDomain = 'http://kf.bocai186.com?pid='+escape("~!@#¥%……&*()——+,./;\'[]");   //用户域名
   if(isIE8){
     availheight= screen.height;
   }
@@ -82,10 +83,10 @@
     // console.log(e.target,index);
     var group_id  = e.target.id.substring(index+1,e.target.id.length);
     console.log(window);
-    if(group_id != 'all'){
-      openWindowCenter(userDomain+"?appid="+appip_source+"&appuid="+appuip_user+'&group_id='+group_id,700,700);
+    if(appuip_user && appip_source){
+      openWindowCenter(userDomain+"&appid="+appip_source+"&appuid="+appuip_user+'&group_id='+group_id,700,700);
     }else{
-      openWindowCenter(userDomain+"/?appid="+appip_source+"&appuid="+appuip_user,700,700);
+      openWindowCenter(userDomain+"&appid="+appip_source+"&appuid="+appuip_user,700,700);
     }
   }
   //将浮动按钮添加到对应到网站body上
@@ -113,7 +114,7 @@
     `;
     popupWindowBox.onclick =function(e){
       if(e.target.id == '$startSession'){
-        openWindowCenter(userDomain+"/?appid="+appip_source+"&appuid="+appuip_user,700,700);
+        openWindowCenter(userDomain+"&appid="+appip_source+"&appuid="+appuip_user,700,700);
       }else if(e.target.id == '$cancel'){
         popupWindowBox.style.display="none";
       }

+ 11 - 0
application/admin/view/users/adduser.html

@@ -10,6 +10,7 @@
     <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">
+    <script src="../../../../../aa/Customer-Service/public/static/customer/js/whisper-cli.js"></script>
 </head>
 <body class="gray-bg">
 <div class="layui-layer-shade" id="all_blank" style="display: none"></div>
@@ -128,6 +129,16 @@
                                 {/if}
                             </div>
                         </div>
+                        <div class="form-group layui-form-item">
+                            <label class="col-sm-3 control-label">会话总览 <span style="color: red;">*</span>:</label>
+                            <div class="input-group col-sm-6">
+                                {if !empty($status)}
+                                {foreach name="status" item="vo" key="key"}
+                                <input type="radio" name="user_overview" value="{$key}" title="{$vo}" {if $key eq 2}checked{/if}>
+                                {/foreach}
+                                {/if}
+                            </div>
+                        </div>
 
                         <div class="form-group">
                             <div class="col-sm-4 col-sm-offset-6">

+ 10 - 0
application/admin/view/users/edituser.html

@@ -129,6 +129,16 @@
                                 {/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="user_overview" value="{$key}" title="{$vo}" {if $key eq $info['user_overview']}checked{/if}>
+                                {/foreach}
+                                {/if}
+                            </div>
+                        </div>
 
 
                         <div class="form-group">

+ 1 - 0
application/admin/view/users/index.html

@@ -73,6 +73,7 @@
                         <th data-field="fullname">真实姓名</th>
                         <th data-field="group">所属组别</th>
                         <th data-field="status">账号状态</th>
+                        <th data-field="user_overview">会话总览</th>
                         <!--<th data-field="online">是否在线</th>-->
                         <th data-field="operate">操作</th>
                         </thead>

+ 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()

+ 7 - 8
application/index/controller/Register.php

@@ -112,21 +112,20 @@ class Register extends Common
             }
         }
 
-        if (!$this->verifyApiToken()) {
+        /*if (!$this->verifyApiToken()) {
             return json(['code' => -6, 'data' => [], 'msg' => 'require false']);
-        }
+        }*/
 
         $appid = trim(input("post.appid/s", ''));
         $appuid = trim(input("post.appuid/s", ''));
         $token = trim(input("post.token/s", ''));
         $nowuid = (empty($appuid) || empty($appuid)) ? uniqid('anon_') : $appid . '_' . $appuid;
-        $avatar = "http://wx2.sinaimg.cn/mw690/5db11ff4gy1flxmew7edlj203d03wt8n.jpg";  //默认头像
 
         if (!empty($nowuid) && !empty($token)) {
             $old = Db::name('accounts')->where(['account_name' => $nowuid, 'tokenvip' => $token])->find();
             if ($old) {
                 Db::name('accounts')->where(['account_name' => $nowuid])->update(['last_login_time' => time()]);
-                return json(['code' => 1, 'data' => ['id' => $old['id'], 'name' => $nowuid, 'token' => $old['tokenvip'], 'avatar' => $avatar], 'msg' => '注册成功', 'tutype' => 1]);
+                return json(['code' => 1, 'data' => ['id' => $old['id'], 'name' => $nowuid, 'token' => $old['tokenvip']], 'msg' => '注册成功', 'tutype' => 1]);
             }
         }
 
@@ -137,7 +136,7 @@ class Register extends Common
                     return json(['code' => 0, 'data' => [], 'msg' => '禁止登陆']);
                 }
                 Db::name('accounts')->where(['token' => $token])->update(['last_login_time' => time()]);
-                return json(['code' => 1, 'data' => ['id' => $old['id'], 'name' => $old['account_name'], 'token' => $old['token'], 'avatar' => $avatar], 'msg' => '注册成功', 'tutype' => 0]);
+                return json(['code' => 1, 'data' => ['id' => $old['id'], 'name' => $old['account_name'], 'token' => $old['token']], 'msg' => '注册成功', 'tutype' => 0]);
             }
         }
 
@@ -163,9 +162,9 @@ class Register extends Common
 
         if ($retid) {
             if (empty($appuid)) {
-                return json(['code' => 1, 'data' => ['id' => $retid, 'name' => $nowuid, 'token' => $token, 'avatar' => $avatar], 'msg' => '注册成功', 'tutype' => -1]);
+                return json(['code' => 1, 'data' => ['id' => $retid, 'name' => $nowuid, 'token' => $token], 'msg' => '注册成功', 'tutype' => -1]);
             } else {
-                return json(['code' => 1, 'data' => ['id' => $retid, 'name' => $nowuid, 'token' => $tokenvip, 'avatar' => $avatar], 'msg' => '注册成功', 'tutype' => 2]);
+                return json(['code' => 1, 'data' => ['id' => $retid, 'name' => $nowuid, 'token' => $tokenvip], 'msg' => '注册成功', 'tutype' => 2]);
             }
         } else {
             return json(['code' => 0, 'data' => [], 'msg' => '注册用户失败']);
@@ -173,4 +172,4 @@ class Register extends Common
 
     }
 
-}
+}

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

@@ -1,6 +1,8 @@
 <?php
 namespace app\service\controller;
 
+use think\cache\driver\Redis;
+
 /**
  * 客服系统会话历史类
  */
@@ -8,6 +10,74 @@ class History extends Common
 {
 
 
+    /**
+     * 获取当前所有会话
+     *
+     * @access public
+     * @return array JsonString
+     */
+    public function allConversation()
+    {
+        // 验证token.
+        $tokenStatus = $this->verifyToken();
+        $code        = -2;
+        $msg         = '错误';
+        if ($tokenStatus === false) {
+            $msg = 'token错误';
+            return json(['code' => $code, 'data' => [], 'msg' => $msg]);
+        }
+
+        try {
+            // 获取用户信息.
+            $getUserInfo = $this->getUserInfo();
+            if ($getUserInfo['user_overview'] != 1) {
+                $msg = '您没有权限查看';
+                return json(['code' => 1, 'data' => [], 'msg' => $msg]);
+            }
+
+            $groups     = model('Groups')->selectGroups();
+            $redis      = new Redis;
+            $kefuInfo   = $redis->handler()->hGetall('KFINFO');
+            $servicelog = $redis->handler()->hGetall('SERVICELOG');
+            foreach ($groups as $k => $v) {
+                $data[$k]           = (object) [
+                    'label' => $v['name'],
+                ];
+                $n                  = 0;
+                $data[$k]->children = [];
+                foreach ($kefuInfo as $va) {
+                    $kefuInfoData = json_decode($va, true);
+                    if ($kefuInfoData['group'] == $v['id']) {
+                        $data[$k]->children[$n] = (object) [
+                            'label' => $kefuInfoData['name'],
+                        ];
+                        $m = 0;
+                        $data[$k]->children[$n]->children = [];
+                        foreach ($servicelog as $val) {
+                            $servicelogData = json_decode($val, true);
+                            if (('KF'.$servicelogData['kf_id']) == $kefuInfoData['id']) {
+                                $data[$k]->children[$n]->children[$m] = (object) [
+                                    'label'         => $servicelogData['user_name'],
+                                    'servicelog_id' => $servicelogData['servicelog_id'],
+                                ];
+                            }
+
+                            $m++;
+                        }
+
+                        $n++;
+                    }
+                }//end foreach
+            }//end foreach
+
+            return json(['code' => 1, 'data' => $data, 'msg' => '成功']);
+        } catch (\Exception $e) {
+            return json(['code' => $code, 'data' => [], 'msg' => $msg]);
+        }//end try
+
+    }//end allConversation()
+
+
     /**
      * 获取会话历史
      *

+ 1 - 1
application/service/controller/Login.php

@@ -19,7 +19,7 @@ class Login extends Controller
         //验证客服IP
         $settings = db('settings')->where('id',1)->find();
         if($settings['kf_white_list'] == 'on'){
-            $ip = $_SERVER["REMOTE_ADDR"];
+            $ip = request()->ip();
             //将ip地址转换成int型
             $intip = bindec(decbin(ip2long($ip)));
             $res = db('iplimit')->where('ip',$ip)->where('object',2)->find();

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

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

+ 6 - 6
entranceJs/FloatingButton.js

@@ -1,7 +1,7 @@
 var xmlhttp=new XMLHttpRequest();
 var data = [];//配置信息
 var appip_source = '';
-var appuip_user = '999';
+var appuip_user = '';
 var isIE=!!window.ActiveXObject;    //是否IE浏览器
 var isIE6=isIE&&!window.XMLHttpRequest;  //是否IE6浏览器
 var isIE7=isIE&&!isIE6&&!isIE8;  //是否IE7浏览器
@@ -10,7 +10,7 @@ var availheight = screen.availHeight;   //默认高度为屏幕的高度
 var hostname = location.protocol+'//'+location.host;
 var adminDomain = 'http://kfadmin.bocai186.com';   //服务器域名
 var serverDomain = 'http://kefu.bocai186.com';   //客服域名
-var userDomain = 'http://kf.bocai186.com';   //用户域名
+var userDomain = 'http://kf.bocai186.com?pid='+escape("~!@#¥%……&*()——+,./;\'[]");   //用户域名
 if(isIE8){
   availheight= screen.height;
 }
@@ -50,10 +50,10 @@ div.onclick =function(e){
   // console.log(e.target,index);
   var group_id  = e.target.id.substring(index+1,e.target.id.length);
   console.log(window);
-  if(group_id != 'all'){
-    openWindowCenter(userDomain+"/?appid="+appip_source+"&appuid="+appuip_user+'&group_id='+group_id,700,700);
+  if(appuip_user && appip_source){
+    openWindowCenter(userDomain+"&appid="+appip_source+"&appuid="+appuip_user+'&group_id='+group_id,700,700);
   }else{
-    openWindowCenter(userDomain+"/?appid="+appip_source+"&appuid="+appuip_user,700,700);
+    openWindowCenter(userDomain+"&appid="+appip_source+"&appuid="+appuip_user,700,700);
   }
 }
 //将浮动按钮添加到对应到网站body上
@@ -84,7 +84,7 @@ function create_prompt_box(){
     `;
   popupWindowBox.onclick =function(e){
     if(e.target.id == '$startSession'){
-      openWindowCenter(userDomain+"/?appid="+appip_source+"&appuid="+appuip_user,700,700);
+      openWindowCenter(userDomain+"&appid="+appip_source+"&appuid="+appuip_user,700,700);
     }else if(e.target.id == '$cancel'){
       popupWindowBox.style.display="none";
     }