Skip to content

Commit

Permalink
payments: bulk op to reset a failed currency payout
Browse files Browse the repository at this point in the history
Generally happen if the wallet balance is too low,
but in some cases could be also a rpc timeout (CHC),
so it require to be manually checked by the admin in the wallet tx history.
  • Loading branch information
tpruvot committed Nov 22, 2017
1 parent 87c7b8c commit 2b98f02
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
33 changes: 33 additions & 0 deletions web/yaamp/modules/site/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,36 @@ public function actionCancelUserPayment()
$this->goback();
}

public function actionCancelUsersPayment()
{
if(!$this->admin) return;
$coin = getdbo('db_coins', getiparam('id'));
if ($coin) {
$amount_failed = 0.0; $cnt = 0;
$time = time() - (48 * 3600);
$failed = getdbolist('db_payouts', "idcoin=:id AND IFNULL(tx,'') = '' AND time>$time", array(':id'=>$coin->id));
if (!empty($failed)) {
foreach ($failed as $payout) {
$user = getdbo('db_accounts', $payout->account_id);
if ($user) {
$user->balance += floatval($payout->amount);
if ($user->save()) {
$amount_failed += floatval($payout->amount);
$cnt++;
}
}
$payout->delete();
}
user()->setFlash('message', "Restored $cnt failed txs to user balances, $amount_failed {$coin->symbol}");
} else {
user()->setFlash('message', 'No failed txs found');
}
} else {
user()->setFlash('error', 'Invalid coin id!');
}
$this->goback();
}

/////////////////////////////////////////////////

public function actionUser()
Expand Down Expand Up @@ -1070,6 +1100,9 @@ public function actionAlgo()
public function actionGomining()
{
$algo = substr(getparam('algo'), 0, 32);
if ($algo == 'all') {
return;
}
user()->setState('yaamp-algo', $algo);
$this->redirect("/site/mining");
}
Expand Down
6 changes: 4 additions & 2 deletions web/yaamp/modules/site/payments_results.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
$failed[$uid] = $row['failed'];
}

$list = getdbolist('db_accounts', "coinid!=6 $sqlFilter AND (".
$list = getdbolist('db_accounts', "is_locked != 1 $sqlFilter AND (".
"balance > 0 OR last_earning > (UNIX_TIMESTAMP()-60*60) OR id IN (SELECT DISTINCT account_id FROM payouts WHERE tx IS NULL)".
") ORDER BY last_earning DESC $limit");

Expand Down Expand Up @@ -135,8 +135,10 @@
echo '<table class="totals">';
echo '<tr><th>Balances</th><td>'.bitcoinvaluetoa($total)." $symbol</td></tr>";
echo '<tr><th>Immature</th><td>'.bitcoinvaluetoa($totalimmat)." $symbol</td></tr>";
if ($totalfailed)
if ($totalfailed) {
echo '<tr class="red"><th>Failed</th><td>'.bitcoinvaluetoa($totalfailed)." $symbol</td></tr>";
echo '<tr><td colspan="2">'.'<a href="/site/cancelUsersPayment?id='.$coin_id.'" title="Add to balance all failed payouts">Reset all failed</a></td></tr>';
}
echo '</tr></table>';
echo '</div>';
}

0 comments on commit 2b98f02

Please sign in to comment.