Commit 0b516633 authored by Anthony.Suerte's avatar Anthony.Suerte

Transaction History Optimization

parent 28bcb09b
...@@ -58,29 +58,38 @@ class UserTransactions extends OpenAPIAbstraction { ...@@ -58,29 +58,38 @@ class UserTransactions extends OpenAPIAbstraction {
} }
private function list(){ private function list(){
$list = $this -> accessSelect('LIST_USER_TRANSACTION', $this -> getUserAccountData()); $countTransactions = $this -> getRowData($this -> accessSelect('SELECT_USER_TRANSACTION_COUNT', [
$this -> holder -> userAccount,
$this -> holder -> currency,
$this -> getWhereCount()
]));
$rowCount = count($list); $totalPage = $this -> getTotalPageCommon(VAR_DEFAULT_PAGE_COUNT, $countTransactions["overall_total"]);
$totalPage = $this -> getTotalPageCommon(VAR_DEFAULT_PAGE_COUNT, $rowCount);
$currentPage = !empty($this -> holder -> page) ? $this -> holder -> page : 1; $params = $this -> getUserAccountData();
$currentPage = empty($this -> holder -> page) || !is_numeric($this -> holder -> page) ? 1 : $this -> holder -> page;
if($currentPage > $totalPage) if($currentPage > $totalPage)
$currentPage = $totalPage; $currentPage = $totalPage;
$start = ($currentPage - 1) * VAR_DEFAULT_PAGE_COUNT;
$params[3] = "LIMIT {$start}, ".VAR_DEFAULT_PAGE_COUNT;
$list = $this -> accessSelect('LIST_USER_TRANSACTION', $params);
$start = ($currentPage - VAL_INT_1) * VAR_DEFAULT_PAGE_COUNT; $start = ($currentPage - VAL_INT_1) * VAR_DEFAULT_PAGE_COUNT;
$end = $currentPage * VAR_DEFAULT_PAGE_COUNT; $end = $currentPage * VAR_DEFAULT_PAGE_COUNT;
$result = [ $result = [
"row_count" => $rowCount, "row_count" => $countTransactions["overall_total"],
"page_total" => $totalPage, "page_total" => $totalPage,
"current_page" => $currentPage, "current_page" => $currentPage,
"result" => [] "result" => []
]; ];
for($i = $start; $i < $end && $i < $rowCount; $i++) { foreach($list as $transaction){
$transaction = $this -> getRowData($list, $i);
$this -> statusIndication($transaction); $this -> statusIndication($transaction);
$result["result"][] = $transaction; $result["result"][] = $transaction;
...@@ -97,6 +106,7 @@ class UserTransactions extends OpenAPIAbstraction { ...@@ -97,6 +106,7 @@ class UserTransactions extends OpenAPIAbstraction {
$rtn[] = $this -> holder -> userAccount; // ユーザアカウント $rtn[] = $this -> holder -> userAccount; // ユーザアカウント
$rtn[] = $this -> holder -> currency; $rtn[] = $this -> holder -> currency;
$rtn[] = $this -> getWhere(); // 検索条件 $rtn[] = $this -> getWhere(); // 検索条件
$rtn[] = NO_STRING;
return $rtn; return $rtn;
} }
...@@ -132,6 +142,29 @@ class UserTransactions extends OpenAPIAbstraction { ...@@ -132,6 +142,29 @@ class UserTransactions extends OpenAPIAbstraction {
return $rtn; return $rtn;
} }
public function getWhereCount(){
// 変数宣言部
$params = array();
$rtn = NO_STRING;
// 日付指定(from)
if($this -> holder -> dateFrom != NO_STRING) {
$params[] = ' create_time >= (\')' . $this -> holder -> dateFrom . '(\')';
}
// 日付指定(to)
if($this -> holder -> dateTo != NO_STRING) {
$params[] = ' create_time < DATE_ADD((\')' . $this -> holder -> dateTo . '(\'), INTERVAL 1 DAY)';
}
// データが存在した場合
if($this -> isLoopData($params)) {
$rtn = DELIMIT_AND . implode(DELIMIT_AND, $params);
}
return $rtn;
}
private function statusIndication(&$row){ private function statusIndication(&$row){
if($this -> getColumnData($row, COLUMN_TRANSACTION_TYPE) == VAL_INT_1) { // 入金 if($this -> getColumnData($row, COLUMN_TRANSACTION_TYPE) == VAL_INT_1) { // 入金
$row['type'] = VAL_STR_DEPOSIT; $row['type'] = VAL_STR_DEPOSIT;
......
...@@ -2239,3 +2239,8 @@ header .logo-block img { ...@@ -2239,3 +2239,8 @@ header .logo-block img {
box-sizing: border-box; box-sizing: border-box;
height: 80px; height: 80px;
padding: 25px 20px 8px; padding: 25px 20px 8px;
}
.ui-pagination{
padding-top: 15px;
}
\ No newline at end of file
...@@ -55,6 +55,16 @@ include_once('template/base_head.php'); ...@@ -55,6 +55,16 @@ include_once('template/base_head.php');
<?php $this -> echoList();?> <?php $this -> echoList();?>
</table> </table>
<input type="hidden" value="" id="type" name="type" /> <input type="hidden" value="" id="type" name="type" />
<input type="hidden" value="<?php $this -> echoTotalPage()?>" id="max_page"/>
<div class="ui-pagination">
<span><strong>Search Results:</strong> <?php $this -> echoTotal(); ?>&nbsp;&nbsp;&nbsp;</span>
<span class="ui-current-page"><?php $this -> echoPage()?>/<?php $this -> echoTotalPage()?></span>
<input type="button" id="btnPrevPage" value="Previous" class="btn bg-filter mb10">
<input type="button" id="btnNextPage" value="Next" class="btn bg-filter mb10">
&nbsp;&nbsp;&nbsp;&nbsp
<input type="text" id="cur_page" name="page" value="<?php $this -> echoPage() ?>" class="px50">
<input type="button" id="dispPage" value="Display" class="btn bg-filter mb10">
</div>
</form> </form>
</article> </article>
</div> </div>
......
...@@ -48,6 +48,16 @@ include_once('template/base_head.php'); ...@@ -48,6 +48,16 @@ include_once('template/base_head.php');
<?php $this -> echoList();?> <?php $this -> echoList();?>
</table> </table>
<input type="hidden" value="" id="type" name="type" /> <input type="hidden" value="" id="type" name="type" />
<input type="hidden" value="<?php $this -> echoTotalPage()?>" id="max_page"/>
<div class="ui-pagination">
<span><strong>Hasil Pencarian:</strong> <?php $this -> echoTotal(); ?>&nbsp;&nbsp;&nbsp;</span>
<span class="ui-current-page"><?php $this -> echoPage()?>/<?php $this -> echoTotalPage()?></span>
<input type="button" id="btnPrevPage" value="Sebelumnya" class="btn bg-filter mb10">
<input type="button" id="btnNextPage" value="Lanjut" class="btn bg-filter mb10">
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" id="cur_page" name="page" value="<?php $this -> echoPage() ?>" class="px50">
<input type="button" id="dispPage" value="Tampilan" class="btn bg-filter mb10">
</div>
</form> </form>
</article> </article>
</div> </div>
......
...@@ -55,6 +55,16 @@ include_once('template/base_head.php'); ...@@ -55,6 +55,16 @@ include_once('template/base_head.php');
<?php $this -> echoList();?> <?php $this -> echoList();?>
</table> </table>
<input type="hidden" value="" id="type" name="type" /> <input type="hidden" value="" id="type" name="type" />
<input type="hidden" value="<?php $this -> echoTotalPage()?>" id="max_page"/>
<div class="ui-pagination">
<span><strong>検索結果:</strong> <?php $this -> echoTotal(); ?>&nbsp;&nbsp;&nbsp;</span>
<span class="ui-current-page"><?php $this -> echoPage()?>/<?php $this -> echoTotalPage()?></span>
<input type="button" id="btnPrevPage" value="前ページ" class="btn bg-filter mb10">
<input type="button" id="btnNextPage" value="次ページ" class="btn bg-filter mb10">
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" id="cur_page" name="page" value="<?php $this -> echoPage() ?>" class="px50">
<input type="button" id="dispPage" value="表示" class="btn bg-filter mb10">
</div>
</form> </form>
</article> </article>
</div> </div>
......
$(function() { $(function() {
$.fn.inputFilter = function(inputFilter) {
return this.on("input keydown keyup mousedown mouseup select contextmenu drop", function() {
if (inputFilter(this.value)) {
this.oldValue = this.value;
this.oldSelectionStart = this.selectionStart;
this.oldSelectionEnd = this.selectionEnd;
} else if (this.hasOwnProperty("oldValue")) {
this.value = this.oldValue;
this.setSelectionRange(this.oldSelectionStart, this.oldSelectionEnd);
} else {
this.value = "";
}
});
};
$("#cur_page").inputFilter(function(value) {
return /^-?\d*$/.test(value); });
var currentPage = parseInt($("#cur_page").val())
if(currentPage == 1)
$("#btnPrevPage").hide()
$('#btnPrevPage').click(function() {
$('#type').val('search');
if((currentPage - 1) < 1)
return;
$("#cur_page").val(currentPage - 1)
submitForm();
});
$('#btnNextPage').click(function() {
$('#type').val('search');
var maximumPage = parseInt($("#max_page").val())
if((currentPage + 1) > maximumPage)
return;
$("#cur_page").val(currentPage + 1)
submitForm();
});
$('#dispPage').click(function(){
$('#type').val('search');
var maximumPage = parseInt($("#max_page").val())
var selectedPage = parseInt($("#cur_page").val())
if($("#cur_page").val().trim().length == 0)
return;
if(selectedPage > maximumPage || selectedPage < 1)
return;
submitForm();
})
$('#btnSearch').click(function() { $('#btnSearch').click(function() {
$('#type').val('search'); $('#type').val('search');
submitForm(); submitForm();
......
...@@ -46,8 +46,23 @@ class LogicHistory extends HistoryModelClass { ...@@ -46,8 +46,23 @@ class LogicHistory extends HistoryModelClass {
* @return : なし * @return : なし
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
private function lists() { private function lists() {
$this -> setResult($this -> accessSelect('LIST_USER_TRANSACTION', $this -> getUserAccountData())); $countRow = $this -> getRowData($this -> accessSelect('SELECT_USER_TRANSACTION_COUNT', [
$this -> getUserData(PARAM_USER_ACCOUNT),
$this -> getCurrency(),
$this -> getWhereCount()
]));
$totalRows = $this -> getColumnData($countRow, "overall_total");
$start = ($this -> getPage() - 1) * $this -> getHistoryDefaultLimitCount();
$this -> setTotal($totalRows);
$this -> setTotalPage($this -> getTotalPageCommon($this -> getHistoryDefaultLimitCount(), $totalRows));
$userAccountArray = $this -> getUserAccountData();
$userAccountArray[3] = "LIMIT {$start}, {$this -> getHistoryDefaultLimitCount()}";
$this -> setResult($this -> accessSelect('LIST_USER_TRANSACTION', $userAccountArray));
$this -> setBalance($this -> accessSelect('LIST_USER_BALANCE_FROM_CURRENCY_DATE', $this -> getBalanceParams())); $this -> setBalance($this -> accessSelect('LIST_USER_BALANCE_FROM_CURRENCY_DATE', $this -> getBalanceParams()));
} }
......
...@@ -12,6 +12,10 @@ class HistoryModelClass extends ModelClassEx { ...@@ -12,6 +12,10 @@ class HistoryModelClass extends ModelClassEx {
private $accountType = NO_STRING; // account type attribute (string). created by joshua dino private $accountType = NO_STRING; // account type attribute (string). created by joshua dino
private $csvData = NO_STRING; // data attribute (string). created by joshua dino private $csvData = NO_STRING; // data attribute (string). created by joshua dino
private $total = NO_STRING;
private $page = NO_STRING;
private $totalPage = NO_STRING;
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* @function_name: コントロールパネルシステムindexモデルクラスコンストラクタ * @function_name: コントロールパネルシステムindexモデルクラスコンストラクタ
* @parameter : なし * @parameter : なし
...@@ -65,6 +69,8 @@ class HistoryModelClass extends ModelClassEx { ...@@ -65,6 +69,8 @@ class HistoryModelClass extends ModelClassEx {
$this -> currency = USD; $this -> currency = USD;
} }
$this -> page = empty($this -> getDataPost("page")) ? 1 : $this -> getDataPost("page");
// Fromの日付は確定させないとダメ // Fromの日付は確定させないとダメ
if($this -> getDataPost(PARAM_FROM) == NO_STRING) { if($this -> getDataPost(PARAM_FROM) == NO_STRING) {
// $this -> from = date('Y/m/1', strtotime('-1 month')); // $this -> from = date('Y/m/1', strtotime('-1 month'));
...@@ -111,6 +117,29 @@ class HistoryModelClass extends ModelClassEx { ...@@ -111,6 +117,29 @@ class HistoryModelClass extends ModelClassEx {
return $rtn; return $rtn;
} }
public function getWhereCount(){
// 変数宣言部
$params = array();
$rtn = NO_STRING;
// 日付指定(from)
if($this -> from != NO_STRING) {
$params[] = ' create_time >= (\')' . $this -> from . '(\')';
}
// 日付指定(to)
if($this -> to != NO_STRING) {
$params[] = ' create_time < DATE_ADD((\')' . $this -> to . '(\'), INTERVAL 1 DAY)';
}
// データが存在した場合
if($this -> isLoopData($params)) {
$rtn = DELIMIT_AND . implode(DELIMIT_AND, $params);
}
return $rtn;
}
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* @function_name: サーバ側データチェック * @function_name: サーバ側データチェック
* @parameter : なし * @parameter : なし
...@@ -145,6 +174,7 @@ class HistoryModelClass extends ModelClassEx { ...@@ -145,6 +174,7 @@ class HistoryModelClass extends ModelClassEx {
$rtn[] = $this -> getUserData(PARAM_USER_ACCOUNT); // ユーザアカウント $rtn[] = $this -> getUserData(PARAM_USER_ACCOUNT); // ユーザアカウント
$rtn[] = $this -> currency; $rtn[] = $this -> currency;
$rtn[] = $this -> getWhere(); // 検索条件 $rtn[] = $this -> getWhere(); // 検索条件
$rtn[] = NO_STRING;
return $rtn; return $rtn;
} }
...@@ -218,7 +248,12 @@ class HistoryModelClass extends ModelClassEx { ...@@ -218,7 +248,12 @@ class HistoryModelClass extends ModelClassEx {
$rtn .= '</tr>'; $rtn .= '</tr>';
$no = count($this -> rs); $pageRowCount = $this -> page * $this -> getHistoryDefaultLimitCount();
if($this -> page == $this -> totalPage)
$pageRowCount = $this -> total;
$no = $pageRowCount;
$counter = $no; //counter for id number - added by Joshua Dino 04/23/2018 $counter = $no; //counter for id number - added by Joshua Dino 04/23/2018
// データの数だけループを回す // データの数だけループを回す
...@@ -465,6 +500,18 @@ class HistoryModelClass extends ModelClassEx { ...@@ -465,6 +500,18 @@ class HistoryModelClass extends ModelClassEx {
return $this -> from; return $this -> from;
} }
function getPage(){
return $this -> page;
}
function getCurrency(){
return $this -> currency;
}
function getHistoryDefaultLimitCount(){
return VAL_INT_10;
}
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* @function_name: 期間開始の取得 * @function_name: 期間開始の取得
* @parameter : なし * @parameter : なし
...@@ -483,6 +530,23 @@ class HistoryModelClass extends ModelClassEx { ...@@ -483,6 +530,23 @@ class HistoryModelClass extends ModelClassEx {
echo $this -> to; echo $this -> to;
} }
/*-------------------------------------------------------------------------
* @function_name: 期間終了の取得
* @parameter : なし
* @return : 期間終了
-------------------------------------------------------------------------*/
function echoTotal() {
echo $this -> total;
}
function echoTotalPage(){
echo $this -> totalPage;
}
function echoPage(){
echo $this -> page;
}
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* @function_name: 通貨一覧の取得 * @function_name: 通貨一覧の取得
* @parameter : なし * @parameter : なし
...@@ -501,6 +565,23 @@ class HistoryModelClass extends ModelClassEx { ...@@ -501,6 +565,23 @@ class HistoryModelClass extends ModelClassEx {
$this -> rs = $rs; $this -> rs = $rs;
} }
/*-------------------------------------------------------------------------
* @function_name: 全額の設定
* @parameter : 全額
* @return : なし
-------------------------------------------------------------------------*/
public function setTotal($total) {
$this -> total = $total;
}
public function setTotalPage($totalPage) {
$this -> totalPage = $totalPage;
}
public function setPage($page){
$this -> page = page;
}
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* @function_name: バランスの設定 * @function_name: バランスの設定
* @parameter : バランス * @parameter : バランス
......
...@@ -55,6 +55,16 @@ include_once('template/base_head.php'); ...@@ -55,6 +55,16 @@ include_once('template/base_head.php');
<?php $this -> echoList();?> <?php $this -> echoList();?>
</table> </table>
<input type="hidden" value="" id="type" name="type" /> <input type="hidden" value="" id="type" name="type" />
<input type="hidden" value="<?php $this -> echoTotalPage()?>" id="max_page"/>
<div class="ui-pagination">
<span><strong>搜寻结果:</strong> <?php $this -> echoTotal(); ?>&nbsp;&nbsp;&nbsp;</span>
<span class="ui-current-page"><?php $this -> echoPage()?>/<?php $this -> echoTotalPage()?></span>
<input type="button" id="btnPrevPage" value="返回" class="btn bg-filter mb10">
<input type="button" id="btnNextPage" value="下一步" class="btn bg-filter mb10">
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" id="cur_page" name="page" value="<?php $this -> echoPage() ?>" class="px50">
<input type="button" id="dispPage" value="表示" class="btn bg-filter mb10">
</div>
</form> </form>
</article> </article>
</div> </div>
......
...@@ -4285,8 +4285,52 @@ WHERE ...@@ -4285,8 +4285,52 @@ WHERE
__ELEMENT03__ __ELEMENT03__
ORDER BY ORDER BY
transaction_time , msecond transaction_time , msecond
__ELEMENT04__
</LIST_USER_TRANSACTION> </LIST_USER_TRANSACTION>
<SELECT_USER_TRANSACTION_COUNT>
SELECT
(remitter + receiver + deposit + withdrawal + benef_exchange
+ debit_exchange + from_request + to_request + with1 + with2 + with3 ) AS 'overall_total'
FROM (
SELECT
(SELECT COUNT(*) FROM t_deposit WHERE user_account = '__ELEMENT01__'
AND currency = '__ELEMENT02__' __ELEMENT03__ AND NOW() + INTERVAL 17 HOUR > deposit_date) deposit,
(SELECT COUNT(*) FROM t_withdraw WHERE user_account = '__ELEMENT01__'
AND debit_currency = '__ELEMENT02__' __ELEMENT03__ AND STATUS &lt;= 3
AND (TYPE = '0'
OR TYPE = '3'
OR TYPE = '1')) withdrawal,
(SELECT COUNT(*) FROM t_exchange WHERE user_account = '__ELEMENT01__'
AND currency = '__ELEMENT02__' __ELEMENT03__) benef_exchange,
(SELECT COUNT(*) FROM t_exchange WHERE user_account = '__ELEMENT01__'
AND debit_currency = '__ELEMENT02__' __ELEMENT03__) debit_exchange,
(SELECT COUNT(*) FROM t_transfer WHERE from_account = '__ELEMENT01__'
AND debit_currency = '__ELEMENT02__' __ELEMENT03__) remitter,
(SELECT COUNT(*) FROM t_transfer WHERE to_account = '__ELEMENT01__'
AND transfer_currency = '__ELEMENT02__' __ELEMENT03__) receiver,
(SELECT COUNT(*) FROM t_request WHERE from_account = '__ELEMENT01__'
AND debit_currency = '__ELEMENT02__' __ELEMENT03__ AND STATUS = 1) from_request,
(SELECT COUNT(*) FROM t_request WHERE to_account = '__ELEMENT01__'
AND currency = '__ELEMENT02__' __ELEMENT03__ AND STATUS = 1) to_request,
(SELECT COUNT(*) FROM t_withdraw WHERE user_account = '__ELEMENT01__'
AND debit_currency = '__ELEMENT02__' __ELEMENT03__ AND STATUS = '4') with1,
(SELECT COUNT(*) FROM t_withdraw WHERE user_account = '__ELEMENT01__'
AND debit_currency = '__ELEMENT02__' __ELEMENT03__ AND STATUS = '6') with2,
(SELECT COUNT(*) FROM t_withdraw WHERE user_account = '__ELEMENT01__'
AND debit_currency = '__ELEMENT02__' __ELEMENT03__ AND STATUS = '2' AND TYPE = '11') with3
) counts
</SELECT_USER_TRANSACTION_COUNT>
<LIST_USER_TRANSACTION_ADMIN_COUNT> <LIST_USER_TRANSACTION_ADMIN_COUNT>
SELECT SELECT
count(*) total count(*) total
......
...@@ -55,6 +55,16 @@ include_once('template/base_head.php'); ...@@ -55,6 +55,16 @@ include_once('template/base_head.php');
<?php $this -> echoList();?> <?php $this -> echoList();?>
</table> </table>
<input type="hidden" value="" id="type" name="type" /> <input type="hidden" value="" id="type" name="type" />
<input type="hidden" value="<?php $this -> echoTotalPage()?>" id="max_page"/>
<div class="ui-pagination">
<span><strong>搜尋結果:</strong> <?php $this -> echoTotal(); ?>&nbsp;&nbsp;&nbsp;</span>
<span class="ui-current-page"><?php $this -> echoPage()?>/<?php $this -> echoTotalPage()?></span>
<input type="button" id="btnPrevPage" value="返回" class="btn bg-filter mb10">
<input type="button" id="btnNextPage" value="下一步" class="btn bg-filter mb10">
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" id="cur_page" name="page" value="<?php $this -> echoPage() ?>" class="px50">
<input type="button" id="dispPage" value="顯示" class="btn bg-filter mb10">
</div>
</form> </form>
</article> </article>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment