@@ -16,8 +16,9 @@ class Transaction extends Base {
1616 * @return bool
1717 **/
1818 public function addTransaction ($ account_id , $ amount , $ type ='Credit ' , $ block_id =NULL , $ coin_address =NULL , $ txid =NULL ) {
19+ $ amount = number_format ($ amount , $ this ->coin ->getCoinValuePrevision (), '. ' , '' );
1920 $ stmt = $ this ->mysqli ->prepare ("INSERT INTO $ this ->table (account_id, amount, block_id, type, coin_address, txid) VALUES (?, ?, ?, ?, ?, ?) " );
20- if ($ this ->checkStmt ($ stmt ) && $ stmt ->bind_param ("idisss " , $ account_id , $ amount , $ block_id , $ type , $ coin_address , $ txid ) && $ stmt ->execute ()) {
21+ if ($ this ->checkStmt ($ stmt ) && $ stmt ->bind_param ("isisss " , $ account_id , $ amount , $ block_id , $ type , $ coin_address , $ txid ) && $ stmt ->execute ()) {
2122 $ this ->insert_id = $ stmt ->insert_id ;
2223 return true ;
2324 }
@@ -296,11 +297,11 @@ public function getLockedBalance() {
296297 $ this ->debug ->append ("STA " . __METHOD__ , 4 );
297298 $ stmt = $ this ->mysqli ->prepare ("
298299 SELECT
299- ROUND( (
300+ (
300301 SUM( IF( ( t.type IN ('Credit','Bonus') AND b.confirmations >= ? ) OR t.type = 'Credit_PPS', t.amount, 0 ) ) -
301302 SUM( IF( t.type IN ('Debit_MP', 'Debit_AP'), t.amount, 0 ) ) -
302303 SUM( IF( ( t.type IN ('Donation','Fee') AND b.confirmations >= ? ) OR ( t.type IN ('Donation_PPS', 'Fee_PPS', 'TXFee') ), t.amount, 0 ) )
303- ), 8) AS balance
304+ ) AS balance
304305 FROM $ this ->table AS t
305306 LEFT JOIN " . $ this ->block ->getTableName () . " AS b
306307 ON t.block_id = b.id
@@ -319,19 +320,19 @@ public function getBalance($account_id) {
319320 $ this ->debug ->append ("STA " . __METHOD__ , 4 );
320321 $ stmt = $ this ->mysqli ->prepare ("
321322 SELECT
322- IFNULL(ROUND( (
323+ IFNULL((
323324 SUM( IF( ( t.type IN ('Credit','Bonus') AND b.confirmations >= ? ) OR t.type = 'Credit_PPS', t.amount, 0 ) ) -
324325 SUM( IF( t.type IN ('Debit_MP', 'Debit_AP'), t.amount, 0 ) ) -
325326 SUM( IF( ( t.type IN ('Donation','Fee') AND b.confirmations >= ? ) OR ( t.type IN ('Donation_PPS', 'Fee_PPS', 'TXFee') ), t.amount, 0 ) )
326- ), 8), 0) AS confirmed,
327- IFNULL(ROUND( (
327+ ), 0) AS confirmed,
328+ IFNULL((
328329 SUM( IF( t.type IN ('Credit','Bonus') AND b.confirmations < ? AND b.confirmations >= 0, t.amount, 0 ) ) -
329330 SUM( IF( t.type IN ('Donation','Fee') AND b.confirmations < ? AND b.confirmations >= 0, t.amount, 0 ) )
330- ), 8), 0) AS unconfirmed,
331- IFNULL(ROUND( (
331+ ), 0) AS unconfirmed,
332+ IFNULL((
332333 SUM( IF( t.type IN ('Credit','Bonus') AND b.confirmations = -1, t.amount, 0) ) -
333334 SUM( IF( t.type IN ('Donation','Fee') AND b.confirmations = -1, t.amount, 0) )
334- ), 8), 0) AS orphaned
335+ ), 0) AS orphaned
335336 FROM $ this ->table AS t
336337 LEFT JOIN " . $ this ->block ->getTableName () . " AS b
337338 ON t.block_id = b.id
@@ -357,12 +358,10 @@ public function getAPQueue($limit=250) {
357358 a.ap_threshold,
358359 ca.coin_address,
359360 IFNULL(
360- ROUND(
361361 (
362362 SUM( IF( ( t.type IN ('Credit','Bonus') AND b.confirmations >= " . $ this ->config ['confirmations ' ] . ") OR t.type = 'Credit_PPS', t.amount, 0 ) ) -
363363 SUM( IF( t.type IN ('Debit_MP', 'Debit_AP'), t.amount, 0 ) ) -
364364 SUM( IF( ( t.type IN ('Donation','Fee') AND b.confirmations >= " . $ this ->config ['confirmations ' ] . ") OR ( t.type IN ('Donation_PPS', 'Fee_PPS', 'TXFee') ), t.amount, 0 ) )
365- ), 8
366365 ), 0
367366 ) AS confirmed
368367 FROM $ this ->table AS t
@@ -451,12 +450,10 @@ public function getMPQueue($limit=250) {
451450 ca.coin_address,
452451 p.id AS payout_id,
453452 IFNULL(
454- ROUND(
455453 (
456454 SUM( IF( ( t.type IN ('Credit','Bonus') AND b.confirmations >= " . $ this ->config ['confirmations ' ] . ") OR t.type = 'Credit_PPS', t.amount, 0 ) ) -
457455 SUM( IF( t.type IN ('Debit_MP', 'Debit_AP'), t.amount, 0 ) ) -
458456 SUM( IF( ( t.type IN ('Donation','Fee') AND b.confirmations >= " . $ this ->config ['confirmations ' ] . ") OR ( t.type IN ('Donation_PPS', 'Fee_PPS', 'TXFee') ), t.amount, 0 ) )
459- ), 8
460457 ), 0
461458 ) AS confirmed
462459 FROM " . $ this ->payout ->getTableName () . " AS p
@@ -481,7 +478,9 @@ public function getMPQueue($limit=250) {
481478$ transaction = new Transaction ();
482479$ transaction ->setMemcache ($ memcache );
483480$ transaction ->setNotification ($ notification );
481+ $ transaction ->setSetting ($ setting );
484482$ transaction ->setDebug ($ debug );
483+ $ transaction ->setCoin ($ coin );
485484$ transaction ->setCoinAddress ($ coin_address );
486485$ transaction ->setMysql ($ mysqli );
487486$ transaction ->setConfig ($ config );
0 commit comments