Please am try to use selectSUM to get the total amount spend by a each user, as well as the total income generated by the system.
$data[\'earnings\'] = $shi