Group.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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_key'] = $system['key'];
  24. $data['system_id'] = $system['id'];
  25. $data['info_id'] = $data['id'];
  26. $data['partition'] = $system['partition'];
  27. $db = Dever::db($system['user_table'], '', 'default', Dever::load('common', 'manage')->system($data));
  28. $info = $db->find(1);
  29. if (!$info) {
  30. $password = '123456';
  31. $insert['name'] = Str::hide($data['mobile']);
  32. $insert['mobile'] = $data['mobile'];
  33. $insert['role'] = 1;
  34. $insert += Dever::load('common')->createPwd($password);
  35. $db->insert($insert);
  36. }
  37. }
  38. }
  39. # 后续废弃,转移到system中
  40. # 创建账户
  41. public function createUser($module, $data_id, $name, $mobile, $password, $state = false)
  42. {
  43. if ($mobile && $password) {
  44. $system = Dever::db('system', 'manage')->find(2);
  45. $data['system_key'] = $system['key'];
  46. $data['system_id'] = $system['id'];
  47. $data['info_id'] = 1;
  48. $data['partition'] = $system['partition'];
  49. $db = Dever::db($system['user_table'], '', 'default', Dever::load('common', 'manage')->system($data));
  50. $info = $db->find(array('mobile' => $mobile));
  51. if ($state && $info) {
  52. Dever::error('手机号' . $mobile . '已存在,请更换手机号');
  53. }
  54. $module = Dever::db('system_module', 'manage')->find(array('key' => $module, 'system' => 'group'));
  55. $insert['name'] = $name;
  56. $insert['mobile'] = $mobile;
  57. $insert['role'] = 2;
  58. $insert['module_data'] = $module['id'] . '-' . $data_id;
  59. if (!$info) {
  60. $insert += Dever::load('common')->createPwd($password);
  61. $db->insert($insert);
  62. } else {
  63. $insert += Dever::load('common')->createPwd($password);
  64. $module_data = $insert['module_data'];
  65. unset($insert['module_data']);
  66. if (!strstr($info['module_data'], $module_data)) {
  67. $insert['module_data'] = $module_data . ',' . $info['module_data'];
  68. }
  69. $db->update($info['id'], $insert);
  70. }
  71. }
  72. }
  73. }