|
|
@@ -2,6 +2,7 @@
|
|
|
namespace app\admin\controller;
|
|
|
|
|
|
use app\admin\model\Office;
|
|
|
+use think\cache\driver\Redis;
|
|
|
|
|
|
/**
|
|
|
* 管理系统系统设置类
|
|
|
@@ -30,19 +31,22 @@ class System extends Base
|
|
|
if (empty($param['logo_img']) === false) {
|
|
|
$updateinfo['logo'] = $param['logo_img'];
|
|
|
}
|
|
|
+ $updateinfo['enterprise_name'] = $param['enterprise_name'];
|
|
|
|
|
|
$updateAstData['advertisement_url'] = $param['advertisementUrl'];
|
|
|
$updateAstData['advertisement_status'] = $param['status'];
|
|
|
model('Advertisement')->updateAst($updateAstData);
|
|
|
- // 修改系统欢迎语.
|
|
|
+ /*// 修改系统欢迎语.
|
|
|
$updateSysData['word'] = $param['systemWord'];
|
|
|
$updateSysWhere['id'] = 1;
|
|
|
- model('Reply')->updateReply($updateSysWhere, $updateSysData);
|
|
|
+ model('Reply')->updateReply($updateSysWhere, $updateSysData);*/
|
|
|
// 修改客服欢迎语.
|
|
|
$updateSevData['word'] = $param['serverWord'];
|
|
|
$updateSevWhere['id'] = 2;
|
|
|
model('Reply')->updateReply($updateSevWhere, $updateSevData);
|
|
|
- db('settings')->where('id',1)->update($updateinfo);
|
|
|
+ if(!empty($updateinfo)){
|
|
|
+ db('settings')->where('id',1)->update($updateinfo);
|
|
|
+ }
|
|
|
return json(['code' => 1, 'data' => '', 'msg' => '设置成功']);
|
|
|
} catch (\Exception $e) {
|
|
|
return json(['code' => -2, 'data' => '', 'msg' => $e->getMessage()]);
|
|
|
@@ -51,9 +55,9 @@ class System extends Base
|
|
|
|
|
|
// 获取广告.
|
|
|
$advertisement = model('Advertisement')->findAst();
|
|
|
- // 获取系统欢迎语.
|
|
|
+ /*// 获取系统欢迎语.
|
|
|
$replySystemWhere['id'] = 1;
|
|
|
- $replySystem = model('Reply')->findReply($replySystemWhere);
|
|
|
+ $replySystem = model('Reply')->findReply($replySystemWhere);*/
|
|
|
// 获取客服欢迎语.
|
|
|
$replyServerWhere['id'] = 2;
|
|
|
$replyServer = model('Reply')->findReply($replyServerWhere);
|
|
|
@@ -62,9 +66,10 @@ class System extends Base
|
|
|
$this->assign(
|
|
|
[
|
|
|
'advertisement' => $advertisement,
|
|
|
- 'replySystem' => $replySystem,
|
|
|
+ //'replySystem' => $replySystem,
|
|
|
'replyServer' => $replyServer,
|
|
|
'settings' => $settings,
|
|
|
+ 'socket' => config('socket'),
|
|
|
'status' => config('kf_status'),
|
|
|
]
|
|
|
);
|
|
|
@@ -73,6 +78,117 @@ class System extends Base
|
|
|
|
|
|
}//end basics()
|
|
|
|
|
|
+ /**
|
|
|
+ * 系统欢迎语
|
|
|
+ *
|
|
|
+ * @access public
|
|
|
+ */
|
|
|
+ public function welcoming()
|
|
|
+ {
|
|
|
+ if (request()->isAjax()) {
|
|
|
+ $replySystemWhere['type'] = 1;
|
|
|
+ $result = model('Reply')->selectReply($replySystemWhere);
|
|
|
+ foreach($result as $key=>$vo){
|
|
|
+ // 生成操作按钮
|
|
|
+ $result[$key]['operate'] = $this->makeBotton($vo['id']);
|
|
|
+ $result[$key]['word'] = htmlspecialchars_decode($vo['word']);
|
|
|
+ }
|
|
|
+ $return['rows'] = $result;
|
|
|
+ return json($return);
|
|
|
+ }
|
|
|
+ $this->assign([
|
|
|
+ 'socket' => config('socket'),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ return $this->fetch();
|
|
|
+
|
|
|
+ }//end welcoming()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改系统欢迎语
|
|
|
+ *
|
|
|
+ * @access public
|
|
|
+ */
|
|
|
+ public function editWelcome()
|
|
|
+ {
|
|
|
+ if(request()->isAjax()){
|
|
|
+ $param = input('post.');
|
|
|
+ $where['id'] = $param['id'];
|
|
|
+ $data['sort'] = $param['sort'];
|
|
|
+ $data['word'] = htmlspecialchars($param['word']);
|
|
|
+
|
|
|
+ try{
|
|
|
+ model('Reply')->updateReply($where, $data);
|
|
|
+ }catch(\Exception $e){
|
|
|
+ return json(['code' => -2, 'data' => '', 'msg' => $e->getMessage()]);
|
|
|
+ }
|
|
|
+
|
|
|
+ return json(['code' => 1, 'data' => '', 'msg' => '编辑成功']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $id = input('param.id');
|
|
|
+ $replySystemWhere['id'] = $id;
|
|
|
+ $replySystem = model('Reply')->findReply($replySystemWhere);
|
|
|
+
|
|
|
+ $this->assign([
|
|
|
+ 'replySystem' => $replySystem,
|
|
|
+ 'socket' => config('socket'),
|
|
|
+ ]);
|
|
|
+ return $this->fetch('editwelcome');
|
|
|
+
|
|
|
+ }//end editWelcome()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增系统欢迎语
|
|
|
+ *
|
|
|
+ * @access public
|
|
|
+ */
|
|
|
+ public function delWelcome()
|
|
|
+ {
|
|
|
+ if (request()->isAjax()) {
|
|
|
+ $id = input('param.id');
|
|
|
+ $where['id'] = $id;
|
|
|
+
|
|
|
+ try {
|
|
|
+ model('Reply')->delReply($where);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return json(['code' => -1, 'data' => '', 'msg' => $e->getMessage()]);
|
|
|
+ }
|
|
|
+
|
|
|
+ return json(['code' => 1, 'data' => '', 'msg' => '删除成功']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增系统欢迎语
|
|
|
+ *
|
|
|
+ * @access public
|
|
|
+ */
|
|
|
+ public function addWelcome()
|
|
|
+ {
|
|
|
+ if(request()->isAjax()){
|
|
|
+ $param = input('post.');
|
|
|
+ $data['sort'] = $param['sort'];
|
|
|
+ $data['word'] = htmlspecialchars($param['word']);
|
|
|
+ $data['status'] = 1;
|
|
|
+ $data['type'] = 1;
|
|
|
+
|
|
|
+ try{
|
|
|
+ model('Reply')->addReply($data);
|
|
|
+ }catch(\Exception $e){
|
|
|
+ return json(['code' => -2, 'data' => '', 'msg' => $e->getMessage()]);
|
|
|
+ }
|
|
|
+
|
|
|
+ return json(['code' => 1, 'data' => '', 'msg' => '新增成功']);
|
|
|
+ }
|
|
|
+ $this->assign([
|
|
|
+ 'socket' => config('socket'),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ return $this->fetch('addwelcome');
|
|
|
+
|
|
|
+ }//end addWelcome()
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 会话设置
|
|
|
@@ -87,12 +203,14 @@ class System extends Base
|
|
|
|
|
|
try {
|
|
|
// 修改会话超时.
|
|
|
- $updateOvertimeData['systemconfig_data'] = $param['overtime'];
|
|
|
- $updateOvertimeWhere['systemconfig_id'] = 1;
|
|
|
+ $updateOvertimeData['systemconfig_data'] = $param['overtime'];
|
|
|
+ $updateOvertimeData['systemconfig_content'] = $param['overtimeInfo'];
|
|
|
+ $updateOvertimeWhere['systemconfig_id'] = 1;
|
|
|
model('Systemconfig')->updateSystemconfig($updateOvertimeWhere, $updateOvertimeData);
|
|
|
// 修改访客静默.
|
|
|
- $upUptdData['systemconfig_data'] = $param['unoperated'];
|
|
|
- $upUptdWhere['systemconfig_id'] = 2;
|
|
|
+ $upUptdData['systemconfig_data'] = $param['unoperated'];
|
|
|
+ $upUptdData['systemconfig_content'] = $param['unoperatedInfo'];
|
|
|
+ $upUptdWhere['systemconfig_id'] = 2;
|
|
|
model('Systemconfig')->updateSystemconfig($upUptdWhere, $upUptdData);
|
|
|
// 质检会话时长设置.
|
|
|
$upAllTimeData['systemconfig_data'] = $param['verifyAllTime'];
|
|
|
@@ -107,9 +225,13 @@ class System extends Base
|
|
|
$upRoundWhere['systemconfig_id'] = 5;
|
|
|
model('Systemconfig')->updateSystemconfig($upRoundWhere, $upRoundData);
|
|
|
// 客服接待人数设置.
|
|
|
- $upKfConfigData['max_service'] = $param['max_service'];
|
|
|
- $upKfConfigData['kfConfig_maxWait'] = $param['kfConfig_maxWait'];
|
|
|
- db('kf_config')->where('id', 1)->update($upKfConfigData);
|
|
|
+ $upMSWhere['systemconfig_enName'] = 'KFMaxServices';
|
|
|
+ $upMSData['systemconfig_data'] = $param['max_service'];
|
|
|
+ model('Systemconfig')->updateSystemconfig($upMSWhere, $upMSData);
|
|
|
+ // 最大排队人数设置.
|
|
|
+ $upMWWhere['systemconfig_enName'] = 'maxWait';
|
|
|
+ $upMWData['systemconfig_data'] = $param['kfConfig_maxWait'];
|
|
|
+ model('Systemconfig')->updateSystemconfig($upMWWhere, $upMWData);
|
|
|
|
|
|
return json(['code' => 1, 'data' => '', 'msg' => '设置成功']);
|
|
|
} catch (\Exception $e) {
|
|
|
@@ -119,12 +241,11 @@ class System extends Base
|
|
|
|
|
|
// 获取设置.
|
|
|
$systemconfig = model('Systemconfig')->selectSystemconfig();
|
|
|
- $kfConfig = db('kf_config')->where('id', 1)->find();
|
|
|
$this->assign(
|
|
|
[
|
|
|
'systemconfig' => $systemconfig,
|
|
|
- 'kfConfig' => $kfConfig,
|
|
|
'status' => config('kf_status'),
|
|
|
+ 'socket' => config('socket'),
|
|
|
]
|
|
|
);
|
|
|
|
|
|
@@ -155,6 +276,7 @@ class System extends Base
|
|
|
$info = db('reply')->where('id', 1)->find();
|
|
|
$this->assign([
|
|
|
'info' => $info,
|
|
|
+ 'socket' => config('socket'),
|
|
|
'status' => config('kf_status')
|
|
|
]);
|
|
|
|
|
|
@@ -164,22 +286,18 @@ class System extends Base
|
|
|
// 历史会话记录
|
|
|
public function wordsLog()
|
|
|
{
|
|
|
- $toExcel = input('param.toExcel', 0);
|
|
|
+// $toExcel = input('param.toExcel', 0);
|
|
|
|
|
|
if(request()->isAjax()){
|
|
|
-
|
|
|
$param = input('param.');
|
|
|
-
|
|
|
$limit = $param['pageSize'];
|
|
|
$offset = ($param['pageNumber'] - 1) * $limit;
|
|
|
-
|
|
|
// 默认显示最近7天
|
|
|
$start = input('param.start');
|
|
|
$end = input('param.end');
|
|
|
|
|
|
$user_id = input('param.user_id');
|
|
|
$group_id = input('param.group_id');
|
|
|
-
|
|
|
$temp = db('service_log');
|
|
|
$countTmp = db('service_log');
|
|
|
if(strlen($param['searchText'])){
|
|
|
@@ -195,18 +313,13 @@ class System extends Base
|
|
|
//结束时间为空
|
|
|
if(!empty($start) && empty($end)){
|
|
|
$temp = $temp->where('start_time','>',strtotime($start));
|
|
|
- $countTmp = $temp->where('start_time','>',strtotime($start));
|
|
|
+ $countTmp = $countTmp->where('start_time','>',strtotime($start));
|
|
|
}
|
|
|
//开始时间为空
|
|
|
if(empty($start) && !empty($end)){
|
|
|
$temp = $temp->where('start_time','<',strtotime($end . ' 23:59:59'));
|
|
|
- $countTmp = $temp->where('start_time','<',strtotime($end . ' 23:59:59'));
|
|
|
+ $countTmp = $countTmp->where('start_time','<',strtotime($end . ' 23:59:59'));
|
|
|
}
|
|
|
- //开始时间/结束时间都为空(默认查七天)
|
|
|
-// if(empty($start) && empty($end)){
|
|
|
-// $temp = $temp->where('start_time','<',time())->where('start_time','>',time()-604800);
|
|
|
-// $countTmp = $temp->where('start_time','<',time())->where('start_time','>',time()-604800);
|
|
|
-// }
|
|
|
|
|
|
//客服
|
|
|
if($user_id != 0){
|
|
|
@@ -217,7 +330,7 @@ class System extends Base
|
|
|
//客服组
|
|
|
if($group_id != 0){
|
|
|
$temp = $temp->where('group_id', $group_id);
|
|
|
- $countTmp = $temp->where('group_id', $group_id);
|
|
|
+ $countTmp = $countTmp->where('group_id', $group_id);
|
|
|
}
|
|
|
|
|
|
$result = $temp->limit($offset, $limit)->order('start_time', 'desc')->select();
|
|
|
@@ -233,16 +346,55 @@ class System extends Base
|
|
|
foreach($result as $key=>$vo){
|
|
|
if($result[$key]['intime'] != 0){
|
|
|
$result[$key]['intime'] = date('Y-m-d H:i:s', $vo['intime']);
|
|
|
+
|
|
|
+ $date = explode(' ',$result[$key]['intime']);
|
|
|
+ $year = explode('-',$result[$key]['intime']);
|
|
|
+ if($date[0] == date('Y-m-d',time())){
|
|
|
+ $result[$key]['intime'] = '<span style="float: right;">'.$date[1].'</span>';
|
|
|
+ }else if($date[0] == date('Y-m-d',strtotime("-1 day"))){
|
|
|
+ $result[$key]['intime'] = '<span style="float: right;">'.'昨天 '.$date[1].'</span>';
|
|
|
+ }else{
|
|
|
+ if($year[0] == date('Y',time())){
|
|
|
+ $result[$key]['intime'] = '<span style="float: right;">'.date('m-d H:i:s',strtotime($result[$key]['intime'])).'</span>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}else{
|
|
|
$result[$key]['intime'] = '-';
|
|
|
}
|
|
|
if($result[$key]['start_time'] != 0){
|
|
|
$result[$key]['start_time'] = date('Y-m-d H:i:s', $vo['start_time']);
|
|
|
+
|
|
|
+ $date = explode(' ',$result[$key]['start_time']);
|
|
|
+ $year = explode('-',$result[$key]['start_time']);
|
|
|
+ if($date[0] == date('Y-m-d',time())){
|
|
|
+ $result[$key]['start_time'] = '<span style="float: right;">'.$date[1].'</span>';
|
|
|
+ }else if($date[0] == date('Y-m-d',strtotime("-1 day"))){
|
|
|
+ $result[$key]['start_time'] = '<span style="float: right;">'.'昨天 '.$date[1].'</span>';
|
|
|
+ }else{
|
|
|
+ if($year[0] == date('Y',time())){
|
|
|
+ $result[$key]['start_time'] = '<span style="float: right;">'.date('m-d H:i:s',strtotime($result[$key]['start_time'])).'</span>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}else{
|
|
|
$result[$key]['start_time'] = '-';
|
|
|
}
|
|
|
if($result[$key]['end_time'] != 0){
|
|
|
$result[$key]['end_time'] = date('Y-m-d H:i:s', $vo['end_time']);
|
|
|
+
|
|
|
+ $date = explode(' ',$result[$key]['end_time']);
|
|
|
+ $year = explode('-',$result[$key]['end_time']);
|
|
|
+ if($date[0] == date('Y-m-d',time())){
|
|
|
+ $result[$key]['end_time'] = '<span style="float: right;">'.$date[1].'</span>';
|
|
|
+ }else if($date[0] == date('Y-m-d',strtotime("-1 day"))){
|
|
|
+ $result[$key]['end_time'] = '<span style="float: right;">'.'昨天 '.$date[1].'</span>';
|
|
|
+ }else{
|
|
|
+ if($year[0] == date('Y',time())){
|
|
|
+ $result[$key]['end_time'] = '<span style="float: right;">'.date('m-d H:i:s',strtotime($result[$key]['end_time'])).'</span>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}else{
|
|
|
$result[$key]['end_time'] = '-';
|
|
|
}
|
|
|
@@ -285,10 +437,10 @@ class System extends Base
|
|
|
$result[$key]['servicelog_close_type'] = '未知';
|
|
|
}
|
|
|
if($vo['servicelog_close_type'] == 1){
|
|
|
- $result[$key]['servicelog_close_type'] = '访客静默';
|
|
|
+ $result[$key]['servicelog_close_type'] = '无效会话';
|
|
|
}
|
|
|
if($vo['servicelog_close_type'] == 2){
|
|
|
- $result[$key]['servicelog_close_type'] = '会话超时';
|
|
|
+ $result[$key]['servicelog_close_type'] = '双方静默';
|
|
|
}
|
|
|
if($vo['servicelog_close_type'] == 3){
|
|
|
$result[$key]['servicelog_close_type'] = '客服关闭';
|
|
|
@@ -297,7 +449,10 @@ class System extends Base
|
|
|
$result[$key]['servicelog_close_type'] = '客服掉线';
|
|
|
}
|
|
|
if($vo['servicelog_close_type'] == 5){
|
|
|
- $result[$key]['servicelog_close_type'] = '转接';
|
|
|
+ $result[$key]['servicelog_close_type'] = '转出';
|
|
|
+ }
|
|
|
+ if($vo['servicelog_close_type'] == 6){
|
|
|
+ $result[$key]['servicelog_close_type'] = '用户关闭';
|
|
|
}
|
|
|
|
|
|
// 生成操作按钮
|
|
|
@@ -309,14 +464,14 @@ class System extends Base
|
|
|
$return['total'] = $countTmp->count(); //总数据
|
|
|
$return['rows'] = $result;
|
|
|
|
|
|
- if (!$toExcel) {
|
|
|
- return json($return);
|
|
|
- } else {
|
|
|
- $head = ['工单id', '访客进线时间', '接待客服', '所在组', '访客账号', '开始时间', '结束时间', '会话时长', '响应时长', '关闭原因', '满意度'];
|
|
|
- $key = ['servicelog_id', 'intime', 'kefu_name', 'group_name', 'user_name', 'start_time', 'end_time', 'conversation', 'response', 'servicelog_close_type', 'evaluate_name'];
|
|
|
- (new Office())->outdata('工作报表数据导出', $result, $head, $key);
|
|
|
- return true;
|
|
|
- }
|
|
|
+// if (!$toExcel) {
|
|
|
+// return json($return);
|
|
|
+// } else {
|
|
|
+// $head = ['工单id', '访客进线时间', '接待客服', '所在组', '访客账号', '开始时间', '结束时间', '会话时长', '响应时长', '关闭原因', '满意度'];
|
|
|
+// $key = ['servicelog_id', 'intime', 'kefu_name', 'group_name', 'user_name', 'start_time', 'end_time', 'conversation', 'response', 'servicelog_close_type', 'evaluate_name'];
|
|
|
+// (new Office())->outdata('工作报表数据导出', $result, $head, $key);
|
|
|
+// return true;
|
|
|
+// }
|
|
|
|
|
|
return json($return);
|
|
|
|
|
|
@@ -329,7 +484,7 @@ class System extends Base
|
|
|
for($i=0;$i<count($users);$i++){
|
|
|
$option = $option.'<option value="'.$users[$i]['id'].'">'.$users[$i]['user_name'].'</option>';
|
|
|
}
|
|
|
- $useroption = '<select lay-verify="required" lay-filter="user_id">'.$option.'</select>';
|
|
|
+ $useroption = '<select class="selector_user" lay-verify="required" lay-filter="user_id" style="height: 30px;">'.$option.'</select>';
|
|
|
}
|
|
|
//所有客服组
|
|
|
$groups = db('groups')->select();
|
|
|
@@ -339,7 +494,7 @@ class System extends Base
|
|
|
for($j=0;$j<count($groups);$j++){
|
|
|
$option = $option.'<option value="'.$groups[$j]['id'].'">'.$groups[$j]['name'].'</option>';
|
|
|
}
|
|
|
- $groupoption = '<select lay-verify="required" lay-filter="group_id">'.$option.'</select>';
|
|
|
+ $groupoption = '<select class="selector_group" lay-verify="required" lay-filter="group_id" style="height: 30px;">'.$option.'</select>';
|
|
|
}
|
|
|
|
|
|
$this->assign([
|
|
|
@@ -360,7 +515,7 @@ class System extends Base
|
|
|
}
|
|
|
|
|
|
// 历史会话记录详情
|
|
|
- public function detail($id)
|
|
|
+ public function detail($id, $type='')
|
|
|
{
|
|
|
$chat = db('chat_log')->where('servicelog_id',$id)->order('time_line')->select();
|
|
|
$html = '';
|
|
|
@@ -368,7 +523,7 @@ class System extends Base
|
|
|
$content = json_decode($chat[$i]['content'], true);
|
|
|
$chat[$i]['time_line'] = date('H:i',$chat[$i]['time_line']);
|
|
|
if(!empty($content['text'])){
|
|
|
- $content['content'] = $content['text'];
|
|
|
+ $content['content'] = '  '.$content['text'].'  ';
|
|
|
}
|
|
|
if(!empty($content['img'])){
|
|
|
$content['content'] = '<img width="100%" src="'.$content['img'].'"/>';
|
|
|
@@ -388,13 +543,22 @@ class System extends Base
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- $servicelog = db('service_log')->where('servicelog_id',$id)->find();
|
|
|
+ $redis = new Redis;
|
|
|
+ if ($type === 'onLine') {
|
|
|
+ $servicelog = json_decode($redis->handler()->Hget('SERVICELOG', $id), true);
|
|
|
+ } else {
|
|
|
+ $servicelog = db('service_log')->where('servicelog_id',$id)->find();
|
|
|
+ }
|
|
|
//满意度
|
|
|
$evaluate = db('evaluate')->where('evaluate_id',$servicelog['evaluate_id'])->find();
|
|
|
$evaluate = '<img width="40px" style="margin-top:15px;" src="'.$evaluate['evaluate_url'].'"/>';
|
|
|
|
|
|
//$alarm报警信息
|
|
|
- $alarm = db('alarm')->where('servicelog_id',$id)->find();
|
|
|
+ if ($type === 'onLine') {
|
|
|
+ $alarm = json_decode($redis->handler()->Hget('SERVICELOG', $id), true);
|
|
|
+ } else {
|
|
|
+ $alarm = db('alarm')->where('servicelog_id',$id)->find();
|
|
|
+ }
|
|
|
|
|
|
//会话超时标准
|
|
|
$verifyAllTime = db('systemconfig')->where('systemconfig_name','质检会话时长设置')->find();
|
|
|
@@ -417,6 +581,9 @@ class System extends Base
|
|
|
if($alarm['alarm_respond'] == 1){
|
|
|
$span = $span . '<span class="alarm_info">客服未回应</span>';
|
|
|
}
|
|
|
+ if($alarm['alarm_count'] == 0 && $type !== 'onLine'){
|
|
|
+ $span = $span . '<span class="alarm_info">会话无内容</span>';
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//用户信息
|
|
|
@@ -437,7 +604,8 @@ class System extends Base
|
|
|
private function makeBtn($id)
|
|
|
{
|
|
|
$operate = '<a href="' . url('system/detail', ['id' => $id]) . '">';
|
|
|
- $operate .= '<button type="button" class="btn btn-primary btn-sm"><i class="fa fa-paste"></i> 详情</button></a> ';
|
|
|
+// $operate .= '<button type="button" class="btn btn-primary btn-sm"><i class="fa fa-paste"></i> 详情</button></a> ';
|
|
|
+ $operate .= '<button type="button" class="btn btn-primary btn-sm"> 详情</button></a> ';
|
|
|
|
|
|
return $operate;
|
|
|
}
|
|
|
@@ -454,16 +622,21 @@ class System extends Base
|
|
|
return $key;
|
|
|
}
|
|
|
|
|
|
+ //导出数据
|
|
|
public function toexcel()
|
|
|
{
|
|
|
$param = input('param.');
|
|
|
+
|
|
|
+ $limit = $param['pageSize'];
|
|
|
+ $offset = ($param['pageNumber'] - 1) * $limit;
|
|
|
+
|
|
|
$start = $param['start'];
|
|
|
$end = $param['end'];
|
|
|
$where = [];
|
|
|
- if(!empty($param['user_id'])){
|
|
|
- $where['user_id'] = $param['user_id'];
|
|
|
+ if($param['user_id'] != 0){
|
|
|
+ $where['kf_id'] = $param['user_id'];
|
|
|
}
|
|
|
- if(!empty($param['group_id'])){
|
|
|
+ if($param['group_id'] != 0){
|
|
|
$where['group_id'] = $param['group_id'];
|
|
|
}
|
|
|
if(!empty($param['username'])){
|
|
|
@@ -479,6 +652,33 @@ class System extends Base
|
|
|
$evaluate = db('evaluate')->select();
|
|
|
//$alarm报警信息
|
|
|
$alarm = db('alarm')->select();
|
|
|
+ //会话超时标准
|
|
|
+ $verifyAllTime = db('systemconfig')->where('systemconfig_name','质检会话时长设置')->find();
|
|
|
+ //会话响应时长标准
|
|
|
+ $verifyReturnTime = db('systemconfig')->where('systemconfig_name','质检会话响应时长设置')->find();
|
|
|
+ for($c=0;$c<count($alarm);$c++){
|
|
|
+ $alarm[$c]['alarminfo'] = '';
|
|
|
+ if($alarm[$c]['alarm_userSensitive'] != 0){
|
|
|
+ $alarm[$c]['alarminfo'] .= '访客敏感词/';
|
|
|
+ }
|
|
|
+ if($alarm[$c]['alarm_serverSensitive'] != 0){
|
|
|
+ $alarm[$c]['alarminfo'] .= '客服敏感词/';
|
|
|
+ }
|
|
|
+ if($alarm[$c]['alarm_corresponding'] > $verifyReturnTime['systemconfig_data']){
|
|
|
+ $alarm[$c]['alarminfo'] .= '响应超时/';
|
|
|
+ }
|
|
|
+ if($alarm[$c]['alarm_cvtOvertime'] > $verifyAllTime['systemconfig_data']){
|
|
|
+ $alarm[$c]['alarminfo'] .= '会话超时/';
|
|
|
+ }
|
|
|
+ if($alarm[$c]['alarm_respond'] == 1){
|
|
|
+ $alarm[$c]['alarminfo'] .= '客服未回应/';
|
|
|
+ }
|
|
|
+ if($alarm[$c]['alarm_count'] == 0){
|
|
|
+ $alarm[$c]['alarminfo'] .= '会话无内容';
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
foreach($result as $key=>$vo){
|
|
|
if($result[$key]['intime'] != 0){
|
|
|
$result[$key]['intime'] = date('Y-m-d H:i:s', $vo['intime']);
|
|
|
@@ -495,8 +695,9 @@ class System extends Base
|
|
|
}else{
|
|
|
$result[$key]['end_time'] = '-';
|
|
|
}
|
|
|
- //客服名称
|
|
|
+ //客服昵称
|
|
|
for($i=0;$i<count($users);$i++){
|
|
|
+ $result[$key]['kefu_name'] = '-';
|
|
|
if($result[$key]['kf_id'] == $users[$i]['id']){
|
|
|
$result[$key]['kefu_name'] = $users[$i]['user_name'];
|
|
|
}
|
|
|
@@ -517,9 +718,10 @@ class System extends Base
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //会话时长/响应时长
|
|
|
+ //会话时长/响应时长/报警信息
|
|
|
$result[$key]['conversation'] = '';
|
|
|
$result[$key]['response'] = '';
|
|
|
+ $result[$key]['alarm'] = '';
|
|
|
for($b=0;$b<count($alarm);$b++){
|
|
|
if($result[$key]['servicelog_id'] == $alarm[$b]['servicelog_id']){
|
|
|
//会话时长
|
|
|
@@ -530,6 +732,8 @@ class System extends Base
|
|
|
$response_min = intval($alarm[$b]['alarm_corresponding']/60);
|
|
|
$response_s = $alarm[$b]['alarm_corresponding']%60;
|
|
|
$result[$key]['response'] = $response_min.'分'.$response_s.'秒';
|
|
|
+ //报警信息
|
|
|
+ $result[$key]['alarminfo'] = $alarm[$b]['alarminfo'];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -537,10 +741,10 @@ class System extends Base
|
|
|
$result[$key]['servicelog_close_type'] = '未知';
|
|
|
}
|
|
|
if($vo['servicelog_close_type'] == 1){
|
|
|
- $result[$key]['servicelog_close_type'] = '访客静默';
|
|
|
+ $result[$key]['servicelog_close_type'] = '无效会话';
|
|
|
}
|
|
|
if($vo['servicelog_close_type'] == 2){
|
|
|
- $result[$key]['servicelog_close_type'] = '会话超时';
|
|
|
+ $result[$key]['servicelog_close_type'] = '双方静默';
|
|
|
}
|
|
|
if($vo['servicelog_close_type'] == 3){
|
|
|
$result[$key]['servicelog_close_type'] = '客服关闭';
|
|
|
@@ -549,7 +753,10 @@ class System extends Base
|
|
|
$result[$key]['servicelog_close_type'] = '客服掉线';
|
|
|
}
|
|
|
if($vo['servicelog_close_type'] == 5){
|
|
|
- $result[$key]['servicelog_close_type'] = '转接';
|
|
|
+ $result[$key]['servicelog_close_type'] = '转出';
|
|
|
+ }
|
|
|
+ if($vo['servicelog_close_type'] == 6){
|
|
|
+ $result[$key]['servicelog_close_type'] = '用户关闭';
|
|
|
}
|
|
|
|
|
|
//工单聊天详情
|
|
|
@@ -559,6 +766,7 @@ class System extends Base
|
|
|
$content = json_decode($chat_log[$c]['content'], true);
|
|
|
$chat_log[$c]['time_line'] = date('Y-m-d H:i:s',$chat_log[$c]['time_line']);
|
|
|
$result[$key]['detail'] = $result[$key]['detail'].' '.$chat_log[$c]['time_line'].' '.$chat_log[$c]['from_name'];
|
|
|
+ $content['content'] = '';
|
|
|
if(!empty($content['text'])){
|
|
|
$content['content'] = $content['text'];
|
|
|
}
|
|
|
@@ -569,10 +777,59 @@ class System extends Base
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- $head = ['工单id', '访客进线时间', '接待客服', '所在组', '访客账号', '开始时间', '结束时间', '会话时长', '响应时长', '关闭原因', '满意度','来源ip','来源网站','来源系统','来源浏览器','聊天详情'];
|
|
|
- $key = ['servicelog_id', 'intime', 'kefu_name', 'group_name', 'user_name', 'start_time', 'end_time', 'conversation', 'response', 'servicelog_close_type', 'evaluate_name','user_ip','website','system','browse','detail'];
|
|
|
+ $head = ['工单id', '访客进线时间', '接待客服', '所在组', '访客账号', '开始时间', '结束时间', '会话时长', '响应时长', '关闭原因', '满意度','来源ip','来源网站','来源系统','来源浏览器','报警信息','聊天详情'];
|
|
|
+ $key = ['servicelog_id', 'intime', 'kefu_name', 'group_name', 'user_name', 'start_time', 'end_time', 'conversation', 'response', 'servicelog_close_type', 'evaluate_name','user_ip','website','system','browse','alarminfo','detail'];
|
|
|
(new Office())->outdata('工单数据导出', $result, $head, $key);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ // 生成按钮
|
|
|
+ private function makeBotton($id)
|
|
|
+ {
|
|
|
+ $operate = '<a href="' . url('editWelcome', ['id' => $id]) . '">';
|
|
|
+ $operate .= '<button type="button" class="btn btn-primary btn-sm"><i class="fa fa-paste"></i> 编辑</button></a> ';
|
|
|
+
|
|
|
+ $operate .= '<a href="javascript:delWelcome(' . $id . ')"><button type="button" class="btn btn-danger btn-sm">';
|
|
|
+ $operate .= '<i class="fa fa-trash-o"></i> 删除</button></a> ';
|
|
|
+ return $operate;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证平台设置
|
|
|
+ *
|
|
|
+ * @access public
|
|
|
+ */
|
|
|
+ public function platform()
|
|
|
+ {
|
|
|
+ // 表单提交.
|
|
|
+ if (request()->isPost()) {
|
|
|
+ $param = input('post.');
|
|
|
+
|
|
|
+ try {
|
|
|
+ $updateWhere['platform_code'] = 'Customer-Service';
|
|
|
+ $updateData = [
|
|
|
+ 'platform_url_token' => $param['urlToken'],
|
|
|
+ 'platform_url_code' => $param['urlToken'],
|
|
|
+ ];
|
|
|
+ db('platform')->where($updateWhere)->update($updateData);
|
|
|
+ return json(['code' => 1, 'data' => '', 'msg' => '设置成功']);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return json(['code' => -2, 'data' => '', 'msg' => $e->getMessage()]);
|
|
|
+ }//end try
|
|
|
+ }//end if
|
|
|
+
|
|
|
+ // 信息.
|
|
|
+ $settings = db('platform')->find();
|
|
|
+ $this->assign(
|
|
|
+ [
|
|
|
+ 'urlToken' => $settings['platform_url_token'],
|
|
|
+ 'urlCode' => $settings['platform_url_code'],
|
|
|
+ ]
|
|
|
+ );
|
|
|
+
|
|
|
+ return $this->fetch();
|
|
|
+
|
|
|
+ }//end basics()
|
|
|
+
|
|
|
}
|