123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- /**
- * UserLogic.php UTF-8
- *
- *
- * @date : 2017/12/22 16:16
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : liguanglong <lgl@huosdk.com>
- * @version : HUOSDK 8.0
- */
- namespace huo\logic\user;
- use huo\model\common\CommonModel;
- use huo\model\game\GameModel;
- use huo\model\user\RoleModel;
- use huo\model\user\RoleUserModel;
- use huo\model\user\UserModel;
- class UserLogic extends CommonModel {
- public function getList() {
- return UserModel::field(['id', 'user_login', 'user_nicename'])->select()->toArray();
- }
- //获取当前登录用户及其子类的:用户id, cpid, 渠道id, 游戏id
- public function getRoleLevelID($adminID = 0) {
- $_id = $_cp_id = $_agent_id = $_app_id = [];
- $_model = new UserModel();
- $_model = $_model->select()->toArray();
- if (!empty($_model)) {
- $_current = null;
- foreach ($_model as $val) {
- if ($val['id'] == $adminID) {
- $_current = $val;
- break;
- }
- }
- $_model = get_child($_model, $adminID);
- $_model = get_single($_model);
- array_unshift($_model, $_current);
- }
- $_id = array_column($_model, 'id');
- $_cp_id = array_column($_model, 'cp_id');
- $_agent_id = array_column($_model, 'id');
- $_model = new RoleModel();
- $_role_model = $_model->where('role_type', RoleModel::ROLE_AGENT)->find();
- $_model = new RoleUserModel();
- $_agent_id = $_model->whereIn('user_id', $_agent_id)
- ->where('role_id', $_role_model['id'])
- ->column('user_id');
- $_model = new GameModel();
- $_app_id = $_model->whereIn('cp_id', $_cp_id)->column('id');
- return [$_id, $_cp_id, $_agent_id, $_app_id];
- }
- }
|