123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <?php
- namespace app\api\controller\v1;
- use app\api\controller\Base;
- use app\common\model\Config;
- use app\hander\HelpHander;
- use think\Db;
- class AppIcon extends Base
- {
- public function lists(){
- $orgId = input('orgId',0);
- $token = input('token','','trim');
- $rolesId = input('rolesId',0);
- $type = input('type',0);
- $ret = [];
- $rolesIds = db('roles')->where('id',$rolesId)->value('appauths');
- $orgapps = Db::name('org')->where('id',$orgId)->value('appauths');
- $rolesIds = $rolesIds?explode(',',$rolesIds):[];
- $orgapps = $orgapps?explode(',',$orgapps):[];
- $ret['appIcons'] = [];
- if($rolesIds || in_array($rolesId,[1,2])){
- $map = [];
- if(in_array($rolesId,[1,2])){
- if($orgapps){
- $map[] = ['id','in',$orgapps];
- }else{
- $map[] = ['id','=',0];
- }
- }else{
- $ids = array_unique(array_intersect($rolesIds,$orgapps));
- if($ids){
- $map[] = ['id','in',$ids];
- }else{
- $map[] = ['id','=',0];
- }
- }
- $map[] = ['enable','=',1];
- $map[] = ['type','=',$type];
- $map[] = ['del','=',0];
- if($type == 0){ //0=首页 1=统计页
- $map[] = ['pid','=',0];
- }
- $appIcon = db('app_icon')
- ->field('id,name,mode,path,url,des')
- ->where($map)
- ->order(['sort'=>'desc','id'=>'asc'])
- ->select();
- foreach ($appIcon as $k=>$v){
- if($v['url']){
- if(strstr($v['url'],'?') === false){
- $appIcon[$k]['url'] = $v['url'].'?token='.$token.'&orgId='.$orgId;
- }else{
- $appIcon[$k]['url'] = $v['url'].'&token='.$token.'&orgId='.$orgId;
- }
- }
- $c = 0;
- if($v['id']==10){//专项保洁
- $c = model('CleanTask')
- ->taskCount2(0,$this->userId,$orgId);
- }elseif ($v['id']==7){//设备维保
- $c = model('Device')
- ->taskCount($this->userId,$orgId);
- }elseif ($v['id']==17){//巡更任务
- $c = model('PatrolTask')
- ->taskCount($this->userId,$orgId,1);
- }elseif ($v['id']==18){//巡检任务
- $c = model('PatrolTask')
- ->taskCount($this->userId,$orgId,4);
- }elseif ($v['id']==19){//巡查任务
- $c = model('PatrolTask')
- ->taskCount($this->userId,$orgId,3);
- }elseif ($v['id']==20){//巡视任务
- $c = model('PatrolTask')
- ->taskCount($this->userId,$orgId,2);
- }
- $appIcon[$k]['name'] = $c>0?$v['name'].'('.$c.')':$v['name'];
- }
- $ret['appIcons'] = $appIcon;
- }
- $orgGrabOrder = (new Config())->getConfig('org_grab_order',$orgId);
- $ret['org_grab_order'] = $orgGrabOrder?(int)$orgGrabOrder:0;
- HelpHander::success($ret,'成功');
- }
- public function notice(){
- $ret['bannerList'] = Db::name('banner')
- ->where('del',0)
- ->where('enable',1)
- ->where('type',0)
- ->select();
- $notice = Db::name('notice')
- ->where('org_id',$this->orgId)
- ->where('user_id',$this->userId)
- ->where('del',0)
- ->field('id,title')
- ->order('id','desc')
- ->find();
- if(!$notice){
- $notice = Db::name('notice_common')
- ->where('org_id',$this->orgId)
- ->where('del',0)
- ->field('id,title')
- ->order('id','desc')
- ->find();
- }
- $ret['notice'] = $notice?$notice:null;
- HelpHander::success($ret,'成功');
- }
- public function wxlist(){
- $token = input('token','','trim');
- $modes = ['1','2','3','4','12','15','42','48'];
- $appicons = Db::name('org')->where('id',$this->orgId)->value('appauths');
- $map[] = ['enable','=',1];
- $map[] = ['type','=',0];
- $map[] = ['pid','=',0];
- $map[] = ['del','=',0];
- $map[] = ['mode','in',$modes];
- if($appicons){
- $map[] = ['id','in',explode(',',$appicons)];
- }
- $appIcon = db('app_icon')
- ->field('id,name,mode,path,url,des')
- ->where($map)
- ->order(['sort'=>'desc','id'=>'asc'])
- ->select();
- foreach ($appIcon as $k=>$v){
- if($v['url']){
- if(strstr($v['url'],'?') === false){
- $appIcon[$k]['url'] = $v['url'].'?token='.$token.'&orgId='.$this->orgId;
- }else{
- $appIcon[$k]['url'] = $v['url'].'&token='.$token.'&orgId='.$this->orgId;
- }
- }
- }
- HelpHander::success($appIcon?$appIcon:[],'成功');
- }
- }
|