How to auto-generate random numbers in username?

This function would generate a unique user login slug:

function my_unique_user_slug( $slug ) {
    global $wpdb;

    $check_sql = "SELECT user_login FROM $wpdb->users WHERE user_login = %s LIMIT 1";
    if ( ! $wpdb->get_var( $wpdb->prepare( $check_sql, $slug ) ) ) {
        return $slug;
    }

    $suffix = 2;
    do {
        $alt_slug = $slug . $suffix;
        $user_slug_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_slug ) );
        $suffix++;
    } while ( $user_slug_check );

    return $alt_slug;
}

It is based on the wp_unique_post_slug() function, and you can use it like so:

if ( ! empty( $complete_name ) ) {
    $slug = sanitize_user( preg_replace( '/\s+/u', '', $complete_name ) );
    $new_customer_data['user_login'] = my_unique_user_slug( $slug );
}

tech