TeamService.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\wechat\service;
  3. use app\model\SysDept;
  4. class TeamService
  5. {
  6. const DEPT_CATEGORY = '获客团队';
  7. /**
  8. * Notes: 根据id获取所有的子集
  9. * User: yb
  10. * Date: 2024/8/12
  11. * Time: 11:34
  12. * @param $id
  13. */
  14. public static function getIds($id)
  15. {
  16. $where = [
  17. ['dept_category', '=', self::DEPT_CATEGORY]
  18. ];
  19. $deptInfo = SysDept::where('dept_id', $id)->where('dept_category', self::DEPT_CATEGORY)->first();
  20. $deptSuperPath = $deptInfo->dept_super_path;
  21. $where[] = ['dept_super_path', 'like', "{$deptSuperPath}%"];
  22. return SysDept::where($where)->pluck('dept_id')->toArray();
  23. }
  24. /**
  25. * Notes: 获取团队信息
  26. * User: yb
  27. * Date: 2024/8/14
  28. * Time: 16:30
  29. * @return
  30. */
  31. public static function getTeams()
  32. {
  33. $where = [
  34. ['dept_category', '=', self::DEPT_CATEGORY]
  35. ];
  36. $data = SysDept::where($where)->select(['dept_id', 'dept_super_id', 'dept_super_path', 'dept_name'])->get();
  37. return $data;
  38. }
  39. /**
  40. * Notes: 根据部门id获取部门信息
  41. * User: yb
  42. * Date: 2024/8/14
  43. * Time: 16:35
  44. * @param $id
  45. */
  46. public static function getTeamList($id)
  47. {
  48. $deptSuperPath = SysDept::where('dept_id', $id)->value('dept_super_path');
  49. $deptList = SysDept::where('dept_super_path', 'like', "{$deptSuperPath}%")->where('dept_category', self::DEPT_CATEGORY)->get();
  50. if ($deptList->isEmpty()) {
  51. return [];
  52. } else {
  53. return $deptList;
  54. }
  55. }
  56. }