0
0

AppIcon.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\common\model\Config;
  5. use app\hander\HelpHander;
  6. use think\Db;
  7. class AppIcon extends Base
  8. {
  9. public function lists(){
  10. $orgId = input('orgId',0);
  11. $token = input('token','','trim');
  12. $rolesId = input('rolesId',0);
  13. $type = input('type',0);
  14. $ret = [];
  15. $rolesIds = db('roles')->where('id',$rolesId)->value('appauths');
  16. $orgapps = Db::name('org')->where('id',$orgId)->value('appauths');
  17. $rolesIds = $rolesIds?explode(',',$rolesIds):[];
  18. $orgapps = $orgapps?explode(',',$orgapps):[];
  19. $ret['appIcons'] = [];
  20. if($rolesIds || in_array($rolesId,[1,2])){
  21. $map = [];
  22. if(in_array($rolesId,[1,2])){
  23. if($orgapps){
  24. $map[] = ['id','in',$orgapps];
  25. }else{
  26. $map[] = ['id','=',0];
  27. }
  28. }else{
  29. $ids = array_unique(array_intersect($rolesIds,$orgapps));
  30. if($ids){
  31. $map[] = ['id','in',$ids];
  32. }else{
  33. $map[] = ['id','=',0];
  34. }
  35. }
  36. $map[] = ['enable','=',1];
  37. $map[] = ['type','=',$type];
  38. $map[] = ['del','=',0];
  39. if($type == 0){ //0=首页 1=统计页
  40. $map[] = ['pid','=',0];
  41. }
  42. $appIcon = db('app_icon')
  43. ->field('id,name,mode,path,url,des')
  44. ->where($map)
  45. ->order(['sort'=>'desc','id'=>'asc'])
  46. ->select();
  47. foreach ($appIcon as $k=>$v){
  48. if($v['url']){
  49. if(strstr($v['url'],'?') === false){
  50. $appIcon[$k]['url'] = $v['url'].'?token='.$token.'&orgId='.$orgId;
  51. }else{
  52. $appIcon[$k]['url'] = $v['url'].'&token='.$token.'&orgId='.$orgId;
  53. }
  54. }
  55. $c = 0;
  56. if($v['id']==10){//专项保洁
  57. $c = model('CleanTask')
  58. ->taskCount2(0,$this->userId,$orgId);
  59. }elseif ($v['id']==7){//设备维保
  60. $c = model('Device')
  61. ->taskCount($this->userId,$orgId);
  62. }elseif ($v['id']==17){//巡更任务
  63. $c = model('PatrolTask')
  64. ->taskCount($this->userId,$orgId,1);
  65. }elseif ($v['id']==18){//巡检任务
  66. $c = model('PatrolTask')
  67. ->taskCount($this->userId,$orgId,4);
  68. }elseif ($v['id']==19){//巡查任务
  69. $c = model('PatrolTask')
  70. ->taskCount($this->userId,$orgId,3);
  71. }elseif ($v['id']==20){//巡视任务
  72. $c = model('PatrolTask')
  73. ->taskCount($this->userId,$orgId,2);
  74. }
  75. $appIcon[$k]['name'] = $c>0?$v['name'].'('.$c.')':$v['name'];
  76. }
  77. $ret['appIcons'] = $appIcon;
  78. }
  79. $orgGrabOrder = getOrgGrabOrder($this->userId,$this->orgId);
  80. $ret['org_grab_order'] = $orgGrabOrder;
  81. HelpHander::success($ret,'成功');
  82. }
  83. public function notice(){
  84. $ret['bannerList'] = Db::name('banner')
  85. ->where('del',0)
  86. ->where('enable',1)
  87. ->where('type',0)
  88. ->select();
  89. $notice = Db::name('notice')
  90. ->where('org_id',$this->orgId)
  91. ->where('user_id',$this->userId)
  92. ->where('del',0)
  93. ->field('id,title')
  94. ->order('id','desc')
  95. ->find();
  96. if(!$notice){
  97. $notice = Db::name('notice_common')
  98. ->where('org_id',$this->orgId)
  99. ->where('del',0)
  100. ->field('id,title')
  101. ->order('id','desc')
  102. ->find();
  103. }
  104. $ret['notice'] = $notice?$notice:null;
  105. HelpHander::success($ret,'成功');
  106. }
  107. public function wxlist(){
  108. $token = input('token','','trim');
  109. $modes = ['1','2','3','4','12','15','42','48'];
  110. $appicons = Db::name('org')->where('id',$this->orgId)->value('appauths');
  111. $map[] = ['enable','=',1];
  112. $map[] = ['type','=',0];
  113. $map[] = ['pid','=',0];
  114. $map[] = ['del','=',0];
  115. $map[] = ['mode','in',$modes];
  116. if($appicons){
  117. $map[] = ['id','in',explode(',',$appicons)];
  118. }
  119. $appIcon = db('app_icon')
  120. ->field('id,name,mode,path,url,des')
  121. ->where($map)
  122. ->order(['sort'=>'desc','id'=>'asc'])
  123. ->select();
  124. foreach ($appIcon as $k=>$v){
  125. if($v['url']){
  126. if(strstr($v['url'],'?') === false){
  127. $appIcon[$k]['url'] = $v['url'].'?token='.$token.'&orgId='.$this->orgId;
  128. }else{
  129. $appIcon[$k]['url'] = $v['url'].'&token='.$token.'&orgId='.$this->orgId;
  130. }
  131. }
  132. }
  133. HelpHander::success($appIcon?$appIcon:[],'成功');
  134. }
  135. }