allkef($erwh = array(), $field = 'service_id,service_name');//所有客服 if(request()->isPost()){ $lyaddtime = $_POST['lyaddtime']; }else{ $lyaddtime = 0; } if($lyaddtime==1){ $kstime = strtotime(date("Y-m-d 23:59:59",strtotime("-3 day"))); }elseif($lyaddtime==2){ $kstime = strtotime(date("Y-m-d 23:59:59",strtotime("-1 week"))); }elseif($lyaddtime==3){ $kstime = strtotime(date("Y-m-d",strtotime("-1 month"))); }else{ $kstime = "1546272000"; } $endtime = TIMESTAMP; if (input('post.kstime')) { $kstime = strtotime(input('post.kstime')); } if (input('post.endtime')) { $endtime = strtotime(input('post.endtime')); } $readok = input('post.record_readok'); $uid = input('post.record_uid'); $condition = array(); $condition['create_time'] = array('between', array($kstime, $endtime)); if($readok){ $condition['sid'] = $readok; } if($uid){ $condition['uid'] = $uid; } $record_list = $model_chatlog->getChatlogList($condition, '*', 10); if($record_list){ for ($i=0; $i < count($record_list); $i++) { $where[' log_id'] = $record_list[$i]["id"]; $list[] = db('chat_message')->field('id,create_time,from')->where($where)->select(); } if(!empty($list)){ for ($ii=0; $ii < count($list); $ii++) { for ($ie=0; $ie < count($list[$ii]); $ie++) { $who['id'] = $list[$ii][$ie]["id"]; $cjtime[] = date("Y-m-d H:i:s",$list[$ii][$ie]["create_time"]); $conlist[] = db('chat_message_content')->where($who)->find(); } } } $this->assign('conlist',$conlist); //所属公司 for ($i=0; $i < count($record_list); $i++) { $ere['member_id'] = $record_list[$i]["uid"]; $gslist[] = db('member')->field('member_name')->where($ere)->find(); } $this->assign('gslist',$gslist); //所属客服 for ($i=0; $i < count($record_list); $i++) { $sere['service_id'] = $record_list[$i]["sid"]; $kflist[] = db('service')->field('service_name')->where($sere)->find(); } $this->assign('kflist',$kflist); } $allgs = Model('member')->allcompany(''); $allpower = $this->qxhans(); $this->assign('allgs',$allgs); $this->assign('allpower',$allpower); $this->assign('record_list', $record_list); $this->assign('lyaddtime',$lyaddtime); $this->assign('endtime',$endtime); $this->assign('kstime',$kstime); $this->assign('show_page', $model_chatlog->page_info->render()); $this->assign('allkf',$allkf); $this->setAdminCurItem('index'); return $this->fetch(); } //客服下的访问客户 public function kfvisitor(){ $pid = $_GET['uid'];//客服id $kflist = model('Chatlog'); $visitorlist = $kflist->allvisitor($pid); echo json_encode($visitorlist); } //客服客户聊天内容 public function chatcontent(){ $sid = $_GET['forWhat'];//客服id $kname = $_GET['kname'];//客户名 $type = $_GET['type']; $choicetime = $_GET['choicetime']; if($type=="nearWeek"){ $begin = strtotime(date('Y-m-d', strtotime('-7 days'))); }else{ $begin = strtotime("-0 year -1 month -0 day"); } $end = TIMESTAMP; if(!empty($choicetime)){ $gap = explode(' - ', $choicetime); $begin = strtotime($gap[0]); $end = strtotime($gap[1]); } $ltlist = model('Chatlog'); $ltjt = $ltlist->chatdata($begin,$end,$kname,$sid); if($ltjt){ for ($i=0; $i < count($ltjt); $i++) { $where[' log_id'] = $ltjt[$i]["id"]; $list[] = db('chat_message')->field('id,create_time,from')->where($where)->select(); } if(!empty($list)){ for ($i=0; $i < count($list); $i++) { for ($ie=0; $ie < count($list[$i]); $ie++) { $who['id'] = $list[$i][$ie]["id"]; $cjtime[] = date("Y-m-d H:i:s",$list[$i][$ie]["create_time"]); $conlist[] = db('chat_message_content')->where($who)->find(); } } } } if(!empty($cjtime) && !empty($conlist) && !empty($kname)){ $array = array( 'list'=>$list, 'cjtime'=>$cjtime, 'conlist'=>$conlist, 'kname'=>$kname, ); }else{ $array = array( 'list'=>'', 'cjtime'=>'', 'conlist'=>'', 'kname'=>'', ); } echo json_encode($array); } protected function getAdminItemList() { $menu_array = array( array( 'name' => 'index', 'text' => lang('ds_manage'), 'url' => url('jobcv/index') ) ); return $menu_array; } } ?>