isPost()){ $param = input('post.'); if(empty($param['word'])){ return json(['code' => -1, 'data' => '', 'msg' => '回复内容不能为空']); } try{ db('reply')->where('id', 1)->update($param); }catch(\Exception $e){ return json(['code' => -2, 'data' => '', 'msg' => $e->getMessage()]); } return json(['code' => 1, 'data' => '', 'msg' => '设置成功']); } $info = db('reply')->where('id', 1)->find(); $this->assign([ 'info' => $info, 'status' => config('kf_status') ]); return $this->fetch(); } // 客服设置 public function customerService() { if(request()->isPost()){ $param = input('post.'); db('kf_config')->where('id', 1)->update($param); return json(['code' => 1, 'data' => '', 'msg' => '设置成功']); } $this->assign([ 'config' => db('kf_config')->where('id', 1)->find(), 'status' => config('kf_status') ]); return $this->fetch(); } // 历史会话记录 public function wordsLog() { if(request()->isAjax()){ $param = input('param.'); $limit = $param['pageSize']; $offset = ($param['pageNumber'] - 1) * $limit; // 默认显示最近7天 $start = input('param.start'); $end = input('param.end'); $temp = db('chat_log'); $countTmp = db('chat_log'); if(!empty($param['searchText'])){ $temp = $temp->where('from_name', $param['searchText'])->whereOr('to_name', $param['searchText']); $countTmp = $countTmp->where('from_name', $param['searchText'])->whereOr('to_name', $param['searchText']); } if(!empty($start) && !empty($end) && $start <= $end){ $temp = $temp->whereBetween('start_time', [strtotime($start), strtotime($end . ' 23:59:59')]); $countTmp = $countTmp->whereBetween('start_time', [strtotime($start), strtotime($end . ' 23:59:59')]); } $result = $temp->limit($offset, $limit)->order('id', 'desc')->select(); foreach($result as $key=>$vo){ $result[$key]['start_time'] = date('Y-m-d H:i:s', $vo['start_time']); $result[$key]['end_time'] = date('Y-m-d H:i:s', $vo['time_line']); } $return['total'] = $countTmp->count(); //总数据 $return['rows'] = $result; return json($return); } return $this->fetch(); } }