12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace app\wechat\service;
- use app\model\SysDept;
- class TeamService
- {
- const DEPT_CATEGORY = '获客团队';
- /**
- * Notes: 根据id获取所有的子集
- * User: yb
- * Date: 2024/8/12
- * Time: 11:34
- * @param $id
- */
- public static function getIds($id)
- {
- $where = [
- ['dept_category', '=', self::DEPT_CATEGORY]
- ];
- $deptInfo = SysDept::where('dept_id', $id)->where('dept_category', self::DEPT_CATEGORY)->first();
- $deptSuperPath = $deptInfo->dept_super_path;
- $where[] = ['dept_super_path', 'like', "{$deptSuperPath}%"];
- return SysDept::where($where)->pluck('dept_id')->toArray();
- }
- /**
- * Notes: 获取团队信息
- * User: yb
- * Date: 2024/8/14
- * Time: 16:30
- * @return
- */
- public static function getTeams()
- {
- $where = [
- ['dept_category', '=', self::DEPT_CATEGORY]
- ];
- $data = SysDept::where($where)->select(['dept_id', 'dept_super_id', 'dept_super_path', 'dept_name'])->get();
- return $data;
- }
- /**
- * Notes: 根据部门id获取部门信息
- * User: yb
- * Date: 2024/8/14
- * Time: 16:35
- * @param $id
- */
- public static function getTeamList($id)
- {
- $deptSuperPath = SysDept::where('dept_id', $id)->value('dept_super_path');
- $deptList = SysDept::where('dept_super_path', 'like', "{$deptSuperPath}%")->where('dept_category', self::DEPT_CATEGORY)->get();
- if ($deptList->isEmpty()) {
- return [];
- } else {
- return $deptList;
- }
- }
- }
|