|
@@ -69,6 +69,9 @@ class System extends Base
|
|
|
$start = input('param.start');
|
|
$start = input('param.start');
|
|
|
$end = input('param.end');
|
|
$end = input('param.end');
|
|
|
|
|
|
|
|
|
|
+ $user_id = input('param.user_id');
|
|
|
|
|
+ $group_id = input('param.group_id');
|
|
|
|
|
+
|
|
|
$temp = db('service_log');
|
|
$temp = db('service_log');
|
|
|
$countTmp = db('service_log');
|
|
$countTmp = db('service_log');
|
|
|
if(!empty($param['searchText'])){
|
|
if(!empty($param['searchText'])){
|
|
@@ -77,13 +80,51 @@ class System extends Base
|
|
|
$countTmp = $countTmp->where('kf_id', $user['id']);
|
|
$countTmp = $countTmp->where('kf_id', $user['id']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //日期
|
|
|
if(!empty($start) && !empty($end) && $start <= $end){
|
|
if(!empty($start) && !empty($end) && $start <= $end){
|
|
|
$temp = $temp->whereBetween('start_time', [strtotime($start), strtotime($end . ' 23:59:59')]);
|
|
$temp = $temp->whereBetween('start_time', [strtotime($start), strtotime($end . ' 23:59:59')]);
|
|
|
$countTmp = $countTmp->whereBetween('start_time', [strtotime($start), strtotime($end . ' 23:59:59')]);
|
|
$countTmp = $countTmp->whereBetween('start_time', [strtotime($start), strtotime($end . ' 23:59:59')]);
|
|
|
}
|
|
}
|
|
|
|
|
+ //结束时间为空
|
|
|
|
|
+ if(!empty($start) && empty($end)){
|
|
|
|
|
+ $temp = $temp->where('start_time','>',strtotime($start));
|
|
|
|
|
+ $countTmp = $temp->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'));
|
|
|
|
|
+ }
|
|
|
|
|
+ //开始时间/结束时间都为空(默认查七天)
|
|
|
|
|
+ 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){
|
|
|
|
|
+ $temp = $temp->where('kf_id', $user_id);
|
|
|
|
|
+ $countTmp = $countTmp->where('kf_id', $user_id);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //客服组
|
|
|
|
|
+ if($group_id != 0){
|
|
|
|
|
+ $temp = $temp->where('group_id', $group_id);
|
|
|
|
|
+ $countTmp = $temp->where('group_id', $group_id);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
$result = $temp->limit($offset, $limit)->order('start_time', 'desc')->select();
|
|
$result = $temp->limit($offset, $limit)->order('start_time', 'desc')->select();
|
|
|
|
|
+
|
|
|
|
|
+ //所有客服
|
|
|
|
|
+ $users = db('users')->select();
|
|
|
|
|
+ //满意度
|
|
|
|
|
+ $evaluate = db('evaluate')->select();
|
|
|
foreach($result as $key=>$vo){
|
|
foreach($result as $key=>$vo){
|
|
|
|
|
+ if($result[$key]['intime'] != 0){
|
|
|
|
|
+ $result[$key]['intime'] = date('Y-m-d H:i:s', $vo['intime']);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $result[$key]['intime'] = '-';
|
|
|
|
|
+ }
|
|
|
if($result[$key]['start_time'] != 0){
|
|
if($result[$key]['start_time'] != 0){
|
|
|
$result[$key]['start_time'] = date('Y-m-d H:i:s', $vo['start_time']);
|
|
$result[$key]['start_time'] = date('Y-m-d H:i:s', $vo['start_time']);
|
|
|
}else{
|
|
}else{
|
|
@@ -95,12 +136,23 @@ class System extends Base
|
|
|
$result[$key]['end_time'] = '-';
|
|
$result[$key]['end_time'] = '-';
|
|
|
}
|
|
}
|
|
|
//客服名称
|
|
//客服名称
|
|
|
- $kefu = db('users')->where('id', $result[$key]['kf_id'])->find();
|
|
|
|
|
- $result[$key]['kefu_name'] = $kefu['user_name'];
|
|
|
|
|
|
|
+ for($i=0;$i<count($users);$i++){
|
|
|
|
|
+ if($result[$key]['kf_id'] == $users[$i]['id']){
|
|
|
|
|
+ $result[$key]['kefu_name'] = $users[$i]['user_name'];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
//满意度
|
|
//满意度
|
|
|
- $evaluate = db('evaluate')->where('evaluate_id', $result[$key]['evaluate_id'])->find();
|
|
|
|
|
- $result[$key]['evaluate_name'] = $evaluate['evaluate_name'];
|
|
|
|
|
|
|
+ for($j=0;$j<count($evaluate);$j++){
|
|
|
|
|
+ if($result[$key]['evaluate_id'] == $evaluate[$j]['evaluate_id']){
|
|
|
|
|
+ $result[$key]['evaluate_name'] = $evaluate[$j]['evaluate_name'];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 生成操作按钮
|
|
|
|
|
+ if(0 != $vo['servicelog_id']){
|
|
|
|
|
+ $result[$key]['operate'] = $this->makeBtn($vo['servicelog_id']);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$return['total'] = $countTmp->count(); //总数据
|
|
$return['total'] = $countTmp->count(); //总数据
|
|
@@ -109,12 +161,65 @@ class System extends Base
|
|
|
return json($return);
|
|
return json($return);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ //所有客服
|
|
|
$users = db('users')->select();
|
|
$users = db('users')->select();
|
|
|
|
|
+ if(!empty($users)){
|
|
|
|
|
+ $option = '<option value="0">全部客服</option>';
|
|
|
|
|
+ for($i=0;$i<count($users);$i++){
|
|
|
|
|
+ $option = $option.'<option value="'.$users[$i]['id'].'">'.$users[$i]['user_name'].'</option>';
|
|
|
|
|
+ }
|
|
|
|
|
+ $useroption = '<select name="user_id" id="user_id" class="form-control">'.$option.'</select>';
|
|
|
|
|
+ }
|
|
|
|
|
+ //所有客服组
|
|
|
|
|
+ $groups = db('groups')->select();
|
|
|
|
|
+ if(!empty($groups)){
|
|
|
|
|
+ $option = '<option value="0">全部客服组</option>';
|
|
|
|
|
+ for($j=0;$j<count($groups);$j++){
|
|
|
|
|
+ $option = $option.'<option value="'.$groups[$j]['id'].'">'.$groups[$j]['name'].'</option>';
|
|
|
|
|
+ }
|
|
|
|
|
+ $groupoption = '<select name="group_id" id="group_id" class="form-control">'.$option.'</select>';
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
$this->assign([
|
|
$this->assign([
|
|
|
- 'users' => $users
|
|
|
|
|
|
|
+ 'useroption' => $useroption,
|
|
|
|
|
+ 'groupoption' => $groupoption
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
return $this->fetch();
|
|
return $this->fetch();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 历史会话记录详情
|
|
|
|
|
+ public function detail($id)
|
|
|
|
|
+ {
|
|
|
|
|
+ $chat = db('chat_log')->where('servicelog_id',$id)->order('time_line')->select();
|
|
|
|
|
+ $html = '';
|
|
|
|
|
+ for($i=0;$i<count($chat);$i++){
|
|
|
|
|
+ $chat[$i]['time_line'] = date('H:i',$chat[$i]['time_line']);
|
|
|
|
|
+ if(!empty(strstr($chat[$i]['to_id'], 'KF'))){
|
|
|
|
|
+ $html = $html . '<div style="margin-top:15px;width: 30%;"><div>'.$chat[$i]['from_name'].'   '.$chat[$i]['time_line'].'</div>';
|
|
|
|
|
+ $html = $html . '<p style="margin-top:5px;" class="form-content">'.$chat[$i]['content'].'</p></div>';
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $html = $html . '<div style="margin-top:15px;width: 30%;margin-left:70%;text-align:right;"><div>'.$chat[$i]['from_name'].'   '.$chat[$i]['time_line'].'</div>';
|
|
|
|
|
+ $html = $html . '<p style="margin-top:5px;" class="form-content">'.$chat[$i]['content'].'</p></div>';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ $servicelog = db('service_log')->where('servicelog_id',$id)->find();
|
|
|
|
|
+ $evaluate = db('evaluate')->where('evaluate_id',$servicelog['evaluate_id'])->find();
|
|
|
|
|
+ $evaluate = $evaluate['evaluate_name'];
|
|
|
|
|
+ $this->assign([
|
|
|
|
|
+ 'html' => $html,
|
|
|
|
|
+ 'evaluate' => $evaluate
|
|
|
|
|
+ ]);
|
|
|
|
|
+ return $this->fetch();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 生成按钮
|
|
|
|
|
+ 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> ';
|
|
|
|
|
+
|
|
|
|
|
+ return $operate;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|