|
@@ -258,33 +258,55 @@ class User extends BaseModel
|
|
|
* @param type $field
|
|
* @param type $field
|
|
|
* @return type
|
|
* @return type
|
|
|
*/
|
|
*/
|
|
|
- public function getDataList($post,$field="*"){
|
|
|
|
|
|
|
+ public function getDataList($post,$field="*",$is_admin=0){
|
|
|
$post["pageSize"] = $post["pageSize"]>50 ? 50 : (int)$post["pageSize"];
|
|
$post["pageSize"] = $post["pageSize"]>50 ? 50 : (int)$post["pageSize"];
|
|
|
$post["page"] = $post["page"]<=0 ? 1 : (int)$post["page"];
|
|
$post["page"] = $post["page"]<=0 ? 1 : (int)$post["page"];
|
|
|
$where=[];
|
|
$where=[];
|
|
|
- if(isset($post["status"]) && in_array((string)$post["status"], ["0","1"])){
|
|
|
|
|
- $where[]=["status","=",(int)$post["status"]];
|
|
|
|
|
|
|
+ //用户uid
|
|
|
|
|
+ if(!empty($post['uid'])){
|
|
|
|
|
+ $where[]=["u.uid","=",$post['uid']];
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ //状态
|
|
|
|
|
+ if(isset($post["status"]) && in_array((string)$post["status"], ["0","1","-1"])){
|
|
|
|
|
+ $where[]=["u.status","=",(int)$post["status"]];
|
|
|
|
|
+ }
|
|
|
|
|
+ //昵称
|
|
|
if(!empty($post["nickname"])){
|
|
if(!empty($post["nickname"])){
|
|
|
- $where[]=["nickname","like","%{$post["nickname"]}%"];
|
|
|
|
|
|
|
+ $where[]=["u.nickname","like","%{$post["nickname"]}%"];
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ //手机号码
|
|
|
if(!empty($post["mobile"])){
|
|
if(!empty($post["mobile"])){
|
|
|
- $where[]=["mobile","=",$post["mobile"]];
|
|
|
|
|
|
|
+ $where[]=["u.mobile","=",$post["mobile"]];
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ //父级uid
|
|
|
if(!empty($post["parent_uid"])){
|
|
if(!empty($post["parent_uid"])){
|
|
|
- $where[]=["parent_uid","=",$post["parent_uid"]];
|
|
|
|
|
|
|
+ $where[]=["u.parent_uid","=",$post["parent_uid"]];
|
|
|
|
|
+ }
|
|
|
|
|
+ //注册时间
|
|
|
|
|
+ if(!empty($post['time']) && !empty($post['time'][0]) && !empty($post['time'][1])) {
|
|
|
|
|
+ $startTime = strtotime($post['time'][0]);
|
|
|
|
|
+ $endTime = strtotime($post['time'][1]);
|
|
|
|
|
+ $where[]=["u.regtime","between","{$startTime},{$endTime}"];
|
|
|
|
|
+ }
|
|
|
|
|
+ if($is_admin=1){
|
|
|
|
|
+ $field = "u.*"
|
|
|
|
|
+ . ",p.nickname as p_nickname,p.mobile as p_mobile"
|
|
|
|
|
+ . ",wt.title as work_type_title"
|
|
|
|
|
+ . ",(select count(*) from table_user_show_template where uid = u.uid) as showTempCount"
|
|
|
|
|
+ . ",(select count(*) from table_info_audit where uid = u.uid and status = 1) as is_info_audit"
|
|
|
|
|
+ . ",(select count(*) from table_type_audit where uid = u.uid and status = 1) as is_type_audit"
|
|
|
|
|
+ . ",(select count(*) from table_user where parent_uid = u.uid) as branchCount";
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- $totalCount = $this->where($where)->count();
|
|
|
|
|
|
|
+ $totalCount = $this->alias("u")->where($where)->count();
|
|
|
$data=null;
|
|
$data=null;
|
|
|
if($totalCount>0){
|
|
if($totalCount>0){
|
|
|
$data = $this
|
|
$data = $this
|
|
|
|
|
+ ->alias("u")
|
|
|
->field($field)
|
|
->field($field)
|
|
|
|
|
+ ->leftJoin("user p","p.uid = u.parent_uid")
|
|
|
|
|
+ ->leftJoin("user_work_type wt", "wt.id = u.work_type_id")//职称
|
|
|
->where($where)
|
|
->where($where)
|
|
|
- ->order("uid", "desc")
|
|
|
|
|
|
|
+ ->order("u.uid", "desc")
|
|
|
->page($post["page"], $post["pageSize"])
|
|
->page($post["page"], $post["pageSize"])
|
|
|
->select();
|
|
->select();
|
|
|
if(!empty($data)){
|
|
if(!empty($data)){
|
|
@@ -292,6 +314,14 @@ class User extends BaseModel
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
$data = empty($data)?[]:$data;
|
|
$data = empty($data)?[]:$data;
|
|
|
|
|
+ foreach($data as $k=>$v){
|
|
|
|
|
+ if(!empty($v["regtime"])){
|
|
|
|
|
+ $data[$k]["regtime"] = date("Y-m-d H:i:s",$v["regtime"]);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!empty($v["parent_time"])){
|
|
|
|
|
+ $data[$k]["parent_time"] = date("Y-m-d H:i:s",$v["parent_time"]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
return ["list" => $data, "pageSize" => $post["pageSize"],"page"=>$post["page"],"totalCount"=>$totalCount];
|
|
return ["list" => $data, "pageSize" => $post["pageSize"],"page"=>$post["page"],"totalCount"=>$totalCount];
|
|
|
}
|
|
}
|
|
|
|
|
|