whereIn('user_id', $ownerUserId)->column('work_id'); $userWhere['work_id'] = ['in', $userIds]; } $userModel = new \app\admin\model\User(); $perUserIds = $userModel->getUserByPer('work', 'work', 'index'); $authUser = array_unique(array_merge([$param['user_id']], $perUserIds)); $data = Db::name('work') ->where(function($query) { $query->where('status', 1); $query->where('ishidden', 0); }) ->where(function ($query) use ($param, $authUser) { $query->whereOr(['create_user_id' => ['in', $authUser]]); $query->whereOr('is_open', 1); $query->whereOr(function ($query) use ($param) { $query->where('is_open', 0); $query->where('owner_user_id', 'like', '%' . $param['user_id'] . '%'); }); }) ->where($searchWhere) ->where($dateWhere) ->where($userWhere) ->order($orderField, $orderSort)->select(); foreach ($data AS $key => $value) { $data[$key]['authList']['project'] = $this->getRuleList($value['work_id'], $param['user_id'], $value['group_id']); } return $data; } }