Group.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php namespace Manage\Lib;
  2. use Dever;
  3. use Dever\Helper\Str;
  4. class Group extends Auth
  5. {
  6. public function getTree()
  7. {
  8. $data = Dever::db('group', 'manage')->select([]);
  9. $result = array();
  10. $result[] = array
  11. (
  12. 'id' => 'root',
  13. 'name' => '全部集团',
  14. 'children' => $data,
  15. );
  16. return $result;
  17. }
  18. # 后续废弃,转移到system中
  19. public function update($data)
  20. {
  21. if ($data['mobile']) {
  22. $system = Dever::db('system', 'manage')->find(2);
  23. $data['system_id'] = $system['id'];
  24. $data['info_id'] = $data['id'];
  25. $data['partition'] = $system['partition'];
  26. $db = Dever::db($system['user_table'], '', 'default', Dever::load('common', 'manage')->system($data));
  27. $info = $db->find(1);
  28. if (!$info) {
  29. $password = '123456';
  30. $insert['name'] = Str::hide($data['mobile']);
  31. $insert['mobile'] = $data['mobile'];
  32. $insert['role'] = 1;
  33. $insert += Dever::load('common')->createPwd($password);
  34. $db->insert($insert);
  35. }
  36. }
  37. }
  38. # 后续废弃,转移到system中
  39. # 创建账户
  40. public function createUser($module, $data_id, $name, $mobile, $password, $state = false)
  41. {
  42. if ($mobile && $password) {
  43. $system = Dever::db('system', 'manage')->find(2);
  44. $data['system_id'] = $system['id'];
  45. $data['info_id'] = 1;
  46. $data['partition'] = $system['partition'];
  47. $db = Dever::db($system['user_table'], '', 'default', Dever::load('common', 'manage')->system($data));
  48. $info = $db->find(array('mobile' => $mobile));
  49. if ($state && $info) {
  50. Dever::error('手机号' . $mobile . '已存在,请更换手机号');
  51. }
  52. $module = Dever::db('system_module', 'manage')->find(array('key' => $module, 'system' => 'group'));
  53. $insert['name'] = $name;
  54. $insert['mobile'] = $mobile;
  55. $insert['role'] = 2;
  56. $insert['module_data'] = $module['id'] . '-' . $data_id;
  57. if (!$info) {
  58. $insert += Dever::load('common')->createPwd($password);
  59. $db->insert($insert);
  60. } else {
  61. $insert += Dever::load('common')->createPwd($password);
  62. $module_data = $insert['module_data'];
  63. unset($insert['module_data']);
  64. if (!strstr($info['module_data'], $module_data)) {
  65. $insert['module_data'] = $module_data . ',' . $info['module_data'];
  66. }
  67. $db->update($info['id'], $insert);
  68. }
  69. }
  70. }
  71. }