From 3e49a01c981fd3a745ea30e6c5492dc6600d4696 Mon Sep 17 00:00:00 2001 From: lyt Date: Tue, 27 Feb 2018 17:29:15 +0800 Subject: [PATCH] =?UTF-8?q?ipaylinks=20=E5=AF=BC=E5=87=BA=E6=94=B6?= =?UTF-8?q?=E6=AC=BE=E8=AE=B0=E5=BD=95,=E6=89=93=E5=8D=B0=E7=BB=99?= =?UTF-8?q?=E9=93=B6=E8=A1=8C=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pay/controllers/iPayLinksService.php | 67 ++++++++++++++++ webht/third_party/pay/models/note_model.php | 13 +++ .../third_party/pay/views/iPayLinks_list.php | 80 ++++++++++++++++--- 3 files changed, 150 insertions(+), 10 deletions(-) diff --git a/webht/third_party/pay/controllers/iPayLinksService.php b/webht/third_party/pay/controllers/iPayLinksService.php index 1159a2ab..12938264 100644 --- a/webht/third_party/pay/controllers/iPayLinksService.php +++ b/webht/third_party/pay/controllers/iPayLinksService.php @@ -1200,4 +1200,71 @@ class IPayLinksService extends CI_Controller ); } + public function export_list() + { + $from_date = $this->input->post("from_date"); + $to_date = $this->input->post("to_date"); + $currency = $this->input->post("currency"); + $export_list = $this->Note_model->date_range($from_date, $to_date, $currency); + if ($export_list == false) { + echo "Not found any records for export."; + return false; + } + $this->load->library('PHPExcel'); + $objPHPExcel = new PHPExcel(); + $objPHPExcel->setActiveSheetIndex(0); + //set width + $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(5); + $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(30); + $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(15); + $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(20); + $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(30); + $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(20); + // 对齐 + $objPHPExcel->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT); + $objPHPExcel->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); + // 表标题行 + $objPHPExcel->getActiveSheet() + ->SetCellValue('A1', '#') + ->SetCellValue('B1', '团号') + ->SetCellValue('C1', '金额') + ->SetCellValue('D1', '付款人') + ->SetCellValue('E1', '交易号') + ->SetCellValue('F1', '收单时间'); + $currency_sum = array(); + bcscale(2); + $rowCount = 2; + foreach ($export_list as $key => $row) { + if( trim($row->IPL_currencyCode) != "") { + $currency_sum[trim($row->IPL_currencyCode)] = bcadd($currency_sum[trim($row->IPL_currencyCode)], $row->IPL_orderAmount); + } + $payer = $row->IPL_payerName ? ($row->IPL_payerName . "<" . $row->IPL_payerEmail . ">") : "退款"; + $objPHPExcel->getActiveSheet() + ->SetCellValue('A'.$rowCount, ($rowCount-1)) + ->setCellValueExplicit('B'.$rowCount, $row->IPL_orderId,PHPExcel_Cell_DataType::TYPE_STRING) + ->setCellValueExplicit('C'.$rowCount, trim($row->IPL_currencyCode) . number_format($row->IPL_orderAmount, 2, ".", ""),PHPExcel_Cell_DataType::TYPE_STRING) + ->SetCellValue('D'.$rowCount, $payer) + ->setCellValueExplicit('E'.$rowCount, $row->IPL_dealId,PHPExcel_Cell_DataType::TYPE_STRING) + ->SetCellValue('F'.$rowCount, $row->IPL_acquiringTime); + $payer = ""; + $rowCount++; + } + $rowCount++; // 隔一行 + // 汇总行 + $objPHPExcel->getActiveSheet() + ->SetCellValue('A' . $rowCount, '合计'); + foreach ($currency_sum as $kc => $cur) { + $objPHPExcel->getActiveSheet() + ->SetCellValue('B' . $rowCount, $kc) + ->setCellValueExplicit('C' . $rowCount, number_format($cur, 2, ".", ""),PHPExcel_Cell_DataType::TYPE_STRING); + $rowCount++; + } + $filename = "export_ipaylinks_" . date('Y-m-d'); + header('Content-Type: application/vnd.ms-excel'); + header('Content-Disposition: attachment;filename="' . $filename . '.xls"'); + header('Cache-Control: max-age=0'); + $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); + $objWriter->save('php://output'); + } + } diff --git a/webht/third_party/pay/models/note_model.php b/webht/third_party/pay/models/note_model.php index 7954f428..0f30a40c 100644 --- a/webht/third_party/pay/models/note_model.php +++ b/webht/third_party/pay/models/note_model.php @@ -273,4 +273,17 @@ class Note_model extends CI_Model { return $query; } + public function date_range($from, $to, $currency=NULL) + { + $this->init(); + $search_sql = " AND pn.IPL_resultCode='0000' "; + $search_sql .= " AND pn.IPL_acquiringTime BETWEEN '$from 00:00:00' AND '$to 23:59:59' "; + if ( ! empty($currency)) { + $search_sql .= " AND IPL_currencyCode = '$currency' "; + } + $this->search = $search_sql; + $this->orderby = ""; + return $this->get_list(); + } + } diff --git a/webht/third_party/pay/views/iPayLinks_list.php b/webht/third_party/pay/views/iPayLinks_list.php index 35e291f7..9551b14a 100644 --- a/webht/third_party/pay/views/iPayLinks_list.php +++ b/webht/third_party/pay/views/iPayLinks_list.php @@ -23,7 +23,7 @@ -
+
-
+