diff --git a/.github/workflows/Deploy.yml b/.github/workflows/Deploy.yml index 164c5b6d..9b24b01e 100644 --- a/.github/workflows/Deploy.yml +++ b/.github/workflows/Deploy.yml @@ -6,8 +6,8 @@ on: branches: [ master ] jobs: - gh-win-us-deploy: - name: 🎉 Deploy InfoSys to US + gh-win-cn-deploy: + name: 🎉 Deploy InfoSys to CN runs-on: ubuntu-latest steps: - name: 🚚 Get latest code @@ -16,13 +16,14 @@ jobs: - name: 📂 Sync files to CHT uses: SamKirkland/FTP-Deploy-Action@v4.3.4 with: - server: ${{ secrets.US_FTP_SERVER }} - username: ${{ secrets.US_FTP_USER }} - password: ${{ secrets.US_FTP_PASSWORD }} - port: ${{ secrets.US_FTP_PORT }} + server: ${{ secrets.CN_FTP_SERVER }} + username: ${{ secrets.CN_FTP_USER }} + password: ${{ secrets.CN_FTP_PASSWORD }} + port: ${{ secrets.CN_FTP_PORT }} local-dir: ./ - server-dir: /information-system/ + server-dir: /wwwroot/origin-cht.mycht.cn/ # dry-run: true + # log-level: verbose exclude: | **/.git* **/.git*/** @@ -36,7 +37,16 @@ jobs: *.exe *.docx .ftp-deploy-sync-state.json - - name: 📂 Sync files to CT + + gh-win-us-deploy: + needs: gh-win-cn-deploy + name: 🎉 Deploy InfoSys to US + runs-on: ubuntu-latest + steps: + - name: 🚚 Get latest code + uses: actions/checkout@v3 + + - name: 📂 Sync files to CHT uses: SamKirkland/FTP-Deploy-Action@v4.3.4 with: server: ${{ secrets.US_FTP_SERVER }} @@ -44,7 +54,7 @@ jobs: password: ${{ secrets.US_FTP_PASSWORD }} port: ${{ secrets.US_FTP_PORT }} local-dir: ./ - server-dir: /origin-ct.mycht.cn/ + server-dir: /information-system/ # dry-run: true exclude: | **/.git* @@ -59,26 +69,16 @@ jobs: *.exe *.docx .ftp-deploy-sync-state.json - - gh-win-cn-deploy: - needs: gh-win-us-deploy - name: 🎉 Deploy InfoSys to CN - runs-on: ubuntu-latest - steps: - - name: 🚚 Get latest code - uses: actions/checkout@v3 - - - name: 📂 Sync files to CHT + - name: 📂 Sync files to CT uses: SamKirkland/FTP-Deploy-Action@v4.3.4 with: - server: ${{ secrets.CN_FTP_SERVER }} - username: ${{ secrets.CN_FTP_USER }} - password: ${{ secrets.CN_FTP_PASSWORD }} - port: ${{ secrets.CN_FTP_PORT }} + server: ${{ secrets.US_FTP_SERVER }} + username: ${{ secrets.US_FTP_USER }} + password: ${{ secrets.US_FTP_PASSWORD }} + port: ${{ secrets.US_FTP_PORT }} local-dir: ./ - server-dir: /wwwroot/origin-cht.mycht.cn/ + server-dir: /origin-ct.mycht.cn/ # dry-run: true - # log-level: verbose exclude: | **/.git* **/.git*/** @@ -93,6 +93,8 @@ jobs: *.docx .ftp-deploy-sync-state.json + + hn-notification: needs: gh-win-cn-deploy name: 🔔 Send notificaiton diff --git a/application/controllers/information.php b/application/controllers/information.php index a5154197..d55eb765 100644 --- a/application/controllers/information.php +++ b/application/controllers/information.php @@ -900,7 +900,32 @@ class Information extends CI_Controller break; default: } - $breadcrumb_data = $this->Information_model->get_path_exclude_self($information->is_id, $information->is_path); + + // CH Home 下层节点名称和链接映射 + $group_map = [ + 278008010 => [ + 'ic_url' => '/travelguide/culture/', + 'ic_url_title' => 'Chinese Culture' + ], + 278008011 => [ + 'ic_url' => '/citytour/', + 'ic_url_title' => 'Destinations' + ], + 278008012 => [ + 'ic_url' => '/aboutus/', + 'ic_url_title' => 'About Us' + ], + 278008013 => [ + 'ic_url' => '/citytour/', + 'ic_url_title' => 'City Tours' + ], + 278008014 => [ + 'ic_url' => '/tour/', + 'ic_url_title' => 'China Tours' + ] + ]; + + $breadcrumb_data = $this->Information_model->get_breadcrumb_data($information->is_id, $information->is_path, $group_map); $breadcrumb_structured_data_content = $this->load->view( $template_path . '-structured-data-breadcrumb', @@ -1047,6 +1072,7 @@ class Information extends CI_Controller $author = $this->Operator_model->get_author_nikename($information->ic_author); if (!empty($author)) { $data_H1['author'] = $author->OPI_FirstName; + $data_H1['OPI_Code'] = $author->OPI_Code; } else { $author_web = $this->Infoauthors_model->detail_by_id($information->ic_author); //原始作者,可能是在线作者等 if (!empty($author_web)) { @@ -1746,6 +1772,7 @@ class Information extends CI_Controller if (!empty($author)) { $data_H1['author'] = $author->OPI_FirstName; + $data_H1['OPI_Code'] = $author->OPI_Code; } else { $author_web = $this->Infoauthors_model->detail_by_id($information->ic_author); //原始作者,可能是在线作者等 if (!empty($author_web)) { @@ -1975,6 +2002,31 @@ class Information extends CI_Controller } } + // 顾问英文名反馈标签 + $feedback_advisor_array = []; + preg_match_all('^^', $information->ic_content, $feedback_advisor_array); + if (!empty($feedback_advisor_array)) { + foreach ($feedback_advisor_array[0] as $index => $tag_name) { + $advisor_name = $feedback_advisor_array[1][$index]; + $feedback_list = $this->Feedback_model->get_feedback_by_advisor_name($advisor_name); + $feedback_content = $this->load->view( + 'mobile_first/gh-feedback-advisor-list', + array( + 'feedback_list' => $feedback_list, + 'advisor_name' => $advisor_name + ), + true + ); + $information->ic_content = str_replace( + $tag_name, + $feedback_content, + $information->ic_content + ); + } + } + + + if (is_file('D:/wwwroot/origin-www.globalhighlights.com/css/gh-global.css')) { //主样式表,内联模式,优先读取本地,没有在从网络读取,为了加速 $main_css_string = compress_css(file_get_contents('D:/wwwroot/origin-www.globalhighlights.com/css/gh-global.css')); } else { @@ -2109,6 +2161,7 @@ class Information extends CI_Controller $author = $this->Operator_model->get_author_nikename($information->ic_author); if (!empty($author)) { $data['author'] = $author->OPI_FirstName; + $data['OPI_Code'] = $author->OPI_Code; } else { $author_web = $this->Infoauthors_model->detail_by_id($information->ic_author); //原始作者,可能是在线作者等 if (!empty($author_web)) { @@ -2273,6 +2326,15 @@ class Information extends CI_Controller ); $information->ic_content = str_replace('', $lantern_form_content, $information->ic_content); + // 水灯节2025表单 + $lantern_form_content_2025 = $this->load->view( + 'mobile_first/ah-lantern-form-2025', + array('information' => $information), + true + ); + $information->ic_content = str_replace('', $lantern_form_content_2025, $information->ic_content); + + // CAD 跨年表单 $new_year_countdown_form_content = $this->load->view( 'mobile_first/ah-new-year-countdown', diff --git a/application/models/feedback_model.php b/application/models/feedback_model.php index f7dcae9f..8d6ed713 100644 --- a/application/models/feedback_model.php +++ b/application/models/feedback_model.php @@ -200,4 +200,56 @@ class Feedback_model extends CI_Model { return $feedback_list; } + + /** + * 根据顾问英文名查找反馈信息 + */ + function get_feedback_by_advisor_name($advisor_name) { + $feedback_query = + $this->HT->query(" + select top 3 + tad.tad_content, + tai.tai_customerid, + tai.tai_title, + tai.tai_getdate, + tai.tai_url, + vci.cii2_name + from Eva_TAInfo tai + join Eva_TADetail tad on tad.TAD_TAI_SN = tai.TAI_SN + join V_CIty_Info vci on vci.cii_sn = tai.tai_cii_sn and vci.LGC_LGC = 1 + where tad.TAD_SN in ( + select TAD_SN + from Eva_TADetail e + join V_Operator_Info v on e.TAD_ObjList like '%,' + cast(v.OPI_SN as varchar) + ',%' + where e.TAD_ObjType = 99002 + and v.LGC_LGC = 1 + and v.OPI2_Name = ? + ) + order by tai.tai_getdate desc; + ", + array($advisor_name)); + + $feedback_result = $feedback_query->result(); + $feedback_list = []; + $customer_id_list = []; + + foreach ($feedback_result as $feedback_row) { + $createdOn = new DateTime($feedback_row->tai_getdate); + $createdOnString = $createdOn->format('M Y'); + + if (!in_array($feedback_row->tai_customerid, $customer_id_list)) { + $feedback = [ + 'title' => $feedback_row->tai_title, + 'customer' => $feedback_row->tai_customerid, + 'content' => $feedback_row->tad_content, + 'url' => $feedback_row->tai_url, + 'createdOn' => $createdOnString + ]; + $feedback_list[] = $feedback; + $customer_id_list[] = $feedback_row->tai_customerid; + } + } + + return $feedback_list; + } } diff --git a/application/third_party/trainsystem/config/config.php b/application/third_party/trainsystem/config/config.php index 06b421e2..521a4f59 100644 --- a/application/third_party/trainsystem/config/config.php +++ b/application/third_party/trainsystem/config/config.php @@ -60,6 +60,15 @@ define("JUHE_TRAIN_EXPORT_API","http://op.juhe.cn/trainTickets/exportAccountChan //http://op.juhe.cn/trainTickets/exportAccountChange?key=79f03107b921ef31310bd40a1415c1cb&since=2016-10-01 00:00&before=2016-10-30 00:00 +// //澜海接口(测试) +// define("LANHAI_appId","3649601564"); +// define("LANHAI_KEY","999c1DtJJ4pEbcxeEqJBKw=="); +// define("LANHAI_URL","http://ctriptest.lhticket.com/"); + +//澜海接口(正式) +define("LANHAI_appId","9082253783"); +define("LANHAI_KEY","YZ6yrAbv0Qn8CsZwHtZExA=="); +define("LANHAI_URL","http://ctrip.lhticket.com/"); //订单状态说明 $config["train_order_status_msg"]=array( diff --git a/application/third_party/trainsystem/controllers/addorders.php b/application/third_party/trainsystem/controllers/addorders.php index c5bc55f0..fc4b0356 100644 --- a/application/third_party/trainsystem/controllers/addorders.php +++ b/application/third_party/trainsystem/controllers/addorders.php @@ -396,6 +396,9 @@ class addorders extends CI_Controller{ case 'ctrip': $this->ctripModel($data,$selectseat,$cold_sn); break; + case 'lanhai': + $this->lanhaiModel($data,$selectseat,$cold_sn,$bpe_sn); //澜海多传用户SN列表 + break; } } @@ -687,8 +690,8 @@ class addorders extends CI_Controller{ $reback["order"] = $orderId; $reback["mes"] = "订单提交成功,等待回调"; }else{ - $reback["mes"] = $confirm_back_json; - $add_data->status = "e"; + // $reback["mes"] = $confirm_back_json; + // $add_data->status = "e"; } //本地订单入库 @@ -829,6 +832,10 @@ class addorders extends CI_Controller{ $regionCode = $PassagerInfo->BPE_Nationality; if ($regionCode =="TW" || $regionCode=="HK" || $regionCode=="MO"){ $passagersdata[$i]->regionCode = "CN"; + } + else if ($regionCode=="UK" || $regionCode=="GB"){ + $passagersdata[$i]->regionCode = "GB"; //英国传GB + }else{ $passagersdata[$i]->regionCode = $regionCode; //国家简码 美国us ,中国cn } @@ -837,6 +844,7 @@ class addorders extends CI_Controller{ $i++; } + //乘客人信息 $PostData->trainOrderInfo->orderInfo->ticketList['0']->passengerList = $passagersdata; $PostData->trainOrderInfo->orderInfo->frontSeatFlag = 0; @@ -998,6 +1006,97 @@ class addorders extends CI_Controller{ //print_r($ResponseData); //支付同步回调信息 {"Status":"SUCCESS","PartnerName":"guilintravel","OrderNumber":"guilintravel1546071576","OperationDateTime":"2018-12-29 16:19:37","RetCode":0,"ResponseStatus":{"Timestamp":"\/Date(1546071577236+0800)\/","Ack":"Success","Errors":[],"Extension":[]}} } + + //澜海请求出票 + function lanhaiModel($data,$selectseat,$cold_sn,$bpe_sn){ + $microtime = get_microtime(); + $OrderNumber = SHUNTU_ORDERUSER.$microtime; //自生成订单号 + + //生成接口请求头参数 + $mainOrderId = $OrderNumber; + $timestamp = $microtime; + $appId = LANHAI_appId; + $url = LANHAI_URL."api/open/push/order"; + + //拼接发送的报文 + $PostData = new stdClass(); + $PostData->mainOrderId = $mainOrderId; + $PostData->timestamp = $timestamp; + $PostData->appId = $appId; + + //本地添加记录 + $add_data = new stdClass(); + $add_data->cold_sn = $cold_sn; + $add_data->ordernumber = $OrderNumber; + $add_data->returncode = ''; + $add_data->status = '2'; + $add_data->errormsg = '预定中'; + $add_data->checi = $data['train']->FlightsNo; + $add_data->fromstationame = $data['train']->DepartAirport_cn; + $add_data->fromstationcode = $data['train']->DepartAirport; + $add_data->tostationame = $data['train']->ArrivalAirport_cn; + $add_data->tostationcode = $data['train']->ArrivalAirport; + $add_data->startdate = date('Y-m-d',strtotime($data['train']->DepartureDate)); + $add_data->startime = date('H:i',strtotime($data['train']->DepartureTime)); + $add_data->endtime = date('H:i',strtotime($data['train']->ArrivalTime)); + $add_data->runtime = (strtotime($data['train']->ArrivalTime) - strtotime($data['train']->DepartureTime)) / 60; + $add_data->channel = 'lanhai'; + $add_data->isauto = $this->isauto; + //出票次数 + $countAuto = $this->train_system_model->get_autotimes($cold_sn); + $add_data->ts_autotimes = $countAuto->countauto + 1; //出票次数+1 + + //澜海数据 + $lanhaiData = new stdClass(); + $lanhaiData->selectseat = $selectseat; + $lanhaiData->bpe_sn = $bpe_sn; + $add_data->lanhaiData = json_encode($lanhaiData,JSON_UNESCAPED_UNICODE); + + //存储到数据库 + $this->train_system_model->add_orders($add_data); + + //print_r(json_encode($PostData)); + //die(); + + $ResponseJson = GetPost_http($url,json_encode($PostData,JSON_UNESCAPED_UNICODE),'json'); + $ResponseData = json_decode($ResponseJson); + + // print_r($ResponseJson); + // die(); + + //预定请求成功后执行支付 + if($ResponseData->code == 0 && $ResponseData->success){ + + + $reback["status"] = 1; + $reback["order"] = $OrderNumber; + $reback["mes"] = "订单提交成功,请等待澜海出票。在出票信息返回之前,千万不要改动汉特里面的订单数据,以免照成出票数据和订单数据不一致!!!!!".$ResponseData->msg ; + + }else{ + $reback["status"] = 0; + $reback["order"] = $OrderNumber; + $reback["mes"] = "订单提交失败,".$ResponseData->msg."。订单发送数据:".json_encode($PostData) ; + + $add_data->status = "e"; + + //更新订单 + $msgData = new stdClass(); + $msgData->bookcallback = $ResponseJson; + $msgData->OrderStatus = "1"; + if (isset($ResponseData->returnMessage)){ + $msg = $ResponseData->returnMessage; + }else{ + $msg = "没有错误信息!"; + } + $msgData->ErrorMsg = $msg; + $msgData->ordernumber = $OrderNumber; + $msgData->addOrderData = json_encode($PostData,JSON_UNESCAPED_UNICODE); //失败了记录提交的订单数据 + $this->train_system_model->update_orders_msg($msgData); + + } + + echo json_encode($reback,JSON_UNESCAPED_UNICODE); + } } 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/callback.php b/application/third_party/trainsystem/controllers/callback.php index b5f75a86..64a24a3d 100644 --- a/application/third_party/trainsystem/controllers/callback.php +++ b/application/third_party/trainsystem/controllers/callback.php @@ -304,6 +304,7 @@ class callback extends CI_Controller{ } $data_passager->seatdetail = $SeatNo; $data_passager->longtrainno = $tItems->longElecNo; + $data_passager->lanhaiData = ""; //对应澜海那边的数据,这边设置为空 //入库 $this->train_system_model->add_passagers($data_passager); diff --git a/application/third_party/trainsystem/controllers/innerTrainSearch.php b/application/third_party/trainsystem/controllers/innerTrainSearch.php index 15899637..4ea55ca5 100644 --- a/application/third_party/trainsystem/controllers/innerTrainSearch.php +++ b/application/third_party/trainsystem/controllers/innerTrainSearch.php @@ -479,13 +479,13 @@ class innerTrainSearch extends CI_Controller{ $ResponseData = json_decode($ResponseJson); -// // 获取 microtime -// $microtime = microtime(true); + // // 获取 microtime + // $microtime = microtime(true); -// // 将时间戳转换为毫秒 -// $timestampInMilliseconds = round($microtime * 1000); + // // 将时间戳转换为毫秒 + // $timestampInMilliseconds = round($microtime * 1000); -// echo $timestampInMilliseconds; + // echo $timestampInMilliseconds; // echo($ResponseJson); // die(); diff --git a/application/third_party/trainsystem/controllers/lanhaiticket.php b/application/third_party/trainsystem/controllers/lanhaiticket.php new file mode 100644 index 00000000..a028b447 --- /dev/null +++ b/application/third_party/trainsystem/controllers/lanhaiticket.php @@ -0,0 +1,703 @@ +load->model("BIZ_train_model"); + $this->load->model("train_system_model"); + $this->load->helper('train'); + $this->db_train_zw = $this->config->item('db_train_zw'); + $this->train_zw = $this->config->item('train_zw'); + $this->black_list = $this->config->item('black_list'); + $this->load->library("lanhaidata"); + + $this->train_certificateType = $this->config->item('train_certificateType'); + $this->train_refundType = $this->config->item('train_refundType'); + } + + public function index() + { + //出票锁单接口: https://www.mycht.cn/info.php/apps/trainsystem/lanhaiticket/pushorderdetail?mainOrderId=HN1720670129499 + //出票回调接口:https://www.mycht.cn/info.php/apps/trainsystem/lanhaiticket/pushorderresult/ + //退票锁单接口: https://www.mycht.cn/info.php/apps/trainsystem/lanhaiticket/refundorderdetail?dataId=82033 + //退票回调接口: https://www.mycht.cn/info.php/apps/trainsystem/lanhaiticket/refundorderresult/ + //退款回调接口:https://www.mycht.cn/info.php/apps/trainsystem/lanhaiticket/refundpriceresult/ + + //http://ct.tms.lhticket.com 账号: GLhaina 密码:123456 + } + + /** + * @description: 澜海获取锁单接口,通过get方式获取参数mainOrderId(订单号) + * @return {*} + * @Date Changed: + * 网前地址:https://www.mycht.cn/info.php/apps/trainsystem/lanhaiticket/pushorderdetail?mainOrderId=HN1720670129499 + */ + public function pushOrderDetail() + { + //获取订单号 + $mainOrderId = $this->input->get_post("mainOrderId"); + $aes = $this->input->get_post("aes"); + if (strpos($mainOrderId, 'HN') !== false) { //由于我们的订单号是HN开头的,所以这里做下判断 + + //根据mainOrderId获取火车票的信息 + $ticketfrom = $this->train_system_model->ticketfrom($mainOrderId); + if (!empty($ticketfrom)) { + $cold_sn = $ticketfrom->ts_cold_sn; + $lanhaiRecord = json_decode($ticketfrom->ts_lanhaiData); //澜海特殊数据字段,保存了选择的出票人员Id + + $data['train'] = $this->BIZ_train_model->biz_order_detail($cold_sn); + $coli_id = $this->BIZ_train_model->cold_sn_get_coli_id($cold_sn)['0']->COLI_ID; + if (empty($this->BIZ_train_model->get_operatorInfo($coli_id))) { + $data['email'] = 'vivi@hainatravel.com'; + } else { + $data['email'] = $this->BIZ_train_model->get_operatorInfo($coli_id)['0']->OPI_Email; + } + + //乘客信息 + $bpe_sn = ''; + if (!empty($lanhaiRecord)) { + $bpe_sn = $lanhaiRecord->bpe_sn; + } + + if (!empty($bpe_sn)) { + $data['people_list'] = $this->BIZ_train_model->in_bpesn_people_info($bpe_sn); + } else { + //没有找到选择的人员列表,就查询整个订单的人员列表 + $people_arr = $this->BIZ_train_model->biz_people($cold_sn); + //护照号如果在黑名单的就不自动出票 + foreach ($people_arr as $people_info) { + $bpe_sn .= $people_info->BPE_SN . ','; + } + $bpe_sn = substr($bpe_sn, 0, strlen($bpe_sn) - 1); + $data['people_list'] = $this->BIZ_train_model->in_bpesn_people_info($bpe_sn); + } + + $AdultNum = 0; + $ChildNum = 0; + $i = 0; + $lanhaiData = new lanhaiData(); + $lanhaiCountryData = json_decode($lanhaiData->CountryData); //国家三字码基础信息 + $passagersdata = array(); + foreach ($data['people_list'] as $PassagerInfo) { + //乘客类型 + switch ($PassagerInfo->BPE_GuestType) { + case 1: + $PiaoType = 1; + $PiaoTypeName = "成人票"; + $AdultNum++; + break; + case 2: + $PiaoType = 2; + $PiaoTypeName = "儿童票"; + $ChildNum++; + break; + default: //外国人应该就两种票吧 + $PiaoType = 1; + $PiaoTypeName = "成人票"; + break; + } + + //证件类型 + switch ($PassagerInfo->BPE_PassportType) { + case 'Chinese ID': + $PassportTypeseId = 1; + $PassportTypeseidName = "二代身份证"; + break; + case 'MainlandTravel Permit from Hong Kong and Macau': + $PassportTypeseId = 7; + $PassportTypeseidName = "回乡证"; + break; + case 'Travel Permit from Hong Kong / Macau': + $PassportTypeseId = 7; + $PassportTypeseidName = "回乡证"; + break; + case 'Travel Permit from Taiwan': + $PassportTypeseId = 8; + $PassportTypeseidName = "台胞证"; + break; + default: + $PassportTypeseId = 2; + $PassportTypeseidName = "护照"; + break; + } + + $passagersdata[$i] = new stdClass(); + $passagersdata[$i]->passengerName = chk_sp_name($PassagerInfo->BPE_FirstName . $PassagerInfo->BPE_MiddleName . $PassagerInfo->BPE_LastName); + $passagersdata[$i]->passengerType = $PiaoType; //乘客类型,1 成人票,2 儿童票 + $passagersdata[$i]->passportType = $PassportTypeseId; //证件类型,身份证 1,护照 2,回乡证 7,台胞证 8,外国人永久居留身份证 9,港澳通行证 10,台湾通行证 22,港澳台居民居住证 23 + $passagersdata[$i]->passportNumber = $PassagerInfo->BPE_Passport; //护照号 + $passagersdata[$i]->passengerId = $PassagerInfo->BPE_SN; //乘客ID + + $regionCode = ""; + $countryName = ""; + if (!empty($PassagerInfo->BPE_Nationality)) { + $htCode = $PassagerInfo->BPE_Nationality; + if ($htCode == "TW" || $htCode == "HK" || $htCode == "MO") { + $regionCode = "CHN"; + $countryName = "中国"; + } else { + foreach ($lanhaiCountryData as $cItem) { + if ($cItem->code == $htCode) { + $regionCode = $cItem->standCode; + $countryName = $cItem->name; + break; + } + } + } + } + $passagersdata[$i]->regionCode = $regionCode; //国家简码 美国USA ,中国CHN + $passagersdata[$i]->countryName = $countryName; //国家名称 中文名称 + $passagersdata[$i]->passportExpireDate = date('Y-m-d', strtotime($PassagerInfo->BPE_PassExpdate)); //证件到期 + $passagersdata[$i]->birthday = date('Y-m-d', strtotime($PassagerInfo->BPE_BirthDate)); //出生日期 + + $i++; + } + + + //拼接发送的报文 + $PostData = new stdClass(); + $PostData->mainOrderId = $mainOrderId; + $currentTime = date("Y-m-d H:i:s"); + $PostData->expireTime = date("Y-m-d H:i:s", strtotime($currentTime . ' +30 minutes')); + $PostData->currentTime = $currentTime; + $PostData->agentCode = LANHAI_appId; + $PostData->contactMobile = "18877331805"; + $PostData->extendParams = ""; + + $PostData->ticketsItems = array(); + $PostData->ticketsItems['0'] = new stdClass(); + $PostData->ticketsItems['0']->deliveryTicketId = $cold_sn; //行程id,cold_sn + $PostData->ticketsItems['0']->fromStationName = $data['train']->DepartAirport_cn; + $PostData->ticketsItems['0']->toStationName = $data['train']->ArrivalAirport_cn; + $PostData->ticketsItems['0']->trainNumber = $data['train']->FlightsNo; //车次 + $PostData->ticketsItems['0']->departTime = date('Y-m-d H:i', strtotime($data['train']->DepartureTime)); //发车时间 + $PostData->ticketsItems['0']->arrivalTime = date('Y-m-d H:i', strtotime($data['train']->ArrivalTime)); //到达时间 + $PostData->ticketsItems['0']->ticketCount = count($data["people_list"]); + + $PostData->ticketsItems['0']->ticketPrice = $data['train']->adultcost; //车票单价,单位(元) + + $seatName = $this->train_zw[$this->db_train_zw[$data['train']->Aircraft]]; //座位名称,中文 + $PostData->ticketsItems['0']->seatName = $seatName; + $PostData->ticketsItems['0']->acceptSeats = array(); //坐席选项 + $lanhaiSeatTypes = json_decode($lanhaiData->seatTypes); //座位选项 + foreach ($lanhaiSeatTypes as $seatItem) { + if ($seatItem->seatName == $seatName) { + $PostData->ticketsItems['0']->acceptSeats = $seatItem->seatItems; + break; + } + } + $acceptSeatRemark = "优先出【同排ABCDF座】,无法满足可出任意座位,不接受站票"; + if (($AdultNum + $ChildNum) > 1) { + //多人时 + if (strstr($seatName, "卧")) { + $acceptSeatRemark = "客人想要2张下铺,最好在同一房间。下铺不足时,至少保证在同一房间,否则不要出票"; + } + } else { + //单人时 + } + + $PostData->ticketsItems['0']->acceptSeatRemark = $acceptSeatRemark; //行程坐席要求 + $PostData->ticketsItems['0']->ticketType = 1; + $PostData->ticketsItems['0']->passengerInfos = $passagersdata; + + $total_price = $AdultNum * $data['train']->adultcost + $ChildNum * $data['train']->childcost; //总价 + $PostData->orderPrice = $total_price; //订单总价,单位(元) + + //加密方式显示 + $this->load->library("aesLanhai"); + $aesUnit = new Security(); + $resultData = $aesUnit->encryptData(json_encode($PostData)); + + //$resultData = $aesUnit->decryptData($resultData); //测试加解密是否正常。 + + if ($aes == "false") { + //加个明文显示判断,用来检查数据 + $resultData = json_encode($PostData, JSON_UNESCAPED_UNICODE); + } + + + echo $resultData; + } else { + $ResultNoticeResponse = new stdClass(); + $ResultNoticeResponse->returnCode = -1; + $ResultNoticeResponse->success = false; + $ResultNoticeResponse->returnMsg = "mainOrderId错误!"; + echo json_encode($ResultNoticeResponse); + } + } + } + + + /** + * 出票结果回调信息 + * 网前URL:https://www.mycht.cn/info.php/apps/trainsystem/lanhaiticket/pushorderresult/ + */ + public function pushOrderResult() + { + $back_json = file_get_contents('php://input'); + log_message('error', '澜海出票回调信息:' . $back_json); + + $lanhai_backdata = json_decode($back_json); + + + if (!empty($lanhai_backdata)) { + //判断回调信息是否正确,主要判断是否是本企业的回调信息 + $companyId = LANHAI_appId; + $messageIdentity = $lanhai_backdata->authentication->appId; //传递的企业ID + $ResultNoticeResponse = new stdClass(); + if ($companyId == $messageIdentity) { + $ResultNoticeResponse->retCode = 0; + $ResultNoticeResponse->success = true; + $ResultNoticeResponse->message = "处理成功!"; + } else { + $ResultNoticeResponse->returnCode = -1; + $ResultNoticeResponse->success = false; + $ResultNoticeResponse->returnMsg = "appId错误!"; + } + echo json_encode($ResultNoticeResponse); + + //处理回调的内容,保存到本地及翰特 + $update_data = new stdClass(); + $update_data->ServiceName = "lanhai.ticketresult"; + $update_data->ordernumber = ''; + $update_data->seatsinfo = ''; + $update_data->TicketCheck = ''; + $update_data->bookcallback = ''; + $update_data->confirmcallback = ''; + $update_data->returncallback = ''; + $update_data->OrderTotleFee = 0; + $update_data->ElectronicOrderNumber = ''; + $update_data->reschedulecallback = ''; + $update_data->OrderTicketTime = ''; + $update_data->operateTradeNo = ""; + + if (!empty($lanhai_backdata->bodyInfo)) { + + // //需要解密 + $this->load->library("aesLanhai"); + $aesUnit = new Security(); + $bodyINfo = json_decode($aesUnit->decryptData($lanhai_backdata->bodyInfo)); + + if ($bodyINfo->failCode == 0) { + $update_data->OrderStatus = '4'; + if (isset($bodyINfo->resultMsg)) { + $update_data->ErrorMsg = $bodyINfo->resultMsg; + } else { + $update_data->ErrorMsg = '出票成功'; + } + } else { + $update_data->OrderStatus = '5'; + if (isset($bodyINfo->resultMsg)) { + $update_data->ErrorMsg = $bodyINfo->resultMsg; + } else { + $update_data->ErrorMsg = '出票失败'; + } + } + $update_data->ordernumber = $lanhai_backdata->authentication->mainOrderId; + if (isset($bodyINfo->orderPrice)) { + $update_data->OrderTotleFee = $bodyINfo->orderPrice; //总价 + } + if (isset($bodyINfo->payTradeNumber)) { + $update_data->operateTradeNo = $bodyINfo->payTradeNumber; ////支付宝流水 + } + + $update_data->ticketresultcallback = json_encode($bodyINfo); + //$update_data->OrderTicketTime = $lanhai_backdata->TrainOrderService->OrderInfo->TicketInfo->OrderTicketTime; + + //新接口数据,不一定保存到数据库里面,原订单已有,做个记录 + if (isset($bodyINfo->ticketSuccessTime)) { + $update_data->ticketSuccTime = $bodyINfo->ticketSuccessTime; //出票成功时间 + } + // $update_data->orderType = $lanhai_backdata->ticketResult->orderMasterInfo->orderType; //订单类型 0电子票 1配送票 2人工客票 3抢票订单 + // $update_data->contactName = $lanhai_backdata->ticketResult->orderMasterInfo->contactName; //联系人 + // $update_data->mobileNo = des_decrypt($lanhai_backdata->ticketResult->orderMasterInfo->mobileNo,$key); //联系电话 (DES加密) + + //人员及车票 + if (isset($bodyINfo->eOrderNumber)) { + $elecNo = $bodyINfo->eOrderNumber; //电子订单号,即12306取票号 + $update_data->ElectronicOrderNumber = $elecNo; + } + + if (isset($bodyINfo->ticketList)) { //如果订票成功,需要保存的数据 + $data_passager = new stdClass(); + foreach ($bodyINfo->ticketList as $tItems) { + + if (isset($tItems->ticketCheck)) { + $checkWindow = $tItems->ticketCheck; //检票口 + $update_data->TicketCheck = $checkWindow; + } + + $update_data->trainNo = $tItems->trainNumber; //车次 + $update_data->departTime = $tItems->departTime; //车次出发时间 + + foreach ($tItems->passengerList as $pItems) { + $data_passager->ordernumber = $update_data->ordernumber; + //人员列表 + $data_passager->status = '4'; + $certificateType = $this->train_certificateType[$pItems->passportType]; //证件类型,身份证 1,护照 2,回乡证 7,台胞证 8,外国人永久居留身份证 9,港澳通行证 10,台湾通行证 22,港澳台居民居住证 23 + $data_passager->identitytype = $certificateType; + $data_passager->realname = $pItems->passengerName; + $data_passager->numberid = $pItems->passportNumber; //证件号码 + //$data_passager->birthday = $pItems->birthday; + if ($pItems->passengerType == 2) { + $passengerType = "儿童"; + } else { + $passengerType = "成人"; + } + $data_passager->ticketype = $passengerType; //乘客类型 1成人 2儿童 + $data_passager->seatype = $pItems->seatName; //坐席类型 + $data_passager->ticketprice = $pItems->realTicketPrice; //实际单价(元) + $SeatNo = ""; + if (isset($pItems->carriageNo)) { + $SeatNo .= $pItems->carriageNo . "车厢"; + } + if (isset($pItems->seatNo)) { + $SeatNo .= $pItems->seatNo; ////坐席号 + } + $data_passager->seatdetail = $SeatNo; + + $passengerId = $pItems->passengerId; // //乘客id + $data_passager->longtrainno = $passengerId; + + $jsonLanhaiData = new stdClass(); //澜海退票需要传递一些数据,尽量保存到这个里面。这样不用从翰特里面读取了。 + $jsonLanhaiData->eOrderNumber = $update_data->ElectronicOrderNumber; //取票号 + $data_passager->lanhaiData = json_encode($jsonLanhaiData); + + //入库 + $this->train_system_model->add_passagers($data_passager); + } + + /****************************************************************************************/ + //添加支付记录 + $add_train_payment_data = new stdClass(); + $add_train_payment_data->TOC_Memo = $update_data->ordernumber . '出票费'; + $add_train_payment_data->TOC_VEI_SN = "33653"; + + //根据订单号获取cold_sn + $order_info = $this->train_system_model->get_order_info($update_data->ordernumber); + $cold_sn = $order_info->ts_cold_sn; + $add_train_payment_data->TOC_COLD_SN = $cold_sn; + $add_train_payment_data->TOC_TrainNumber = $update_data->trainNo; + $add_train_payment_data->TOC_DepartureDate = date('Y-m-d', strtotime($update_data->departTime)); + $add_train_payment_data->TOC_TicketCost = $update_data->OrderTotleFee; + $passengerNum = $tItems->ticketCount; //车票数 + if ($passengerNum>0){ + $poundage = $passengerNum*10; + }else{ + $poundage = 0; + } + $add_train_payment_data->poundage = $poundage; //手续费 + $add_train_payment_data->FOI_TrainNetOrderNo = $update_data->ElectronicOrderNumber; //电子票号 + //print_r($add_train_order_data);die(); + $this->BIZ_train_model->add_train_payment($add_train_payment_data); + //记录供应商(瀚特) + $this->BIZ_train_model->update_cold_planvei_sn($cold_sn, '33653'); + } + } + } + + //更新订单信息(出票系统) + $this->train_system_model->update_orders($update_data); + } + } + + + /** + * 澜海退票锁单接口,通过get方式获取前参数dataId + * 网前地址:https://www.mycht.cn/info.php/apps/trainsystem/lanhaiticket/refundorderdetail?dataId=82033 + */ + public function refundOrderDetail() + { + //获取客人ID + $dataId = $this->input->get_post("dataId"); + $aes = $this->input->get_post("aes"); + + //根据客人ID获取退票数据 + $passenger_data = $this->train_system_model->get_passenger_byId($dataId); + if (!empty($passenger_data)) { + //拼接发送的报文 + $PostData = new stdClass(); + $PostData->id = $passenger_data->tst_id; //dataId + $PostData->mainOrderId = $passenger_data->tst_ordernumber; //出票订单id,如产生过线上改签成功,则使用改签的dataId + $PostData->priority = 1; //0紧急退票,1非紧急退票 默认1 + + //获取出票是保存的lanhaiData + if (!empty($passenger_data->tst_lanhaiData)){ + $lanhaiData = json_decode($passenger_data->tst_lanhaiData); + } + + $eOrderNumber = ""; + if (isset($lanhaiData->eOrderNumber)){ + $eOrderNumber = $lanhaiData->eOrderNumber; //取票号 + } + + $PostData->eOrderNumber = $eOrderNumber; //取票号 + $PostData->passengerType = $passenger_data->tst_ticketype."票"; //票种 + $PostData->passportType = $passenger_data->tst_identitytype; //"身份证"; //证件类型 + $PostData->passportName = $passenger_data->tst_realname; //姓名 + $PostData->passportNumber = $passenger_data->tst_numberid; //证件号 + $PostData->departStation = $passenger_data->ts_fromstationame; //发站 + $PostData->arriveStation = $passenger_data->ts_tostationame; //到站 + + $rPrice = $passenger_data->tst_ticketprice; + $PostData->ticketPrice = $rPrice; //票价(元) + $PostData->preRefundPrice = $rPrice; //原票价(元) + $PostData->percent = 100; //比例 默认100,我只取返回记录的价格。不管汉特的价格 + + $PostData->trainNo = $passenger_data->ts_checi ; //车次 + + //车厢及座位分解 + $tst_seatdetail = $passenger_data->tst_seatdetail; + $carriageNo = ""; + $seatNo = ""; + if (strpos($tst_seatdetail,"车厢")!=false){ + $arrSeat = explode("车厢",$tst_seatdetail); + $carriageNo = $arrSeat[0]; + $seatNo = $arrSeat[1]; + } + $PostData->carriageNo = $carriageNo; //车厢 + $PostData->seatName = $passenger_data->tst_seatstype; //席别 + $PostData->seatNo = $seatNo; //席位号 + + $strDt = $passenger_data->ts_startdate." ".$passenger_data->ts_startime; + $DepartureTime = date('Y-m-d H:i', strtotime($strDt)); + + // 出发时间前三十分钟的时间 + $thirtyMinutesAgo = strtotime('-30 minutes', strtotime($DepartureTime)); + $dealine = date('Y-m-d H:i', $thirtyMinutesAgo); + + $PostData->ticketTime = $DepartureTime; //发车时间 + $PostData->createTime = ""; //可空 + $PostData->deadline = $dealine; //处理截止时间 建议最晚处理时间设置为发车前30分钟 + $PostData->refundTime = ""; //可空 + $PostData->getTicketTime = ""; //可空 + $PostData->refundPrice = 0; //可空 + $PostData->firstImage = null; //可空 + $PostData->secondImage = null; //可空 + $PostData->lockStatus = 0; //可空 + $PostData->lockUser = ""; //可空 + $PostData->status = 0; //可空 + $PostData->longEOrderNumber = ""; //可空 + $PostData->extendParams = ""; //拓展json对象 + + //加密方式显示 + $this->load->library("aesLanhai"); + $aesUnit = new Security(); + $resultData = $aesUnit->encryptData(json_encode($PostData)); + //$resultData = $aesUnit->decryptData($resultData); //测试加解密是否正常。 + if ($aes == "false") { + //加个明文显示判断,用来检查数据 + $resultData = json_encode($PostData, JSON_UNESCAPED_UNICODE); + } + + echo $resultData; + + } else { + $ResultNoticeResponse = new stdClass(); + $ResultNoticeResponse->returnCode = -1; + $ResultNoticeResponse->success = false; + $ResultNoticeResponse->returnMsg = "dataId错误!"; + echo json_encode($ResultNoticeResponse); + } + } + + + /** + * 澜海退票返回信息 + * 网前URL:https://www.mycht.cn/info.php/apps/trainsystem/lanhaiticket/refundorderresult/ + */ + public function refundOrderResult() + { + $back_json = file_get_contents('php://input'); + log_message('error', '澜海退票回调信息:' . $back_json); + + $lanhai_backdata = json_decode($back_json); + if (!empty($lanhai_backdata)) { + $dataId = $lanhai_backdata->id; + //根据客人ID获取退票数据 + $passenger_data = $this->train_system_model->get_passenger_byId($dataId); + $ResultNoticeResponse = new stdClass(); + if (!empty($passenger_data)) { + $ResultNoticeResponse->retCode = 0; + $ResultNoticeResponse->success = true; + $ResultNoticeResponse->message = "处理成功!"; + echo json_encode($ResultNoticeResponse); + + + //处理回调的内容,保存到本地及翰特 + $update_data = new stdClass(); + $update_data->ServiceName = ''; + $update_data->ordernumber = ''; + $update_data->seatsinfo = ''; + $update_data->TicketCheck = ''; + $update_data->bookcallback = ''; + $update_data->confirmcallback = ''; + $update_data->returncallback = ''; + $update_data->OrderTotleFee = 0; + $update_data->ElectronicOrderNumber = ''; + $update_data->reschedulecallback = ''; + $update_data->OrderTicketTime = ''; + //新字段 + $update_data->operateTradeNo =""; + + $update_data->ordernumber = $passenger_data->tst_ordernumber; + $passpager_info = new stdClass(); + $passpager_info->returncallback = $back_json; + $passpager_info->ordernumber = $passenger_data->tst_ordernumber; + $passpager_info->tst_id = $dataId; //乘客ID,用来更新 + //回调的数据正确,开始判断成功还是失败。 + if (isset($lanhai_backdata->refundPrice)){ //如果有退款金额,说明退票成功 + //退票成功 + $update_data->OrderStatus = '7'; + //退票时还需要单独对对每个乘客存储回调信息 + $passpager_info->status = '7'; + $refundPrice = $lanhai_backdata->refundPrice; //退款金额 + $update_data->ErrorMsg = "退票成功,"."退票金额:".$refundPrice; + + //退票手续费保存到数据库 + //翰特添加退款记录 + $returnticket = new stdClass(); + $return_order = $update_data->ordernumber; + $returnticket->TOC_VEI_SN = "33653"; + + //根据订单号获取cold_sn + $cold_sn = $passenger_data->ts_cold_sn; + $returnSuccTime = date("Y-m-d H:i:s"); + + $memo = $return_order.'_退票成功_' . $dataId; //退票集合信息 ,用$dataId是为了标识唯一性 + $returnticket->TOC_Memo = $memo; + $returnticket->TOC_COLD_SN = $cold_sn; + $returnticket->TOC_TrainNumber = $passenger_data->ts_checi; + $returnticket->TOC_DepartureDate = $passenger_data->ts_startdate; + $returnticket->TOC_TicketCost = -15; + //print_r($add_train_payment_data);die(); + $this->BIZ_train_model->returnticket_train($returnticket); + + }else{ + //退票失败 + $update_data->OrderStatus = '8'; + //失败也保存下信息 + $passpager_info->status = '8'; + $update_data->ErrorMsg = "退票失败:".$lanhai_backdata->failReason; + } + + $this->train_system_model->return_update_passager_lanhai($passpager_info); + $update_data->returncallback = $back_json; + + //更新订单信息(出票系统) + $this->train_system_model->update_orders($update_data); + + } else { + $ResultNoticeResponse->returnCode = -1; + $ResultNoticeResponse->success = false; + $ResultNoticeResponse->returnMsg = "退票订单数据没找到!"; + echo json_encode($ResultNoticeResponse); + } + } + } + + /** + * 澜海退款回调信息 + * 网前URL:https://www.mycht.cn/info.php/apps/trainsystem/lanhaiticket/refundpriceresult/ + */ + public function refundPriceResult(){ + $back_json = file_get_contents('php://input'); + log_message('error', '澜海退款回调信息:' . $back_json); + + $lanhai_backdata = json_decode($back_json); + if (!empty($lanhai_backdata)) + { + $id = $lanhai_backdata->id; //线上低改高后的订单为dataId,其他情况为出票的mainOrderId + //先判断是否是低改高的订单,目前我们没有改签。 + if (1==2){ + //这里是改签的操作,目前没有 + }else{ + //这里的ID是mainOrderId ,出票订单ID + $order_info = $this->train_system_model->get_order_info($id); + if (!empty($order_info)){ + $ResultNoticeResponse = new stdClass(); + $ResultNoticeResponse->retCode = 0; + $ResultNoticeResponse->success = true; + $ResultNoticeResponse->message = "处理成功!"; + echo json_encode($ResultNoticeResponse); //找到订单 对应数据就返回处理成功的结果,后面的错误不关澜海那边的事。 + + + //处理回调的内容,保存到本地及翰特 + $update_data = new stdClass(); + $update_data->ServiceName = ''; + $update_data->ordernumber = ''; + $update_data->seatsinfo = ''; + $update_data->TicketCheck = ''; + $update_data->bookcallback = ''; + $update_data->confirmcallback = ''; + $update_data->returncallback = ''; + $update_data->OrderTotleFee = 0; + $update_data->ElectronicOrderNumber = ''; + $update_data->reschedulecallback = ''; + $update_data->OrderTicketTime = ''; + //新字段 + $update_data->operateTradeNo =""; + + + $isOnline = $lanhai_backdata->isOnline; //1:线上退款,0:线下退款 + if ($isOnline==1){ + $refundType = "线上退款"; + }else{ + $refundType = "线下退款"; + } + $refundTime = date("Y-m-d H:i:s"); //退款时间 + $return_money = $lanhai_backdata->refundPrice; //退款金额,单位元 + $refundId = $lanhai_backdata->refundId; //退款唯一id(幂等性) + + $update_data->ordernumber = $order_info->ts_ordernumber; + $update_data->OrderStatus = '11'; //11是订单退款 + + $update_data->ErrorMsg = '退款:'.$refundType." 金额:".$return_money." time:". $refundTime; + $update_data->refundcallback = $back_json; + + //翰特添加退款记录 + $refund_train_payment = new stdClass(); + $return_order = $order_info->ts_ordernumber; + $refund_train_payment->TOC_VEI_SN = "33653"; + + $cold_sn = $order_info->ts_cold_sn; + //print_r($order_info); + + $memo = $return_order.'_'.$refundType. '_' . $refundId; //退款集合信息 + $refund_train_payment->TOC_Memo = $memo; + $refund_train_payment->TOC_COLD_SN = $cold_sn; + $refund_train_payment->TOC_TrainNumber = $order_info->ts_checi; + $refund_train_payment->TOC_DepartureDate = $order_info->ts_startdate; + $refund_train_payment->TOC_TicketCost = -$return_money; + //print_r($add_train_payment_data);die(); + $this->BIZ_train_model->refund_train_payment($refund_train_payment); + + //更新订单信息(出票系统) + $this->train_system_model->update_orders($update_data); + + }else{ + $ResultNoticeResponse = new stdClass(); + $ResultNoticeResponse->returnCode = -1; + $ResultNoticeResponse->success = false; + $ResultNoticeResponse->returnMsg = "订单对应数据没找到!"; + echo json_encode($ResultNoticeResponse); + } + } + + + + + + } + } +} + + /* End of file lanhaiticket.php */ diff --git a/application/third_party/trainsystem/controllers/pages.php b/application/third_party/trainsystem/controllers/pages.php index ee9c1da1..7fd3259b 100644 --- a/application/third_party/trainsystem/controllers/pages.php +++ b/application/third_party/trainsystem/controllers/pages.php @@ -80,6 +80,7 @@ class pages extends CI_Controller{ $page = $this->input->get("page"); $order = $this->input->get("order"); $web_code = $this->input->get("web_code"); + $channel = $this->input->get("channel"); $where = "1=1";//搜索条件 $page_parameter = "";//返回的分页条件参数 if(empty($page) or !is_numeric($page)){ @@ -95,6 +96,11 @@ class pages extends CI_Controller{ $where = "BIZ_ConfirmLineInfo.COLI_WebCode='{$web_code}'"; $page_parameter = "web_code=".$web_code; } + + if (!empty($channel)){ + $where = " InfoManager.dbo.trainsystem.ts_channel='{$channel}' "; + $page_parameter = " channel=".$channel; + } //获取订单数据 $data = $this->train_system_model->get_order($page_size,$page,$where); @@ -239,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; @@ -331,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/controllers/returnorders.php b/application/third_party/trainsystem/controllers/returnorders.php index 2cd8732d..e8832379 100644 --- a/application/third_party/trainsystem/controllers/returnorders.php +++ b/application/third_party/trainsystem/controllers/returnorders.php @@ -59,6 +59,9 @@ class returnorders extends CI_Controller{ case 'ctrip': $this->ctripModel($ticket_data,$passenger_data); break; + case 'lanhai': + $this->lanhaiModel($ticket_data,$passenger_data); + break; } } @@ -185,6 +188,51 @@ class returnorders extends CI_Controller{ echo '{"reason":"退票失败","status":"404"}'; } } + + /** + * 澜海退票,这里只是提交退票提交。没有具体退票信息 + */ + function lanhaiModel($ticket_data,$passenger_data){ + $microtime = get_microtime(); + + //生成接口请求头参数 + $dataId = $passenger_data->tst_id; + $mainOrderId = $passenger_data->tst_ordernumber; + $timestamp = $microtime; + $appId = LANHAI_appId; + $url = LANHAI_URL."api/open/refund/order"; + + //拼接发送的报文 + $PostData = new stdClass(); + $PostData->dataId = $dataId; + $PostData->mainOrderId = $mainOrderId; + $PostData->timestamp = $timestamp; + $PostData->appId = $appId; + + // print_r(json_encode($PostData)); + // die(); + + + $ResponseJson = GetPost_http($url,json_encode($PostData),'json'); + log_message('error','澜海退票请求返回信息:'.$ResponseJson); + $ResponseData = json_decode($ResponseJson); + + // print_r($ResponseData); + // die(); + + //退票请求成功后执行支付 + if($ResponseData->code == 0 && $ResponseData->success){ + echo '{"reason":"退票提交成功","status":"200"}'; + }else{ + if (isset($ResponseData->msg)){ + $errMsg = $ResponseData->msg; + }else{ + $errMsg = ""; + } + header("HTTP/1.1 404 Not Found"); + echo '{"reason":"退票提交失败"'.$errMsg.',"status":"404"}'; + } + } //改签退票 public function returnreschedule(){ diff --git a/application/third_party/trainsystem/helpers/train_helper.php b/application/third_party/trainsystem/helpers/train_helper.php index 499740ff..c2396ed5 100644 --- a/application/third_party/trainsystem/helpers/train_helper.php +++ b/application/third_party/trainsystem/helpers/train_helper.php @@ -421,8 +421,4 @@ function pkcs5_unpad($text) { - - - - ?> \ No newline at end of file diff --git a/application/third_party/trainsystem/libraries/aesLanhai.php b/application/third_party/trainsystem/libraries/aesLanhai.php new file mode 100644 index 00000000..b1606999 --- /dev/null +++ b/application/third_party/trainsystem/libraries/aesLanhai.php @@ -0,0 +1,51 @@ +load->config(); + $this->key = LANHAI_KEY; + //$this->key = "999c1DtJJ4pEbcxeEqJBKw=="; + } + + + public function encryptData($input) { + $size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB); + $input = Security::pkcs5_pad($input, $size); + $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_ECB, ''); + $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND); + mcrypt_generic_init($td, $this->key, $iv); + $data = mcrypt_generic($td, $input); + mcrypt_generic_deinit($td); + mcrypt_module_close($td); + $data = base64_encode($data); + return $data; + + } + + private static function pkcs5_pad ($text, $blocksize) { + $pad = $blocksize - (strlen($text) % $blocksize); + return $text . str_repeat(chr($pad), $pad); + } + + public function decryptData($sStr) { + $decrypted= mcrypt_decrypt( + MCRYPT_RIJNDAEL_128, + $this->key, + base64_decode($sStr), + MCRYPT_MODE_ECB + ); + $dec_s = strlen($decrypted); + $padding = ord($decrypted[$dec_s-1]); + $decrypted = substr($decrypted, 0, -$padding); + return $decrypted; + } + +} diff --git a/application/third_party/trainsystem/models/train_system_model.php b/application/third_party/trainsystem/models/train_system_model.php index cb38cdb2..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; @@ -99,7 +101,8 @@ class train_system_model extends CI_Model { ts_channel, ts_isauto, ts_autotimes, - ts_autolasttime + ts_autolasttime, + ts_lanhaiData ) VALUES( '{$data->cold_sn}', @@ -120,7 +123,8 @@ class train_system_model extends CI_Model { '{$data->channel}', '{$data->isauto}', '{$data->ts_autotimes}', - getdate() + getdate(), + '{$data->lanhaiData}' ) "; //echo $sql; @@ -128,7 +132,7 @@ class train_system_model extends CI_Model { } public function ticketfrom($ts_ordernumber){ - $sql = "select ts_channel,ts_cold_sn,ts_ordernumber from trainsystem where ts_ordernumber = ?"; + $sql = "select ts_channel,ts_cold_sn,ts_ordernumber,ts_lanhaiData from trainsystem where ts_ordernumber = ?"; $query = $this->INFO->query($sql,array($ts_ordernumber)); return $query->row(); } @@ -152,7 +156,8 @@ class train_system_model extends CI_Model { tst_seatstype = '{$data->seatype}', tst_seatdetail = '{$data->seatdetail}', tst_status = '{$data->status}', - tst_LongTrainNo = '{$data->longtrainno}' + tst_LongTrainNo = '{$data->longtrainno}', + tst_lanhaiData = '{$data->lanhaiData}' where tst_ordernumber = '{$data->ordernumber}' and @@ -170,7 +175,8 @@ class train_system_model extends CI_Model { tst_ticketprice, tst_seatstype, tst_seatdetail, - tst_LongTrainNo + tst_LongTrainNo, + tst_lanhaiData )VALUES( '{$data->ordernumber}', '{$data->status}', @@ -181,7 +187,8 @@ class train_system_model extends CI_Model { '{$data->ticketprice}', '{$data->seatype}', '{$data->seatdetail}', - '{$data->longtrainno}' + '{$data->longtrainno}', + '{$data->lanhaiData}' ) "; $query =$this->INFO->query($sql); @@ -294,6 +301,23 @@ class train_system_model extends CI_Model { $query = $this->INFO->query($sql); } + /** + * 更新退票后的乘客信息,澜海退票返回乘客的ID,其它信息没有。 + */ + public function return_update_passager_lanhai($data){ + + $sql = "update + trainsystem_tickets + set + tst_status = '{$data->status}', + tst_returncallback = '{$data->returncallback}', + tst_lasteditdate = getdate() + where + tst_id = '{$data->tst_id}' + "; + $query = $this->INFO->query($sql); + } + //获取订单出票状态 public function get_tickets_info($cold_sn){ $sql = "select top 1 ts_status,ts_ordernumber,ts_elecnumber,ts_seatsinfo from trainsystem where ts_cold_sn = ? and ts_status in ('4','7') order by ts_subtime desc"; @@ -346,4 +370,36 @@ class train_system_model extends CI_Model { $query = $this->INFO->query($sql, $cold_sn); return $query->row(); } + + /** + * 根据客人ID获取客人信息及出票信息 + */ + public function get_passenger_byId($tst_id){ + $sql = "select top 1 * from trainsystem_tickets inner join trainsystem on tst_ordernumber=ts_ordernumber and tst_id = ?"; + $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 @@
- " autocomplete="off">至 - " autocomplete="off"> + " autocomplete="off" placeholder="开始日期">  至   + " autocomplete="off" placeholder="结束日期"> 审核状态: name="examine" />   
diff --git a/application/third_party/trainsystem/views/export_lanhai.php b/application/third_party/trainsystem/views/export_lanhai.php new file mode 100644 index 00000000..484880b5 --- /dev/null +++ b/application/third_party/trainsystem/views/export_lanhai.php @@ -0,0 +1,76 @@ +
+
+
+

