|
|
@@ -17,15 +17,28 @@ class Accounts extends Base
|
|
|
$offset = (($param['pageNumber'] - 1) * $limit);
|
|
|
$where = [];
|
|
|
if (empty($param['searchText']) === false) {
|
|
|
- $where['account_name'] = $param['searchText'];
|
|
|
+ $where['account_name'] = ['like', '%' . $param['searchText'] . '%'];
|
|
|
}
|
|
|
- $result = db('accounts')->where($where)->limit($offset, $limit)->order('add_time', 'desc')->select();
|
|
|
+ if (empty($param['start']) === false && empty($param['end']) === false && $param['start'] <= $param['end']) {
|
|
|
+ $start = strtotime($param['start']);
|
|
|
+ $end = strtotime($param['end'] . ' 23:59:59');
|
|
|
+ $return['total'] = db('accounts')->whereBetween('add_time', [$start, $end])->count(); //总数据
|
|
|
+ }
|
|
|
+ $result = db('accounts')->whereBetween('add_time', [$start, $end])->where($where)->limit($offset, $limit)->order('add_time', 'desc')->select();
|
|
|
+ //所有客服
|
|
|
+ $users = db('users')->select();
|
|
|
foreach($result as $key=>$vo){
|
|
|
$result[$key]['add_time'] = date('Y-m-d H:i:s',$result[$key]['add_time']);
|
|
|
+ $result[$key]['last_login_time'] = date('Y-m-d H:i:s',$result[$key]['last_login_time']);
|
|
|
+ for($i=0;$i<count($users);$i++){
|
|
|
+ if($vo['user_id'] == $users[$i]['id']){
|
|
|
+ $result[$key]['user_name'] = $users[$i]['user_name'];
|
|
|
+ }
|
|
|
+ }
|
|
|
// 生成操作按钮
|
|
|
$result[$key]['operate'] = $this->makeBtn($vo['id']);
|
|
|
}
|
|
|
- $return['total'] = db('accounts')->count(); //总数据
|
|
|
+ //$return['total'] = db('accounts')->count(); //总数据
|
|
|
$return['rows'] = $result;
|
|
|
return json($return);
|
|
|
}
|
|
|
@@ -56,21 +69,27 @@ class Accounts extends Base
|
|
|
$info = array();
|
|
|
$rules = '/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/';
|
|
|
|
|
|
- if(!preg_match($rules,$param['account_email'])){
|
|
|
- return json(['code' => -9, 'data' => '', 'msg' => '请输入正确的邮箱']);
|
|
|
+ if(!empty($param['account_email'])){
|
|
|
+ if(!preg_match($rules,$param['account_email'])){
|
|
|
+ return json(['code' => -9, 'data' => '', 'msg' => '请输入正确的邮箱']);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if(!preg_match("/^1[34578]\d{9}$/", $param['account_phone'])){
|
|
|
- return json(['code' => -10, 'data' => '', 'msg' => '请输入正确的手机号码']);
|
|
|
+ if(!empty($param['account_phone'])){
|
|
|
+ if(!preg_match("/^1[34578]\d{9}$/", $param['account_phone'])){
|
|
|
+ return json(['code' => -10, 'data' => '', 'msg' => '请输入正确的手机号码']);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ $info['account_name'] = $param['account_name'];
|
|
|
$info['account_email'] = $param['account_email'];
|
|
|
$info['account_phone'] = $param['account_phone'];
|
|
|
$info['address'] = $param['address'];
|
|
|
$info['label'] = $param['label'];
|
|
|
$info['remark'] = $param['remark'];
|
|
|
- $info['status'] = $param['status'];
|
|
|
- $info['user_id'] = $param['user_id'];
|
|
|
+ if(!empty($param['user_id']) && $param['user_id'] != 0){
|
|
|
+ $info['user_id'] = $param['user_id'];
|
|
|
+ }
|
|
|
|
|
|
try{
|
|
|
db('accounts')->where('id', $param['id'])->update($info);
|
|
|
@@ -115,9 +134,9 @@ class Accounts extends Base
|
|
|
// 生成按钮
|
|
|
private function makeBtn($id)
|
|
|
{
|
|
|
- $operate = '<a href="javascript:resetPwd(' . $id . ')"><button type="button" class="btn btn-primary btn-sm"><i class="fa fa-paste"></i> 重置密码</button></a>';
|
|
|
+ //$operate = '<a href="javascript:resetPwd(' . $id . ')"><button type="button" class="btn btn-primary btn-sm"><i class="fa fa-paste"></i> 重置密码</button></a>';
|
|
|
|
|
|
- $operate .= '<a style="margin-left:5px;" href="' . url('Accounts/edit', ['id' => $id]) . '"><button type="button" class="btn btn-primary btn-sm"><i class="fa fa-paste"></i> 编辑</button></a> ';
|
|
|
+ $operate = '<a style="margin-left:5px;" href="' . url('Accounts/edit', ['id' => $id]) . '"><button type="button" class="btn btn-primary btn-sm"><i class="fa fa-paste"></i> 编辑</button></a> ';
|
|
|
|
|
|
$operate .= '<a href="javascript:accountDel(' . $id . ')"><button type="button" class="btn btn-danger btn-sm">';
|
|
|
$operate .= '<i class="fa fa-trash-o"></i> 删除</button></a> ';
|