123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659 |
- <?php
- declare (strict_types = 1);
- namespace app\admin\controller;
- use app\BaseController;
- use think\facade\Db;
- use app\admin\model\ActionLog;
- //用户
- class User extends BaseController
- {
- /**
- * 显示资源列表
- *
- * @return \think\Response
- */
- public function list()
- {
- $post =$this->request->post();
- $token = isset($post['token']) ? trim($post['token']) : "";
- if($token==""){
- return error_show(101,'token不能为空');
- }
- $effetc =VerifyTokens($token);
- if(!empty($effetc) && $effetc['code']!=0){
- return error_show($effetc['code'],$effetc['message']);
- }
- if(isset($post['status'])&&$post['status']!==''){
- $uid =Db::name("user_role")->where(["status"=>1,"is_del"=>0])->column("uid");
- if($post['status']==1){
- $post['uid']=$uid;
- }else{
- $post['nouid']=$uid;
- unset($post['status']);
- }
- }
- $data = Getlist($token,$post);
- if(!empty($data) && $data['code']!=0){
- return error_show($data['code'],$data['message']);
- }
- $list=[];
- foreach($data['data']['list'] as $key=>$value){
- $role = Db::name("user_role")->alias('a')->leftJoin('role b',"a.roleid = b.id")->where("a.uid","=",$value['id'])
- ->field("roleid,role_name,a.status")->find();
- $value['roleid'] = isset($role['roleid']) ? $role['roleid'] :"";
- $value['role_name'] = isset($role['role_name']) ? $role['role_name'] :"";
- $depart = Db::name("depart_user")->where([["uid","=",$value['id']],["is_del","=",0]])->column("itemid");
- $value['depart']="";
- $value['status']=$value['status']==1?($role['status']??"0"):'0';
- if(!empty($depart)){
- $deparname = Db::name("company_item")->where(["id"=>$depart,"is_del"=>0])->column("id,name,depart_link");
- $value['depart_code'] = [];
- if(!empty($deparname)){
- foreach ($deparname as $item) {
- $value['depart_code'][] = array_filter(explode("-",$item['depart_link'])) ;
- $value['depart_info'][] = Db::name("company_item")->where(["id"=>array_filter(explode("-",
- $item['depart_link'])),"is_del"=>0])->column("name");
- }
- }
- $value['depart'] = $deparname;
- }
- $list[]=$value;
- }
- $data['data']['list'] = $list;
- return app_show($data['code'],$data['message'],$data['data']);
- }
- /**
- * @param token
- * @return \think\response\Json
- * @throws \think\exception\DbException
- */
- public function userInfo(){
- $post =$this->request->post();
- $token = isset($post['token']) ? trim($post['token']) : "";
- if($token==""){
- return app_show(101,'token不能为空');
- }
- $effetc = VerifyTokens($token);
- if(!empty($effetc) && $effetc['code']!=0){
- return app_show($effetc['code'],$effetc['message']);
- }
- $userinfo=GetUserInfo($token);
- if(empty($userinfo)||$userinfo['code']!=0){
- return app_show(102,"员工信息不存在");
- }
- $id = isset($post['id']) && $post['id'] !==""? trim($post['id']):"";
- if($id ==""){
- return error_show(1004,"id不能为空");
- }
- $to= GetInfoById($token,['id'=>$id]);
- if(empty($to)||$to['code']!=0){
- return app_show(1002,"员工信息不存在");
- }
- // $nickname = isset($to['data']['nickname']) &&$to['data']['nickname']!="" ? $to['data']['nickname'] :"" ;
- $data = $to['data'];
- $role = Db::name("user_role")->alias('a')->leftJoin('role b',"a.roleid = b.id")->where("a.uid","=",$data['id'])
- ->field("roleid,role_name,business_all,uid,a.status")->find();
- $data['role_name']=isset($role['role_name']) ? $role['role_name'] :"";
- $data['roleid']=isset($role['roleid']) ? $role['roleid'] :"";
- $data['status']= $data['status']==1? ($role['status']??'0'):"0";
- $st = Db::name('user_business')->where(['userid'=>$role['uid'],"is_del"=>0])->field('businessid,is_main')->select()->toArray();
- $val=[];
- if (!empty($st)){
- foreach ($st as $itom){
- $tep=[];
- $business= Db::name('business')->where(['id'=>$itom['businessid'],"is_del"=>0])->field("company,companyNo")->find();
- $tep['company']=isset($business['company'])?$business['company']:"";
- $tep['companyNo']=isset($business['companyNo'])?$business['companyNo']:"";
- $tep['businessid']=$itom['businessid'];
- $tep['is_main']=$itom['is_main'];
- $val[]=$tep;
- }
- }
- $data['business'] =$val;
- $info=[];
- $stn = Db::name('user_platform')->where(['uid'=>$role['uid']])->find();
- if($stn!=false){
- $plat =isset($stn['platform'])?explode(",",$stn['platform']):"";
- if($plat!=""){
- $platform = Db::name('platform')->where(['id'=>$plat,'is_del'=>0])->column("id,platform_name,platform_code");
- $info=$platform;
- }
- }
- $depart = Db::name("depart_user")->where([["uid","=",$data['id']],["is_del","=",0]])->column("itemid");
- $data['depart']="";
- if(!empty($depart)){
- $deparname = Db::name("company_item")->where(["id"=>$depart,"is_del"=>0])->field("id,name,depart_link")->select()->toArray();
- if(!empty($deparname)){
- foreach ($deparname as $ky=> $item) {
- $deparname[$ky]['depart_code']= array_filter(explode("-",$item['depart_link'])) ;
- }
- }
- $data['depart'] = $deparname;
- }
- $data['platform']=$info;
- return app_show(0,"获取成功",$data);
- }
- /**
- * @param token
- * @param passwd
- * @return \think\response\Json
- * @throws \think\exception\DbException
- */
- public function resetPwd(){
- $post =$this->request->post();
- $token = isset($post['token']) ? trim($post['token']) : "";
- if($token==""){
- return error_show(101,'token不能为空');
- }
- $effetc = VerifyTokens($token);
- if(!empty($effetc) && $effetc['code']!=0){
- return error_show($effetc['code'],$effetc['message']);
- }
- $newPwd= isset($post['newpwd']) ? trim($post['newpwd']) : "";
- if($newPwd==""){
- return error_show(1001,'新密码不能为空');
- }
- $oldpwd = isset($post['oldpwd'])?trim($post['oldpwd']):"";
- if($oldpwd==""){
- return error_show(1002,"原密码不能为空");
- }
- $data = resetpasswd($token,['newpwd'=>$newPwd,'oldpwd'=>$oldpwd]);
- if(empty($userinfo)||$userinfo['code']!=0){
- return error_show($userinfo['code'],$userinfo['message']);
- }else{
- return app_show(0,"密码修改成功");
- }
- }
- public function userAll(){
- $post =$this->request->post();
- $token = isset($post['token']) ? trim($post['token']) : "";
- if($token==""){
- return app_show(101,'token不能为空');
- }
- $effetc = VerifyTokens($token);
- if(!empty($effetc) && $effetc['code']!=0){
- return app_show($effetc['code'],$effetc['message']);
- }
- if(isset($post['status'])&&$post['status']!==''){
- $uid =Db::name("user_role")->where(["status"=>1,"is_del"=>0])->column("uid");
- if($post['status']==1){
- $post['uid']=$uid;
- }else{
- $post['nouid']=$uid;
- }
- unset($post['status']);
- }
- $userinfo=GetAccountall($token,$post);
- if(empty($userinfo)||$userinfo['code']!=0){
- return app_show(1002,"员工信息不存在");
- }
- $data = $userinfo['data'];
- $list=[];
- foreach ($data as $value){
- $role = Db::name("user_role")->alias('a')->leftJoin('role b',"a.roleid = b.id")->where("a.uid","=",$value['id'])
- ->field("roleid,role_name,a.status")->find();
- $value['roleid'] = isset($role['roleid']) ? $role['roleid'] :"";
- $value['role_name'] = isset($role['role_name']) ? $role['role_name'] :"";
- $depart = Db::name("depart_user")->where([["uid","=",$value['id']],["is_del","=",0]])->column("itemid");
- $value['depart']="";
- $value['status']= $value['status']==1?($role['status']??"0"):'0';
- if(!empty($depart)){
- $deparname = Db::name("company_item")->where(["id"=>$depart,"is_del"=>0])->field("id,name,depart_link")
- ->select()->toArray();
- array_walk($deparname,function (&$v){
- $v = array_filter(explode("-",$v['depart_link'])) ;
- });
- $value['depart'] = $deparname;
- }
- $list[]=$value;
- }
- return app_show(0,"获取成功",$list);
- }
- /**
- * @return \think\response\Json|void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function userList(){
- $post =$this->request->post();
- $token = isset($post['token']) ? trim($post['token']) : "";
- if($token==""){
- return app_show(101,'token不能为空');
- }
- $effetc = VerifyTokens($token);
- if(!empty($effetc) && $effetc['code']!=0){
- return app_show($effetc['code'],$effetc['message']);
- }
- $itemid = isset($post['itemid']) && $post['itemid']!=="" ? intval($post['itemid']) :"";
- if($itemid!==""){
- $uids = Db::name("depart_user")->where([["itemid","=",$itemid],["is_del","=",0]])->column("uid");
- $post['uid'] =$uids;
- }
- if(isset($post['status'])&&$post['status']!==''){
- $uid =Db::name("user_role")->where(["status"=>1,"is_del"=>0])->column("uid");
- if($post['status']==1){
- $post['uid']= isset($uids)?array_unique(array_merge($uids,$uid)):$uid;
- }else{
- $post['nouid']=$uid;
- unset($post['status']);
- }
- }
- $userinfo=GetList($token,$post);
- if(empty($userinfo)||$userinfo['code']!=0){
- return app_show($userinfo['code'],$userinfo['msg']);
- }
- $data = $userinfo['data']['list'];
- $list=[];
- foreach ($data as $value){
- $role = Db::name("user_role")->alias('a')->leftJoin('role b',"a.roleid = b.id")->where("a.uid","=",$value['id'])
- ->field("roleid,role_name,a.status")->find();
- $value['roleid'] = isset($role['roleid']) ? $role['roleid'] :"";
- $value['role_name'] = isset($role['role_name']) ? $role['role_name'] :"";
- $depart = Db::name("depart_user")->where([["uid","=",$data['uid']],["is_del","=",0]])->column("itemid");
- $value['depart']="";
- $value['status']=$value['status']==1?($role['status']??"0"):'0';
- if(!empty($depart)){
- $deparname = Db::name("company_item")->where(["id"=>$depart,"is_del"=>0])->field("id,name,depart_link")
- ->select()->toArray();
- $value['depart'] = $deparname;
- $value['depart_code'] = [];
- if(!empty($deparname)){
- foreach ($deparname as $item) {
- $value['depart_code'][] = array_filter(explode("-",$item['depart_link'])) ;
- }
- }
- }
- $list[]=$value;
- }
- return app_show(0,"获取成功",["list"=>$list,"count"=>$userinfo['data']["count"]]);
- }
- public function setRole(){
- $post =$this->request->post();
- $token = isset($post['token']) ? trim($post['token']) : "";
- if($token==""){
- return app_show(101,'token不能为空');
- }
- $effetc = VerifyTokens($token);
- if(!empty($effetc) && $effetc['code']!=0){
- return app_show($effetc['code'],$effetc['message']);
- }
- $uid = isset($post['id'])&&$post['id']!=='' ? intval($post['id']) :"";
- if($uid===''){
- return error_show(1004,"参数id 不能为空");
- }
- $role =isset($post['roleid']) && $post['roleid']!=="" ? intval($post['roleid']) :"";
- if($role===''){
- return error_show(1004,"参数roleid 不能为空");
- }
- $isRole = Db::name('role')->where([['id',"=",$role],['status',"=",1]])->find();
- if(empty($isRole)){
- return error_show(1004,"所选角色不存在");
- }
- $data = [
- 'uid'=>$uid,
- 'roleid'=>$role,
- 'status'=>1,
- 'addtime'=>date('Y-m-d H:i:s'),
- 'updatetime'=>date('Y-m-d H:i:s'),
- ];
- $insert = Db::name('user_role')->insert($data);
- $st = ["order_code"=>$uid,"status"=>1,"action_remark"=>'',"action_type"=>"create"];
- ActionLog::logAdd($token,$st,"resign_info",1,$st);
- return $insert? app_show(0,'数据新建成功'):error_show(1004,'数据新建失败');
- }
- /**
- * 保存新建的资源
- *
- * @param \think\Request $request
- * @return \think\Response
- */
- public function UserSave()
- {
- $post=$this->request->post();
- $toke= isset($post['token'])? trim($post['token']):"";
- if ($toke==""){
- return app_show(100,"token不能为空");
- }
- $verify = VerifyTokens($toke);
- if ($verify['code']!=0){
- return app_show($verify['code'],$verify['message']);
- }
- $userid = isset($post['id'])&&$post['id']!==""?intval($post['id']):"";
- if($userid==""){
- return error_show(1004,"参数id 不能为空");
- }
- $nickname= isset($post['nickname'])? trim($post['nickname']):"";
- if ($nickname==""){
- return app_show(1001,"昵称不能为空");
- }
- $mobile= isset($post['mobile'])? trim($post['mobile']):"";
- if ($mobile==""){
- return app_show(1002,"手机号不能为空");
- }
- if (checkMobile($mobile)==false){
- return app_show(1002,"手机号格式不正确");
- }
- $email= isset($post['email'])? trim($post['email']):"";
- $role =isset($post['role'])? intval($post['role']):0;
- if($role!=0){
- $roleinfo =Db::name("role")->where("id","=",$role)->find();
- if(empty($roleinfo)){
- return error_show(1002,"角色不存在");
- }
- if($roleinfo['status']==0){
- return error_show(1002,"角色已禁用");
- }
- }
- $itemid = isset($post['itemid'])&&$post['itemid']!=="" ?$post['itemid'] :"";
- $item_arr = [];
- if($itemid!==""){
- foreach ($itemid as $value){
- $item_arr[]=end($value);
- }
- $iteminfo = Db::name("company_item")->where(["id"=>$item_arr,'is_del'=>0])->select()->toArray();
- if(empty($iteminfo)){
- return error_show(1002,"未找到部门信息");
- }
- }
- $companyArr = isset($post['companyArr'])&&!empty($post['companyArr']) ? $post['companyArr']:"";
- if($companyArr==""){
- return error_show(1004,"参数companyArr不能为空");
- }
- $compArr=[];
- foreach ($companyArr as $value){
- $tmp=[];
- if(!isset($value['businessid'])||$value['businessid']==''){
- return error_show(1004,"参数业务公司businessid不能为空");
- }
- $tmp['userid']=$userid;
- $tmp['businessid']=$value['businessid'];
- $tmp['is_main']=isset($value['is_main'])?$value['is_main']:0;
- $tmp['is_del']=0;
- $tmp['addtime']=date("Y-m-d H:i:s");
- $tmp['updatetime']=date("Y-m-d H:i:s");
- $compArr[]=$tmp;
- }
- $platform = isset($post['platform'])&&!empty($post['platform']) ? $post['platform']:"";
- if($platform==""){
- return error_show(1004,"参数platform不能为空");
- }
- $plta =Db::name("platform")->where(["id"=>$platform,"is_del"=>0])->select()->toArray();
- if(empty($plta)){
- return error_show(1004,"未找到可用平台");
- }
- $userplat =Db::name("user_platform")->where(["uid"=>$userid,"is_del"=>0])->find();
- $isall = isset($post['is_all'])&&$post['is_all']!==""?intval($post['is_all']):"0";
- Db::startTrans();
- try{
- $sc=Db::name("user_business")->where(["userid"=>$userid,"is_del"=>0])->select()->toArray();
- if(!empty($sc)){
- $del= Db::name("user_business")->where(["userid"=>$userid,"is_del"=>0])->save(["is_del"=>1,
- "updatetime"=>date("Y-m-d H:i:s")]);
- if($del==false){
- Db::rollback();
- return error_show(1005,'业务公司添加失败');
- }
- }
- if(!empty($compArr)){
- $in = Db::name("user_business")->insertAll($compArr);
- if($in==0){
- Db::rollback();
- return error_show(1005,'业务公司添加失败');
- }
- }
- if($userplat==false){
- $userplat=[
- "uid"=>$userid,
- "platform"=>implode(",",$platform),
- "is_del"=>0,
- "addtime"=>date("Y-m-d H:i:s"),
- "updatetime"=>date("Y-m-d H:i:s")
- ];
- }else{
- $userplat['platform']= implode(",",$platform);
- $userplat['updatetime']= date("Y-m-d H:i:s");
- }
- $patup =Db::name("user_platform")->save($userplat);
- if($patup==false){
- Db::rollback();
- return error_show(1005,'业务平台添加失败');
- }
- $userrole = Db::name("user_role")->where(["uid"=>$userid,"is_del"=>0])->find();
- if(empty($userrole)){
- $roledata =[
- "uid"=>$userid,
- "roleid"=>$role,
- "status"=>1,
- "business_all"=>$isall,
- "addtime"=>date("Y-m-d H:i:s"),
- "updatetime"=>date("Y-m-d H:i:s")
- ];
- $up= Db::name("user_role")->insert($roledata);
- }else{
- $userrole['roleid'] = $role;
- $userrole['business_all'] = $isall;
- $userrole['updatetime'] = date("Y-m-d H:i:s");
- $up=Db::name("user_role")->save($userrole);
- }
- if($up){
- Db::name("depart_user")->where(["uid"=>$userid])->save(['is_del'=>1]);
- if(isset($item_arr)&&!empty($item_arr)){
- foreach ($item_arr as $v){
- $depin =[
- "uid"=>$userid,
- "nickname"=>$nickname,
- "itemid"=>$v,
- "is_del"=>0,
- "updatetime"=>date("Y-m-d H:i:s")
- ];
- $ist = Db::name("depart_user")->where(["uid"=>$userid,"itemid"=>$v])->find();
- if($ist){
- $up = Db::name("depart_user")->where(["uid"=>$userid,"itemid"=>$v])->save($depin);
- }else{
- $depin['addtime']=date("Y-m-d H:i:s");
- $up = Db::name("depart_user")->insert($depin);
- }
- if($up==false){
- Db::rollback();
- return error_show(1005,'用户部门更新失败');
- }
- }
- }
- }else{
- Db::rollback();
- return error_show(1005,'角色更新失败');
- }
- $data=[
- "id"=>$userid,
- "nickname"=>$nickname,
- "mobile"=>$mobile,
- "email"=>$email
- ];
- $save =resetinfo($toke,$data);
- if(!empty($save) && $save['code']!=0){
- Db::rollback();
- return error_show($save['code'],$save['message']);
- }
- Db::commit();
- return app_show(0,"更新成功");
- }catch(\Exception $e){
- Db::rollback();
- return app_show(1002,$e->getMessage());
- }
- }
- public function setPwd(){
- $post =$this->request->post();
- $token = isset($post['token']) ? trim($post['token']) : "";
- if($token==""){
- return error_show(101,'token不能为空');
- }
- $effetc = VerifyTokens($token);
- if(!empty($effetc) && $effetc['code']!=0){
- return error_show($effetc['code'],$effetc['message']);
- }
- $userid = isset($post['id'])&&$post['id']!==""?intval($post['id']):"";
- if($userid==""){
- return error_show(1004,"参数id 不能为空");
- }
- $newPwd= isset($post['password']) ? trim($post['password']) : "";
- if($newPwd==""){
- return error_show(1001,'密码不能为空');
- }
- $data = resetpwd($token,["id"=>$userid,'password'=>$newPwd]);
- if(empty($data)||$data['code']!=0){
- return error_show($data['code'],$data['message']);
- }else{
- return app_show(0,"密码修改成功");
- }
- }
- public function UserStatus()
- {
- $post=$this->request->post();
- $toke= isset($post['token'])? trim($post['token']):"";
- if ($toke==""){
- return app_show(100,"token不能为空");
- }
- $verify = VerifyTokens($toke);
- if ($verify['code']!=0){
- return app_show($verify['code'],$verify['message']);
- }
- $userid = isset($post['id'])&&$post['id']!==""?intval($post['id']):"";
- if($userid==""){
- return error_show(1004,"参数userid 不能为空");
- }
- $status = isset($post['status'])&&$post['status']!=""?intval($post['status']):"";
- if($status===""){
- return error_show(1004,"参数status 不能为空");
- }
- if(!in_array($status,[0,1])){
- return error_show(1004,"参数status无效");
- }
- $message = $status==1?"启用":"禁用";
- $userinfo =Db::name("user_role")->where(["uid"=>$userid,"is_del"=>0])->find();
- if($userinfo==false){
- $data=[
- "uid"=>$userid,
- "roleid"=>0,
- "status"=>$status,
- "is_del"=>0,
- "addtime"=>date("Y-m-d H:i:s"),
- "updatetime"=>date("Y-m-d H:i:s"),
- ];
- $sa=Db::name("user_role")->save($data);
- }else{
- $userinfo['status']=$status;
- $userinfo['updatetime']=date("Y-m-d H:i:s");
- $sa=Db::name("user_role")->save($userinfo);
- }
- if($sa==false){
- return error_show(1005,"{$message}失败");
- }else{
- return app_show(0,"{$message}成功");
- }
- // $set = resetstatus($toke,["id"=>$userid,"status"=>$status]);
- //
- // if(empty($set)||$set['code']!=0){
- // return error_show(1005,"{$message}失败");
- // }else{
- // D
- // return app_show(0,"{$message}成功");
- // }
- }
- public function getinfo(){
- $post =$this->request->post();
- $token = isset($post['token']) ? trim($post['token']) : "";
- if($token==""){
- return app_show(101,'token不能为空');
- }
- $effetc = VerifyTokens($token);
- if(!empty($effetc) && $effetc['code']!=0){
- return app_show($effetc['code'],$effetc['message']);
- }
- $userinfo=GetUserInfo($token);
- if(empty($userinfo)||$userinfo['code']!=0){
- return app_show(102,"员工信息不存在");
- }
- $data = $userinfo['data'];
- $role = Db::name("user_role")->alias('a')->leftJoin('role b',"a.roleid = b.id")->where("a.uid","=",$data['id'])
- ->field("roleid,role_name,business_all,uid")->find();
- $data['role_name']=isset($role['role_name']) ? $role['role_name'] :"";
- $data['roleid']=isset($role['roleid']) ? $role['roleid'] :"";
- $st = Db::name('user_business')->where(['userid'=>$role['uid'],"is_del"=>0])->field('businessid,is_main')->select()->toArray();
- $val=[];
- if (!empty($st)){
- foreach ($st as $itom){
- $tep=[];
- $business= Db::name('business')->where(['id'=>$itom['businessid'],"is_del"=>0])->field("company,companyNo")->find();
- $tep['company']=isset($business['company'])?$business['company']:"";
- $tep['companyNo']=isset($business['companyNo'])?$business['companyNo']:"";
- $tep['businessid']=$itom['businessid'];
- $tep['is_main']=$itom['is_main'];
- $val[]=$tep;
- }
- }
- $data['private_field'] = [];
- if($data['roleid']!=""){
- $action =Db::name("role_action")->where(["role_id"=>$data['roleid'],"status"=>1])->find();
- if($action!=false){
- $data['private_field']=isset($action['private_field'])&&$action['private_field']!=""?explode(",",
- $action['private_field']):[];
- }
- }
- $data['business'] =$val;
- $info=[];
- $stn = Db::name('user_platform')->where(['uid'=>$role['uid']])->find();
- if($stn!=false){
- $plat =isset($stn['platform'])?explode(",",$stn['platform']):"";
- if($plat!=""){
- $platform = Db::name('platform')->where(['id'=>$plat,'is_del'=>0])->column("id,platform_name,platform_code");
- $info=$platform;
- }
- }
- $depart = Db::name("depart_user")->where([["uid","=",$data['id']],["is_del","=",0]])->column("itemid");
- $data['depart']="";
- if(!empty($depart)){
- $deparname = Db::name("company_item")->where(["id"=>$depart,"is_del"=>0])->field("id,name,depart_link")->select()->toArray();
- if(!empty($deparname)){
- foreach ($deparname as $ky=> $item) {
- $deparname[$ky]['depart_code']= array_filter(explode("-",$item['depart_link'])) ;
- }
- }
- $data['depart'] = $deparname;
- }
- $data['platform']=$info;
- return app_show(0,"获取成功",$data);
- }
- }
|