CheckPower.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. namespace app\common\service;
  3. use app\common\model\ArticleCate;
  4. use app\common\model\ArticleIntro;
  5. use app\common\model\ArticleItem;
  6. use app\common\model\DatumCate;
  7. use app\common\model\DatumIntro;
  8. use app\common\model\DatumUrl;
  9. use app\common\model\DiscountActivity;
  10. use app\common\model\DiscountGoods;
  11. use app\common\model\ForumReply;
  12. use app\common\model\GoodsCate;
  13. use app\common\model\GroupActivity;
  14. use app\common\model\GroupGoods;
  15. use app\common\model\PlatformDemand;
  16. use app\common\model\Press;
  17. use app\common\model\Recruit;
  18. use app\common\model\RecruitCate;
  19. use app\common\model\RecruitResume;
  20. use app\common\model\ReductionActivity;
  21. use app\common\model\SeckillActivity;
  22. use app\common\model\SeckillGoods;
  23. use app\common\model\SeriesArticleCate;
  24. use app\common\model\SeriesVideoCate;
  25. use app\common\model\StoreGoods;
  26. use app\common\model\Supplier;
  27. use app\common\model\SupplierCate;
  28. use app\common\model\SupplierGoods;
  29. use app\common\model\UserForum;
  30. use app\common\model\VideoCate;
  31. use app\common\model\VideoIntro;
  32. use app\common\model\VideoUrl;
  33. /**
  34. * 验证权限
  35. * Class Activity
  36. */
  37. class CheckPower
  38. {
  39. // 检查各个模块详情是否能跳转
  40. public static function checkModulesPower($first_id,$second_id,$module,$type_id = 0)
  41. {
  42. $check_val = 1;
  43. $module= strtolower($module);
  44. switch ($module)
  45. {
  46. case 'video':
  47. $item = VideoUrl::where('id',$second_id)->where('status',1)->where('is_deleted',0)->value('id');
  48. if(!$item) return 0;
  49. $parent = VideoIntro::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  50. if(!$parent) return 0;
  51. if($parent->type == 1)
  52. {
  53. $cate = VideoCate::where('id','in',[$parent->first_classify,$parent->second_classify])
  54. ->where('status',1)->where('is_deleted',0)->count();
  55. }else{
  56. $cate = SeriesVideoCate::where('id','in',[$parent->first_classify,$parent->second_classify])
  57. ->where('status',1)->where('is_deleted',0)->count();
  58. }
  59. // if($cate != 2) return 0;
  60. break;
  61. case 'article':
  62. if($second_id != 0){
  63. $item = ArticleItem::where('id',$second_id)->where('status',1)->where('is_deleted',0)->value('id');
  64. if(!$item) return 0;
  65. }
  66. if($first_id != 0) {
  67. $parent = ArticleIntro::where('id', $first_id)->where('status', 1)->where('is_deleted', 0)->find();
  68. if (!$parent) return 0;
  69. }
  70. if($parent->type == 1)
  71. {
  72. $cate = ArticleCate::where('id','in',[$parent->first_classify,$parent->second_classify])
  73. ->where('status',1)->where('is_deleted',0)->count();
  74. }else{
  75. $cate = SeriesArticleCate::where('id','in',[$parent->first_classify,$parent->second_classify])
  76. ->where('status',1)->where('is_deleted',0)->count();
  77. }
  78. // if($cate != 2) return 0;
  79. break;
  80. case 'datum':
  81. $item = DatumUrl::where('id',$second_id)->where('status',1)->where('is_deleted',0)->value('id');
  82. if(!$item) return 0;
  83. $parent = DatumIntro::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  84. if(!$parent) return 0;
  85. if(!$parent->datum_cate) return 1;
  86. $cate = DatumCate::where('id','in',[$parent->datum_cate])
  87. ->where('status',1)->where('is_deleted',0)->count();
  88. //if($cate != 1) return 0;
  89. break;
  90. case 'press':
  91. $item = Press::where('id',$first_id)->where('status',1)->where('is_deleted',0)->value('id');
  92. if(!$item) return 0;
  93. break;
  94. case 'forum':
  95. $item = UserForum::where('id',$first_id)->where('status',1)->where('is_deleted',0)->value('id');
  96. if(!$item) return 0;
  97. break;
  98. case 'reply':
  99. $item = ForumReply::where('id',$first_id)->where('is_deleted',0)->value('id');
  100. if(!$item) return 0;
  101. break;
  102. case 'recruit':
  103. if($type_id == 4){
  104. $item = RecruitResume::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  105. }else{
  106. $item = Recruit::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  107. }
  108. if(!$item) return 0;
  109. /* $cate = RecruitCate::where('id','in',[$item->first_classify,$item->second_classify])
  110. ->where('status',1)->where('is_deleted',0)->count();
  111. if($cate != 2) return 0;*/
  112. break;
  113. case 'mall':
  114. $item = StoreGoods::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  115. if(!$item) return 0;
  116. /* $cate = GoodsCate::where('id','in',[$item->first_classify,$item->second_classify])
  117. ->where('status',1)->where('is_deleted',0)->count();
  118. if($cate != 2) return 0;*/
  119. break;
  120. case 'supplier':
  121. $item = SupplierGoods::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  122. if(!$item) return 0;
  123. /* $parent = Supplier::where('id',$item->supplier_id)->where('status',1)->where('is_deleted',0)->find();
  124. if(!$parent) return 0;
  125. $cate = SupplierCate::where('id','in',[$parent->first_classify,$parent->second_classify,$parent->third_classify])
  126. ->where('status',1)->where('is_deleted',0)->count();
  127. if($cate != 3) return 0;*/
  128. break;
  129. case 'demand':
  130. $item = PlatformDemand::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  131. if(!$item) return 0;
  132. break ;
  133. case 'activity':
  134. //$item = \app\common\model\ActivityApply::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  135. $item1 = \app\common\model\Activity::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  136. if(!$item1) return 0;
  137. break;
  138. case 'activityapply':
  139. $item = \app\common\model\ActivityApply::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  140. $item1 = \app\common\model\Activity::where('id',$item['act_id'])->where('status',1)->where('is_deleted',0)->find();
  141. if(!$item1) return 0;
  142. break;
  143. case 'apply':
  144. $item = \app\common\model\ActivityApplyItem::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  145. if(!$item) return 0;
  146. break;
  147. }
  148. return $check_val;
  149. }
  150. // 检查各个模块是否能跳转
  151. public static function checkItemPower($first_id,$second_id,$module)
  152. {
  153. }
  154. }