Merge pull request #919 from TheSerapher/issue-904
[IMPROVED] Added balance checks post payouts
This commit is contained in:
commit
f4beb36708
@ -83,8 +83,15 @@ if (! empty($users)) {
|
||||
$aMailData['amount'] = $dBalance;
|
||||
if (!$notification->sendNotification($aUserData['id'], 'auto_payout', $aMailData))
|
||||
$log->logError('Failed to send notification email to users address: ' . $aMailData['email']);
|
||||
// Recheck the users balance to make sure it is now 0
|
||||
$aBalance = $transaction->getBalance($aUserData['id']);
|
||||
if ($aBalance['confirmed'] > 0) {
|
||||
$log->logFatal('User has a remaining balance of ' . $aBalance['confirmed'] . ' after a successful payout!');
|
||||
$monitoring->endCronjob($cron_name, 'E0065', 1, true);
|
||||
}
|
||||
} else {
|
||||
$log->logError('Failed to add new Debit_AP transaction in database for user ' . $user->getUserName($aUserData['id']));
|
||||
$log->logFatal('Failed to add new Debit_AP transaction in database for user ' . $user->getUserName($aUserData['id']));
|
||||
$monitoring->endCronjob($cron_name, 'E0064', 1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,6 +81,12 @@ if (count($aPayouts) > 0) {
|
||||
$aMailData['payout_id'] = $aData['id'];
|
||||
if (!$notification->sendNotification($aData['account_id'], 'manual_payout', $aMailData))
|
||||
$log->logError('Failed to send notification email to users address: ' . $aMailData['email']);
|
||||
// Recheck the users balance to make sure it is now 0
|
||||
$aBalance = $transaction->getBalance($aUserData['id']);
|
||||
if ($aBalance['confirmed'] > 0) {
|
||||
$log->logFatal('User has a remaining balance of ' . $aBalance['confirmed'] . ' after a successful payout!');
|
||||
$monitoring->endCronjob($cron_name, 'E0065', 1, true);
|
||||
}
|
||||
} else {
|
||||
$log->logFatal('Failed to add new Debit_MP transaction in database for user ' . $user->getUserName($aData['account_id']));
|
||||
$monitoring->endCronjob($cron_name, 'E0064', 1, true);
|
||||
|
||||
@ -68,4 +68,5 @@ $aErrorCodes['E0061'] = 'Failed to delete worker';
|
||||
$aErrorCodes['E0062'] = 'Block has no share_id, not running payouts';
|
||||
$aErrorCodes['E0063'] = 'Upstream share already assigned to previous block';
|
||||
$aErrorCodes['E0064'] = 'Failed to create transaction record';
|
||||
$aErrorCodes['E0065'] = 'Remaining balance is greater than 0';
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user