I'm a little bit confused that you explain the problem a lot and also the threats and punishments you tried, but no word about what he says about it.
He sounds smart enough to understand that his behavior isn't beneficial in every way, and I have a lot of reason to assume he's even already well aware of that.
Willow Rex already pointed out that it's a good idea to let him face the consequences, I also think that's a very important start.
In my opinion doing so serves two goals:
- Stop giving the impression he's doing these things for you. It's his life after all, not yours. If you want to teach him responsibility, stop taking it away from him, or you'll give contradicting signals.
- Get more relaxed to actually start seeing what's actually going on. If you're constantly focused on what's not getting done properly, and getting upset or even mad about it, you stop noticing details and hints he's giving between the lines. Obsession makes blind, and being preoccupied with the idea he has to do these things is an obsession. Or in other words: What's happening can be described in a hundred different ways. You chose to describe it as "whiling away", but make sure you're at least aware of the 99 others.
Then, when you've reached this point of being more relaxed and open to actually reading his behavior, talk to him. Talk to him on eye level. You seem to be making a lot of assumptions about what he's supposed to know from your threats and punishments, but start by assuming that he has absolutely no idea and in particular the threatening has reliably been keping him oblivious of it, because it totally removed his focus from what really counts.
Start your conversation by explaining what you observe. At that point avoid all judgements, even terms like "whiling away". Be as neutral as possible with regard to your observations. For instance say that he's taking hours to do something you personally think he could do in 10 minutes on a regular basis. If you have, give him examples. Say you often observe that he's given enough time to do something, but he doesn't even start for a very long time. And so on. Explain to him in every detail how you perceive the situation, without judging anything yet. Just describe.
Make sure you also describe situations where he does do what's expected. Being neutral includes not being single-sided. Don't take anything as self-evident.
Then tell him how you feel about what you observe and why. Explain to him that it often makes you irritated because as his parents you feel deeply responsible for his well-being, which includes proper eating, success at school, basic life skills, reliability, etc., etc. You don't want to leave him on his own, and seeing him behave the way he does actually scares you because you're secretly imagining that he's missing a lot of chances already and that the thing might go on until later in life and that he'll stay behind his potential. Explain to him that you're aware that not every successful life strictly requires these things he's not doing, and you have no strict right to demand them from him and you're really sorry for the violence you've been using so far, but in our society there's a strong predisposition to expect them to be necessary to some crucial extent, that's why you're really worried, and sometimes you can't contain this worry anymore, and you don't know what to do, so you try the only thing that has helped in the past, that is strong threats, shouting, spanking, but you're really unhappy about it, and you're looking for something else, and you need his help with hit. Express your concern, express you emotions.
Then ask him how he sees the situation and let him talk. Do not interrupt, do not judge. Encourage him to be open and honest, with your attitude, and if necessary also with words. Be prepared that he may need time to open up, you probably have destroyed some of his trust in you and your willingness to accept him as he is and whatever way he feels like, especially in case he's just starting to discover it for himself (which is not that unlikely), but I'm sure with perseverance from your end you can finally make him open up. Maybe he's even subcionsciously waiting for it and will talk right away, but it isn't guaranteed. Be prepared it may require weeks of effort and a non-judgemental attitude from your end.
Important rule at this point: Listen! Ask!
Do not judge, do not belittle, do not argue. Just listen and ask until you have full understanding of how it is from his point of view.
Once you have this full understanding of his perspective as he expresses it after having heard yours, I'm 99% sure that improvements either happen automatically or next steps towards them become obvious. I can't predict them here.
However I personally advise against asking a doctor yet (that is right now). It's not wrong per se, and it may be necessary at some point, but before you do, it's your responsibility as parents to do several things first:
- Make him responsible for the problem to the extent that is reasonable for a 6-year-old of his intelligence, and this doesn't seem THAT little. He must be involved in a far-reaching decision as whether to see a doctor about it.
- Talk to him on eye-level, keep talking over some time, thoroughly discuss the problem together, and THEN at some point if it becomes obvious nobody of you has any other idea what could be done nor is he able to explore his feelings any deeper you CAN bring up that there are diseases which promote such behavior, and if he feels a doctor might help him, then OFFER seeing one. If he's hesitant, convince him, do not decide over his head unless absolutely necessary. Give him enough time to make an own decision.
- Never ever give your child the impression you see him/her as broken from your subjective point of view, and you're asking someone else to fix them the way you'd like them, UNLESS they're also feeling they need that help.
As a general rule make sure you also see his behavior as a strength, which it certainly is. It just depends on the point of view. He is very special, that's already obvious, and none of us knows what's waiting inside him to be revealed throughout his life. You currently have no other bet other than assuming that good grades in school will help him, but if you have to enforce it with violence, keep questioning it. It's probably not necessary. There are may lives/carreers that may develop from where he is now that would make you feel like morons beating him now over such petty things. See it in perspective: He's not stealing, not being violent himself, he has friends he likes to play with and which even come many times to pick him up, so he's obviously popular and respected, and probably many things more.
I have a strong feeling the situation will lighten up a lot. All the best.