|
@@ -6,6 +6,7 @@ namespace app\model\api;
|
|
|
use Closure;
|
|
|
use library\basic\BaseModel;
|
|
|
use think\db\exception\DbException;
|
|
|
+use app\model\api\ShowTemplate;
|
|
|
use think\Model;
|
|
|
use think\facade\Db;
|
|
|
|
|
@@ -251,6 +252,79 @@ class User extends BaseModel
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+ * 获取从业人员列表
|
|
|
+ * @param type $post
|
|
|
+ * @param type $field
|
|
|
+ * @param type $is_admin
|
|
|
+ */
|
|
|
+ public function getWorkerList($post,$field="*",$is_admin=0){
|
|
|
+ $post["pageSize"] = $post["pageSize"]>50 ? 50 : (int)$post["pageSize"];
|
|
|
+ $post["page"] = $post["page"]<=0 ? 1 : (int)$post["page"];
|
|
|
+ $where=[];
|
|
|
+ $where[]=["u.work_type_id",">",0];
|
|
|
+
|
|
|
+ if(!empty($post['uid'])){
|
|
|
+ $where[]=["u.uid","=",$post['uid']];
|
|
|
+ }
|
|
|
+ if(!empty($post['work_type_id'])){
|
|
|
+ $where[]=["u.work_type_id","=",$post['work_type_id']];
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!empty($post["mobile"])){
|
|
|
+ $where[]=["u.mobile","=",$post["mobile"]];
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isset($post["status"]) && in_array((string)$post["status"], ["0","1","-1"])){
|
|
|
+ $where[]=["u.status","=",(int)$post["status"]];
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!empty($post["parent_uid"])){
|
|
|
+ $where[]=["u.parent_uid","=",$post["parent_uid"]];
|
|
|
+ }
|
|
|
+ if($is_admin==1){
|
|
|
+ $field = "u.*"
|
|
|
+ . ",ut.show_template_id"
|
|
|
+ . ",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->alias("u")->where($where)->count();
|
|
|
+ $data=null;
|
|
|
+ if($totalCount>0){
|
|
|
+ $data = $this
|
|
|
+ ->alias("u")
|
|
|
+ ->field($field)
|
|
|
+ ->leftJoin("user p","p.uid = u.parent_uid")
|
|
|
+ ->leftJoin("user_work_type wt", "wt.id = u.work_type_id")
|
|
|
+ ->leftJoin("user_show_template ut", "ut.uid = u.uid and ut.is_default = 1")
|
|
|
+ ->where($where)
|
|
|
+ ->order("u.show_temp_seq", "desc")
|
|
|
+ ->order("u.uid", "desc")
|
|
|
+ ->page($post["page"], $post["pageSize"])
|
|
|
+ ->select();
|
|
|
+ if(!empty($data)){
|
|
|
+ $data = $data->toArray();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $data = empty($data)?[]:$data;
|
|
|
+ $ShowTemplateDb = new ShowTemplate();
|
|
|
+ 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"]);
|
|
|
+ }
|
|
|
+ if(!empty($v["show_template_id"])){
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ["list" => $data, "pageSize" => $post["pageSize"],"page"=>$post["page"],"totalCount"=>$totalCount];
|
|
|
+ }
|
|
|
|
|
|
|
|
|
* 前端获取用户列表
|