123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace app\model;
- use think\Model;
- class Permission extends Model
- {
- public function getTree($condition, $root_id)
- {
- $excep = $this->exception_condition($root_id);
- $all = self::where($condition)->order('pid desc, sort asc')->select()->toArray();
- $arr = [];
- $company_id = Company::where('root_id', '=', $root_id)->value('id');
- $wework_setting = WeworksingleCompanySetting::where('company_id', '=', $company_id)->find();
- $wework_per = self::where('auth_name', 'in', ['企微管理', '企业微信'])->column('id');
- foreach ($all as $item) {
- ///直播开通 menu 展示
- if ($excep && isset($item['auth_name']) && in_array($item['auth_name'],[ '新建直播', '营销获客', '聊天管理', '业绩考核', '获客看板', '我的订单' ])) {
- continue;
- }
- if (!$excep && isset($item['auth_name']) && in_array($item['auth_name'],[ '直播管理' ])) {
- continue;
- }
- // 没开通企业微信隐藏模块功能
- /* if (empty($wework_setting) && (in_array($item['id'], $wework_per) || in_array($item['pid'], $wework_per))) {
- continue;
- } */
- if (in_array($item['id'], $wework_per) || in_array($item['pid'], $wework_per)) {
- continue;
- }
- /*if (empty($wework_setting) && isset($item['auth_name']) && in_array($item['auth_name'], ['企微客户', '企微管理', '企微群发', '企业微信', '客户运营', '客户群管理', '数据统计'])) {
- continue;
- }*/
- ///
- if (isset($arr[$item['id']])) {
- $item['child'] = $arr[$item['id']];
- unset($arr[$item['id']]);
- }
- $arr[$item['pid']][] = $item;
- }
- $data = [];
- foreach($arr as $item){
- $data = array_merge($data, $item);
- }
- return $data;
- }
- private function exception_condition($root_id){
- $condition = [
- ['root_id' ,'=', $root_id],
- ['end_at', '>', date('Y-m-d'). ' 00:00:00']
- ];
- $companybossopened = CompanyBossOpen::where($condition)->find();
- if(!$companybossopened){
- return true;
- }else{
- return false;
- }
- }
- }
|