model = new Personnel(); } //获取员工信息 public function info(array $where,string $field = '*'){ $model = $this->model; if(!empty($where['id'])){ $model = $model->where('id',$where['id']); } $res = $model->field($field)->find();//员工信息 //查询部门信息 $campus_person_role = CampusPersonRole::where('person_id',$where['id'])->select()->toArray(); $role_id = array_column($campus_person_role, 'role_id'); $dept_id = array_column($campus_person_role, 'dept_id'); if($res){ $res = $res->toArray(); }else{ $res = []; return $res; } } /** * 获取会员的模型对象(todo 慎用!!! 现主要用于登录) * @param array $data * @return Member|array|mixed|Model !!! 仔细看,返回值是模型对象 如果想要判断是否为空 请用 $member->isEmpty() */ public function findMemberInfo(array $data){ //会员账号 if(!empty($data['username'])) $where[] = ['username', '=', $data['username']]; //会员手机号 if(!empty($data['mobile'])) $where[] = ['mobile', '=', $data['mobile']]; //会员id if(!empty($data['id'])) $where[] = ['id', '=', $data['id']]; //微信公众号openid if(!empty($data['wx_openid'])) $where[] = ['wx_openid', '=', $data['wx_openid']]; //微信小程序openid if(!empty($data['weapp_openid'])) $where[] = ['weapp_openid', '=', $data['weapp_openid']]; // 微信unionid if(!empty($data['wx_unionid'])) $where[] = ['wx_unionid', '=', $data['wx_unionid']]; if(!empty($data['username|mobile'])) $where[] = ['username|mobile', '=', $data['username|mobile']]; if(empty($where)){ $where[] = ['member_id', '=', -1]; } return $this->model->where($where)->findOrEmpty(); } }