";
+
+ $this->pagination->initialize($config);
+
+ $list["page_link"]=$this->pagination->create_links();
+
+ foreach ($list["data"] as $key => $value) {
+ $value->info=$this->order_status_msg[$value->JOL_Status];//自定义说明信息;
+ }
+
+
+
+ $this->load->view('bootstrap3/header');
+ $this->load->view('ht_order_list.html',$list);
+ $this->load->view('bootstrap3/footer');
+ }
+ //输入翰特订单号cols_id,获取火车订票的相关信息,模拟翰特订单详情页面
+ public function ht_train_order(){
+ $cols_id=$this->input->post("ht_order");
+ $list=new StdClass;
+ if(!empty($cols_id)){
+ $cold_sn=$this->BIZ_train_model->get_biz_cold($cols_id);
+ $list->wl=$this->BIZ_train_model->get_operatorinfo($cols_id);
+ $i=0;
+ $list->info=array();
+ foreach ($cold_sn as $v) {
+ $list->info[$i]=new StdClass;
+ $list->info[$i]->people=$this->BIZ_train_model->biz_people($v->COLD_SN);
+ $list->info[$i]->train=$this->BIZ_train_model->get_biz_foi($v->COLD_SN);
+ $list->info[$i]->status=$this->BIZ_train_model->get_biz_jol($v->COLD_SN);
+ $i++;
+ }
+ $list->cols_id=$cols_id;
+ }
+ $this->load->view('bootstrap3/header');
+ $this->load->view('ht_train_order.html',$list);
+ $this->load->view('bootstrap3/footer');
+ }
+ //输入翰特订单号cols_id,获取火车订票的相关信息,模拟翰特订单详情页面
+ public function ht_train_order_info(){
+ $cols_id=$this->input->post("ht_order");
+ $list=new StdClass;
+ if(!empty($cols_id)){
+ $cold_sn=$this->BIZ_train_model->get_biz_cold($cols_id);
+ $list->wl=$this->BIZ_train_model->get_operatorinfo($cols_id);
+ $i=0;
+ $list->info=array();
+ foreach ($cold_sn as $v) {
+ $list->info[$i]=new StdClass;
+ $list->info[$i]->people=$this->BIZ_train_model->biz_people($v->COLD_SN);
+ $list->info[$i]->train=$this->BIZ_train_model->get_biz_foi($v->COLD_SN);
+ $list->info[$i]->status=$this->BIZ_train_model->get_biz_jol($v->COLD_SN);
+ $i++;
+ }
+ $list->cols_id=$cols_id;
+ }
+ $post_data=array(
+ "key"=>$this->key
+ );
+ $back_data=$this->post_data($this->balance_api,$post_data);
+ $back_data = json_decode($back_data);
+ if(!empty($back_data->result)){
+ $list->balance = $back_data->result;
+ }else{
+ $list->balance = "NULL";
+ }
+ $this->load->view('bootstrap3/header');
+ $this->load->view('ht_train_order_info',$list);
+ $this->load->view('bootstrap3/footer');
+ }
+ //订单信息填写
+ public function booking_write(){
+ $this->load->model("order_people_model","op");
+ $order=$this->input->post("order");
+ $data["order"]="";
+ if(!empty($order) && is_numeric($order)){
+ $data["order"]=$this->op->biz_people($order);
+ $data["order_id"]=$order;
+ }
+
+ $data["code_zw"]=$this->code_zw;
+ $data["piaotype"]=$this->piaotype;
+ $data["passportty"]=$this->passportty;
+
+ $this->load->view('bootstrap3/header');
+ $this->load->view('booking_write',$data);
+ $this->load->view('bootstrap3/footer');
+ }
+
+
+ public function booking_do(){
+ //以下是为测试用,未做完善的判断!
+
+ $this->load->helper('form');
+ $this->load->library('my_form_validation');
+ $zw=$this->input->post("train_booking_zw");
+ $piaotype_post=$this->input->post("train_booking_piaotype");
+ $passengersename=$this->input->post("train_booking_passengersename");
+ $passportty=$this->input->post("train_booking_passportty");
+ $passportseno=$this->input->post("train_booking_passportseno");
+ $mobile=$this->input->post("train_booking_mobile");
+ $train_code=$this->input->post("train_booking_train_code");
+ $from_station_code=$this->input->post("train_booking_from_station_code");
+ $from_station_name=$this->input->post("train_booking_from_station_name");
+ $to_station_code=$this->input->post("train_booking_to_station_code");
+ $to_station_name=$this->input->post("train_booking_to_station_name");
+ $date=$this->input->post("train_booking_date");
+
+ $rebakc="";//返回数据
+ $flag=TRUE;//标示变量
+ $passengers="";//乘客信息集合
+ $num=count($zw);
+ if($num>5){
+ // die("乘客太多");
+ $rebakc="乘客太多";
+ }else{
+ $config_zw=$this->code_zw;//检查座位信息是否和配置文件相符合
+ $config_piaotype=$this->piaotype;//检查票种信息是否和配置文件相符合
+ $config_passportty=$this->passportty;//检查证件信息是否和配置文件相符合
+
+ for($i=0;$i<$num;++$i){
+
+ if(empty($config_zw[$zw[$i]])){
+ $zwname[]=$config_zw["1"];
+ $zwcode[]="1";
+ }else{
+ $zwname[]=$config_zw[$zw[$i]];
+ $zwcode[]=$zw[$i];
+ }
+
+ if(empty($config_piaotype[$piaotype_post[$i]])){
+ $piaotypename[]=$config_piaotype["1"];
+ $piaotype[]="1";
+ }else{
+ $piaotypename[]=$config_piaotype[$piaotype_post[$i]];
+ $piaotype[]=$piaotype_post[$i];
+ }
+
+ if(empty($config_passportty[$passportty[$i]])){
+ $zwname[]=$config_passportty["1"];
+ $zwcode[]="1";
+ }else{
+ $zwname[]=$config_passportty[$passportty[$i]];
+ $zwcode[]=$passportty[$i];
+ }
+
+ }
+ //表单验证
+ $this->form_validation->set_rules('train_booking_train_code', '车次不能为空', 'required');
+ $this->form_validation->set_rules('train_booking_from_station_name', '出发站点不能为空', 'required');
+ $this->form_validation->set_rules('train_booking_to_station_name', '目的站点不能空', 'required');
+ $this->form_validation->set_rules('train_booking_date', '日期不能为空', 'required');
+ $this->form_validation->set_rules('train_booking_passportseno[]', '证件号不能为空且为数字', 'required|numeric');
+
+ $this->form_validation->set_rules('train_booking_passengersename[]', '姓名不能为空', 'required');
+
+ if($this->form_validation->run()){
+ for($i=0;$i<$num;$i++){
+ $passengers.=',{"passengerid":'.($i+1).',"passengersename":"'.$passengersename[$i].'","piaotype":"'.$piaotype[$i].'","piaotypename":"'.$piaotypename[$i].'","passporttypeseid":"'.$passporttypeseid[$i].'","passporttypeseidname":"'.$passporttypeseidname[$i].'","passportseno":"'.$passportseno[$i].'","price":"1","zwcode":"'.$zwcode[$i].'","zwname":"'.$zwname[$i].'"}';
+ }
+ $passengers.="]";
+ $passengers=substr($passengers, 1);
+ $passengers="[".$passengers;
+ // die($passengers);
+ $url=$this->dp_api;
+ $post_data=array(
+ "key"=>$this->key,
+ "user_orderid"=>time(),//自定义订单号
+ "train_date"=>$date,
+ "from_station_name"=>$from_station_name,
+ "from_station_code"=>$from_station_code,
+ "to_station_code"=>$to_station_code,
+ "to_station_name"=>$to_station_name,
+ "passengers"=>$passengers,
+ "checi"=>$train_code
+ );
+
+ $bakc=$this->my_post($url,$post_data);
+ if($bakc['error_code']){
+ $rebakc=$bakc;
+ }else{
+ //提交订单成功,但并不意味着信息没错
+ $url_status=$this->cx_api;//订单状态查询
+ $post_status=array(
+ "key"=>$this->key,
+ "orderid"=>$bakc["result"]["orderid"]
+ );
+ $bakc_status=$this->my_post($url_status,$post_status);
+
+
+ if($bakc_status["error_code"]){
+ $rebakc=$bakc_status;
+ }else{
+ $this->load->model("api_model","api");
+ $this->api->_insert("order",array(
+ "order_num"=>$bakc['result']['orderid'],
+ "sub_time"=>time(),
+ "status"=>$bakc_status["result"]["status"],
+ "msg"=>$bakc_status["result"]["msg"],
+ "from_station"=>$from_station_name,
+ "to_station"=>$to_station_name,
+ "train_code"=>$train_code,
+ "price"=>$bakc_status["result"]["orderamount"]
+ ));
+ // echo "";
+ redirect("apps/train/index/order_list");//windows服务器会报错?
+ }
+
+ }
+ var_dump($rebakc);
+ }else{
+ // var_dump($this->form_validation->_error_array);
+ var_dump(validation_errors());
+ }
+
+ }
+
+ }
+
+
+ public function order_list(){
+ $this->load->model("api_model","api");
+ $list["data"]=$this->api->getAll("order");
+ $count=count($list["data"]);
+ for ($i=0; $i < $count; $i++) {
+ $list["data"][$i]["info"]=$this->order_status_msg[$list["data"][$i]["status"]];//自定义说明信息
+ }
+ $this->load->view('bootstrap3/header');
+ $this->load->view('order_list.html',$list);
+ $this->load->view('bootstrap3/footer');
+ }
+ public function order(){
+
+ if($order=$this->input->get("order")){
+ $post_data=array(
+ "key"=>"79f03107b921ef31310bd40a1415c1cb",
+ "orderid"=>$order
+ );
+ $back_data=$this->my_post("http://op.juhe.cn/trainTickets/orderStatus",$post_data);
+ $data=array(
+ "JOL_Status"=>$back_data["result"]["status"],
+ "JOL_RebackMsg"=>$back_data["result"]["msg"]
+ );
+ $this->load->model("BIZ_train_model");
+ //查询到订单最新情况,更新本地数据库
+ $this->BIZ_train_model->update_biz_jol(array("JOL_JuheOrder"=>$order),$data);
+ // var_dump($back_data);
+ $this->load->view('bootstrap3/header');
+ $this->load->view('order',$back_data);
+ $this->load->view('bootstrap3/footer');
+ }
+ }
+ //取消订单
+ public function cancel_order(){
+ if($order=$this->input->get("order")){
+ $post_data=array(
+ "key"=>$this->key,
+ "orderid"=>$order
+ );
+ $back=$this->my_post($this->qxdd_api,$post_data);
+ var_dump($back);
+
+ }
+ }
+
+ //请求出票,支付
+ public function pay(){
+ if($order=$this->input->get("order")){
+ $post_data=array(
+ "key"=>$this->key,
+ "orderid"=>$order
+ );
+ $back=$this->my_post($this->pay_api,$post_data);
+ var_dump($back);
+ }
+ }
+
+ //线上退票
+ public function refund(){
+ if($order=$this->input->get("order")){
+ $post_data=array(
+ "key"=>$this->key,
+ "orderid"=>$order
+ );
+ $back_data=$this->my_post($this->status_api,$post_data);
+ $data=array(
+ "JOL_Status"=>$back_data["result"]["status"],
+ "JOL_RebackMsg"=>$back_data["result"]["msg"]
+ );
+ $this->load->model("BIZ_train_model");
+ //查询到订单最新情况,更新本地数据库
+ $this->BIZ_train_model->update_biz_jol(array("JOL_JuheOrder"=>$order),$data);
+
+ $this->load->view('bootstrap3/header');
+ $this->load->view('refund',$back_data);
+ $this->load->view('bootstrap3/footer');
+ }
+ }
+ public function refund_do(){
+ $order=$this->input->get("order");
+ $passportseno=$this->input->get("passportseno");
+ $passporttypeseid=$this->input->get("passporttypeseid");
+ $ticket_no=$this->input->get("ticket_no");
+ $passengername=$this->input->get("name");
+
+ if(!empty($order) && !empty($passportseno) && !empty($passporttypeseid) && !empty($ticket_no) && !empty($passengername)){
+ $post_data=array(
+ "key"=>$this->key,
+ "orderid"=>$order,
+ "tickets"=>'[{"ticket_no":"'.$ticket_no.'","passengername":"'.$passengername.'","passporttypeseid":"'.$passporttypeseid.'","passportseno":"'.$passportseno.'"}]',
+ );
+ $back_data=$this->my_post($this->refund_api,$post_data);
+
+ if($back_data["error_code"]==0){
+ echo "";
+ }
+ }
+ return;
+ }
+ function my_post($url,$post_data){
+ // $url = "http://op.juhe.cn/trainTickets/cityCode";
+ // $post_from = array("stationName" => $from,"key"=>"79f03107b921ef31310bd40a1415c1cb");
+ // $post_to = array("stationName" => $to,"key"=>"79f03107b921ef31310bd40a1415c1cb");
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ // post数据
+ curl_setopt($ch, CURLOPT_POST, 1);
+ // post的变量
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
+ $output = curl_exec($ch);
+
+ curl_close($ch);
+
+ $output=json_decode($output,TRUE);//json => array
+ return $output;
+ }
+ function get_data($url){
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+ $output = curl_exec($ch);
+ curl_close($ch);
+ return $output;
+ }
+ function post_data($url,$post_data){
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ // post数据
+ curl_setopt($ch, CURLOPT_POST, 1);
+ // post的变量
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
+ $output = curl_exec($ch);
+
+ curl_close($ch);
+
+ // $output=json_decode($output,TRUE);//json => array
+ return $output;
+ }
+
+}
\ No newline at end of file
diff --git a/application/third_party/train_it/controllers/ticket.php b/application/third_party/train_it/controllers/ticket.php
new file mode 100644
index 00000000..8fc9d4d0
--- /dev/null
+++ b/application/third_party/train_it/controllers/ticket.php
@@ -0,0 +1,92 @@
+config->load('config');
+ $this->load->model("BIZ_train_model"); //加载模型
+ }
+
+ //输入翰特订单号cols_id,获取火车订票的相关信息,模拟翰特订单详情页面
+ public function index() {
+ $data = array();
+ $coli_id = $this->input->post("ht_order"); //商务订单号
+ //主订单信息
+ $data['order_detail'] = $this->BIZ_train_model->confirm_line_info($coli_id);
+ if (empty($data['order_detail'])) {
+ echo '找不到订单';
+ return false;
+ }
+
+ //外联信息
+ $data['operator_detail'] = $this->BIZ_train_model->operator_detail($data['order_detail']->COLI_OPI_ID);
+ if (empty($data['operator_detail'])) {
+ echo '找不到外联信息';
+ return false;
+ }
+
+ //子订单信息+产品信息,一对一
+ $data['order_detail_list'] = $this->BIZ_train_model->confirm_line_detail($data['order_detail']->COLI_SN);
+ if (empty($data['order_detail_list'])) {
+ echo '找不到订单详情';
+ return false;
+ }
+//子订单信息+乘客信息,一对多
+
+
+
+ $cols_id = $this->input->post("ht_order");
+ $list = new StdClass;
+ if (!empty($cols_id)) {
+ $cold_sn = $this->BIZ_train_model->get_biz_cold($cols_id);
+ $list->wl = $this->BIZ_train_model->get_operatorinfo($cols_id);
+ $people = array();
+ $i = 0;
+ $list->info = "";
+ foreach ($cold_sn as $v) {
+ $list->info[$i]->people = $this->BIZ_train_model->biz_people($v->COLD_SN);
+ $list->info[$i]->train = $this->BIZ_train_model->get_biz_foi($v->COLD_SN);
+ $list->info[$i]->status = $this->BIZ_train_model->get_biz_jol($v->COLD_SN);
+ $i++;
+ }
+ $list->cols_id = $cols_id;
+ }
+
+ $this->load->view('bootstrap3/header');
+ $this->load->view('ht_train_order.html', $list);
+ $this->load->view('bootstrap3/footer');
+ }
+
+ public function search() {
+ $data = array();
+ $data['from_station'] = $this->input->get_post("from_station");
+ $data['to_station'] = $this->input->get_post("to_station");
+ $data['query_date'] = $this->input->get_post("query_date");
+ $url = "http://op.juhe.cn/trainTickets/cityCode";
+ $post_from = array("stationName" => $from, "key" => $this->key);
+ $post_to = array("stationName" => $to, "key" => $this->key);
+ $output_from = $this->my_post($url, $post_from);
+ $output_to = $this->my_post($url, $post_to);
+ if ($output_from["error_code"] === 0 && $output_to["error_code"] === 0) {//error_code=0代表成功,其他有错,返回错误信息
+ // var_dump($output_from["result"]["code"]);var_dump($output_to["result"]["code"]);
+ $ticket_data = array("key" => $this->key, "train_date" => $date, "from_station" => $output_from["result"]["code"], "to_station" => $output_to["result"]["code"]);
+ $ticket = $this->my_post("http://op.juhe.cn/trainTickets/ticketsAvailable", $ticket_data);
+
+ if ($ticket["error_code"] != 0) { //error_code=0代表成功,其他有错,返回错误信息
+ die(json_encode(array("status" => 0, "mes" => $ticket["reason"]))); //
+ } else {
+ $backdata = "";
+ $backdata = $this->load->view("booking_table", array("result" => $ticket["result"], "date" => $date), true);
+
+ die(json_encode(array("status" => 1, "mes" => "成功", "backdata" => $backdata)));
+ }
+ } else {
+ die(json_encode(array("status" => 0, "mes" => "站点名称错误")));
+ }
+ }
+
+}
diff --git a/application/third_party/train_it/models/BIZ_train_model.php b/application/third_party/train_it/models/BIZ_train_model.php
new file mode 100644
index 00000000..0bd387da
--- /dev/null
+++ b/application/third_party/train_it/models/BIZ_train_model.php
@@ -0,0 +1,328 @@
+HT = $this->load->database('HT', TRUE);
+ $this->INFO = $this->load->database('INFO', TRUE);
+ }
+
+ //新增或更新价格
+ public function addOrUpdate($TPL_Train_No,$TPL_Train_Code,$TPL_From_Station_Code,$TPL_To_Station_Code,$TPL_Price){
+ $sql = "IF NOT EXISTS(
+ SELECT 1
+ FROM TrainPriceList
+ WHERE TPL_Train_Code = '$TPL_Train_Code'
+ AND TPL_From_Station_Code = '$TPL_From_Station_Code'
+ AND TPL_To_Station_Code = '$TPL_To_Station_Code'
+ ) BEGIN
+ INSERT INTO TrainPriceList
+ (
+ TPL_Train_No,
+ TPL_Train_Code,
+ TPL_From_Station_Code,
+ TPL_To_Station_Code,
+ TPL_Price,
+ TPL_Datetime,
+ TPL_Source
+ )
+ VALUES
+ (
+ '$TPL_Train_No','$TPL_Train_Code','$TPL_From_Station_Code','$TPL_To_Station_Code','$TPL_Price',GETDATE(),'juhe'
+ )
+ END
+ ELSE
+ BEGIN
+ UPDATE TrainPriceList
+ SET TPL_Train_No = '$TPL_Train_No',
+ TPL_Price = '$TPL_Price',
+ TPL_Datetime = GETDATE(),
+ TPL_Source = 'juhe'
+ WHERE TPL_Train_Code = '$TPL_Train_Code'
+ AND TPL_From_Station_Code = '$TPL_From_Station_Code'
+ AND TPL_To_Station_Code = '$TPL_To_Station_Code'
+ END
+ ";
+ $query = $this->INFO->query($sql);
+ return $query;
+ }
+
+ //获取价格
+ public function get_price($fromStationCode,$toStationCode,$trainCode){
+ $sql = "SELECT
+ TPL_Price
+ FROM
+ TrainPriceList
+ WHERE
+ TPL_Train_Code = '$trainCode'
+ AND
+ TPL_From_Station_Code = '$fromStationCode'
+ AND
+ TPL_To_Station_Code = '$toStationCode'";
+ $query = $this->INFO->query($sql);
+ return $query->row();
+ }
+
+
+ function biz_order_detail($cold_sn) {
+ $sql = "
+ SELECT TOP 1 bfoi.FOI_SN
+ ,bfoi.FOI_COLD_SN
+ ,bfoi.DepartAirport
+ ,bfoi.ArrivalAirport
+ ,bfoi.FlightsNo
+ ,bfoi.Aircraft
+ ,bfoi.DepartureDate
+ ,(
+ SELECT TOP 1 TRS_StationCN
+ FROM TrainStation
+ WHERE TRS_Code = DepartAirport
+ ) AS DepartAirport_cn
+ ,(
+ SELECT TOP 1 TRS_StationCN
+ FROM TrainStation
+ WHERE TRS_Code = ArrivalAirport
+ ) AS ArrivalAirport_cn
+ FROM BIZ_FlightsOrderInfo bfoi
+ WHERE bfoi.FOI_COLD_SN = ?
+ ";
+ $query = $this->HT->query($sql, $cold_sn);
+ if ($query->num_rows() > 0) {
+ return $query->row();
+ } else {
+ return false;
+ }
+ }
+ //传入一组BPE_SN获取乘客信息
+ function in_bpesn_people_info($bpe_sn){
+ $sql = "
+ SELECT bbp.BPE_SN
+ ,bbp.BPE_FirstName
+ ,bbp.BPE_MiddleName
+ ,bbp.BPE_LastName
+ ,bbp.BPE_GuestType
+ ,bbp.BPE_Passport
+ FROM BIZ_BookPeople bbp
+ WHERE BPE_SN in(".$bpe_sn.")
+ ";
+ $query = $this->HT->query($sql);
+ return $query->result();
+ }
+ //传入子订单COLD_SN,获取子订单对应的乘客信息
+ function biz_people($cold_sn) {
+ $sql = "
+ SELECT bbp.BPE_SN
+ ,bbp.BPE_FirstName
+ ,bbp.BPE_MiddleName
+ ,bbp.BPE_LastName
+ ,bbp.BPE_GuestType
+ ,bbp.BPE_Passport
+ FROM BIZ_BookPeople bbp
+ WHERE EXISTS(
+ SELECT TOP 1 1
+ FROM BIZ_BookPeopleList bbpl
+ WHERE bbpl.BPL_BPE_SN = bbp.BPE_SN
+ AND bbpl.BPL_COLD_SN = ?
+ )
+ ";
+ $query = $this->HT->query($sql, $cold_sn);
+ return $query->result();
+ }
+
+ //添加聚合订单记录,BIZ_JuheOrderList
+ function add_biz_jol($data){
+ $sql="
+ INSERT INTO BIZ_JuheOrderList(
+ JOL_SubTime,
+ JOL_COLD_SN,
+ JOL_JuheOrder,
+ JOL_Status,
+ JOL_RebackMsg,
+ JOL_FromStation,
+ JOL_ToStation,
+ JOL_FromStationCode,
+ JOL_ToStationCode,
+ JOL_TrainCode,
+ JOL_BackTxt
+ )
+ VALUES(getdate(),?,?,?,?,?,?,?,?,?,?)
+ ";
+ $query = $this->HT->query($sql, array($data->JOL_COLD_SN,$data->JOL_JuheOrder,$data->JOL_Status,$data->JOL_RebackMsg,$data->JOL_FromStation,$data->JOL_ToStation,$data->JOL_FromStationCode,$data->JOL_ToStationCode,$data->JOL_TrainCode,$data->JOL_BackTxt
+ ));
+ return $query;
+ }
+ /* 以下为get_ht_order优化代码 */
+
+ //传入主订单翰特订单号COLI_ID(161014006M),获取子订单中火车订单的COLD_SN
+ function get_biz_cold($cols_id) {
+ $sql = "SELECT COLD_SN
+ FROM BIZ_ConfirmLineDetail bcld
+ WHERE bcld.COLD_COLI_SN=(
+ SELECT COLI_SN FROM BIZ_ConfirmLineInfo bcli WHERE bcli.COLI_ID=?)
+ AND bcld.DeleteFlag=0 AND bcld.COLD_ServiceType='2'";
+ $query = $this->HT->query($sql, $cols_id);
+ return $query->result();
+ }
+
+ //传入COLD_SN,获取火车车次等信息
+ function get_biz_foi($cold_sn) {
+ $sql = "
+ SELECT FOI_COLD_SN,
+ FlightsNo,
+ Cabin,
+ DepartureCity,
+ ArrivalCity,
+ DepartureDate,
+ DepartureTime,
+ ArrivalTime,
+ adultcost
+ FROM BIZ_FlightsOrderInfo
+ WHERE FOI_COLD_SN = ?
+ ";
+ $query = $this->HT->query($sql, $cold_sn);
+ return $query->result();
+ }
+
+ //传入COLD_SN,获取BIZ_JuheOrderList是否存在此子订单,用来判断是否提交过给聚合
+ function get_biz_jol($cold_sn) {
+ $sql = "SELECT top 1 JOL_SN FROM BIZ_JuheOrderList WHERE JOL_COLD_SN= ?";
+ $query = $this->HT->query($sql, $cold_sn);
+ return $query->result();
+ }
+
+ //传入COLI_ID,获取外联名
+ function get_operatorinfo($cols_id) {
+ $sql = "
+ SELECT OPI_Name
+ FROM OperatorInfo
+ WHERE OPI_SN = (
+ SELECT COLI_OPI_ID
+ FROM BIZ_ConfirmLineInfo bcli
+ WHERE bcli.COLI_ID = ?
+ )
+ ";
+ $query = $this->HT->query($sql, $cols_id);
+ return $query->result();
+ }
+
+ /* 以上为get_ht_order优化代码 */
+
+ //修改BIZ_JuheOrderList
+ function update_biz_jol($where,$data){
+ return $this->HT->where($where)->update("BIZ_JuheOrderList", $data);
+ }
+
+ //获取站点简码
+ function get_train_station_code($where){
+ $data=$this->HT->where($where)->select("TRS_Code")->from("TrainStation")->get();
+ return $data->result();
+ }
+
+ //接收聚合订单号,获取翰特订单号,即BIZ_ConfirmLineInfo的COLI_ID
+ function jh_order_get_coli_id($jh_order){
+ $sql="SELECT COLI_ID FROM BIZ_ConfirmLineInfo bcli WHERE bcli.COLI_SN=
+ (SELECT COLD_COLI_SN FROM BIZ_ConfirmLineDetail bcld WHERE bcld.COLD_SN=
+ (SELECT JOL_COLD_SN FROM BIZ_JuheOrderList bjol WHERE bjol.JOL_JuheOrder= ? ))
+ ";
+ $query = $this->HT->query($sql, $jh_order);
+ return $query->result();
+ }
+ //通过COLI_ID获取团名 即 GroupInfo的GRI_No
+ function get_gri_no($coli_id){
+ $sql="SELECT GRI_No FROM GroupInfo
+ WHERE GRI_SN=(
+ SELECT COLI_GRI_SN FROM BIZ_ConfirmLineInfo WHERE COLI_ID=?
+ )
+ ";
+ $query = $this->HT->query($sql, $coli_id);
+ return $query->result();
+ }
+ //通过COLI_ID获取我的支付 BIZ_TrainOrderCost
+ function get_train_order_cost($coli_id){
+ $sql="SELECT TOC_Memo,TOC_TrainNumber,TOC_DepartureDate,TOC_TicketCost
+ FROM BIZ_TrainOrderCost btoc
+ WHERE btoc.TOC_COLI_SN=
+ (SELECT COLI_SN FROM BIZ_ConfirmLineInfo bcli
+ WHERE bcli.COLI_ID=?)";
+ $query = $this->HT->query($sql, $coli_id);
+ return $query->result();
+ }
+
+ //-----------------------------自动出票 begin-----------
+ //用于自动出票,传入主订单翰特订单号COLI_SN,获取子订单中火车订单的COLD_SN和COLD_SPFS(寄送票标示,大于1的为寄送)
+ public function get_cold_sn($COLI_SN){
+ $sql="SELECT COLD_SN,COLD_SPFS
+ FROM BIZ_ConfirmLineDetail bcld
+ WHERE bcld.COLD_COLI_SN=?
+ AND bcld.DeleteFlag=0 AND bcld.COLD_ServiceType='2'";
+ $query = $this->HT->query($sql,$COLI_SN);
+ return $query->result();
+ }
+ //用于自动出票,传入主订单翰特订单号 COLI_ID ,获取客人的姓名和邮箱
+ public function get_guest_info($COLI_ID){
+ $sql = "SELECT GUT_LastName,GUT_Email FROM BIZ_GUEST bg WHERE bg.GUT_SN =
+ ( SELECT COLI_GUT_SN FROM BIZ_ConfirmLineInfo bcli WHERE bcli.COLI_ID = ?)
+ ";
+ $query = $this->HT->query($sql,$COLI_ID);
+ return $query->result();
+ }
+ //通过 JOL_JuheOrder 获取 BIZ_JuheOrderList 获取聚合订单详情
+ public function get_biz_jol_info($cold_sn,$jol_jo){
+ $sql = "SELECT top 1
+ JOL_SN,
+ JOL_COLD_SN,
+ JOL_JuheOrder,
+ JOL_SubTime,
+ JOL_Status,
+ JOL_RebackMsg,
+ JOL_FromStation,
+ JOL_ToStation,
+ JOL_FromStationCode,
+ JOL_ToStationCode,
+ JOL_TrainCode,
+ JOL_Price,
+ JOL_PayTime,
+ JOL_BackTxt
+ FROM BIZ_JuheOrderList
+ WHERE JOL_COLD_SN = ? AND JOL_JuheOrder = ?
+ ";
+ $query = $this->HT->query($sql,array($cold_sn,$jol_jo));
+ return $query->result();
+ }
+ // 传入coli_sn获取订单号
+ public function coli_sn_get_coli_id($coli_sn){
+ $sql="SELECT COLI_ID FROM BIZ_ConfirmLineInfo WHERE COLI_SN = ? ";
+ $query = $this->HT->query($sql,array($coli_sn));
+ return $query->result();
+ }
+ // 传入 cold_sn 获取订单号
+ public function cold_sn_get_coli_id($cold_sn){
+ $sql="SELECT COLI_ID FROM BIZ_ConfirmLineInfo
+ WHERE COLI_SN = (
+ SELECT COLD_COLI_SN FROM BIZ_ConfirmLineDetail WHERE COLD_SN = ?
+ )
+ ";
+ $query = $this->HT->query($sql,array($cold_sn));
+ return $query->result();
+ }
+ //-----------------------------自动出票 end-----------
+
+ function SendMail($fromName, $fromEmail, $toName, $toEmail, $subject, $body) {
+ $toName = str_replace("'","''",$toName);
+ $body = str_replace("'","''",$body);
+ $sql = "INSERT INTO Email_AutomaticSend
+ (
+ M_ReplyToName, M_ReplyToEmail, M_ToName, M_ToEmail, M_Title, M_Body, M_Web,
+ M_FromName, M_State
+ )
+ VALUES
+ (
+ ?, ?, N'{$toName}', ?, N'{$subject}', N'{$body}', ?, ?, 0
+ ) ";
+ $query = $this->HT->query($sql, array($fromName, $fromEmail, $toEmail, 'cht', 'information'));
+ echo $query;
+
+ //return $query;
+ }
+}
diff --git a/application/third_party/train_it/models/api_model.php b/application/third_party/train_it/models/api_model.php
new file mode 100644
index 00000000..c02502e0
--- /dev/null
+++ b/application/third_party/train_it/models/api_model.php
@@ -0,0 +1,21 @@
+JH=$this->load->database('JH', TRUE);
+ }
+
+ function getAll($table,$where="1=1",$order="id desc") {
+ $query = $this->JH->order_by("id desc")->get($table);
+ return $query->result_array();
+ }
+
+ function _insert($table,$data){
+ return $this->JH->insert($table, $data);
+ }
+ function _update($table,$data,$where){
+ return $this->JH->where($where)->update($table, $data);
+ }
+}
\ No newline at end of file
diff --git a/application/third_party/train_it/models/order_people_model.php b/application/third_party/train_it/models/order_people_model.php
new file mode 100644
index 00000000..495772f4
--- /dev/null
+++ b/application/third_party/train_it/models/order_people_model.php
@@ -0,0 +1,327 @@
+HT=$this->load->database('HT', TRUE);
+ }
+
+ function biz_people($order){
+ //订单信息
+ $sql="SELECT COLD_ServiceType,COLD_StartDate FROM BIZ_ConfirmLineDetail WHERE COLD_SN= ?";
+
+ $data=new StdClass();
+ $query_cold=$this->HT->query($sql,$order);
+ $data->cold=$query_cold->result();
+
+ //城市名称
+ if(!empty($data->cold)){
+
+ //车次信息
+ $sql="SELECT DepartAirport,ArrivalAirport,FlightsNo,Aircraft,DepartureDate FROM BIZ_FlightsOrderInfo WHERE FOI_COLD_SN= ?";
+ $query_zdjm=$this->HT->query($sql,(int)$order);
+ $query_zdjm=$query_zdjm->result();
+ if(!empty($query_zdjm)){
+ $data->cold[0]->DepartAirport=$query_zdjm[0]->DepartAirport;
+ $data->cold[0]->ArrivalAirport=$query_zdjm[0]->ArrivalAirport;
+ $data->cold[0]->FlightsNo=$query_zdjm[0]->FlightsNo;
+ $data->cold[0]->Aircraft=$query_zdjm[0]->Aircraft;
+
+ //站点中文名称
+ $sql="SELECT TRS_StationCN AS LeaveStation FROM TrainStation WHERE TRS_Code='".$query_zdjm[0]->DepartAirport."'";
+ $query_LeaveStation=$this->HT->query($sql);
+ $LeaveStation=$query_LeaveStation->result();
+
+ $sql="SELECT TRS_StationCN AS ServerStation FROM TrainStation WHERE TRS_Code='".$query_zdjm[0]->ArrivalAirport."'";
+ $query_ServerStation=$this->HT->query($sql);
+ $ServerStation=$query_ServerStation->result();
+
+ $data->cold[0]->LeaveStation=$LeaveStation[0]->LeaveStation;
+ $data->cold[0]->ServerStation=$ServerStation[0]->ServerStation;
+
+ }
+ }
+
+ $sql="SELECT BPE_FirstName,BPE_MiddleName,BPE_LastName,BPE_GuestType,BPE_Passport
+ FROM BIZ_BookPeople
+ WHERE BPE_SN in (
+ SELECT BPL_BPE_SN FROM BIZ_BookPeopleList WHERE BPL_COLD_SN=?
+ )";
+ $query_people=$this->HT->query($sql,$order);
+ $data->people=$query_people->result();
+ return $data;
+
+ }
+ //添加聚合订单记录,BIZ_JuheOrderList
+ public function add_jh_order($data){
+ $sql="IF NOT EXISTS(
+ SELECT TOP 1 1 FROM BIZ_JuheOrderList
+ WHERE JOL_COLD_SN=? AND JOL_JuheOrder=?
+ )
+ INSERT INTO BIZ_JuheOrderList(
+ JOL_SubTime,
+ JOL_COLD_SN,
+ JOL_JuheOrder,
+ JOL_Status,
+ JOL_RebackMsg,
+ JOL_FromStation,
+ JOL_ToStation,
+ JOL_FromStationCode,
+ JOL_ToStationCode,
+ JOL_TrainCode,
+ JOL_BackTxt
+ )
+ VALUES(getdate(),?,?,?,?,?,?,?,?,?,?)
+ ELSE UPDATE BIZ_JuheOrderList
+ SET
+ JOL_SubTime=getdate(),
+ JOL_JuheOrder=?,
+ JOL_Status=?,
+ JOL_RebackMsg=?,
+ JOL_FromStation=?,
+ JOL_ToStation=?,
+ JOL_FromStationCode=?,
+ JOL_ToStationCode=?,
+ JOL_TrainCode=?,
+ JOL_BackTxt=?
+ WHERE
+ JOL_COLD_SN=?
+ ";
+ $query = $this->HT->query($sql, array($data->JOL_COLD_SN,$data->JOL_JuheOrder,$data->JOL_COLD_SN,$data->JOL_JuheOrder,$data->JOL_Status,$data->JOL_RebackMsg,$data->JOL_FromStation,$data->JOL_ToStation,$data->JOL_FromStationCode,$data->JOL_ToStationCode,$data->JOL_TrainCode,$data->JOL_BackTxt,
+ $data->JOL_JuheOrder,$data->JOL_Status,$data->JOL_RebackMsg,$data->JOL_FromStation,$data->JOL_ToStation,$data->JOL_FromStationCode,$data->JOL_ToStationCode,$data->JOL_TrainCode,$data->JOL_BackTxt,$data->JOL_COLD_SN));
+
+ return $query;
+ }
+ public function update_jh_order($data){
+ $sql="UPDATE BIZ_JuheOrderList
+ SET JOL_RebackMsg=?,
+ JOL_BackTxt=?,
+ JOL_Status=?,
+ JOL_Price=?
+ WHERE
+ JOL_JuheOrder=?
+ ";
+ $query = $this->HT->query($sql,array($data->JOL_RebackMsg,$data->JOL_BackTxt,$data->JOL_Status,$data->JOL_Price,$data->JOL_JuheOrder));
+ return $query;
+ }
+
+
+ //BIZ_TrainOrderCost,我的支付
+ //BIZ_FlightsOrderInfo.FOI_TrainNetOrderNo,更新取票号
+ public function add_train_order($data){
+ //主表ID,下面两个地方用到,所以先筛选出来,不知道能不能通过合并提高效率
+ $sql="SELECT COLD_COLI_SN FROM BIZ_ConfirmLineDetail WHERE COLD_SN=?";
+ $query=$this->HT->query($sql,$data->TOC_COLD_SN);
+ $query=$query->result();
+ $CCSN=$query[0]->COLD_COLI_SN;
+ if(empty($data->FOI_TrainNetOrderNo)){
+ //退票
+ $sql="IF NOT EXISTS(
+ SELECT TOP 1 1 FROM BIZ_TrainOrderCost
+ WHERE TOC_COLD_SN = ? AND TOC_Memo like ?
+ )
+ INSERT INTO BIZ_TrainOrderCost(
+ TOC_Memo,
+ TOC_CreateDate,
+ TOC_COLI_SN,
+ TOC_COLD_SN,
+ TOC_TrainNumber,
+ TOC_DepartureDate,
+ TOC_TicketCost,
+ TOC_WL
+ )
+ VALUES(?,getdate(),{$CCSN},?,?,?,?,(SELECT COLI_OPI_ID FROM BIZ_ConfirmLineInfo WHERE COLI_SN={$CCSN}))";
+ $query = $this->HT->query($sql,array($data->TOC_COLD_SN,"%".$data->TOC_Memo."%","聚合退票费 ".$data->TOC_Memo,$data->TOC_COLD_SN,$data->TOC_TrainNumber,$data->TOC_DepartureDate,$data->TOC_TicketCost));
+ }else{
+ //出票
+ //BIZ_FlightsOrderInfo.FOI_TrainNetOrderNo,更新取票号
+ $sql="UPDATE BIZ_FlightsOrderInfo
+ SET
+ FOI_TrainNetOrderNo=?
+ WHERE
+ FOI_COLD_SN=?";
+ $this->HT->query($sql,array($data->FOI_TrainNetOrderNo,$data->TOC_COLD_SN));
+ $sql="IF NOT EXISTS(
+ SELECT TOP 1 1 FROM BIZ_TrainOrderCost
+ WHERE TOC_COLD_SN = ? AND TOC_Memo like ?
+ )
+ INSERT INTO BIZ_TrainOrderCost(
+ TOC_Memo,
+ TOC_CreateDate,
+ TOC_COLI_SN,
+ TOC_COLD_SN,
+ TOC_TrainNumber,
+ TOC_DepartureDate,
+ TOC_TicketCost,
+ TOC_WL,
+ TOC_OtherCost
+ )
+ VALUES(?,getdate(),{$CCSN},?,?,?,?,(SELECT COLI_OPI_ID FROM BIZ_ConfirmLineInfo WHERE COLI_SN={$CCSN}),null),(?,getdate(),{$CCSN},?,?,?,?,(SELECT COLI_OPI_ID FROM BIZ_ConfirmLineInfo WHERE COLI_SN={$CCSN}),1)";
+ $query = $this->HT->query($sql,array($data->TOC_COLD_SN,"%".$data->TOC_Memo."%",$data->TOC_Memo." 聚合自动出票",$data->TOC_COLD_SN,$data->TOC_TrainNumber,$data->TOC_DepartureDate,$data->TOC_TicketCost,$data->TOC_Memo." 手续费",$data->TOC_COLD_SN,$data->TOC_TrainNumber,$data->TOC_DepartureDate,$data->poundage));
+ }
+ return $query;
+
+ }
+ public function get_order($pagesize=2,$page=0,$where="1=1"){
+ $data=new StdClass();
+ //获取总条数
+ $sql="SELECT COUNT(*) AS count FROM BIZ_JuheOrderList
+ LEFT JOIN
+ BIZ_ConfirmLineInfo
+ ON
+ BIZ_ConfirmLineInfo.COLI_SN=(SELECT COLD_COLI_SN FROM BIZ_ConfirmLineDetail WHERE COLD_SN=BIZ_JuheOrderList.JOL_COLD_SN)
+ WHERE
+ {$where}
+ ";
+ $query = $this->HT->query($sql);
+ $count=$query->result();
+ $data->count=$count[0]->count;
+
+ $sql="SELECT TOP {$pagesize} BIZ_JuheOrderList.JOL_SubTime,
+ BIZ_JuheOrderList.JOL_COLD_SN,
+ BIZ_JuheOrderList.JOL_JuheOrder,
+ BIZ_JuheOrderList.JOL_Status,
+ BIZ_JuheOrderList.JOL_RebackMsg,
+ BIZ_JuheOrderList.JOL_FromStation,
+ BIZ_JuheOrderList.JOL_ToStation,
+ BIZ_JuheOrderList.JOL_TrainCode,
+ BIZ_JuheOrderList.JOL_Price,
+ BIZ_ConfirmLineInfo.COLI_ID
+ FROM
+ BIZ_JuheOrderList
+ LEFT JOIN
+ BIZ_ConfirmLineInfo
+ ON
+ BIZ_ConfirmLineInfo.COLI_SN=(SELECT COLD_COLI_SN FROM BIZ_ConfirmLineDetail WHERE COLD_SN=BIZ_JuheOrderList.JOL_COLD_SN)
+ WHERE
+ BIZ_JuheOrderList.JOL_SN NOT IN(SELECT TOP {$page} BIZ_JuheOrderList.JOL_SN FROM BIZ_JuheOrderList ORDER BY BIZ_JuheOrderList.JOL_SubTime DESC)
+ AND
+ {$where}
+ ORDER BY BIZ_JuheOrderList.JOL_SubTime DESC";
+ $query = $this->HT->query($sql);
+ $data->list=$query->result();
+ return $data;
+
+ }
+ //外联
+ public function get_wl($select="*",$where="1=1"){
+ // $sql="SELECT COLI_OPI_ID FROM BIZ_ConfirmLineInfo bcli WHERE bcli.COLI_ID=?";
+ $sql="SELECT {$select} FROM OperatorInfo WHERE {$where}";
+
+
+ }
+ //获取火车订票的相应信息
+ public function get_ht_order($order=""){
+ $sql="SELECT COLD_SN
+ FROM BIZ_ConfirmLineDetail bcld
+ WHERE bcld.COLD_COLI_SN=(
+ SELECT COLI_SN FROM BIZ_ConfirmLineInfo bcli WHERE bcli.COLI_ID=?)
+ AND bcld.DeleteFlag=0 AND bcld.COLD_ServiceType='2'";
+ $query = $this->HT->query($sql,$order);
+ $cold_sn=$query->result();
+
+
+ $data=new StdClass();
+
+ if(!empty($cold_sn)){
+ // $cold_sn_str="";
+ $i=0;
+ foreach ($cold_sn as $value) {
+ // $cold_sn_str.=",".$value->COLD_SN;
+ //乘客信息
+ $sql="SELECT BPE_FirstName,BPE_MiddleName,BPE_LastName,BPE_GuestType,BPE_Passport
+ FROM BIZ_BookPeople
+ WHERE BPE_SN IN (
+ SELECT BPL_BPE_SN FROM BIZ_BookPeopleList WHERE BPL_COLD_SN = ".$value->COLD_SN."
+ )";
+ $query=$this->HT->query($sql,$order);
+ $data->info[$i]->people=$query->result();
+
+ //火车订票信息
+ $sql="SELECT * FROM BIZ_FlightsOrderInfo WHERE FOI_COLD_SN = ".$value->COLD_SN;
+ $query = $this->HT->query($sql);
+ $data->info[$i]->train=$query->result();
+
+
+ //BIZ_JuheOrderList是否有JOL_COLD_SN记录 ,返回1(已提交过)
+ $sql="SELECT JOL_SN FROM BIZ_JuheOrderList WHERE JOL_COLD_SN=".$value->COLD_SN;
+ $query = $this->HT->query($sql);
+
+ $o=$query->result();
+ if(!empty($o)){
+ $data->info[$i]->status=1;
+ }else{
+ $data->info[$i]->status=0;
+ }
+ // $data->info[$i]->status= $query->result();
+ $i++;
+ }
+ // $cold_sn_str=substr($cold_sn_str, 1);
+ //火车订票信息
+ // $sql="SELECT * FROM BIZ_FlightsOrderInfo WHERE FOI_COLD_SN IN(".$cold_sn_str.")";
+ // $query = $this->HT->query($sql);
+ // $data->train=$query->result();
+ $sql="SELECT OPI_Name FROM OperatorInfo WHERE OPI_SN=(SELECT COLI_OPI_ID FROM BIZ_ConfirmLineInfo bcli WHERE bcli.COLI_ID=?)";
+ $query = $this->HT->query($sql,$order);
+ $data->wl=$query->result();
+ }
+
+ return $data;
+ }
+
+/*以下为get_ht_order优化代码*/
+ //传入主订单翰特订单号COLI_ID(161014006M),获取子订单中火车订单的COLD_SN
+ public function get_biz_cold($order){
+ $sql="SELECT COLD_SN
+ FROM BIZ_ConfirmLineDetail bcld
+ WHERE bcld.COLD_COLI_SN=(
+ SELECT COLI_SN FROM BIZ_ConfirmLineInfo bcli WHERE bcli.COLI_ID=?)
+ AND bcld.DeleteFlag=0 AND bcld.COLD_ServiceType='2'";
+ $query = $this->HT->query($sql,$order);
+ return $query->result();
+ }
+ //传入子订单COLD_SN,获取子订单对应的乘客信息
+ public function get_biz_people($cold_sn){
+ $sql="SELECT BPE_FirstName,BPE_MiddleName,BPE_LastName,BPE_GuestType,BPE_Passport
+ FROM BIZ_BookPeople
+ WHERE BPE_SN IN (
+ SELECT BPL_BPE_SN FROM BIZ_BookPeopleList WHERE BPL_COLD_SN = ?
+ )";
+ $query=$this->HT->query($sql,$cold_sn);
+ return $query->result();
+ }
+ //传入COLD_SN,获取火车车次等信息
+ public function get_biz_foi($cold_sn){
+ $sql="SELECT FOI_COLD_SN,
+ FlightsNo,
+ Cabin,
+ DepartureCity,
+ ArrivalCity,
+ DepartureDate,
+ DepartureTime,
+ ArrivalTime,
+ adultcost
+ FROM BIZ_FlightsOrderInfo WHERE FOI_COLD_SN = ?";
+ $query = $this->HT->query($sql,$cold_sn);
+ return $query->result();
+ }
+
+ //传入COLD_SN,获取BIZ_JuheOrderList是否存在此子订单,用来判断是否提交过给聚合
+ public function get_biz_jol($cold_sn){
+ $sql="SELECT top 1 JOL_SN FROM BIZ_JuheOrderList WHERE JOL_COLD_SN= ?";
+ $query = $this->HT->query($sql,$cold_sn);
+ return $query->result();
+ }
+
+ //传入COLI_ID,获取外联名
+ public function get_operatorinfo($order){
+ $sql="SELECT OPI_Name FROM OperatorInfo WHERE OPI_SN=(SELECT COLI_OPI_ID FROM BIZ_ConfirmLineInfo bcli WHERE bcli.COLI_ID=?)";
+ $query = $this->HT->query($sql,$order);
+ return $query->result();
+ }
+/*以上为get_ht_order优化代码*/
+
+
+}
\ No newline at end of file
diff --git a/application/third_party/train_it/models/sendmail_model.php b/application/third_party/train_it/models/sendmail_model.php
new file mode 100644
index 00000000..824f98ee
--- /dev/null
+++ b/application/third_party/train_it/models/sendmail_model.php
@@ -0,0 +1,80 @@
+HT = $this->load->database('HT', TRUE);
+ }
+
+ function SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body)
+ {
+ if($this->validEmail($toEmail))
+ {
+ $data = array(
+ "M_ReplyToName" => $fromName, //回复人
+ "M_ReplyToEmail" => $fromEmail, //回复地址
+ "M_ToName" => $toName, //收件人名
+ "M_ToEmail" => $toEmail, //收件邮件地址
+ "M_Title" => $subject, //主题
+ "M_Body" => $body, //邮件正文
+ "M_Web" => "CHT", //所属站点
+ "M_FromName" => "Chinahighlights.com", //站点名称
+ "M_State" => 0,
+ );
+ $this->HT->insert('Email_AutomaticSend',$data);
+ return TRUE;
+ }else{
+ return FALSE;
+ }
+ }
+
+
+ public function validEmail($email){
+ $isValid = true;
+ $atIndex = strrpos($email, "@");
+ if (is_bool($atIndex) && !$atIndex){
+ $isValid = false;
+ }else{
+ $domain = substr($email, $atIndex+1);
+ $local = substr($email, 0, $atIndex);
+ $localLen = strlen($local);
+ $domainLen = strlen($domain);
+ if ($localLen < 1 || $localLen > 64){
+ // local part length exceeded
+ $isValid = false;
+ }else if ($domainLen < 1 || $domainLen > 255){
+ // domain part length exceeded
+ $isValid = false;
+ }else if ($local[0] == '.' || $local[$localLen-1] == '.'){
+ // local part starts or ends with '.'
+ $isValid = false;
+ }else if (preg_match('/\\.\\./', $local)){
+ // local part has two consecutive dots
+ $isValid = false;
+ }else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)){
+ // character not valid in domain part
+ $isValid = false;
+ }else if (preg_match('/\\.\\./', $domain)){
+ // domain part has two consecutive dots
+ $isValid = false;
+ }else if(!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/',str_replace("\\\\","",$local))){
+ // character not valid in local part unless
+ // local part is quoted
+ if (!preg_match('/^"(\\\\"|[^"])+"$/',str_replace("\\\\","",$local))){
+ $isValid = false;
+ }
+ }
+ /*
+ 不检查是否有DNS解析
+ if ($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A"))){
+ // domain not found in DNS
+ $isValid = false;
+ }
+ */
+ }
+ return $isValid;
+ }
+
+}
\ No newline at end of file
diff --git a/application/third_party/train_it/views/booking.php b/application/third_party/train_it/views/booking.php
new file mode 100644
index 00000000..278f827f
--- /dev/null
+++ b/application/third_party/train_it/views/booking.php
@@ -0,0 +1,160 @@
+
+
+
+
列车信息
+
+
+
站(开)到站(到)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
乘客信息
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application/third_party/train_it/views/booking_table.php b/application/third_party/train_it/views/booking_table.php
new file mode 100644
index 00000000..3a50c355
--- /dev/null
+++ b/application/third_party/train_it/views/booking_table.php
@@ -0,0 +1,110 @@
+
+
+
+
\ No newline at end of file
diff --git a/application/third_party/train_it/views/booking_write.php b/application/third_party/train_it/views/booking_write.php
new file mode 100644
index 00000000..ac49fe5e
--- /dev/null
+++ b/application/third_party/train_it/views/booking_write.php
@@ -0,0 +1,202 @@
+
+
+
+
订单号
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application/third_party/train_it/views/email.php b/application/third_party/train_it/views/email.php
new file mode 100644
index 00000000..66184036
--- /dev/null
+++ b/application/third_party/train_it/views/email.php
@@ -0,0 +1,70 @@
+
+
+
+
+无标题文档
+
+
+
+
China Highlights Booking Confirmation
+
Dear GUT_LastName?>,
+
Thanks for payment US$145 . The train tickets have already been issued.
+
You can collect the paper ticket(s) from now at any train station in mainland China.
+
Please present all passenger(s) original passport(s) and Ticket Pick Up No.E601014106 at any ticket collecting counters (in Chinese 取票窗口)of any railway stations in mainland China. They will then issue your paper train ticket(s).
+
+
+
Passenger(s)
+
2 adult(s)
+
+
1. ALEXANDER JAMES JOHNSON , passport number 503406354
+2. SIAN MARIE JOHNSON , passport number 528876517
+
+
+
Train 1:
+
+
+
Ticket Pick Up No.
+
E601014106
+
+
+
Train No.
+
Z19
+
+
+
Departure
+
20:40 Jun.06 Beijing Xi (West) Station(in Chinese 北京西火车站)
+
+
+
Arrival
+
08:31AM Jun.07 Xi'an Station(in Chinese 西安火车站)
+
+
+
Class
+
Soft Sleeper
+
+
+
Kindly note below:
+
1. The same passport that was used for booking should also be used for ticket collection. A renewed passport won't be acceptable even if the holder is the same person. The system does not allow us to change passport number or passenger name after issue ticket. Have to issue new ticket if wrong passport number or name.
+
2. There is no further fee if collect train ticket(s) at the DEPARTURE station shown on your ticket(s). RMB 5 per ticket will be charged at a ticket counter at other stations. E.g. if you have booked Beijing-Shanghai and Shanghai-Beijing ticket(s), and you collect them all at Beijing, you will be charged RMB 5 per ticket for the Shanghai-Beijing ticket(s), but if you pick up the return leg ticket(s) separately in Shanghai you will avoid the charge.
+
3. On departure day, please time your arrival wisely. If you are going to collect your tickets on departure day, we suggest you be at the station at least 1.5 hours ahead of the stated departure time to allow for waiting in queue at the ticket-counter, for security checks and for ticket checks.
+If you’ve already collected before the departure day, it is also wise to be at the station at least 40 minutes ahead.
Best Regards!
+ Iris Wang, Travel Advisor
+ Tel: +86-773-2801368 Mobile:+86-18775900313
+ Fax: 86-773-2827424, 86-773-2885308
+ E-mail: iris@chinahighlights.me
+ www.chinahighlights.com
+ Address: Building 6, Chuangyi Business Park, 70 Qilidian Road, Guilin, Guangxi, 541004, China
+If you wish to share anything with my supervisor (Ms. Alex Yang), please feel free to send your email to alex@chinahighlights.net.
+
\ No newline at end of file
diff --git a/application/third_party/train_it/views/ht_order_list.html b/application/third_party/train_it/views/ht_order_list.html
new file mode 100644
index 00000000..dc7256e7
--- /dev/null
+++ b/application/third_party/train_it/views/ht_order_list.html
@@ -0,0 +1,59 @@
+
\ No newline at end of file
diff --git a/application/third_party/train_it/views/ht_train_order.html b/application/third_party/train_it/views/ht_train_order.html
new file mode 100644
index 00000000..ef399d0b
--- /dev/null
+++ b/application/third_party/train_it/views/ht_train_order.html
@@ -0,0 +1,112 @@
+
+
+
\ No newline at end of file
diff --git a/application/third_party/train_it/views/ht_train_order_info.php b/application/third_party/train_it/views/ht_train_order_info.php
new file mode 100644
index 00000000..6189118b
--- /dev/null
+++ b/application/third_party/train_it/views/ht_train_order_info.php
@@ -0,0 +1,169 @@
+
+
+
\ No newline at end of file
diff --git a/application/third_party/train_it/views/order.php b/application/third_party/train_it/views/order.php
new file mode 100644
index 00000000..f3bf123a
--- /dev/null
+++ b/application/third_party/train_it/views/order.php
@@ -0,0 +1,51 @@
+
\ No newline at end of file
diff --git a/application/third_party/train_it/views/refund.php b/application/third_party/train_it/views/refund.php
new file mode 100644
index 00000000..59382456
--- /dev/null
+++ b/application/third_party/train_it/views/refund.php
@@ -0,0 +1,41 @@
+