rule – rearrange the sum and change the duplicate rates

I try to transform myself
$$ left ( sum_ {j = 1} ^ J A (j) right) sum_ {j = 1} ^ J sum_ {k = 1} ^ K B (j, k) $$

to

$$ sum_ {j = 1} ^ J sum_ {k = 1} ^ K sum_ {j_ {2} = 1} ^ J A (j_ {2}) B (j, k) $$

The rule would add subscript to duplicate indexes. I want to group all the sums if possible.

Does Mathematica already have a function that does this?