setAttributes($params); $this->initSearchParams(); $pagination = new Pagination(); $pagination->setPageSize($this->pageSize); $data['page'] = $this->page; $data['pageSize'] = $pagination->getPageSize(); if ($this->orderBy) { $data['orderBy'] = $this->orderBy; } if (!empty($this->search['value']) && trim($this->search['value']) !== '') { $data['search'] = trim($this->search['value']); } $data['remit_no'] = $this->remit_no; $data['batch_no'] = $params['batch_no']; if ($this->pageSize > 1000) { if (\Yii::$app->getRequest()->isAjax) { \Yii::$app->getResponse()->redirect(Url::current(), UserAgentHelper::isIE() ? 200 : 302); } else { $this->exportXls($data); } \Yii::$app->end(); } $api = new RemitApi(); $result = $api->financeRemitDetail($data); // $result = $this->multiQuery($api, 'financeRemitDetail', $data); $models = []; if ($result['code'] == 1) { $models = (array)$result['data']['dataList']; $pagination->totalCount = (int)$result['data']['totalCount']; } $dataProvider = new ArrayDataProvider([ 'models' => $models, 'pagination' => $pagination, 'totalCount' => $pagination->totalCount, ]); return $dataProvider; } /** * @param array $params */ protected function exportXls($params) { ExcelHelper::init(); $attachmentName = "财务打款审核记录_" . date('Y-m-d') . '.xls'; $header = ['打款批次号', '打款单号', '打款方式', '出金单号', '收款人名字', '打款金额', '银行名称', '银行支行', '银行卡号', '开户行所在省', '开户行所在市', '银行代码', '备注', '打款信息']; $source = []; $api = new RemitApi(); $leftSize = $this->pageSize; while ($leftSize > 0) { // 重新计算页数和分页大小 start $pageSize = $leftSize > 1000 ? 1000 : $leftSize; $params['pageSize'] = $pageSize; $params['page'] = ceil($this->start / $pageSize) + 1; $result = $api->financeRemitDetail($params); if ($result['code'] == 1 && !empty($result['data']['dataList'])) { foreach ((array)$result['data']['dataList'] as $key => $row) { $arr = []; $arr[] = ' '.$row['batch_no']; $arr[] = ' '.$row['remit_no']; $pay_type = ''; if ((int)$row['pay_type'] == 1) { $pay_type = '爱农'; } elseif ((int)$row['pay_type'] == 2) { $pay_type = '汇道'; } elseif ((int)$row['pay_type'] == 3) { $pay_type = ''; } elseif ((int)$row['pay_type'] == 4) { $pay_type = '华银'; } elseif ((int)$row['pay_type'] == 5) { $pay_type = '奥凸'; } $arr[] = $pay_type; $arr[] = ' '.$row['biz_no']; $arr[] = $row['payee_name']; $arr[] = $row['amount']; $arr[] = $row['bank_name']; $arr[] = $row['bank_branch']; $arr[] = ' '.$row['bank_card_no']; $arr[] = $row['bank_province']; $arr[] = $row['bank_city']; $arr[] = $row['bank_code']; $arr[] = $row['memo']; $arr[] = $row['ret_msg']; $source[] = $arr; } } else { break; } $this->start += $pageSize; $leftSize -= $pageSize; if ($this->start >= $result['data']['totalCount']) { break; } } ExcelHelper::output($source, $header, $attachmentName); } private function exportXlsx($data) { \Yii::$app->getResponse()->setDownloadHeaders("财务打款审核记录_" . date('Y-m-d') . '.xls')->send(); if (!ob_get_level()) { ob_start(); } echo ''; echo '
| 打款批次号 | 打款单号 | 打款方式 | 出金单号 | 收款人名字 | 打款金额 | 银行名称 | 银行支行 | 银行卡号 | 开户行所在省 | 开户行所在市 | 银行代码 | 备注 | 打款信息 | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {$row['batch_no']} | "; $str .= "{$row['remit_no']} | "; if ((int)$row['pay_type'] == 1) { $str .= "爱农 | "; } elseif ((int)$row['pay_type'] == 2) { $str .= "汇道 | "; } elseif ((int)$row['pay_type'] == 3) { $str .= ""; } elseif ((int)$row['pay_type'] == 4) { $str .= " | 华银 | "; } elseif ((int)$row['pay_type'] == 5) { $str .= "奥凸 | "; } $str .= "{$row['biz_no']} | "; $str .= "{$row['payee_name']} | "; $str .= "{$row['amount']} | "; $str .= "{$row['bank_name']} | "; $str .= "{$row['bank_branch']} | "; $str .= "{$row['bank_card_no']} | "; $str .= "{$row['bank_province']} | "; $str .= "{$row['bank_city']} | "; $str .= "{$row['bank_code']} | "; $str .= "{$row['memo']} | "; $str .= "{$row['ret_msg']} | "; $str .= "