private function buildTransferReversal($xml)
 {
     $transferReversal = new TransferReversal();
     $transferReversal->setRequestId((string) $xml->RequestId);
     $transferReversal->setOriginalRequestId((string) $xml->OriginalRequestId);
     $transferReversal->setTransactionReference((string) $xml->TransactionReference);
     $transactionHistory = new TransactionHistory();
     $tmpTransaction = new Transaction();
     $transaction = $xml->TransactionHistory->Transaction;
     $tmpTransaction->setType((string) $transaction->Type);
     $tmpTransaction->setSystemTraceAuditNumber((string) $transaction->SystemTraceAuditNumber);
     $tmpTransaction->setNetworkReferenceNumber((string) $transaction->NetworkReferenceNumber);
     $tmpTransaction->setSettlementDate((string) $transaction->SettlementDate);
     $tmpResponse = new Response();
     $response = $transaction->Response;
     $tmpResponse->setCode((string) $response->Code);
     $tmpResponse->setDescription((string) $response->Description);
     $tmpTransaction->setSubmitDateTime((string) $transaction->SubmitDateTime);
     $tmpTransaction->setResponse($tmpResponse);
     $transactionHistory->setTransaction($tmpTransaction);
     $transferReversal->setTransactionHistory($transactionHistory);
     return $transferReversal;
 }
Exemple #2
0
 /** 
  * 查询用户账户消费历史
  * @param $userId
  * @param $perPage
  * @param $currPage
  * 返回json数据
  */
 public function querryUserTransactionHistory($userId, $perPage, $currPage)
 {
     $ip = new IPFilter(getonlineip());
     if ($ip->isAllowable() != 1) {
         return json_encode(lang('ip_denied'));
     }
     $account = new Account($userId);
     $transactionHistory = new TransactionHistory($account->accountId);
     return json_encode($transactionHistory->getHistoryList($perPage, $currPage));
 }
Exemple #3
0
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;
echo "<br>";
//测试查询产品列表
echo "<br>productList->getProducts-----------------------<br>";
$productList = new ProductList();
$res = $productList->getProducts();
print_r($res);
echo "<br>";
echo "<br>rechargeHistory->getHistoryList-----------------------<br>";
//测试查询账户历史
$rechargeHistory = new RechargeHistory($account->accountId);
$res = $rechargeHistory->getHistoryList("10", "1");
print_r($res);
echo "<br>";
//测试查询测试查询交易历史
echo "<br>transactionHistory->getHistoryList-----------------------<br>";
$transactionHistory = new TransactionHistory($account->accountId);
$res = $transactionHistory->getHistoryList("10", "1");
print_r($res);
?>
</span>
    </pre>
    <table>

        <tr>
            <th>Transaction Date</th>
            <th>Source Name</th>
            <th>Source IBAN</th>
            <th>Receiver Name</th>
            <th>Receiver IBAN</th>
            <th>Amount</th>
            <th>Description</th>
        </tr>
        <?php 
