Selaa lähdekoodia

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

Jonlin 6 vuotta sitten
vanhempi
commit
4344d1fc9c
2 muutettua tiedostoa jossa 121 lisäystä ja 32 poistoa
  1. 4 19
      application/admin/view/kfonitoring/kfjiankong.html
  2. 117 13
      application/common/KfjkLogic.php

+ 4 - 19
application/admin/view/kfonitoring/kfjiankong.html

@@ -63,7 +63,7 @@
                 <div class="example">
                     <table id="cusTable">
                         <thead>
-                        <th data-field="uid">客服</th>
+                        <th data-field="uidname">客服</th>
                         <th data-field="hhl">会话量</th>
                         <th data-field="jdl">接待量</th>
                         <th data-field="pjhysc">平均会话时长</th>
@@ -71,7 +71,7 @@
                         <th data-field="mydl">满意度率</th>
                         <th data-field="pjxysc">平均响应时长</th>
                         <th data-field="jrxxsc">今日休息时长</th>
-                        <th data-field="">发消息</th>
+                        <th data-field="fxx">发消息</th>
                         </thead>
                     </table>
                 </div>
@@ -135,23 +135,8 @@
         $("#search").bind("click", initTable);
     });
 
-    function Del(id) {
-        layer.confirm('确认删除记录?', {icon: 3, title: '提示'}, function (index) {
-            //do something
-            $.getJSON("{:url('kfnotice/del')}", {'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);
-        })
+    function msg(id) {
+        
     }
 </script>
 </body>

+ 117 - 13
application/common/KfjkLogic.php

@@ -42,17 +42,26 @@ class KfjkLogic
         $kfuidarray_index = kftoKey($kfuidarray, 1);
 
         $uids = $kfuidarray;
+        $uidsname = $this->uidName($kfuidarray);
         $hyl = $this->hyl($kfuidarray, $todayall);
         $jdl = $this->jdl($kfuidarray, $todayall);
         $pjhysc = $this->pjhusc($kfuidarray, $todayall);
         $cpl = $this->cpl($kfuidarray, $todayall);
+        $mydl = $this->mydl($kfuidarray, $todayall);
+        $pjxysc = $this->pjxysc($kfuidarray, $todayall);
+        $jrxxsc = $this->jrxxsc($kfuidarray, $todayall);
 
         foreach ($kfuidarray_index as $uid => $val) {
             $kfuidarray_index[$uid]['uid'] = $uids[$uid];
+            $kfuidarray_index[$uid]['uidname'] = $uidsname[$uid];
             $kfuidarray_index[$uid]['hhl'] = $hyl[$uid];
             $kfuidarray_index[$uid]['jdl'] = $jdl[$uid];
             $kfuidarray_index[$uid]['pjhysc'] = $pjhysc[$uid];
             $kfuidarray_index[$uid]['cpl'] = $cpl[$uid];
+            $kfuidarray_index[$uid]['mydl'] = $mydl[$uid];
+            $kfuidarray_index[$uid]['pjxysc'] = $pjxysc[$uid];
+            $kfuidarray_index[$uid]['jrxxsc'] = $jrxxsc[$uid];
+            $kfuidarray_index[$uid]['fxx'] = $this->makeBtn($uid);
         }
 
         $last = [];
@@ -64,6 +73,15 @@ class KfjkLogic
     }
 
 
+    // 生成按钮
+    private function makeBtn($id)
+    {
+        $operate = '<a href="javascript:msg(' . $id . ')"><button type="button" class="btn btn-info btn-sm">';
+        $operate .= '发消息</button></a> ';
+
+        return $operate;
+    }
+
     //按条件获取用户数组 组ID, 在线状态  0为全部
     public function getValiKF($groupid, $onlinestatus)
     {
@@ -79,6 +97,18 @@ class KfjkLogic
         return $return;
     }
 
+    public function  uidName($uidArray){
+        $users = (new Users)->where(['id'=>['IN',$uidArray]])->select();
+        $return = kftoKey($uidArray);
+        foreach ($return as $uid=>$ttttt){
+            foreach ($users as $nowuser){
+                if ($uid == $nowuser['id']){
+                    $return[$uid] = $nowuser['user_name'];
+                }
+            }
+        }
+        return $return ;
+    }
 
     //会话量 统计
     public function hyl($uidArray, $alllogs)
@@ -87,7 +117,7 @@ class KfjkLogic
 
         foreach ($rets as $uid => $aaaa) {
             foreach ($alllogs as $log) {
-                if ($uid == $log['kf_id'] && $log['status'] == 2) {
+                if ($uid == $log['kf_id'] && ($log['status'] == 1  || $log['status'] == 3)) {
                     $rets[$uid]++;
                 }
             }
@@ -118,12 +148,9 @@ class KfjkLogic
 
         foreach ($rets as $uid => $aaa) {
             foreach ($alllogs as $log) {
-                //if ($uid == $log['kf_id'] && $log['status'] == 2) {
                 if ($uid == $log['kf_id']) {
                     (!isset($rets[$uid]['count'])) ? ($rets[$uid]['count'] = 1) : $rets[$uid]['count']++;
-
-                    (!isset($rets[$uid]['times'])) ? ($rets[$uid]['times'] = 0) : ($log['end_time'] - $log['start_time']);
-
+                    (!isset($rets[$uid]['times'])) ? ($rets[$uid]['times'] = 0) : ($rets[$uid]['times'] += (($log['end_time'] ?  $log['end_time'] : $log['start_time']) - $log['start_time']));
                 }
             }
         }
@@ -131,7 +158,7 @@ class KfjkLogic
         $return = [];
         foreach ($rets as $uid => $val) {
             if (isset($rets[$uid]['count'])) {
-                $return[$uid] = $rets[$uid]['times'] / $rets[$uid]['count'];
+                $return[$uid] = intval($rets[$uid]['times'] / $rets[$uid]['count']);
             } else {
                 $return[$uid] = 0;
             }
@@ -144,15 +171,12 @@ class KfjkLogic
     //参评率
     public function cpl($uidArray, $alllogs)
     {
-
         $rets = kftoKey($uidArray, 1);
         foreach ($rets as $uid => $aaa) {
             foreach ($alllogs as $log) {
                 if ($uid == $log['kf_id']) {
-
                     !(isset($rets[$uid]['count'])) ? 1 : $rets[$uid]['count']++;
                     isset($rets[$uid]['pl']) ? ($rets[$uid]['pl'] = ($log['evaluate_id'] > 0 ? 1 : 0)) : 0;
-
                 }
             }
         }
@@ -168,19 +192,99 @@ class KfjkLogic
         return $return;
     }
 
-    public function mydl($kfuid)
+    //满意度率
+    public function mydl($uidArray, $alllogs)
     {
+        $rets = kftoKey($uidArray, 1);
+
+        foreach ($rets as $uid => $aaa) {
+            foreach ($alllogs as $log) {
+                if ($uid == $log['kf_id'] && $log['evaluate_id'] > 0) {
+                    (!isset($rets[$uid]['count'])) ? ($rets[$uid]['count'] = 1) : $rets[$uid]['count']++;
+                    (!isset($rets[$uid]['times'])) ? (($log['evaluate_id'] == 1) ? 1 : 0) : (($log['evaluate_id'] == 1) ? $rets[$uid]['times']++ : '');
+                }
+            }
+        }
+
+        $return = [];
+        foreach ($rets as $uid => $val) {
+            if (isset($rets[$uid]['count']) && isset($rets[$uid]['times'])) {
+                $return[$uid] = $rets[$uid]['times'] / $rets[$uid]['count'];
+            } else {
+                $return[$uid] = 0;
+            }
+        }
+
+        return $return;
 
     }
 
-    public function pjxysc($kfuid)
+    //平均响应时长
+    public function pjxysc($uidArray, $alllogs)
     {
+        $rets = kftoKey($uidArray);
+        if (empty($alllogs)){
+            return $rets ;
+        }
+        $serids =[] ;
+        foreach ($alllogs as $val){
+            $serids[] = $val['servicelog_id'];
+        }
+        $times = Db::name('alarm')->field('alarm_corresponding,servicelog_id')->where(['alarm_respond' => 2,'servicelog_id'=>['IN',$serids]])->select();
+        if ($times){
+            foreach ($alllogs as $key=>$val){
+                foreach ($times as $sval){
+                    if ($val['servicelog_id'] == $sval['servicelog_id']){
+                        $alllogs[$key]['corresponding'] = $sval['alarm_corresponding'];
+                    }
+                }
+            }
+        }
+
+        $rets = kftoKey($uidArray, 1);
+        foreach ($rets as $uid => $aaa) {
+            foreach ($alllogs as $log) {
+                if ($uid == $log['kf_id'] && isset($log['corresponding'])) {
+                    (!isset($rets[$uid]['count'])) ? ($rets[$uid]['count'] = 1) : $rets[$uid]['count']++;
+                    (!isset($rets[$uid]['times'])) ? ($rets[$uid]['times'] = intval($log['corresponding'])) : ($rets[$uid]['times'] += intval($log['corresponding']));
+                }
+            }
+        }
+
+        $return = [];
+        foreach ($rets as $uid => $val) {
+            if (isset($rets[$uid]['count']) && isset($rets[$uid]['times'])) {
+                $return[$uid] = intval($rets[$uid]['times'] / $rets[$uid]['count']);
+            } else {
+                $return[$uid] = 0;
+            }
+        }
 
+        return $return;
     }
 
-    public function jrxxsc($kfuid)
+
+    //今日休息时长统计
+    public function jrxxsc($uidArray, $alllogs)
     {
+        $kfuidarray = array_map(function($i){return 'KF'.$i; },$uidArray);
+        $return = kftoKey($uidArray);
+        $rets = kftoKey($uidArray, 1);
+        $today =date("Y-m-d");
+        $ret = Db::name('kfstatetimes')->field('kfuid,stime')->where(['sday'=>$today,'kfuid'=>['IN',$kfuidarray],'kstatus'=>3])->select();
+        if (!$ret){
+            return $return;
+        }
 
+        foreach ($return as $uid=>$ttttt){
+            foreach ($ret as $val){
+                $ruid = trim($val['kfuid'],'KF');
+                if ($uid == $ruid){
+                    $return[$uid] = $val['stime'];
+                }
+            }
+        }
+        return $return ;
     }
 
     public function getTodayServiceData($kfuidArray = [])
@@ -188,7 +292,7 @@ class KfjkLogic
         $today_begin = strtotime(date("Y-m-d"));
         $today_end = $today_begin + 86400;
 
-        $filds = "group_id,kf_id,user_id,status,start_time,intime,end_time,evaluate_id";
+        $filds = "servicelog_id,group_id,kf_id,user_id,status,start_time,intime,end_time,evaluate_id";
         if ($kfuidArray) {
             $ret = Db::name('service_log')->field($filds)->where(['start_time' => ['>=', $today_begin], 'kf_id' => ['IN', $kfuidArray]])->where(['start_time' => ['<', $today_end]])->select();
         } else {