diff --git a/application/third_party/trainsystem/controllers/api.php b/application/third_party/trainsystem/controllers/api.php index a2c810d7..567d7471 100644 --- a/application/third_party/trainsystem/controllers/api.php +++ b/application/third_party/trainsystem/controllers/api.php @@ -413,6 +413,77 @@ class api extends CI_Controller{ } } + + //澜海账单导出api + public function lanhai_export_excel(){ + set_time_limit(0); + + //参数 + $from_date = $this->input->post("from_date"); + $to_date = $this->input->post("to_date"); + if(!empty($from_date) && !empty($to_date)){ + //拼接发送的报文 + $PostData = new stdClass(); + $bodyInfo = new stdclass(); + $bodyInfo->startTime = $from_date." 00:00:00"; + $bodyInfo->endTime = $to_date." 23:59:59"; + $bodyInfo->pageNum = 1; + $bodyInfo->pageSize = 20000; + + $authentication = new stdClass(); //需加密的数据 + $authentication->appId = LANHAI_appId; + + //加密 + $this->load->library("aesLanhai"); + $aesUnit = new Security(); + $resultData = $aesUnit->encryptData(json_encode($bodyInfo)); + + $PostData->bodyInfo = $resultData; + $PostData->authentication = $authentication; + + //echo (json_encode($PostData)); + + $url = LANHAI_URL."api/open/bill"; + $ResponseJson = GetPost_http($url,json_encode($PostData,JSON_UNESCAPED_UNICODE),'json'); + $ResponseData = json_decode($ResponseJson); + if($ResponseData->code == 0 && $ResponseData->success){ + + $string_r = "";//输出 + $arr = array();//整合完成的数组,写进excel表的数据 + + foreach ($ResponseData->data->records as $record) { + # code... + $arrRecord = array(); + $arrRecord["saveDay"] = $record->saveDay; + $arrRecord["type"] = $record->type; //类型 包括:出票、低改高、出票退票、改签退票、退票 + $arrRecord["mainOrderId"] = $record->mainOrderId; //订单号 + $arrRecord["passengerName"] = $record->passengerName; //乘车人 + $arrRecord["price"] = $record->price ;//金额,整数是支付票款,负数是退回金额 + $arrRecord["wl"] = ""; //外联 + $arrRecord["griName"]=""; //团号 + $orderData = $this->train_system_model->get_OPIName($record->mainOrderId); + if (!empty($orderData)){ + $arrRecord["wl"] = $orderData->OPIName; + $arrRecord["griName"] = $orderData->griName; + } + + $arr[] = $arrRecord; + } + + //print_r($arr); + + + //写入excel模板 + header("Content-type:application/vnd.ms-excel;charset=utf-8"); + header("Content-Disposition:attachment;filename=juhe_train.xls"); + $string_r= $this->load->view("lanhai_transaction_excel",array("arr"=>$arr),TRUE); + echo $string_r;die; + + } + + } + + } //订单同步到trainsystem public function sync_orders(){ diff --git a/application/third_party/trainsystem/controllers/pages.php b/application/third_party/trainsystem/controllers/pages.php index 296d2d06..7fd3259b 100644 --- a/application/third_party/trainsystem/controllers/pages.php +++ b/application/third_party/trainsystem/controllers/pages.php @@ -245,14 +245,21 @@ class pages extends CI_Controller{ //账单导出页面 public function export(){ - if(get_cookie('dingname') == '' && get_cookie('dingunionid') == ''){ - redirect('/apps/dinglogin/login/?returnurl=/apps/trainsystem/pages/'); - } + // if(get_cookie('dingname') == '' && get_cookie('dingunionid') == ''){ + // redirect('/apps/dinglogin/login/?returnurl=/apps/trainsystem/pages/'); + // } $this->load->view('header'); $this->load->view('export'); $this->load->view('footer'); } + //澜海账单导出页面 + public function lanhaiExport(){ + $this->load->view('header'); + $this->load->view('export_lanhai'); + $this->load->view('footer'); + } + //预售时间列表 public function presale_list(){ $page_size = 10; @@ -337,6 +344,115 @@ class pages extends CI_Controller{ echo $rUrl; } + //澜海查询信息 + public function lanhaiMsg(){ + + $order = $this->input->get_post("order"); //订单号 + $type = $this->input->get_post("type"); //出票,退票,账单等类型 + + $microtime = get_microtime(); //时间戳 + //生成接口请求头参数 + $timestamp = $microtime; + $appId = LANHAI_appId; + + if ($type == "orderticket"){ + $url = LANHAI_URL."api/open/get/orderDetails"; + }else if ($type == "returnticket"){ + $url = LANHAI_URL."api/open/get/orderRefundDetails"; + } + + //拼接发送的报文 + $PostData = new stdClass(); + $PostData->mainOrderId = $order; + $PostData->timestamp = $timestamp; + $PostData->appId = $appId; + + $ResponseJson = GetPost_http($url,json_encode($PostData),'json'); + //log_message('error','澜海出票详细信息:'.$ResponseJson); + $ResponseData = json_decode($ResponseJson); + if (isset($ResponseData->data)){ + // //需要解密 + $this->load->library("aesLanhai"); + $aesUnit = new Security(); + $data = json_decode($aesUnit->decryptData($ResponseData->data)); + + $result = array(); + $this->handle_array($data,$type,$result); + $formattedJson = json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); + echo "
$formattedJson"; + + }else{ + $ResultNoticeResponse = new stdClass(); + $ResultNoticeResponse->returnCode = -1; + $ResultNoticeResponse->success = false; + $ResultNoticeResponse->returnMsg = "找不到订单数据!"; + $formattedJson = json_encode($ResultNoticeResponse, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); + echo $formattedJson; + } + } + + //循环展示JSON + private function handle_array($arr,$type,&$array_to_fill){ + foreach($arr as $key => $value){ + if(is_array($value) || is_object($value)){ + $array_to_fill[$key] = array(); + $this->handle_array($value,$type, $array_to_fill[$key]); + }else{ + if ($type=="orderticket"){ //出票特殊显示 + if ($key == "passengerType"){ + if ($value==0){ + $value = "成人"; + }else if($value == 1){ + $value = "儿童"; + } + } + + if ($key == "certificateType"){ + if ($value==1){ + $value = "身份证"; + }else if ($value == 2) { + $value = "护照"; + }else if ($value == 7){ + $value = "回乡证"; + }else if ($value == 8 ){ + $value = "台胞证"; + } + } + + if ($key == "status"){ + switch ($value) { + case 0: + $value = "待出票"; + break; + case 1: + $value = "锁定订单"; + break; + case 2: + $value = "已出票"; + break; + case 3: + $value = "超时订单"; + break; + case 4: + $value = "已驳回"; + break; + case 6: + $value = "出票超时"; + break; + case 12: + $value = "锁单失败"; + break; + default: + # code... + break; + } + } + } + $array_to_fill[$key] = $value; + } + } + } + public function presale_add(){ $this->load->view('header'); diff --git a/application/third_party/trainsystem/models/train_system_model.php b/application/third_party/trainsystem/models/train_system_model.php index cd01a5e4..32c0cd64 100644 --- a/application/third_party/trainsystem/models/train_system_model.php +++ b/application/third_party/trainsystem/models/train_system_model.php @@ -63,7 +63,9 @@ class train_system_model extends CI_Model { AND {$where} ORDER BY InfoManager.dbo.trainsystem.ts_subtime DESC"; - + // echo($sql); + // die(); + $query = $this->HT->query($sql); $data->list=$query->result(); return $data; @@ -377,4 +379,27 @@ class train_system_model extends CI_Model { $query = $this->INFO->query($sql,array($tst_id)); return $query->row(); } + + //根据订单号获取外联名称 + public function get_OPIName($orderNumber){ + $sql = "select top 1 + (SELECT TOP 1 OPI2_Name + FROM OperatorInfo2 + WHERE OPI2_OPI_SN = coli_opi_id + AND OPI2_LGC = 2 + ) AS OPIName, + (select top 1 Gri_No from GRoupInfo where GRI_SN=BIZ_ConfirmLineInfo.COLI_GRI_SN) as griName + + FROM InfoManager.dbo.trainsystem + INNER JOIN BIZ_ConfirmLineInfo ON BIZ_ConfirmLineInfo.COLI_SN = ( + SELECT COLD_COLI_SN + FROM BIZ_ConfirmLineDetail + WHERE COLD_SN = InfoManager.dbo.trainsystem.ts_cold_sn + ) + where ts_ordernumber=? + "; + + $query = $this->HT->query($sql,array($orderNumber)); + return $query->row(); + } } \ No newline at end of file diff --git a/application/third_party/trainsystem/views/export.php b/application/third_party/trainsystem/views/export.php index 1da65ee6..8811d267 100644 --- a/application/third_party/trainsystem/views/export.php +++ b/application/third_party/trainsystem/views/export.php @@ -5,8 +5,8 @@
+ +
时间 | 信息 | 变化值 | 团名 | 外联 |
---|---|---|---|---|
+ |