mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 17:37:25 +00:00
enhance "payout check" command for VNL
and allow to link account data to the payout model
This commit is contained in:
parent
8a313b1281
commit
62f8e3e344
2 changed files with 23 additions and 1 deletions
|
@ -68,10 +68,31 @@ class PayoutCommand extends CConsoleCommand
|
|||
return 0;
|
||||
}
|
||||
|
||||
// failed payouts, generally related to bad wallet 'accounts' balances (VNL)
|
||||
$dbPayouts = new db_payouts;
|
||||
$min_payout = max($coin->txfee, floatval(YAAMP_PAYMENTS_MINI));
|
||||
$failed_payouts = $dbPayouts->with('account')->findAll(array(
|
||||
'condition'=>"tx IS NULL AND amount > $min_payout AND account.coinid = ".$coin->id,
|
||||
'order'=>'time DESC',
|
||||
));
|
||||
|
||||
$condOr = '';
|
||||
if (!empty($failed_payouts)) {
|
||||
$ids = array();
|
||||
$sum = 0.;
|
||||
foreach ($failed_payouts as $payout) {
|
||||
$uid = (int) $payout['account_id'];
|
||||
$ids[$uid] = floatval($payout['amount']) + arraySafeVal($ids, $uid, 0.);
|
||||
$sum += floatval($payout['amount']);
|
||||
}
|
||||
echo "failed payouts detected for ".count($ids)." account(s), $sum {$coin->symbol}\n";
|
||||
$condOr = "OR A.id IN (".implode(',', array_keys($ids)).')';
|
||||
}
|
||||
|
||||
// Get users using the coin...
|
||||
$users = dbolist("SELECT DISTINCT A.id AS userid, A.username AS username ".
|
||||
"FROM accounts A LEFT JOIN coins C ON C.id = A.coinid ".
|
||||
"WHERE A.coinid={$coin->id} AND A.balance > 0.0"
|
||||
"WHERE A.coinid={$coin->id} AND (A.balance > 0.0 $condOr)"
|
||||
);
|
||||
$ids = array();
|
||||
foreach ($users as $uids) {
|
||||
|
|
|
@ -21,6 +21,7 @@ class db_payouts extends CActiveRecord
|
|||
public function relations()
|
||||
{
|
||||
return array(
|
||||
'account' => array(self::BELONGS_TO, 'db_accounts', 'account_id', 'alias'=>'account'),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue