column('user_id'); if(empty($firstUserIds)){ return []; } // 查询父级下面的用户 $userIds = UserModel::where('origin_user_id','in',$firstUserIds)->column('user_id'); return array_merge($firstUserIds, $userIds); // return UserModel::where('origin_user_id','in',$firstUserIds)->column('user_id'); } // 判断操作用户是否是代理商 public static function checkUserIsAgent($adminId) { // 代理角色 $roleId = 10; $admin = self::where('id', $adminId)->find(); if($admin && $admin['role_id'] == $roleId){ return true; } return false; // $agentGroupId = env('AGENT.AGENT_GROUP_ID'); // $authGroupAccess = AuthGroupAccessModel::where('uid', $adminId)->find(); // if($authGroupAccess && $authGroupAccess['group_id'] == $agentGroupId){ // return true; // } // return false; } /** * @desc 根据用户id 查询指定字段 * @param $fields * @param $userId * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public static function getFieldsByUserId($fields, $userId): array { $self = self::where('id', $userId)->field($fields)->find(); if(empty($self)){ return []; } return $self->toArray(); } /** * @desc 获取邀请码用户 * @param $inviteCode * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public static function getIdByInviteCode($inviteCode): int { $self = self::where('invite_code', $inviteCode)->value('id'); if(empty($self)){ return 0; } return $self; } public static function getCustomerIdsByAgentId($agentId): array { return self::where('parent_id', $agentId)->column('id'); } }