How to put a block of code between [shortcode][/shortcode] in do_shortcode()?

Your issue with output is because you are using versions of template tags that immediately output the result when called, rather than return it to be concatenated with the string.

For example the_permalink() as opposed to get_permalink().