/** * Test that depositing the same amount on contracted and non contracted * class yields the same result. */ public function testDepositMoney() { $this->account->deposit($this->amount); $this->accountContract->deposit($this->amount); $this->assertEquals($this->amount, $this->account->getBalance()); $this->assertEquals($this->account->getBalance(), $this->accountContract->getBalance()); }
/** * 查询用户账户余额 * @param $userId * 返回 正整数,单位人民币分 */ public function querryUserBalance($userId) { $ip = new IPFilter(getonlineip()); if ($ip->isAllowable() != 1) { return lang('ip_denied'); } $account = new Account($userId); $balance = $account->getBalance(); return $balance; }
function calc_accts() { global $DB, $error_ar; echo "Billing accounts ...\n"; $start_time = microtime(1); //$n = 0; $account_result = $DB->make_select('Accounts'); //$account_result = $DB->make_select('Accounts', '', "`status`='Open'"); for ($n = 0; $account_row = $DB->row($account_result); $n++) { $status = $account_row['status']; $amount = $account_row['amount']; $bonustime = $account_row['bonustime']; //$statusinfo = $account_row['statusinfo']; $NOW = date('Y-m-d H:i:s'); $now = strtotime($NOW); //$now = time(); $addsql = array(); if ($status == 'Active') { $account = new Account(); $account->load($account_row); list($amount, $bonustime, $closetime) = $account->getBalance(); $ostperiod = $closetime - $now; $ostdays = round($ostperiod / iDAY, 0); $addsql['closetime'] = date('Y-m-d H:i:s', $closetime); if ($ostperiod + iDAY * $account->billing_opts['credit_days'] <= 0) { echo "Suspend account {$account->domain} (id={$account->id})\n"; if (ACTION) { if ($account->suspend(false)) { } $account->mail_send(3); } } elseif ($ostdays == 7 || $ostdays == 3 || $ostdays <= 1) { echo "Send mail to account {$account->domain} ({$account->contact->Email}) with '{$status}' status about close date in {$ostdays} days\n"; if (ACTION) { $account->mail_send(2); } } unset($account); $addsql['amount'] = $amount; $addsql['bonustime'] = $bonustime; } elseif ($status == 'Open') { $account = new Account(); $account->load($account_row); //$amount = 0; $bonustime = 0; $period_live = $now - strtotime($account_row['opentime']); $days_live = round($period_live / iDAY, 0); if ($days_live == 25) { if (ACTION) { $account->mail_send(2); } echo "Send mail to account {$account->domain} ({$account->contact->Email}) with '{$status}' status about close date in {$ostdays} days\n"; } elseif ($days_live >= 30) { echo "Close account {$account->domain} (id={$account->id})\n"; if (ACTION) { if ($account->suspend(false)) { } $account->mail_send(3); } } unset($account); //$addsql['amount'] = $amount; //$addsql['bonustime'] = $bonustime; } elseif ($status == 'Suspend') { $account = new Account(); $account->load($account_row); $period = $now - strtotime($account_row['closetime']); if ($period >= 60 * iDAY) { echo "Delete account {$account_row['domain']} (id={$account_row['AccountID']})\n"; if (ACTION) { log_event('delete account', 'notice', '', $account_row['AccountID'], $account_row['ResellerID']); $whm = new WhmAPI($account->ServerID); $result = $whm->killacct($account); if ($result) { //echo nl2br($whm->xml->rawout); } else { echo $whm->geterrmsg(); } } $addsql['status'] = 'Deleted'; //$addsql['statusinfo'] = "$statusinfo\nautomatic deleted $NOW"; } } elseif ($status == 'Deleted') { $addsql['lastproc'] = 0; // pack and archive account if closetime > 6 * iMON } elseif ($status == 'Staff') { // our accounts } else { $error_ar[] = "Unknown Status for account {$account_row['domain']} (id={$account_row['AccountID']})\n"; } if (ACTION) { $addsql['lastproc'] = $NOW; $result = $DB->make_update('Accounts', '`AccountID`=' . $account_row['AccountID'], $addsql); } //$n++; } echo "Finished Step. {$n} account calculated. Time " . intval((microtime(1) - $start_time) * 1000) . "ms.\n\n"; }
<?php define('IN_EZBOSS', true); ini_set("display_errors", 'on'); error_reporting(E_ERROR | E_PARSE); require dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'webservice' . DIRECTORY_SEPARATOR . 'init.php'; //echo "test<br>"; //echo getonlineip(); //writelog("it is test log."); $account = new Account('123456'); echo "updateStatus=" . $account->updateStatus("1"); //1正常 2冻结 echo "<br>"; echo "getBalance=" . $account->getBalance(); echo "<br>"; echo "getStatus=" . $account->getStatus(); echo "<br>"; echo "getStatusDesc=" . $account->getStatusDesc(); echo "<br>"; //测试用户账户充值 单位人民币分 $res = $account->addBalance("10", "2"); echo "addBalance=" . $res; echo "<br>"; $res = $account->buy("100004", "1", "1"); echo "buy=" . $res; echo "<br>"; $res = $account->getServiceTime("100003"); echo "getServiceTime=" . $res; echo "<br>"; $res = $account->isInService("100003"); echo "isInService=" . $res;
<?php require 'inc.php'; /* * initiate Banking account for online Banking */ $account = new Account('DEXXXXXXXXXXX'); $account->setLogin('XXXXXXXXXXX'); $account->setPin('XXXXX'); $account->setOwner('Peter Lustig'); echo $account->getBalance(); $transactions = $account->listTransactions('2015-09-01'); print_r($transactions); /* * initiate Account2 to transfer money */ $account2 = new Account('DEXXXXXXXXXXXX'); $account2->setOwner('Benjamin Bluemchen'); /* * transfer money */ $transfer = new Transfer($account, $account2, 2); $transfer->setSubject('Hallo Ben'); $transfer->exec(); /* * Dauerauftrag einreichen */ $trans = new StandingOrder($account, $account2, 1); $trans->setSubject('Dauertest Ben'); $trans->exec(); /*