request; $ibId = (int) $request->get('ibId'); $api = new MemberApi(); $ibs = $api->getIbs()['data']; return $this->render('index', [ 'ibId' => $ibId, 'ibs' => $ibs, 'isHaveAdmin' => Yii::$app->user->identity->isHaveAdmin(), ]); } /** * 列表数据 */ public function actionList() { $get = Yii::$app->request->get(); $orderInt = isset($get['order'][0]['column']) ? (int) $get['order'][0]['column'] : 1; $order = isset($get['columns'][$orderInt]['data']) ? $get['columns'][$orderInt]['data'] : ''; $orderBy = isset($get['order'][0]['dir']) ? $get['order'][0]['dir'] : 'desc'; $search = isset($get['search']['value']) ? $get['search']['value'] : ''; $start = isset($get['start']) ? (int) $get['start'] : 0; $length = isset($get['length']) ? (int) $get['length'] : 20; $ibId = isset($get['ibId']) ? $get['ibId'] : 0; $draw = isset($get['draw']) ? $get['draw'] : 1; $params = [ 'order' => $order, 'orderBy' => $orderBy, 'search' => $search, 'start' => $start, 'length' => $length, 'ibId' => $ibId, 'draw' => $draw, ]; if ($params['length'] > 5000) { if (Yii::$app->getRequest()->getIsAjax()) { Yii::$app->getResponse()->redirect(Url::current(), UserAgentHelper::isIE() ? 200 : 302); } else { $this->exportXls($params); } Yii::$app->end(); } $api = new Mt4UserApi(); $result = $api->getList($params); echo json_encode($result['data']); } /** * @param array $params */ protected function exportXls($params) { ExcelHelper::init(); $attachmentName = Yii::$app->user->identity->name . "_名下账户_" . date('Y-m-d') . '.xlsx'; $header = ['代理商', '账户', '姓名', '杠杆', '余额', '保证金', '可用保证金', '保证金比例', '净值', '最后更新时间']; $source = []; $summaryRow = []; $api = new Mt4UserApi(); $params['length'] = 5000; while (true) { $result = $api->getList($params); if ($result['code'] == 1 && !empty($result['data']['data'])) { foreach ((array)$result['data']['data'] as $key => $row) { $arr = []; $arr[] = $row['name']; $arr[] = $row['LOGIN']; $arr[] = $row['NAME']; $arr[] = $row['LEVERAGE']; $arr[] = $row['BALANCE']; $arr[] = $row['MARGIN']; $arr[] = $row['MARGIN_FREE']; $arr[] = $row['MARGIN_LEVEL']; $arr[] = $row['EQUITY']; $arr[] = $row['MODIFY_TIME']; $source[] = $arr; } $summaryRow = array_pop($source); } else { break; } $params['start'] += $params['length']; if ($params['start'] >= $result['data']['recordsTotal']) { break; } } $source[] = $summaryRow; ExcelHelper::output($source, $header, $attachmentName); } }