Ejemplo n.º 1
0
 public function Lists()
 {
     include 'Include/LevelArray.php';
     $MysqlWhere = ' where 1';
     $Page = intval($this->_GET['Page']);
     $Page = $Page ? $Page : 1;
     $AgentModule = new AgentModule();
     $AgentApiModule = new AgentApiModule();
     $ListsNum = $AgentModule->GetListsNum($MysqlWhere);
     $Rscount = $ListsNum['Num'];
     $PageSize = 20;
     if ($Rscount) {
         $Data['RecordCount'] = $Rscount;
         $Data['PageSize'] = $PageSize ? $PageSize : $Data['RecordCount'];
         $Data['PageCount'] = ceil($Data['RecordCount'] / $PageSize);
         $Data['Page'] = min($Page, $Data['PageCount']);
         $Offset = ($Page - 1) * $Data['PageSize'];
         if ($Page > $Data['PageCount']) {
             $Page = $Data['PageCount'];
         }
         $Data['Data'] = $AgentModule->GetLists($MysqlWhere, $Offset, $Data['PageSize']);
         $AgentAccountModule = new AgentAccountModule();
         foreach ($Data['Data'] as $Key => $Value) {
             $Array['AgentID'] = $Value['AgentID'];
             $AgentApiInfo = $AgentApiModule->GetOneInfoByForID($Value['AgentID']);
             if (!empty($AgentApiInfo)) {
                 $Data['Data'][$Key]['Api']['url'] = $AgentApiInfo['url'];
                 $Data['Data'][$Key]['Api']['token'] = $AgentApiInfo['token'];
             }
             $AgentAccountInfo = $AgentAccountModule->GetLists('where AgentID=' . $Array['AgentID']);
             $Num = count($AgentAccountInfo);
             if ($Num == 0) {
                 $Data['Data'][$Key]['Total'] = '0';
                 $Data['Data'][$Key]['Balance'] = '0';
             } else {
                 foreach ($AgentAccountInfo as $V) {
                     $Data['Data'][$Key]['Total'] += $V['Total'];
                     $Data['Data'][$Key]['Balance'] += $V['Balance'];
                 }
             }
         }
         MultiPage($Data, 10);
         //dd($Data);
         $this->Data = $Data;
     }
 }