交易记录导出 订单列表>>

+
+
+
+ " autocomplete="off" placeholder="开始日期">  至   + " autocomplete="off" placeholder="结束日期"> + 显示列表: name="examine" />    + +
+

+ +

" style="width:90%;margin:0 auto;"> +
+ + + + + + + $value) {?> + + + + + + +
时间信息变化值团名外联
+
+
+
+
+ +
+ + \ No newline at end of file diff --git a/application/third_party/trainsystem/views/homepage.php b/application/third_party/trainsystem/views/homepage.php index 5088ceaf..718ab26a 100644 --- a/application/third_party/trainsystem/views/homepage.php +++ b/application/third_party/trainsystem/views/homepage.php @@ -77,8 +77,8 @@ function selseat(seat){
-

翰特订单号 订单列表>>预售时间维护>> 版本:V2.0聚合余额(RMB):

- +

翰特订单号 订单列表>>预售时间维护>> 澜海导出账单>>版本:V2.0

+
@@ -299,7 +299,7 @@ function selseat(seat){ - + @@ -411,7 +411,7 @@ function selseat(seat){ var cold_sn = $(this).attr('data-order'); var istanding = $('input[name="istanding_'+cold_sn+'"]').is(':checked'); - url2+=$(this).attr("data-order")+"&people="+people_sn+"&selectseat="+selectseat+"&type=juhe&istanding="+istanding; + url2+=$(this).attr("data-order")+"&people="+people_sn+"&selectseat="+selectseat+"&type=lanhai&istanding="+istanding; var THIS=$(this); THIS.parent().parent().find(".back_mes").html(" ");//清空提示 @@ -423,7 +423,7 @@ function selseat(seat){ }, success:function(data){ THIS.removeAttr("disabled"); - THIS.html("聚合订票"); + THIS.html("澜海订票"); var str = ""+data.mes+""; THIS.parent().parent().find(".back_mes").html(str); diff --git a/application/third_party/trainsystem/views/lanhai_transaction_excel.php b/application/third_party/trainsystem/views/lanhai_transaction_excel.php new file mode 100644 index 00000000..77b93253 --- /dev/null +++ b/application/third_party/trainsystem/views/lanhai_transaction_excel.php @@ -0,0 +1,181 @@ + + + + + c21 + c21 + 2024-08-07T01:21:46Z + 2024-08-07T01:38:10Z + 1.00 + + + 9630 + 21555 + 0 + 90 + False + False + + + + + + + + + + + + + + + + + + + + + 三亚澜海商旅服务有限公司 地址:海南省三亚市崖州区崖州湾科技城雅布伦产业园5号楼3楼310室 开户银行:三亚惠民村镇银行 银行账号:2019 0379 3100 12 + + + + 桂林海纳国际旅行社有限公司火车票对账文件 + + + 账单日期 + 账单类型 + 结算金额 + 订单号 + 外联 + 团号 + 乘客 + + =0;$i--){?> + + + + + + + + + + + + + +
+ + +
+
+ + + + + + + 3 + 4 + 4 + + + False + False + + + + + +
+ + +
+
+ + + + False + False + + + + + +
+ + +
+
+ + + + False + False + + + diff --git a/application/third_party/trainsystem/views/order.php b/application/third_party/trainsystem/views/order.php index 417fbff9..39ec6757 100644 --- a/application/third_party/trainsystem/views/order.php +++ b/application/third_party/trainsystem/views/order.php @@ -24,7 +24,7 @@

查看详情

- +

查看详情

@@ -38,6 +38,13 @@

+ + +

出票详细信息 +      + 退票详细信息 +

+
diff --git a/application/third_party/trainsystem/views/order_list.php b/application/third_party/trainsystem/views/order_list.php index fbd86850..9050b2dd 100644 --- a/application/third_party/trainsystem/views/order_list.php +++ b/application/third_party/trainsystem/views/order_list.php @@ -20,6 +20,13 @@
+
+ +
+
  • Destinations
  • @@ -129,7 +128,7 @@
  • Plan Your China Trip
  • China Visa
  • China Weather
  • -
  • Great Wall Of China
  • +
  • Great Wall of China
  • Giant Panda
  • @@ -137,29 +136,23 @@
  • Culture
  • -
  • Create My Trip - -
  • -
  • Trains +
  • Create My Trip
  • +
  • Trains
  • diff --git a/application/views/mobile_first/chinatravel.php b/application/views/mobile_first/chinatravel.php index 78ce3599..cc1d3e0a 100644 --- a/application/views/mobile_first/chinatravel.php +++ b/application/views/mobile_first/chinatravel.php @@ -66,38 +66,38 @@ - - + + - - - -