$dataArray = TransactionHistory::GetTransactionHistory($id);
foreach ($dataArray as &$element) {
    ?>
        <tr>
            <td><?php 
    echo $element->date;
    ?>
</td>
            <td><?php 
    echo $element->sourceName;
    ?>
</td>
            <td><?php 
    echo $element->sourceIBAN;
    ?>
</td>
 private function buildTransfer($xml)
 {
     $transfer = new Transfer();
     $transfer->setRequestId((string) $xml->RequestId);
     $transfer->setTransactionReference((string) $xml->TransactionReference);
     $transactionHistory = new TransactionHistory();
     $transactionArray = array();
     foreach ($xml->TransactionHistory->Transaction as $transaction) {
         $tmpTransaction = new Transaction();
         $tmpTransaction->setType((string) $transaction->Type);
         $tmpTransaction->setSystemTraceAuditNumber((string) $transaction->SystemTraceAuditNumber);
         $tmpTransaction->setNetworkReferenceNumber((string) $transaction->NetworkReferenceNumber);
         $tmpTransaction->setSettlementDate((string) $transaction->SettlementDate);
         $tmpResponse = new Response();
         $response = $transaction->Response;
         $tmpResponse->setCode((string) $response->Code);
         $tmpResponse->setDescription((string) $response->Description);
         $tmpTransaction->setSubmitDateTime((string) $transaction->SubmitDateTime);
         $tmpTransaction->setResponse($tmpResponse);
         array_push($transactionArray, $tmpTransaction);
     }
     $transactionHistory->setTransaction($transactionArray);
     $transfer->setTransactionHistory($transactionHistory);
     return $transfer;
 }
<?php

session_start();
require_once '../Model/TransactionHistory.php';
if (isset($_SESSION['isEmployee'])) {
    $id = "";
    if ($_SESSION['isEmployee'] == false) {
        $id = $_SESSION['iban'];
    } else {
        if (isset($_POST['iban'])) {
            $id = intval($_POST['iban']);
        } else {
            exit;
        }
    }
    $outputPathAbs = "/tmp/TransactionHistory_" . $id . ".pdf";
    TransactionHistory::ExportPDF($id, $outputPathAbs);
    if (file_exists($outputPathAbs)) {
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename="' . basename($outputPathAbs) . '"');
        header('Expires: 0');
        header('Cache-Control: private, max-age=0, no-cache');
        header('Content-Length: ' . filesize($outputPathAbs));
        readfile($outputPathAbs);
        exit;
    }
}
 public function getPaymentFailerAction()
 {
     $amount = $this->request->getPost('amount');
     $status = $this->request->getPost('status');
     $txnid = $this->request->getPost('txnid');
     $smscredit = $this->request->getPost('udf1');
     $gateway_txnid = $this->request->getPost('payuMoneyId');
     $user = Users::findFirstByEmail($this->request->getPost('email'));
     $transation = TransactionHistory::findFirstByGatewayTxnid($gateway_txnid);
     if (!$transation) {
         $transactionhistory = new TransactionHistory();
         $transactionhistory->amount = $amount;
         $transactionhistory->user_id = $user->id;
         $transactionhistory->sms_credit = $smscredit;
         $transactionhistory->txnid = $txnid;
         $transactionhistory->gateway_txnid = $gateway_txnid;
         $transactionhistory->new_sms_balance = $user->smsbalance->balance;
         $transactionhistory->status = 'FAILED';
         $transactionhistory->created_at = date("Y-m-d H:i:s");
         $transactionhistory->updated_at = date("Y-m-d H:i:s");
         $transactionhistory->save();
         // $this->flash->error($transactionhistory->getMessages());
         $this->response->redirect($this->config->application->apiUri . '/payment-fail/' . $txnid);
     } else {
         $this->response->redirect($this->config->application->apiUri . '/payment-fail/' . $txnid);
     }
 }
 public function userTransactionHistoryAction()
 {
     if ($this->request->isPost() == true) {
         $this->response->setContentType('application/json');
         $user_id = $this->request->getPost("user_id");
         $transactionhistory = TransactionHistory::find("user_id = '{$user_id}' ORDER BY updated_at DESC");
         $orders = array();
         if ($transactionhistory) {
             foreach ($transactionhistory as $history) {
                 $orders[] = array('invoice_id' => $history->id, 'sms_credit' => $history->sms_credit, 'amount' => $history->amount, 'transation_id' => $history->txnid, 'new_sms_balance' => $history->new_sms_balance, 'date' => date('M d, Y', strtotime($history->updated_at)), 'time' => date('M d,Y, H:i A', strtotime($history->updated_at)), 'status' => $history->status);
             }
         }
         $this->response->setContent(json_encode(array('orders' => $orders)));
         $this->response->send();
     }
 }
 /**
  * 购买产品
  * @param $productCode
  * @param $count
  * @param $platform
  * 返回 001 成功,002失败,003余额不足,004账户已被冻结
  */
 function buy($productCode, $count, $platform)
 {
     $ok = true;
     $product = new Product($productCode);
     $product = $product->getProduct();
     $amount = $product['price'] * $count;
     //检查状态
     if ($this->getStatus() == 2) {
         return '004';
     }
     //检查余额
     if ($this->getBalance() < $amount) {
         return '003';
     }
     $this->db->StartTrans();
     //事务块开始
     //扣款
     $sqlstr = "update account act set BALANCE = BALANCE - '{$amount}' \r\n\t\t\t\t\twhere ACCOUNT_ID='{$this->accountId}' ";
     $this->db->Execute($sqlstr);
     //记录交易
     $transactionHistory = new TransactionHistory($this->accountId);
     $transactionHistory->recordTransaction($product['productCode'], $product['productName'], $product['price'], $product['priceUnit'], $count, $amount, $platform);
     //包月产品增加服务时间
     if ($product['priceUnit'] > 1) {
         switch ($product['priceUnit']) {
             case 2:
                 $timeSql = 'DATE_ADD(EXPIRY_DATE,INTERVAL ' . $count . ' DAY)';
                 //天
                 break;
             case 3:
                 $timeSql = 'DATE_ADD(EXPIRY_DATE,INTERVAL ' . $count * 7 . ' DAY)';
                 //周
                 break;
             case 4:
                 $timeSql = 'DATE_ADD(EXPIRY_DATE,INTERVAL ' . $count . ' MONTH)';
                 //月
                 break;
             case 5:
                 $timeSql = 'DATE_ADD(EXPIRY_DATE,INTERVAL ' . $count . ' YEAR)';
                 //年
                 break;
         }
         $sqlstr = "update service_time st set EXPIRY_DATE = {$timeSql} \r\n\t\t\t\t\twhere st.ACCOUNT_ID='{$this->accountId}' and st.PRODUCT_CODE='{$productCode}' ";
         $this->db->Execute($sqlstr);
         if ($this->db->Affected_Rows() == 0) {
             //第一次购买 insert
             $sqlstr = "insert into service_time values(NULL, '{$this->accountId}','{$productCode}', NOW() )";
             $this->db->Execute($sqlstr);
             $sqlstr = "update service_time st set EXPIRY_DATE = {$timeSql} \r\n\t\t\t\t\twhere st.ACCOUNT_ID='{$this->accountId}' and st.PRODUCT_CODE='{$productCode}' ";
             $this->db->Execute($sqlstr);
         }
     }
     if (!$this->db->HasFailedTrans()) {
         //在事务块结束前捕获
         $ok = true;
     } else {
         $ok = false;
     }
     $this->db->CompleteTrans();
     //事务块结束
     return $ok ? '001' : '002';
 }