UserLogic.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * UserLogic.php UTF-8
  4. *
  5. *
  6. * @date : 2017/12/22 16:16
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : liguanglong <lgl@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\logic\user;
  13. use huo\model\common\CommonModel;
  14. use huo\model\game\GameModel;
  15. use huo\model\user\RoleModel;
  16. use huo\model\user\RoleUserModel;
  17. use huo\model\user\UserModel;
  18. class UserLogic extends CommonModel {
  19. public function getList() {
  20. return UserModel::field(['id', 'user_login', 'user_nicename'])->select()->toArray();
  21. }
  22. //获取当前登录用户及其子类的:用户id, cpid, 渠道id, 游戏id
  23. public function getRoleLevelID($adminID = 0) {
  24. $_id = $_cp_id = $_agent_id = $_app_id = [];
  25. $_model = new UserModel();
  26. $_model = $_model->select()->toArray();
  27. if (!empty($_model)) {
  28. $_current = null;
  29. foreach ($_model as $val) {
  30. if ($val['id'] == $adminID) {
  31. $_current = $val;
  32. break;
  33. }
  34. }
  35. $_model = get_child($_model, $adminID);
  36. $_model = get_single($_model);
  37. array_unshift($_model, $_current);
  38. }
  39. $_id = array_column($_model, 'id');
  40. $_cp_id = array_column($_model, 'cp_id');
  41. $_agent_id = array_column($_model, 'id');
  42. $_model = new RoleModel();
  43. $_role_model = $_model->where('role_type', RoleModel::ROLE_AGENT)->find();
  44. $_model = new RoleUserModel();
  45. $_agent_id = $_model->whereIn('user_id', $_agent_id)
  46. ->where('role_id', $_role_model['id'])
  47. ->column('user_id');
  48. $_model = new GameModel();
  49. $_app_id = $_model->whereIn('cp_id', $_cp_id)->column('id');
  50. return [$_id, $_cp_id, $_agent_id, $_app_id];
  51. }
  52. }