|
@@ -19,13 +19,38 @@ class Messages extends Base
|
|
|
$offset = ($param['pageNumber'] - 1) * $limit;
|
|
$offset = ($param['pageNumber'] - 1) * $limit;
|
|
|
|
|
|
|
|
$where = [];
|
|
$where = [];
|
|
|
|
|
+ $orwhere = [];
|
|
|
|
|
+ //用户名称
|
|
|
if (empty($param['searchText']) === false) {
|
|
if (empty($param['searchText']) === false) {
|
|
|
- $where['account_name'] = $param['searchText'];
|
|
|
|
|
|
|
+ $where['a.name'] = $param['searchText'];
|
|
|
|
|
+ $orwhere['name'] = $param['searchText'];
|
|
|
|
|
+ }
|
|
|
|
|
+ //处理客服id
|
|
|
|
|
+ if (empty($param['user_id']) === false) {
|
|
|
|
|
+ $where['a.user_id'] = $param['user_id'];
|
|
|
|
|
+ $orwhere['user_id'] = $param['user_id'];
|
|
|
|
|
+ }
|
|
|
|
|
+ //留言状态
|
|
|
|
|
+ if ($param['message_status'] != -1) {
|
|
|
|
|
+ $where['a.message_status'] = $param['message_status'];
|
|
|
|
|
+ $orwhere['message_status'] = $param['message_status'];
|
|
|
|
|
+ }
|
|
|
|
|
+ //公开状态
|
|
|
|
|
+ if ($param['if_public'] != -1) {
|
|
|
|
|
+ $where['a.if_public'] = $param['if_public'];
|
|
|
|
|
+ $orwhere['if_public'] = $param['if_public'];
|
|
|
|
|
+ }
|
|
|
|
|
+ //留言类型id
|
|
|
|
|
+ if (empty($param['type_id']) === false) {
|
|
|
|
|
+ $where['a.type_id'] = $param['type_id'];
|
|
|
|
|
+ $orwhere['type_id'] = $param['type_id'];
|
|
|
}
|
|
}
|
|
|
|
|
+ $return['total'] = db('Accountsmessage')->where($orwhere)->count(); //总数据
|
|
|
$start = '';$end = '';
|
|
$start = '';$end = '';
|
|
|
if (empty($param['start']) === false && empty($param['end']) === false && $param['start'] <= $param['end']) {
|
|
if (empty($param['start']) === false && empty($param['end']) === false && $param['start'] <= $param['end']) {
|
|
|
$start = strtotime($param['start']);
|
|
$start = strtotime($param['start']);
|
|
|
$end = strtotime($param['end'] . ' 23:59:59');
|
|
$end = strtotime($param['end'] . ' 23:59:59');
|
|
|
|
|
+ $return['total'] = db('Accountsmessage')->whereBetween('add_time', [$start, $end])->where($orwhere)->count(); //总数据
|
|
|
}
|
|
}
|
|
|
$join = [
|
|
$join = [
|
|
|
'messagetype b' => 'a.type_id = b.id',
|
|
'messagetype b' => 'a.type_id = b.id',
|
|
@@ -73,12 +98,36 @@ class Messages extends Base
|
|
|
$result[$key]['operate'] = $this->makeBtn($vo['message_id']);
|
|
$result[$key]['operate'] = $this->makeBtn($vo['message_id']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $return['total'] = db('Accountsmessage')->count(); //总数据
|
|
|
|
|
|
|
+ //$return['total'] = db('Accountsmessage')->where($orwhere)->count(); //总数据
|
|
|
$return['rows'] = $result;
|
|
$return['rows'] = $result;
|
|
|
|
|
|
|
|
return json($return);
|
|
return json($return);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ //所有客服
|
|
|
|
|
+ $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>';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //留言类型
|
|
|
|
|
+ $type = db('messagetype')->select();
|
|
|
|
|
+ if(!empty($users)){
|
|
|
|
|
+ $option = '<option value="0">留言类型</option>';
|
|
|
|
|
+ for($i=0;$i<count($type);$i++){
|
|
|
|
|
+ $option = $option.'<option value="'.$type[$i]['id'].'">'.$type[$i]['name'].'</option>';
|
|
|
|
|
+ }
|
|
|
|
|
+ $optiontype = '<select name="type_id" id="type_id" class="form-control">'.$option.'</select>';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $this->assign([
|
|
|
|
|
+ 'useroption' => $useroption,
|
|
|
|
|
+ 'optiontype' => $optiontype
|
|
|
|
|
+ ]);
|
|
|
|
|
|
|
|
return $this->fetch();
|
|
return $this->fetch();
|
|
|
}
|
|
}
|
|
@@ -226,7 +275,6 @@ class Messages extends Base
|
|
|
// 生成操作按钮
|
|
// 生成操作按钮
|
|
|
$result[$key]['operate'] = $this->makeBtnType($vo['id']);
|
|
$result[$key]['operate'] = $this->makeBtnType($vo['id']);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
$return['total'] = db('messagetype')->count(); //总数据
|
|
$return['total'] = db('messagetype')->count(); //总数据
|
|
|
$return['rows'] = $result;
|
|
$return['rows'] = $result;
|
|
|
|
|
|
|
@@ -235,6 +283,32 @@ class Messages extends Base
|
|
|
return $this->fetch();
|
|
return $this->fetch();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 添加留言类型
|
|
|
|
|
+ public function add()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (request()->isAjax()) {
|
|
|
|
|
+ $param = input('post.');
|
|
|
|
|
+ $has = db('messagetype')->where('name',$param['name'])->find();
|
|
|
|
|
+ if(!empty($has)){
|
|
|
|
|
+ return json(['code' => -1, 'data' => '', 'msg' => '此留言类型已存在']);
|
|
|
|
|
+ }
|
|
|
|
|
+ $info = array();
|
|
|
|
|
+ $info['name'] = $param['name'];
|
|
|
|
|
+ $info['addtime'] = time();
|
|
|
|
|
+ $info['status'] = $param['status'];
|
|
|
|
|
+ try {
|
|
|
|
|
+ db('messagetype')->insert($info);
|
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
|
+ return json(['code' => -2, 'data' => '', 'msg' => $e->getMessage()]);
|
|
|
|
|
+ }
|
|
|
|
|
+ return json(['code' => 1, 'data' => '', 'msg' => '添加留言类型成功']);
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->assign([
|
|
|
|
|
+ 'status' => config('kf_status')
|
|
|
|
|
+ ]);
|
|
|
|
|
+ return $this->fetch();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 编辑留言类型
|
|
// 编辑留言类型
|
|
|
public function edit()
|
|
public function edit()
|
|
|
{
|
|
{
|
|
@@ -242,7 +316,7 @@ class Messages extends Base
|
|
|
$id = input('param.id/d');
|
|
$id = input('param.id/d');
|
|
|
if (request()->isAjax()) {
|
|
if (request()->isAjax()) {
|
|
|
$param = input('post.');
|
|
$param = input('post.');
|
|
|
- $has = db('messagetype')->where('name',$param['name'])->find();
|
|
|
|
|
|
|
+ $has = db('messagetype')->where('name',$param['name'])->where('id','<>',$id)->find();
|
|
|
if(!empty($has)){
|
|
if(!empty($has)){
|
|
|
return json(['code' => -1, 'data' => '', 'msg' => '此留言类型已存在']);
|
|
return json(['code' => -1, 'data' => '', 'msg' => '此留言类型已存在']);
|
|
|
}
|
|
}
|
|
@@ -283,8 +357,6 @@ class Messages extends Base
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
// 生成按钮
|
|
// 生成按钮
|
|
|
private function makeBtnType($id)
|
|
private function makeBtnType($id)
|
|
|
{
|
|
{
|
|
@@ -294,7 +366,6 @@ class Messages extends Base
|
|
|
$operate .= '<a href="javascript:typeDel(' . $id . ')"><button type="button" class="btn btn-danger btn-sm">';
|
|
$operate .= '<a href="javascript:typeDel(' . $id . ')"><button type="button" class="btn btn-danger btn-sm">';
|
|
|
$operate .= '<i class="fa fa-trash-o"></i> 删除</button></a> ';
|
|
$operate .= '<i class="fa fa-trash-o"></i> 删除</button></a> ';
|
|
|
|
|
|
|
|
-
|
|
|
|
|
return $operate;
|
|
return $operate;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|