<?php

include_once dirname(__FILE__) . '/../main.php';

$paras = query_paras();

$platform = $paras["platform"];
$startTime = $paras["startTime"];
$endTime = $paras["endTime"];
$pageNumber = $paras['pageNumber'];
$pageSize = $paras['pageSize'];

$start = ($pageNumber - 1) * $pageSize;


$count = daoInst()->select('*')->from('tpl_order_tab')
        ->where('status')->eq(1)
        ->andWhere('close_ts')->ge(strtotime($startTime))
        ->andWhere('close_ts')->lt(strtotime($endTime))
        ->count();

$list = daoInst()->select('*')->from('tpl_order_tab')
        ->where('status')->eq(1)
        ->andWhere('close_ts')->ge(strtotime($startTime))
        ->andWhere('close_ts')->lt(strtotime($endTime))
        ->limit($start . "," . $pageSize)
        ->fetch_array();

$array = new stdClass();
$array->total = $count;
$array->rows = $list;

echo json_encode($array);
