hotfix/远程访问多媒体中心
赵鹏 6 years ago
commit 2f9ea4884e

3
.gitignore vendored

@ -7,4 +7,7 @@
/kcfinder/cache/*
*/cache/*
/author/document/*
*/statement_files/*
*/paypal_activities/*
/author/document/*
/application/libraries/composer

@ -18,7 +18,26 @@ if (!defined('BASEPATH'))
| path to your installation.
|
*/
$config['base_url'] = '';
//CDN分发之后源站和前端域名不一致在这里修正否则程序生成的链接是源站的域名
$base_url='';
switch ($_SERVER['SERVER_NAME']){
case 'origin-ct.mycht.cn':
$base_url='https://ct.mycht.cn';
break;
case 'origin-gm.mycht.cn':
$base_url='https://gm.mycht.cn';
break;
case 'origin-cht.mycht.cn':
$base_url='https://cht.mycht.cn';
break;
case 'origin-int.mycht.cn':
$base_url='https://int.mycht.cn';
break;
default:$base_url='';
}
$config['base_url'] = $base_url;
/*
|--------------------------------------------------------------------------
@ -660,7 +679,7 @@ $config['media_image_url_remote2'] = 'http://116.251.217.48:3581/upload';
//是否开启权限控制
$config['check_access'] = TRUE;
//权限管理超级管理
$config['access_super_manage'] = array('ycc', 'lmr');
$config['access_super_manage'] = array('ycc', 'lmr', 'lyj');
//编辑器预览样式路径
$config['css_source_cht'] = '<link href="https://data.chinahighlights.com/css/min.php?f=/public/css/global.min.css,/css/festival-detail.css" rel="stylesheet">';

@ -1,158 +0,0 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Gaapi extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->permission->is_admin();
$this->site_code = $this->config->item('site_code');
//ga verder
$this->load->library('MY_Composer');
}
public function user_track()
{
$cid = $this->input->get_post('cid');
$analytics = $this->initializeAnalytics();
$response = $this->getReport($analytics, $cid);
$this->printResults($response);
}
/**
* Initializes an Analytics Reporting API V4 service object.
*
* @return An authorized Analytics Reporting API V4 service object.
*/
function initializeAnalytics()
{
// Use the developers console and download your service account
// credentials in JSON format. Place them in this directory or
// change the key file location if necessary.
$KEY_FILE_LOCATION = __DIR__ . '/gaapi_json/sylvan-box-234910-357cb59e6bf0.json';
// Create and configure a new client object.
$client = new Google_Client();
$client->setApplicationName("User Tracker");
$client->setAuthConfig($KEY_FILE_LOCATION);
$client->setScopes(['https://www.googleapis.com/auth/analytics.readonly']);
$analytics = new Google_Service_AnalyticsReporting($client);
return $analytics;
}
/**
* Queries the Analytics Reporting API V4.
*
* @param service An authorized Analytics Reporting API V4 service object.
* @return The Analytics Reporting API V4 response.
*/
function getReport($analytics, $cid_no)
{
//die($cid);
// Replace with your view ID, for example XXXX.
$VIEW_ID = "68484932";
// Create the DateRange object.
$dateRange = new Google_Service_AnalyticsReporting_DateRange();
$dateRange->setStartDate("30daysAgo");
$dateRange->setEndDate("today");
// Create the Metrics object.
$pv = new Google_Service_AnalyticsReporting_Metric();
$pv->setExpression("ga:pageviews");
$pv->setAlias("pageviews");
//Create the dimensions
$pageUrl = new Google_Service_AnalyticsReporting_Dimension();
$pageUrl->setName("ga:pagePath");
$cid = new Google_Service_AnalyticsReporting_Dimension();
$cid->setName("ga:dimension1");
$hitTime = new Google_Service_AnalyticsReporting_Dimension();
$hitTime->setName("ga:dimension3");
$ip = new Google_Service_AnalyticsReporting_Dimension();
$ip->setName("ga:dimension3");
// Create Dimension Filter 1
$cidFilter = new Google_Service_AnalyticsReporting_DimensionFilter();
$cidFilter->setDimensionName("ga:dimension1");
$cidFilter->setOperator('EXACT');
$cidFilter->setExpressions($cid_no);
// Create the DimensionFilterClauses
$dimensionFilterClause = new Google_Service_AnalyticsReporting_DimensionFilterClause();
$dimensionFilterClause->setFilters(array($cidFilter));
// OrderBy maybe some bugs
$order = new Google_Service_AnalyticsReporting_OrderBy;
$order->setFieldName("ga:dimension3");
$order->setOrderType("VALUE");
$order->setSortOrder("DESCENDING");
// Create the ReportRequest object.
$request = new Google_Service_AnalyticsReporting_ReportRequest();
$request->setViewId($VIEW_ID);
$request->setDateRanges($dateRange);
$request->setMetrics(array($pv));
$request->setDimensions(array($pageUrl, $cid, $hitTime));
$request->setDimensionFilterClauses(array($dimensionFilterClause));
$request->setOrderBys(array($order));
$body = new Google_Service_AnalyticsReporting_GetReportsRequest();
$body->setReportRequests(array($request));
return $analytics->reports->batchGet($body);
}
/**
* Parses and prints the Analytics Reporting API V4 response.
*
* @param An Analytics Reporting API V4 response.
*/
function printResults($reports)
{
$alais_array = array(
"ga:dimension1" => "cid",
"ga:dimension3" => "hitTime",
"ga:pagePath" => "path"
);
$rs_array = array();
for ($reportIndex = 0; $reportIndex < count($reports); $reportIndex++) {
$report = $reports[$reportIndex];
$header = $report->getColumnHeader();
$dimensionHeaders = $header->getDimensions();
$metricHeaders = $header->getMetricHeader()->getMetricHeaderEntries();
$rows = $report->getData()->getRows();
$rs_row = array();
for ($rowIndex = 0; $rowIndex < count($rows); $rowIndex++) {
$row = $rows[$rowIndex];
$dimensions = $row->getDimensions();
$metrics = $row->getMetrics();
for ($i = 0; $i < count($dimensionHeaders) && $i < count($dimensions); $i++) {
//print($dimensionHeaders[$i] . ": " . $dimensions[$i] . "\n");
$rs_row[$alais_array[$dimensionHeaders[$i]]] = $dimensions[$i];
}
for ($j = 0; $j < count($metrics); $j++) {
$values = $metrics[$j]->getValues();
for ($k = 0; $k < count($values); $k++) {
$entry = $metricHeaders[$k];
//print($entry->getName() . ": " . $values[$k] . "\n");
$rs_row[$entry->getName()] = $values[$k];
}
}
array_push($rs_array, $rs_row);
}
}
echo(json_encode($rs_array));
}
}
//end of gaapi

@ -1,12 +0,0 @@
{
"type": "service_account",
"project_id": "sylvan-box-234910",
"private_key_id": "357cb59e6bf066231fe9d421a1cada76b6af29ef",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDSNl/aj3hQf6bf\naPBHuGTLemiUl2OborE8MNvl5brhJMncTSslS1Q5CQRPk4K6nW1gAq2/gQ5KZ7Sd\nh9gdtWzIDoUS1DBDaZiPB8vVN6YOjIWpRSylIXTewQ6YYuw9kt7vW0orfDSsaWrE\nc2Yb5YN+6GTxVBjFEb19IYg5/8zfmvaUCOinDwO+F8mh6fCS9FyhiN5omKD+ixiQ\nYFIo1CM1SCpT3eH67JIF+hzuGAVWhF7YmdNTBdfrM0/1PBM8HRry0jD1VaDeyv+e\n4lTnPCtvUgc5SJOaLv/UR06X1FpIYikK0RHJ04fTslQxu7hTLqbhg/7d/+aj95K0\nAwaGERvdAgMBAAECggEAAOQZHFdoDVxwlSJEqeNyIDZh+GIfmnYQAUFhMKkOsPCc\nw9rtTxrNRxace0fd2sXtVkF8pp5dWTasmmIMPGNt+dLR7pP/z4Of2o9ZQcJR1vCp\nZc195rz/EL+AmGgLgZXg/5lxGhyDKhJ9vpORNt/FPiFALyOueJ/wslEnkZfwDANv\n0C+uIv2L3g0mrgTqXVwU/dVdYi9UK7hhn0YMgtlbdpxRHV0cIiilb23Cyy0QsFXN\n2MsoHPQWf+72nE+5jNnysXcR8AjAthzOvP/jIcqqBguid1w9F3goH4adLTa1aPIL\ndNGI/z9mwuqGQg5C78ZfmZMb3YIRwV4nmUia7kzrowKBgQDr2h14VyEGAypCjo+r\nXRvDti55PY+jKUnUzbseJca7Z1Z2snvGXWgkoasZc8ozsQjoH7wJJnRoJOGnAJdF\ntyZxtJV5W0pefB6Pfqy6k5MlJJhMy6lGpkQo96iPOBqfowHa1r/S55USHjQAMXG2\nKrX6oq1IWmEmFYMFZnQo7+SPqwKBgQDkK4rnCbirwHC0Z6eXkbk0Fb8KrS0huq3C\nupaoBtwkfkyISBzcXx6Bup/Gg7czSxvY6U/Bg93WtTzzJwVuqKSqcTUrwW4rAmrh\nZNEYjJc5YLKK1xXVOEeisMIsWCEpF8JHvyrCRsoBCOVRbQROFqz9IOSGrplw1Rq6\ntuPp2fsalwKBgQDgbfabG/X9vadKHFSUUY5pBwRkNHNpZJGwIXEMeBALJoN9gcwM\nb7f5G6owFyHzXGRIVmJdJq2gqG/dtc889NJtYtTV3UwAawW9sGH3TRS5RIB0m1xi\nMTcs8LYCSvXysG/EaZOxwtL0oa8D/AjjuvLeJEzWS8KkNdYunlas2dJZ7wKBgEAO\nlWV9jjHxyfJr81oTGDquLD80FSqV/ThhJ/CuVFmOd6//BtM7hRYIrdiOm/0zhfLk\ntXZvrfUcVqsw9k513BzZwYKyQFqkyBrVMfrBZac/JYDjF4cP0NS06R6H829U8z8v\nRTLbqtSVicPNZlsB9Ljv5hiFpiBOQ73NoLjDcMKrAoGAC+mrH9aOBeQuikQllpWJ\naZ7XoDdZcmh3j+o7OZWHAP3mpQ6q6/1iPW4lhG/q6l+syjsYRmQuzYICtSJ6xQlC\nM+AYPjD+O6sW3MWGz469cqrym8o+Bm24emxJNvilo/U/N2Yif2gUGWgw8qXLEGsu\nUedwiH6aWGBFnlVuPz6CZ6s=\n-----END PRIVATE KEY-----\n",
"client_email": "gaapi-904@sylvan-box-234910.iam.gserviceaccount.com",
"client_id": "112785767675412711830",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/gaapi-904%40sylvan-box-234910.iam.gserviceaccount.com"
}

@ -3,9 +3,11 @@
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Information extends CI_Controller {
class Information extends CI_Controller
{
function __construct() {
function __construct()
{
parent::__construct();
$this->permission->is_admin();
//$this->output->enable_profiler(TRUE);
@ -22,11 +24,13 @@ class Information extends CI_Controller {
$this->load->library('Amplib'); //加载AMP处理类
}
public function index() {
public function index()
{
echo '信息首页';
}
public function add($is_parent_id) {
public function add($is_parent_id)
{
//添加空内容.
$this->InfoContents_model->Add('', 'New Information', '', '', '', '', '', '', '', 0, 0, '', '', 0, 0, '', '', 0, '', 0, '', '');
$infocontent = $this->InfoContents_model->get_ic_contents($this->InfoContents_model->insert_id);
@ -44,7 +48,8 @@ class Information extends CI_Controller {
}
//移动结构顺序
public function move() {
public function move()
{
//网站会提交一个同级节点id列表字符串按照这个去排序
$parent_id = $this->input->post('pid');
$idsStr = $this->input->post('ids');
@ -65,7 +70,8 @@ class Information extends CI_Controller {
//把文章移动到任意板块文章下
//is_id 信息结构IDis_parent_id即将转移到的信息结构id
public function move_by_is_id() {
public function move_by_is_id()
{
$data = array();
$is_id = $this->input->post('is_id');
$is_parent_id = $this->input->post('is_parent_id');
@ -90,7 +96,8 @@ class Information extends CI_Controller {
return TRUE;
}
public function delete($is_id) {
public function delete($is_id)
{
//查询结构信息
$Structure = $this->InfoStructures_model->Detail($is_id);
if ($Structure == FALSE) {
@ -124,7 +131,8 @@ class Information extends CI_Controller {
}
}
public function edit($is_id) {
public function edit($is_id)
{
set_time_limit(30);
//$this->output->enable_profiler(true);
//查询结构信息
@ -188,37 +196,37 @@ class Information extends CI_Controller {
if ($Structure->is_sitecode=='ct'){
if ($Structure->is_sitecode == 'ct') {
$data['infoTypeList'] = $this->config->item('InfoType_ct');
}else {
} else {
switch ($data['rootInformation']->ic_ht_area_type) {
case 'c': //城市
$data['infoTypeList'] = $this->config->item('InfoType_city');
$data['unlink_landscape_list'] = $this->Information_model->get_unlink_landscape_list($data['rootInformation']->ic_ht_area_id);
break;
case 'p'://省份
case 'p': //省份
$data['infoTypeList'] = $this->config->item('InfoType_province');
break;
case 'n'://国家
case 'n': //国家
$data['infoTypeList'] = $this->config->item('InfoType_country');
break;
case 't'://特殊区域
case 't': //特殊区域
$data['infoTypeList'] = $this->config->item('InfoType_special');
break;
case 'e'://大洲
case 'e': //大洲
$data['infoTypeList'] = array();
break;
case 'z'://公民游
case 'z': //公民游
$data['infoTypeList'] = $this->config->item('InfoType_citizen');
break;
case 'v'://视频
case 'v': //视频
$data['infoTypeList'] = $this->config->item('InfoType_video');
break;
case 'f'://节庆
case 'f': //节庆
$data['infoTypeList'] = $this->config->item('InfoType_festival');
break;
case 'pd'://产品管理
case 'pd': //产品管理
$data['infoTypeList'] = $this->config->item('InfoType_product');
//LMR 2016-7-14
if (in_array($this->config->item('site_code'), array('vac', 'vc', 'jp', 'ru', 'it'))) {
@ -297,7 +305,8 @@ class Information extends CI_Controller {
exit();
} */
public function test_proxy($url = false) {
public function test_proxy($url = false)
{
$curl = curl_init();
//curl_setopt($curl,CURLOPT_URL, "http://graph.facebook.com/?id=http://www.chinahighlights.com");
//curl_setopt($curl,CURLOPT_URL, 'http://graph.facebook.com/?id=http://www.mybeijingchina.com/beijing-attractions/beihai-park/');
@ -313,7 +322,8 @@ class Information extends CI_Controller {
}
// 分享数 lzq
public function statistical_sharing() {
public function statistical_sharing()
{
//$info_ic = $this->Information_model->get_ic_url_by_code('mbj');
$info_ic = $this->Information_model->get_ic_url();
@ -355,7 +365,8 @@ class Information extends CI_Controller {
$this->load->view('bootstrap3/statistical_sharing');
}
public function edit_save() {
public function edit_save()
{
header('Cache-Control: no-cache');
$information = $this->Information_model->Detail($this->input->post('is_id'));
if ($information === false) {
@ -387,18 +398,18 @@ class Information extends CI_Controller {
//AMP更新和生成 beign
$auto_update_amp = $this->input->get_post('auto_update_amp');
if (!empty($auto_update_amp) && $auto_update_amp == 'true' && $this->input->post('ic_status') == 1) {
$amp_result=$this->amplib->auto_create($information->ic_id);
$amp_result = $this->amplib->auto_create($information->ic_id);
if (!empty($amp_result)) {
$amp_result = json_decode($amp_result);
if($amp_result->result=='ok'){
$amp_save_result= $this->amplib->edit_save($information->ic_id,$amp_result->data->amp,'1');
if(!empty($amp_save_result)){
$amp_save_result = json_decode($amp_save_result);
if($amp_save_result->name=='no'){
echo json_encode(array('name' => 'no', 'value' => 'AMP转换语法错误请重新进入AMP编辑器检查'));
return;
}
}
if ($amp_result->result == 'ok') {
$amp_save_result = $this->amplib->edit_save($information->ic_id, $amp_result->data->amp, '1');
if (!empty($amp_save_result)) {
$amp_save_result = json_decode($amp_save_result);
if ($amp_save_result->name == 'no') {
echo json_encode(array('name' => 'no', 'value' => 'AMP转换语法错误请重新进入AMP编辑器检查'));
return;
}
}
}
}
}
@ -428,7 +439,7 @@ class Information extends CI_Controller {
$update_info_log = $this->update_cache($ic_url, true);
} else if (strcasecmp($site_code, "cht") == 0 && !empty($auto_update_cache)) {
$update_info_log = $this->update_cache($ic_url);
} else if (strcasecmp($site_code, "cht") != 0 && strcasecmp($site_code, "gm") != 0) {//非cht站点并且非GM
} else if (strcasecmp($site_code, "cht") != 0 && strcasecmp($site_code, "gm") != 0) { //非cht站点并且非GM
$update_info_log = $this->update_cache($ic_url);
}
@ -470,7 +481,8 @@ class Information extends CI_Controller {
}
//URL不重复检查
function ic_url_check() {
function ic_url_check()
{
if ($this->input->post('ignore_url_check')) {
return true;
}
@ -484,7 +496,8 @@ class Information extends CI_Controller {
}
//URL格式检查不能包含大小写、空格等特殊字符
function ic_url_format($url) {
function ic_url_format($url)
{
if ($url != mb_strtolower($url) || strpos($url, ' ') !== false || strpos($url, '--') !== false || strpos($url, ')') !== false || strpos($url, '(') !== false || strpos($url, '//') !== false || strpos($url, '\\') !== false) {
return false;
}
@ -493,7 +506,8 @@ class Information extends CI_Controller {
//更新静态文件
//不用参数提交的原因是可能url带有特殊字符CI会报错
public function update_cache($static_html_url = false, $delete_only = false) {
public function update_cache($static_html_url = false, $delete_only = false)
{
$url = !empty($static_html_url) ? $static_html_url : $this->input->post('cache_url');
$url = str_replace($this->config->item('site_url'), '', $url);
$original_url = $url; //原始链接
@ -518,7 +532,7 @@ class Information extends CI_Controller {
case 'ah':
if ($delete_only === true) {
$url = 'https://www.asiahighlights.com/index.php/information/delete_cache_8X913mksJ/?static_html_url=' . $url;
} else {// static_html_optimize=comeon 启用静态化压缩和js、css延迟加载
} else { // static_html_optimize=comeon 启用静态化压缩和js、css延迟加载
$url = 'https://www.asiahighlights.com/index.php/information/detail/?static_html_url=' . $url . '&static_html_optimize=comeon';
}
break;
@ -534,16 +548,16 @@ class Information extends CI_Controller {
}
break;
case 'vac'://国际站
case 'vac': //国际站
case 'vc':
case 'it':
case 'ru':
case 'jp':
if ($delete_only) {
$information = $this->Information_model->Detail($url);
if ($delete_only || !$information || $information->ic_ht_area_type === 'q') {
//只删除操作在url修改和不发布信息的时候使用
$url = $this->config->item('site_url') . '/index.php/welcome/update_cache/delete_only?static_html_url=' . $url;
} else {
$information = $this->Information_model->Detail($url);
$tmp = $url;
//判断是否是更新信息
// 产品页面不能生成静态页面,比如/beijing/hotel/只是为了在导航显示一个链接,如果生成了静态页面,网前只会显示一个空白页面了
@ -558,9 +572,9 @@ class Information extends CI_Controller {
if (isset($information->ic_type) && $information->ic_type == 'product') {
$url = $this->config->item('site_url') . '/index.php/welcome/update_cache/?static_html_url=' . $tmp;
}
//int return direct
$cache_url = $this->input->post('cache_url');
if ($url && !$cache_url) {
//int return direct
$cache_url = $this->input->post('cache_url');
if ($url && !$cache_url) {
/*
ignore_user_abort(true);
$ch = curl_init();
@ -577,24 +591,25 @@ class Information extends CI_Controller {
curl_close($ch);
*/
$data['async_update'] = $url;
$data[] = array('name' => 'ok', 'value' => '信息保存成功请在8秒后检查更新页面。', 'url' => $url);
//如果是外部调用就返回结果,内部就不返回了
if ($cache_url) {
echo json_encode($data);
}
return $data;
}
$data[] = array('name' => 'ok', 'value' => '信息保存成功请在8秒后检查更新页面。', 'url' => $url);
//如果是外部调用就返回结果,内部就不返回了
if ($cache_url) {
echo json_encode($data);
}
return $data;
}
}
break;
case 'ct'://子站点使用
case 'ct': //子站点使用
case 'sht':
case 'gl':
case 'mbj':
case 'yz':
$url = $this->config->item('site_url') . $url . '@cache@refresh';
break;
default:return false;
default:
return false;
break;
}
@ -623,7 +638,8 @@ class Information extends CI_Controller {
}
//更新CDN缓存
public function update_cdn($static_html_url = false) {
public function update_cdn($static_html_url = false)
{
$flag = false; //false不更新true更新
$update_site = array('jp', 'ru'); //需要更新CDN的站点
//需要更新的url
@ -658,7 +674,8 @@ class Information extends CI_Controller {
}
//获取产品信息,提供给用户选择进行绑定
function get_products() {
function get_products()
{
$HT_productType = $this->input->post('product_type');
$HT_productName = $this->input->post('product_name');
//产品类型
@ -679,7 +696,8 @@ class Information extends CI_Controller {
}
//显示备份的内容
function backup_content($log_id) {
function backup_content($log_id)
{
$data['log_info'] = $this->Logs_model->read($log_id);
$data['log_list'] = $this->Logs_model->get_all_backup_list($data['log_info']->log_res_id);
$this->load->view('bootstrap/header', $data);
@ -688,7 +706,8 @@ class Information extends CI_Controller {
}
//保存自定义配置
function save_meta() {
function save_meta()
{
$im_ic_id = $this->input->post('im_ic_id');
$im_key = $this->input->post('im_key');
$im_value = $this->input->post('im_value');
@ -708,7 +727,8 @@ class Information extends CI_Controller {
}
//保存自定义配置
function delete_meta() {
function delete_meta()
{
$im_ic_id = $this->input->post('im_ic_id');
$im_key = $this->input->post('im_key');
if ($im_ic_id && $im_key) {
@ -721,5 +741,4 @@ class Information extends CI_Controller {
echo json_encode($data);
return true;
}
}

@ -123,6 +123,12 @@ class ctrip_train extends CI_Controller{
$rwNum = $Seats->TicketLeft;
}
/*if($Seats->SeatName == '一等双软下'){
$ydrwPrice = $Seats->Price * 10;
$SeaType .= '"I":"'.$ydrwPrice.'","AI":"¥'.$Seats->Price.'",';
$ydrwNum = $Seats->TicketLeft;
}*/
if($Seats->SeatName == '软座'){
$rzPrice = $Seats->Price * 10;
$SeaType .= '"2":"'.$rzPrice.'","A2":"¥'.$Seats->Price.'",';
@ -167,6 +173,12 @@ class ctrip_train extends CI_Controller{
$ywNum = $Seats->TicketLeft;
}
/*if($Seats->SeatName == '二等双软下'){
$errwPrice = $Seats->Price * 10;
$SeaType .= '"J":"'.$errwPrice.'","AJ":"¥'.$Seats->Price.'",';
$errwNum = $Seats->TicketLeft;
}*/
if($Seats->SeatName == '动卧下'){
$SeaType .= '"F":"¥'.$Seats->Price.'",';
$dwNum = $Seats->TicketLeft;
@ -175,6 +187,7 @@ class ctrip_train extends CI_Controller{
$PriceStr = $SeaType.'"train_no":'.'"'.$TrainInfo->TrainNo.'"';
}
//对返回的数据进行容错处理
$gjrwNum = isset($gjrwNum) ? ticket_exchange($gjrwNum,$iseven) : '';
$rwNum = isset($rwNum) ? ticket_exchange($rwNum,$iseven) : '';
@ -187,6 +200,17 @@ class ctrip_train extends CI_Controller{
$ydzNum = isset($ydzNum) ? ticket_exchange($ydzNum,$iseven) : '';
$swzNum = isset($swzNum) ? ticket_exchange($swzNum,$iseven) : '';
$dwNum = isset($dwNum) ? ticket_exchange($dwNum,$iseven) : '';
/*$ydrwNum = isset($ydrwNum) ? ticket_exchange($ydrwNum,$iseven) : '';
$errwNum = isset($errwNum) ? ticket_exchange($errwNum,$iseven) : '';
if($rwNum == '' && $ydrwNum != ''){
$rwNum = $ydrwNum;
}
if($ywNum == '' && $errwNum != ''){
$ywNum = $errwNum;
}*/
$runMin = $TrainInfo->DurationMinutes % 60;
$runHour = ($TrainInfo->DurationMinutes - $runMin) / 60;

@ -49,23 +49,6 @@ footer p { margin-bottom:0.5rem;}
#crumbNav a:hover { color: #a31022; text-decoration: none }
/* from font awesome */
@font-face{font-family:FontAwesome;src:url(https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/fonts/fontawesome-webfont.eot?v=4.7.0);src:url(https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/fonts/fontawesome-webfont.eot?#iefix&v=4.7.0) format('embedded-opentype'),url(https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/fonts/fontawesome-webfont.woff2?v=4.7.0) format('woff2'),url(https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/fonts/fontawesome-webfont.woff?v=4.7.0) format('woff'),url(https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/fonts/fontawesome-webfont.ttf?v=4.7.0) format('truetype'),url(https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular) format('svg');font-weight:400;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-facebook-square:before{content:"\f082"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-tripadvisor:before{content:"\f262"}.fa-500px:before{content:"\f26e"}.fa-angle-down:before{content:"\f107"}.fa-square-o:before{content:"\f096"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}
.fa-facebook-square:before { content: "\f082" }
.fa-facebook-f:before, .fa-facebook:before { content: "\f09a" }
.fa-twitter:before { content: "\f099" }
.fa-pinterest:before { content: "\f0d2" }
.fa-pinterest-square:before { content: "\f0d3" }
.fa-caret-down:before { content: "\f0d7" }
.fa-caret-up:before { content: "\f0d8" }
.fa-caret-left:before { content: "\f0d9" }
.fa-caret-right:before { content: "\f0da" }
.fa-instagram:before { content: "\f16d" }
.fa-flickr:before { content: "\f16e" }
.fa-tripadvisor:before { content: "\f262" }
.fa-500px:before { content: "\f26e" }
.fa-angle-down:before { content: "\f107" }
.fa-square-o:before { content: "\f096" }
.fa-angle-left:before { content: "\f104" }
.fa-angle-right:before { content: "\f105" }
.fa-navicon:before,.fa-reorder:before,.fa-bars:before { content: "\f0c9"; color:#333; margin:0.32rem 0 0 1rem; }
.fa-google-plus::before { content: "\f0d5";}
/* sidebar style */
@ -134,9 +117,9 @@ html{font-size:16px}
<section>
<h3 class="ampstart-nav-link amphtml-accordion-header"><a class="ampstart-nav-link" href="/china-tours/">China Tours</a> <i class="fa fa-angle-right" aria-hidden="true"></i></h3>
<ul class="ampstart-dropdown-items list-reset ">
<li><a href="/china-tours/ct-1.htm">Classic China Tour from $1,419</a></li>
<li><a href="/china-tours/ct-2.htm">The History and Nature of China from $1,999</a></li>
<li><a href="/china-tours/ct-3.htm">China Adventure Journey from $2149</a></li>
<li><a href="/china-tours/ct-1.htm">Classic China Tour</a></li>
<li><a href="/china-tours/ct-2.htm">The History and Nature of China</a></li>
<li><a href="/china-tours/ct-3.htm">China Adventure Journey</a></li>
<li><a href="/china-tours/theme/china-panda-tours/">Panda Tours</a></li>
<li><a href="/china-tours/top-10-china-tours.htm"> See All Top 10 China Tours</a></li>
</ul>

@ -731,7 +731,7 @@
});
$("#btn-add-personinfo-box").click();
// $("#btn-add-personinfo-box").click();
//日期初始化

@ -25,7 +25,6 @@
<h3>Contact Information</h3>
<p style="margin:0;">Land line:<?php if (isset($postdata['landline'])) echo $postdata['landline']; ?></p>
<p style="margin:0;">Mobile:<?php if (isset($postdata['mobile'])) echo $postdata['mobile']; ?></p>
<p style="margin:0;">Home Address:<?php if (isset($MEI_Street)) echo $MEI_Street; ?></p>
<h4 class="text-red" style="box-sizing:border-box;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight:500;line-height:1.1;color:#AA2E2D;margin-top:10px;margin-bottom:15px;font-size:24px;padding:12px 0 12px 0;border-bottom:1px solid #dddddd;border-top:1px solid #dddddd;white-space:normal;background-color:#FFFFFF;">
Flight Information

@ -1,5 +1,13 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//途牛apiurl (测试)
//define("TUNIU_URL","218.94.82.118:13532");
//define("TUNIU_KEY","Te56CBQmorzJGeYIIK");
//途牛apiurl (正式)
define("TUNIU_URL","https://open.tuniu.cn");
define("TUNIU_KEY","AILvoDj8El7KCSMe25");
//聚合火车订票API key
define("JUHE_TRAIN_API_KEY","79f03107b921ef31310bd40a1415c1cb");
@ -52,6 +60,7 @@ $config["train_zw"]=array(
"2"=>"软座",
"3"=>"硬卧",
"1"=>"硬座",
"F"=>"动卧",
);
//数据库座次配对,包厢硬卧(5),无座(WZ),聚合没有
$config["db_train_zw"]=array(
@ -65,7 +74,7 @@ $config["db_train_zw"]=array(
"A"=>"6",
"S"=>"4",
"4"=>"4",
"F"=>"4",
"F"=>"F",
"3"=>"3",
"2"=>"2",
"1"=>"1",
@ -85,4 +94,8 @@ $config["train_passportty"]=array(
"2"=>"一代身份证",
"C"=>"港澳通行证",
"G"=>"台湾通行证"
);
);
//黑名单用户
$config['black_list'] = array('209582910','539152642','506157109','E66735489','E66735492','E80377215','G23001338','E95287649','345276546','PA4286015','G09382769','G26113116','G25996274','572309763','506620366','505897939','E71156367','E21961674','v716898','561669436','EL657289','533300106','482225223','514815909','592108236');

@ -0,0 +1,4 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
define("JUHE_API_KEY","123");

@ -1,5 +1,4 @@
<?php
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
@ -35,70 +34,152 @@ class Auto extends CI_Controller{
$this->code_zw=$this->config->item('train_zw');
$this->piaotype=$this->config->item('train_piaotype');
$this->passportty=$this->config->item('train_passportty');
$this->load->model("BIZ_train_model");//加载模型
$this->balance_api = "http://op.juhe.cn/trainTickets/balance.php";//余额
$this->load->model("BIZ_train_model");//加载模型
}
//index
public function index(){
echo 'index';
//print_r($black_list);
}
//用于自动出票,接收COLI_SN
//用于自动发送确认信
public function send_confirmmail(){
//header('Location: http://www.mycht.cn/info.php/apps/trainsystem/api/send_confirmmail');
die();
$mailarr = $this->BIZ_train_model->auto_sendmail();
foreach($mailarr as $obj){
$coli_id = $this->BIZ_train_model->cold_sn_get_coli_id($obj->JOL_COLD_SN);
$coli_id = $coli_id[0]->COLI_ID;
$juhe_order = $obj->JOL_JuheOrder;
$this->send_mail_to_guest($coli_id,$juhe_order);
}
}
//用于自动出票
public function auto_pay_ticket(){
//header('Location: http://www.mycht.cn/info.php/apps/trainsystem/addorders/auto_pay_ticket');
die();
date_default_timezone_set('Asia/Shanghai');
// $coli_sn="473013018";
$coli_sn = $this->input->post("coli_sn");
$list=new StdClass;
$back_data = 1;
if(!empty($coli_sn)){
$cold_sn=$this->BIZ_train_model->get_cold_sn($coli_sn);
$coli_id = $this->BIZ_train_model->coli_sn_get_coli_id($coli_sn);
$i = 0;
$list->info=array();
foreach ($cold_sn as $v) {
if($v->COLD_SPFS > 1){
//寄送票
$back_data = 0;
break;
}
$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);
if(count($list->info[$i]->people) > 5){
$back_data = 0;
break;
};
if((strtotime($list->info[$i]->train[0]->DepartureTime) - time())/3600 < 3 or (strtotime($list->info[$i]->train[0]->DepartureTime) - time())/24/3600 >29){
$back_data = 0;
break;
}
if($list->info[$i]->train[0]->adultcost > 1000){
$back_data = 0;
break;
}
$i++;
}
if($back_data == 0){
echo 0;
return false;
}else{
foreach ($cold_sn as $v) {
$reback = $this->submit_juhe_order($v->COLD_SN,$coli_id[0]->COLI_ID);
if($reback["status"] && !empty($reback["order"])){
$back_data .= ",".$reback["order"];
}
}
}
$back_data = substr($back_data, 2);
if($back_data){ //这里 $back_data 还有可能没数据,所以判断一下
echo $back_data;
}else{
echo 0;
}
return false;
}
//$this->BIZ_train_model->auto_add();
//判断账户余额如果小于1000自动退出。
$post_data=array("key"=>$this->key);
$back_data=$this->post_data($this->balance_api,$post_data);
$price = json_decode($back_data)->result;
print_r('账户余额:'.$price);
if($price < 1000){
exit('账户余额不足');
}
//筛选出能自动出票的订单
$auto_pool = $this->BIZ_train_model->auto_check_ticket();
//创建一个不允许自动出票的国际火车票数组
$nation_train = array('K19', 'K23', 'Z8701', 'Z8702', 'Z97', 'Z98', 'Z99', 'Z100', 'K9795');
//创建黑名单
$black_list = $this->config->item('black_list');
$string = '';
foreach($auto_pool as $item){
$this->ticketype = 1;
$back_message = '';
$cold_sn = $item->COLD_SN;
$coli_id = $item->coli_id;
$back_data = 1;
$people_arr = $this->BIZ_train_model->biz_people($cold_sn);
$train_info = $this->BIZ_train_model->get_biz_foi($cold_sn);
//print_r($train_info);
if($item->COLD_SPFS > 1){
//寄送票
$back_data = 0;
$back_message .= '-邮寄不自动出票';
}
//乘客人数大于5人不出票
if(count($people_arr) > 5){
$back_data = 0;
$back_message .= '-乘客人数大于5不自动出票';
}
//护照号如果在黑名单的就不自动出票
foreach($people_arr as $people_info){
if(in_array($people_info->BPE_Passport,$black_list)){
$back_data = 0;
$back_message .= '-此用户为黑名单用户,不自动出票';
}
if(strlen($people_info->BPE_Passport) >= 18){
$back_data = 0;
$back_message .= '-护照位数大于18不自动出票';
}
}
//单张票价不能大于1000人民币
if($train_info[0]->adultcost > 1000){
$back_data = 0;
$back_message .= '-单价大于1000不自动出票';
}
//如果为国际火车票就不出票
if(in_array($train_info[0]->FlightsNo, $nation_train)){
$back_data = 0;
$back_message .= '-国际火车票不自动出票';
}
//无座的订单不做出票
if($train_info[0]->Aircraft == 'WZ'){
$back_data = 0;
$back_message .= '-无座不自动出票';
}
//香港火车不自动出票
if($train_info[0]->DepartAirport == 'XJA'){
$back_data = 0;
$back_message .= '-香港火车不自动出票';
}
$DepartureDate = strtotime($train_info[0]->DepartureDate);
$time = time();
$depart_diff = ($DepartureDate - $time) / 86400;
if($train_info[0]->ArrivalAirport == 'XJA' && $train_info[0]->adultcost > 500 && $depart_diff > 5){
$back_data = 0;
$back_message .= '-内地香港火车金额大于500超过五天不自动出票';
}
//print_r($train_info);
//如果刚好是第三十天的订单
if(($item->COLI_State == '8' || $item->COLI_State == '63')){
$this->ticketype = 3;
$time_obj = $this->BIZ_train_model->get_saletime($train_info['0']->DepartAirport_cn);
//print_r($time_obj);
if(!empty($time_obj)){
$saletime = strtotime($time_obj->TST_saletime);
//echo $saletime;
$sale_diff = (time() - $saletime) / 3600;
if($sale_diff > 1){
$back_data = 0;
$back_message .= '-超过抢票时间';
}else if($sale_diff <0){
$back_data = 0;
$back_message .= '-未到抢票时间';
}
}
}
if($back_data == 0){
$string .= '<tr><td>汉特订单号:'.$coli_id.'('.$cold_sn.')'.$back_message.'</td></tr>';
}else{
//单个订单提交
$this->submit_juhe_order($cold_sn,$coli_id);
//$string .= '<tr><td>汉特订单号:'.$coli_id.'('.$cold_sn.')可以自动出票</td></tr>';
}
}
print_r('<table border="1">'.$string.'</table>');
}
//根据汉特订单明细表SN来获取车次乘客信息拼接成聚合提交订单的url
public function submit_juhe_order($cold_sn,$coli_id) {
// $cold_sn=$this->input->get("order");
@ -122,7 +203,15 @@ class Auto extends CI_Controller{
return false;
}
//选座功能
$selectseat = '';
$train_select = $data['train']->FOI_SelectedSeat;
$obj = explode(',',$train_select);
foreach($obj as $value){
$selectseat .= $value;
}
$data['people_list'] = $this->BIZ_train_model->biz_people($cold_sn);
if (empty($data['people_list'])) {
//显示错误,找不到用户信息
@ -130,6 +219,7 @@ class Auto extends CI_Controller{
echo json_encode($reback);
return false;
}
//前面做过判断,为什么还要再判断一次
if (count($data['people_list']) > 5) {
//显示错误,用户超过五个
$reback["mes"]="乘客不能超过五个";
@ -144,9 +234,13 @@ class Auto extends CI_Controller{
foreach ($data['people_list'] as $key => $item) {
$zwcode = $db_train_zw[$data['train']->Aircraft]; //座位简码
$zwname = $train_zw[$db_train_zw[$data['train']->Aircraft]]; //座位名称
//乘客姓名
$passengersename = trim($item->BPE_FirstName) . trim($item->BPE_MiddleName) . trim($item->BPE_LastName);
//乘客类型
//乘客姓名(聚合要求名字中不能出现空格字符)
$passengersename = str_replace(' ','',$item->BPE_FirstName) . str_replace(' ','',$item->BPE_MiddleName) . str_replace(' ','',$item->BPE_LastName);
//将/替换掉
$passengersename = str_replace('/','',$passengersename);
$passengersename = $this->chk_sp_name($passengersename);
//乘客类型
switch ($item->BPE_GuestType) {
case 1:
$piaotype = 1;
@ -161,9 +255,24 @@ class Auto extends CI_Controller{
$piaotypename = "成人票";
break;
}
$passporttypeseid = "B"; //护照
$passporttypeseidname = "护照";
$passportseno = $item->BPE_Passport;
//证件类型
switch ($item->BPE_PassportType){
case 'Travel Permit from Hong Kong / Macau':
$passporttypeseid = "C";
$passporttypeseidname = "港澳通行证";
break;
case 'Travel Permit from Taiwan':
$passporttypeseid = "G";
$passporttypeseidname = "台湾通行证";
break;
default :
$passporttypeseid = "B";
$passporttypeseidname = "护照";
break;
}
$passportseno = str_replace(' ','',$item->BPE_Passport);
$passengers.=',{"passengerid":' . ( ++$key) . ',"passengersename":"' . $passengersename . '","piaotype":"' . $piaotype . '","piaotypename":"' . $piaotypename . '","passporttypeseid":"' . $passporttypeseid . '","passporttypeseidname":"' . $passporttypeseidname . '","passportseno":"' . $passportseno . '","price":"1","zwcode":"' . $zwcode . '","zwname":"' . $zwname . '"}';
}
$passengers.="]";
@ -174,6 +283,8 @@ class Auto extends CI_Controller{
"key"=>$this->key,
"user_orderid"=>$cold_sn,//自定义订单号
"train_date"=>substr($data["train"]->DepartureDate, 0, 10),
"is_accept_standing"=>"no",
"choose_seats"=>$selectseat,
"from_station_name"=>$data["train"]->DepartAirport_cn,
"from_station_code"=>$data["train"]->DepartAirport,
"to_station_code"=>$data["train"]->ArrivalAirport,
@ -181,9 +292,22 @@ class Auto extends CI_Controller{
"passengers"=>$passengers,
"checi"=>$data["train"]->FlightsNo
);
// $bakc_json=$this->post_data($url,$post_data);
$arr = '';
foreach($post_data as $key=>$value){
$arr .= $key.'='.$value.';';
}
//return '汉特订单号:'.$coli_id.'-可以自动出票---'.$arr;
//echo '<br>';
//print_r($url);
//print_r($post_data);
//echo '<br>';
//print_r($post_data);
//die();
$bakc_json=$this->post_data($url,$post_data);
$bakc=json_decode($bakc_json);//json=>obj
$add_data=new StdClass();
$add_data->JOL_COLD_SN=(int)$cold_sn;
@ -201,17 +325,18 @@ class Auto extends CI_Controller{
$reback["status"]=1;
$reback["order"]=$bakc->result->orderid;
$reback["mes"]="订单提交成功,等待回调";
$this->send_mail_to_wl("订单:{$coli_id} 提交成功","翰特订单号:{$coli_id} ;聚合订单号:{$bakc->result->orderid}");
}else{
//$this->send_mail_to_wl("订单:{$coli_id} 提交成功","翰特订单号:{$coli_id} ;聚合订单号:{$bakc->result->orderid}",$coli_id);
}else{
$add_data->JOL_JuheOrder=null;
$reback["mes"]= $bakc_json;
$add_data->JOL_Status="e";
$this->send_mail_to_wl("订单:{$coli_id} 提交失败","翰特订单号:{$coli_id}");
// $this->send_mail_to_wl("订单:{$coli_id} 提交失败","翰特订单号:{$coli_id}",$coli_id);
}
$add_back_data=$this->BIZ_train_model->add_biz_jol($add_data);
//聚合返回数据之后记录到聚合订单表
$add_back_data=$this->BIZ_train_model->add_biz_jol($add_data,$this->ticketype);
return $reback;
}
public function ticket_status($coli_sn="",$jh_id=""){
if(empty($coli_sn)){
$coli_sn = $this->input->get("sn");
@ -246,99 +371,207 @@ class Auto extends CI_Controller{
$list->cols_id = $cols_id[0]->COLI_ID;
$this->load->view("ticket_status",$list);
}
//发邮件给外联
public function send_mail_to_wl($subject,$body){
$this->load->model("Sendmail_model");
$fromName = "csk";
$fromEmail = "csk@hainatravel.com";
$toName = "ethel";
$toEmail = "ethel@chinahighlights.com";
$this->Sendmail_model->SendGuest($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
//发邮件给外联
public function send_mail_to_wl($subject,$body,$coli_id){
//$subject = 'autopay ticket';
//$body = 'this is autopay ticket';
$this->load->model("Sendmail_model");
$fromName = "cyc";
$fromEmail = "cyc@hainatravel.com";
//获取该订单的操作员的邮箱以及姓名
$info = $this->BIZ_train_model->get_operatorInfo($coli_id);
$toName = $info[0]->OPI_Name;
$toEmail = $info[0]->OPI_Email;
$this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
}
//发邮件给客人
public function send_mail_to_guest($coli_id,$jh_order){
$this->load->model("Sendmail_model");
//发邮件给客人(测试)
public function send_mail_to_guest_old($coli_id,$jh_order){
$this->load->model("Sendmail_model");
$info = $this->BIZ_train_model->get_user_info($jh_order);
$guest = $this->BIZ_train_model->get_guest_info($coli_id);
$fromName = "sharon";
$fromEmail = "sharon@chinahighlights.com";
$toName = $guest[0]->GUT_LastName;
$toEmail = $guest[0]->GUT_Email;
$subject = "auto pay test $jh_order";
$body = "csk test train ticket $jh_order";
$this->Sendmail_model->SendGuest($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
//print_r($guest);
$operator_info = $this->BIZ_train_model->get_operatorInfo($coli_id);
$fromName = $operator_info[0]->Name;
$fromEmail = $operator_info[0]->OPI_Email;
$toName = $guest[0]->GUT_LastName.$guest[0]->GUT_FirstName;
$toEmail = $guest[0]->GUT_Email;//
$data['coli_id'] = $coli_id;
$data['toname'] = $toName;
$data['adult'] = $info->COLD_PersonNum;
$data['chlid'] = $info->COLD_ChildNum;
$data['baby'] = $info->COLD_BabyNum;
$data['price'] = $this->BIZ_train_model->get_paypal($coli_id);
$data['allpeople'] = $this->BIZ_train_model->biz_people($info->COLD_SN);
$data['train_info'] = $this->BIZ_train_model->get_biz_foi($info->COLD_SN);
$differtime = (strtotime($data['train_info'][0]->DepartureTime) - time()) / 3600;
$obj = $this->BIZ_train_model->get_biz_jol_info($info->COLD_SN,$jh_order);
$data['juhe_info'] = json_decode($obj->JOL_BackTxt);
$status = $obj->JOL_Status;
$data['operator'] = $operator_info;
$data['emailarr'] = explode(';',$operator_info[0]->Email);
$coach = array();
$seats = array();
$string = '';
foreach($data['juhe_info']->passengers as $item){
foreach(explode(',',$item->cxin) as $item){
if(strpos($item,'车厢')){
$item = str_replace('车厢','',$item);
array_push($coach,$item);
}else{
$find = array('座上铺','座中铺','座下铺','座');
$replace = array(' upper',' middle',' lower','');
$item = str_replace($find,$replace,$item);
array_push($seats,$item);
}
}
}
//判断车厢是否唯一,如果不唯一的话,分成两个车厢
if(count(array_unique($coach)) == 1){
$onlycoach = array_unique($coach);
$string .= 'Coach '.$onlycoach[0].',';
}else{
foreach (array_unique($coach) as $item_coach){
$string .= 'Coach '.$item_coach.',';
}
}
$string .= 'Seat ';
foreach($seats as $item_seat){
$string .= $item_seat.',';
}
$data['seatinfo'] = substr($string,0,strlen($string)-1);
if($status == '4' && $differtime > 0){
$subject = "Got payment and issued train ticket(s), Order No $coli_id";
$body = $this->load->view('email',$data,true);
print_r($body);
//$this->send_mail_to_wl("订单:{$coli_id} 出票成功","翰特订单号:{$coli_id};聚合订单号:{$jh_order}",$coli_id);
//发送邮件给客人
//$flag = $this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
}else if($status == '1' && $differtime < 18 && $differtime > 0){
$subject = "The train ticket(s) will be issued manually, Order No $coli_id";
$body = $this->load->view('email_fault',$data,true);
print_r($body);
//$this->send_mail_to_wl("订单:{$coli_id} 出票失败","翰特订单号:{$coli_id};聚合订单号:{$jh_order}",$coli_id);
//测试阶段,将失败邮件发送一份给操作外联。
//$flag = $this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$fromName,$fromEmail,$subject,$body);
//测试阶段,将失败邮件发送一份给操作外联。
//$this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
}else{
echo $jh_order.'不需要发邮件<br>';
//$this->BIZ_train_model->update_biz_jol(array("JOL_JuheOrder"=>$jh_order),array("JOL_SendMail"=>2));
$flag = false;
}
if($flag){
//$this->BIZ_train_model->update_biz_jol(array("JOL_JuheOrder"=>$jh_order),array("JOL_SendMail"=>1,"JOL_M_SN"=>$flag));
}
}
//
public function sub_callback(){
$data_post=$this->input->post();
// $data_post["data"]='{"from_station_name":"桂林北","from_station_code":"GBZ","to_station_name":"柳州","to_station_code":"LZZ","train_date":"2017-01-05","orderid":"111111H","user_orderid":"488015272","orderamount":null,"ordernumber":null,"checi":"K457","msg":"没有余票","status":"4","passengers":[{"passengerid":1,"passengersename":"CSK","piaotype":"1","piaotypename":"成人票","passporttypeseid":"B","passporttypeseidname":"护照","passportseno":"E132124","price":"1","zwcode":"1","zwname":"硬座"},{"passengerid":2,"passengersename":"TW","piaotype":"1","piaotypename":"成人票","passporttypeseid":"B","passporttypeseidname":"护照","passportseno":"E02030609","price":"1","zwcode":"1","zwname":"硬座"}],"refund_money":null,"sign":"a5bc2ac8ef2b3a4c1bca323c3898e748"}';
$data=json_decode($data_post["data"]);
$this->load->model("order_people_model","op");
$update_data=new StdClass();
$update_data->JOL_BackTxt=$data_post["data"];
$update_data->JOL_RebackMsg=$data->msg;
$update_data->JOL_Status=$data->status;
$update_data->JOL_JuheOrder=$data->orderid;
$update_data->JOL_Price=$data->passengers[0]->price;
$coli_id = $this->BIZ_train_model->cold_sn_get_coli_id($data->user_orderid);
$add_train_order_data = new StdClass;
if($data->status=="2"){
$post_data=array(
"key"=>$this->key,
"orderid"=>$data->orderid
);
$back_json=$this->my_post($this->pay_api,$post_data);
$back=json_decode($back_json);
$update_data->JOL_BackTxt=$back_json;
$update_data->JOL_RebackMsg=$back->reason;
}elseif($data->status=="4"){
//付款成功 写入TOC表
$add_train_order_data->TOC_Memo=$data->orderid;
$add_train_order_data->TOC_COLD_SN=$data->user_orderid;
$add_train_order_data->TOC_TrainNumber=$data->checi;
$add_train_order_data->TOC_DepartureDate=$data->train_date;
$add_train_order_data->TOC_TicketCost=$data->orderamount;
$add_train_order_data->poundage=(count($data->passengers)*2)."";//手续费,每人两块,转换成字符串
$add_train_order_data->FOI_TrainNetOrderNo=$data->ordernumber;
$this->op->add_train_order($add_train_order_data);
$this->send_mail_to_wl("订单:{$coli_id[0]->COLI_ID} 出票成功","翰特订单号:{$coli_id[0]->COLI_ID};聚合订单号:{$data->orderid}");
$this->send_mail_to_guest($coli_id[0]->COLI_ID,$data->orderid);
}elseif($data->status=="7"){
//退票成功 写入TOC表
$newtime="";//记录最新操作时间
$refund_passportseno="";//退票人护照号
$refund_money="";//退票金额
foreach ($data->passengers as $p) {
//找出退票人,规则:操作时间最新的
if($p->refundTimeline){//是否有退票操作
//$p->refundTimeline[count($p->refundTimeline)-1] 最新操作
if($p->refundTimeline[count($p->refundTimeline)-1]->time > $newtime){
$newtime=$p->refundTimeline[count($p->refundTimeline)-1]->time;
$refund_passportseno=$p->refundTimeline[count($p->refundTimeline)-1]->detail->passportseno;
$refund_money=$p->refundTimeline[count($p->refundTimeline)-1]->detail->returnmoney;
}
}
}
$add_train_order_data->TOC_Memo=$data->orderid." ".$refund_passportseno;
$add_train_order_data->TOC_COLD_SN=$data->user_orderid;
$add_train_order_data->TOC_TrainNumber=$data->checi;
$add_train_order_data->TOC_DepartureDate=$data->train_date;
$add_train_order_data->TOC_TicketCost=-$refund_money;
$add_train_order_data->FOI_TrainNetOrderNo=null;//退票不用更新取票号,以此在模型里面判断是否为退票消息
$this->op->add_train_order($add_train_order_data);
}else{
$this->send_mail_to_wl("订单:{$coli_id[0]->COLI_ID} 出票失败","翰特订单号:{$coli_id[0]->COLI_ID};聚合订单号:{$data->orderid};返回信息:{$data->msg}");
}
$this->op->update_jh_order($update_data);
echo "success";
//发邮件给客人
public function send_mail_to_guest($coli_id,$jh_order){
$this->load->model("Sendmail_model");
$info = $this->BIZ_train_model->get_user_info($jh_order);
$guest = $this->BIZ_train_model->get_guest_info($coli_id);
//print_r($guest);
$operator_info = $this->BIZ_train_model->get_operatorInfo($coli_id);
$fromName = $operator_info[0]->Name;
$fromEmail = $operator_info[0]->OPI_Email;
$toName = $guest[0]->GUT_LastName.$guest[0]->GUT_FirstName;
$toEmail = $guest[0]->GUT_Email;//
$data['coli_id'] = $coli_id;
$data['toname'] = $toName;
$data['adult'] = $info->COLD_PersonNum;
$data['chlid'] = $info->COLD_ChildNum;
$data['baby'] = $info->COLD_BabyNum;
$data['price'] = $this->BIZ_train_model->get_paypal($coli_id);
$data['allpeople'] = $this->BIZ_train_model->biz_people($info->COLD_SN);
$data['train_info'] = $this->BIZ_train_model->get_biz_foi($info->COLD_SN);
$differtime = (strtotime($data['train_info'][0]->DepartureTime) - time()) / 3600;
$obj = $this->BIZ_train_model->get_biz_jol_info($info->COLD_SN,$jh_order);
$data['juhe_info'] = json_decode($obj->JOL_BackTxt);
$status = $obj->JOL_Status;
$data['operator'] = $operator_info;
$data['emailarr'] = explode(';',$operator_info[0]->Email);
$coach = array();
$seats = array();
$string = '';
foreach($data['juhe_info']->passengers as $item){
foreach(explode(',',$item->cxin) as $item){
if(strpos($item,'车厢')){
$item = str_replace('车厢','',$item);
array_push($coach,$item);
}else{
$find = array('座上铺','座中铺','座下铺','座');
$replace = array(' upper',' middle',' lower','');
$item = str_replace($find,$replace,$item);
array_push($seats,$item);
}
}
}
//判断车厢是否唯一,如果不唯一的话,分成两个车厢
if(count(array_unique($coach)) == 1){
$onlycoach = array_unique($coach);
$string .= 'Coach '.$onlycoach[0].',';
}else{
foreach (array_unique($coach) as $item_coach){
$string .= 'Coach '.$item_coach.',';
}
}
$string .= 'Seat ';
foreach($seats as $item_seat){
$string .= $item_seat.',';
}
$data['seatinfo'] = substr($string,0,strlen($string)-1);
if($status == '4' && $differtime > 0){
$subject = "Got payment and issued train ticket(s), Order No $coli_id";
$body = $this->load->view('email',$data,true);
$this->send_mail_to_wl("订单:{$coli_id} 出票成功","翰特订单号:{$coli_id};聚合订单号:{$jh_order}",$coli_id);
//发送邮件给客人
$flag = $this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
$this->BIZ_train_model->update_biz_jol(array("JOL_JuheOrder"=>$jh_order),array("JOL_SendMail"=>1,"JOL_M_SN"=>$flag));
}else if($status == '1' && $differtime < 18 && $differtime > 0){
$subject = "The train ticket(s) will be issued manually, Order No $coli_id";
$body = $this->load->view('email_fault',$data,true);
$this->send_mail_to_wl("订单:{$coli_id} 出票失败","翰特订单号:{$coli_id};聚合订单号:{$jh_order}",$coli_id);
//测试阶段,将失败邮件发送一份给操作外联。
$flag = $this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$fromName,$fromEmail,$subject,$body);
//测试阶段,将失败邮件发送一份给操作外联。
$this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
$this->BIZ_train_model->update_biz_jol(array("JOL_JuheOrder"=>$jh_order),array("JOL_SendMail"=>1,"JOL_M_SN"=>$flag));
}else{
echo $jh_order.'不需要发邮件<br>';
$this->BIZ_train_model->update_biz_jol(array("JOL_JuheOrder"=>$jh_order),array("JOL_SendMail"=>2));
$flag = false;
}
}
//存储火车票开售时间
public function add_sale_time(){
$time = '18:00';
$str = '';
$station_arr = explode('、',$str);
foreach($station_arr as $station){
$this->BIZ_train_model->sale_time_station($station,$time);
}
}
public function update_sale_time(){
$this->BIZ_train_model->test();
}
function my_post($url,$post_data){
// $url = "http://op.juhe.cn/trainTickets/cityCode";
// $post_from = array("stationName" => $from,"key"=>"79f03107b921ef31310bd40a1415c1cb");
@ -380,6 +613,15 @@ class Auto extends CI_Controller{
// $output=json_decode($output,TRUE);//json => array
return $output;
}
}
function chk_sp_name($name){
$name = str_replace(
array('á', 'é', 'è', 'í', 'ó', 'ú', 'ñ', 'Á', 'É', 'Í', 'Ó', 'Ú', 'Ñ',' ','/',' ',','),
array('a', 'e', 'e', 'i', 'o', 'u', 'n', 'A', 'E', 'I', 'O', 'U', 'N','','','',''),
$name
);
return substr(strtoupper($name),0,30);
}
}
}

File diff suppressed because one or more lines are too long

@ -0,0 +1,585 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
//帐号密钥
define("ORDERUSER","guilintravel");
define("ORDERKEY","07f811fe29f04008a8fcc86e81c012b9");
//数据返回格式地址
define("JSONRETURN","http://m.ctrip.com/restapi/soa2/12976/json/");
define("XMLRETURN","http://m.ctrip.com/restapi/soa2/12976/xml/");
class ctrip_train extends CI_Controller{
public function __construct(){
parent::__construct();
$this->load->helper("train");//加载模型
$this->load->model("ctrip_train_model");//加载模型
}
public function addorders(){
//接收参数
$cold_sn = $this->input->get("order");
$bpe_sn = $this->input->get("people");
$SelectSeat = $this->input->get("selectseat");
$data = array();
$rebakc = array();//返回数据
$rebakc["status"] = 0;
$rebakc["mes"] = "";
if(!is_numeric($cold_sn)){
$rebakc["mes"] = "订单号是数字";
echo json_encode($rebakc);
return false;
}
if(empty($bpe_sn)){
$rebakc["mes"] = "请选择乘客";
echo json_encode($rebakc);
return false;
}
$data['train'] = $this->ctrip_train_model->biz_order_detail($cold_sn);
$data['people_list'] = $this->ctrip_train_model->in_bpesn_people_info($bpe_sn);
/*print_r($data['train']);
print_r($data['people_list']);*/
//生成订单号
$OrderNumber = ORDERUSER.time();
if (empty($data['train'])) {
//显示错误,找不到车次
$rebakc["mes"] = "找不到车次";
echo json_encode($rebakc);
return false;
}
if (empty($data['people_list'])) {
//显示错误,找不到用户信息
$rebakc["mes"] = "找不到乘客信息";
echo json_encode($rebakc);
return false;
}
if (count($data['people_list']) > 5) {
//显示错误,用户超过五个
$rebakc["mes"] = "乘客不能超过五个";
echo json_encode($rebakc);
return false;
}
$db_train_zw = $this->config->item('db_train_zw');
$train_zw = $this->config->item('train_zw');
$zwcode = $db_train_zw[$data['train']->Aircraft]; //座位简码
$zwname = $train_zw[$db_train_zw[$data['train']->Aircraft]]; //座位名称
$black_list = $this->config->item('black_list');
//拼接发送的报文
$PostData = array();
$TimeStamp = time();
$time = date('Y-m-d H:i:s',$TimeStamp);
$PostData['Authentication']->TimeStamp = $time;
$PostData['Authentication']->ServiceName = 'order.PartnerAddOrder';
$PostData['Authentication']->PartnerName = ORDERUSER;
$MessageIdentity = md5($time.'order.PartnerAddOrder'.ORDERKEY);
$PostData['Authentication']->MessageIdentity = $MessageIdentity;
$PostData['TrainOrderService']->PartnerName = ORDERUSER;
$PostData['TrainOrderService']->Operation = '';
$PostData['TrainOrderService']->OrderType = '电子';
$PostData['TrainOrderService']->OrderTicketType = '0';
$PostData['TrainOrderService']->OrderNumber = $OrderNumber;
$PostData['TrainOrderService']->ChannelName = ORDERUSER;
$PostData['TrainOrderService']->Order->OrderTime = $time;
$PostData['TrainOrderService']->Order->OrderMedia = 'pc';
$PostData['TrainOrderService']->Order->Insurance = 'N';
$PostData['TrainOrderService']->Order->Invoice = 'N';
$PostData['TrainOrderService']->Order->PrivateCustomization = '0';
$PostData['TrainOrderService']->Order->TicketItem->FromStationName = $data['train']->DepartAirport_cn;
$PostData['TrainOrderService']->Order->TicketItem->ToStationName = $data['train']->ArrivalAirport_cn;
$PostData['TrainOrderService']->Order->TicketItem->TicketTime = date('Y-m-d H:i:s',strtotime($data['train']->DepartureTime));
$PostData['TrainOrderService']->Order->TicketItem->TrainNumber = $data['train']->FlightsNo;
$PostData['TrainOrderService']->Order->TicketItem->ArrivalDateTime = date('Y-m-d H:i:s',strtotime($data['train']->ArrivalTime));
$PostData['TrainOrderService']->Order->TicketItem->TicketPrice = $data['train']->adultcost;
$PostData['TrainOrderService']->Order->TicketItem->TicketCount = count($data['people_list']);
$AdultNum = 0;
$ChildNum = 0;
$Passport = '';
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 'Travel Permit from Hong Kong / Macau':
$PassportTypeseidName = "港澳通行证";
break;
case 'Travel Permit from Taiwan':
$PassportTypeseId = "G";
$PassportTypeseidName = "台湾通行证";
break;
default :
$PassportTypeseId = "B";
$PassportTypeseidName = "护照";
break;
}
//$Passport .= chk_sp_name($PassagerInfo->BPE_FirstName.$PassagerInfo->BPE_MiddleName.$PassagerInfo->BPE_LastName).','.$PassportTypeseidName.','.$PassagerInfo->BPE_Passport.','.$PiaoTypeName.','.''.',0|';
if($PiaoType == 1){
$RelatioNme = chk_sp_name($PassagerInfo->BPE_FirstName.$PassagerInfo->BPE_MiddleName.$PassagerInfo->BPE_LastName);
$Passport .= chk_sp_name($PassagerInfo->BPE_FirstName.$PassagerInfo->BPE_MiddleName.$PassagerInfo->BPE_LastName).','.$PassportTypeseidName.','.$PassagerInfo->BPE_Passport.','.$PiaoTypeName.','.''.',0|';
}elseif($PiaoType == 2){
$Passport .= $RelatioNme.','.$PassportTypeseidName.','.$PassagerInfo->BPE_Passport.','.$PiaoTypeName.','.''.',0,'.chk_sp_name($PassagerInfo->BPE_FirstName.$PassagerInfo->BPE_MiddleName.$PassagerInfo->BPE_LastName).'|';
}
}
$PostData['TrainOrderService']->Order->TicketItem->AuditTicketCount = $AdultNum;
$PostData['TrainOrderService']->Order->TicketItem->ChildTicketCount = $ChildNum;
$PostData['TrainOrderService']->Order->TicketItem->SeatName = $train_zw[$db_train_zw[$data['train']->Aircraft]];
$PostData['TrainOrderService']->Order->TicketItem->SelectedSeat = $SelectSeat;
$PostData['TrainOrderService']->Order->TicketItem->AcceptSeat = '';
$PostData['TrainOrderService']->Order->TicketItem->passport = substr($Passport,0,strlen($Passport)-1);
$PostData['TrainOrderService']->Order->TicketItem->OrderPrice = $data['train']->adultcost * $AdultNum + $data['train']->childcost * $ChildNum;
$PostData['TrainOrderService']->Order->FrontSeatFlag = '0';
$PostData['TrainOrderService']->Order->User->UserID = '';
$PostData['TrainOrderService']->Order->User->UserName = 'guilintravel';
$PostData['TrainOrderService']->Order->User->userLoginName = 'guilintravel';
$PostData['TrainOrderService']->Order->User->UserMobile = '18877381547';
//print_r($PostData);die();
//本地添加记录
$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 = 'ctrip';
$add_data->isauto = 0;
//存储到数据库
$this->ctrip_train_model->add_orders($add_data);
$Url = 'http://m.ctrip.com/restapi/soa2/11009/json/PartnerAddOrder';
$ResponseJson = GetPost_http($Url,json_encode($PostData),'POST');
$ResponseData = json_decode($ResponseJson);
//echo '预定';
//print_r($ResponseData);
//预定请求成功后执行支付
if($ResponseData->Status == 'SUCCESS'){
//计算订单总价,进行支付
$total_price = $AdultNum * $data['train']->adultcost + $ChildNum * $data['train']->childcost;
$this->payorders($OrderNumber,$total_price);
$rebakc["status"] = 1;
$rebakc["order"] = $OrderNumber;
$rebakc["mes"] = "订单提交成功,等待回调";
echo json_encode($rebakc);
}
}
//取消订单
public function cancelorders(){
$CtripOrder = $this->input->post('CtripOrder');
$CtripOrder = '488110485_1543999756';
//生成报文
$PostData = array();
$TimeStamp = time();
$time = date('Y-m-d H:i:s',$TimeStamp);
$PostData['Authentication']->TimeStamp = $time;
$PostData['Authentication']->ServiceName = 'order.PartnerPayOrder';
$PostData['Authentication']->PartnerName = ORDERUSER;
$MessageIdentity = md5($time.'order.PartnerPayOrder'.ORDERKEY);
$PostData['Authentication']->MessageIdentity = $MessageIdentity;
$PostData['TrainOrderService']->PartnerName = ORDERUSER;
$PostData['TrainOrderService']->OrderNumber = $CtripOrder;
$PostData['TrainOrderService']->CancelTime = date('Y-m-d H:s:i',time());
$Url = 'http://ws-ordercenter-train.fat.ctripqa.com/orderCore/api/json/PartnerCancelOrder';
$ResponseData = GetPost_http($Url,json_encode($PostData),'POST');
print_r($ResponseData);
}
//请求支付
public function payorders($CtripOrder,$Price){
if(empty($CtripOrder) && !is_numeric($Price)){
exit('传参错误!');
}
//生成报文
$PostData = array();
$TimeStamp = time();
$time = date('Y-m-d H:i:s',$TimeStamp);
$PostData['Authentication']->TimeStamp = $time;
$PostData['Authentication']->ServiceName = 'order.PartnerPayOrder';
$PostData['Authentication']->PartnerName = ORDERUSER;
$MessageIdentity = md5($time.'order.PartnerPayOrder'.ORDERKEY);
$PostData['Authentication']->MessageIdentity = $MessageIdentity;
$PostData['TrainOrderService']->PartnerName = ORDERUSER;
$PostData['TrainOrderService']->OrderNumber = $CtripOrder;
$PostData['TrainOrderService']->PayedPrice = $Price;
//$PostData['TrainOrderService']->PayType = $time;
//$PostData['TrainOrderService']->TradeNumber = $time;
$Url = 'http://m.ctrip.com/restapi/soa2/11009/json/PartnerPayOrder';
$ResponseJson = GetPost_http($Url,json_encode($PostData),'POST');
$ResponseData = json_decode($ResponseJson);
//echo '支付';
//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":[]}}
}
//退票接口
public function returnticket(){
//接收数据
$CtripOrder = $this->input->get_post('CtripOrder');
$PassagerId = $this->input->get_post('PassagerId');
//根据获取到的订单号获取信息
if(empty($CtripOrder)){
exit('订单号为空');
}
$ReturnObj = $this->ctrip_train_model->get_passager_info($CtripOrder,$PassagerId);
if(empty($ReturnObj)){
exit('订单详情为空');
}
$PostData = array();
$TimeStamp = time();
$time = date('Y-m-d H:i:s',$TimeStamp);
$PostData['Authentication']->TimeStamp = $time;
$PostData['Authentication']->ServiceName = 'order.ticketReturn';
$PostData['Authentication']->PartnerName = ORDERUSER;
$MessageIdentity = md5($time.'order.ticketReturn'.ORDERKEY);
$PostData['Authentication']->MessageIdentity = $MessageIdentity;
$PostData['TrainOrderService']->contactName = '陈宇超';
$PostData['TrainOrderService']->contactMobile = '18877381547';
$PostData['TrainOrderService']->OrderNumber = $CtripOrder;
$PostData['TrainOrderService']->OperatorType = '0';
$PostData['TrainOrderService']->TicketInfo = '';
$PostData['TrainOrderService']->TicketInfo = array();
$i = 0;
foreach($ReturnObj as $items){
$PostData['TrainOrderService']->TicketInfo[$i]['eOrderNumber'] = $items->ts_elecnumber;
if($items->tst_ticketype == '儿童票'){
$PostData['TrainOrderService']->TicketInfo[$i]['eOrderType'] = '2';
}else{
$PostData['TrainOrderService']->TicketInfo[$i]['eOrderType'] = '1';
}
$PostData['TrainOrderService']->TicketInfo[$i]['seatNumber'] = $items->tst_seatdetail;
$PostData['TrainOrderService']->TicketInfo[$i]['passportName'] = $items->tst_realname;
$PostData['TrainOrderService']->TicketInfo[$i]['passport'] = $items->tst_numberid;
$PostData['TrainOrderService']->TicketInfo[$i]['realName'] = $items->tst_realname;
$i++;
}
//发起退票请求
$Url = 'http://m.ctrip.com/restapi/soa2/11009/json/PartnerReturnTicket';
$ResponseJson = GetPost_http($Url,json_encode($PostData),'POST');
$ResponseData = json_decode($ResponseJson);
//请求结束后,将乘客状态更改为出票状态
/*$ResponseData = new stdClass();
$ResponseData->Status = '';
$ResponseData->Status = 'SUCCESS';*/
if($ResponseData->Status == 'SUCCESS'){
echo "<script>alert('请求成功,正在处理退票...');location.href='".site_url("/apps/trainsystem/pages/refund?order=$CtripOrder")."';</script>";
}
//print_r($ResponseJson);
}
//火车票改签
public function rescheduleticket(){
//订单号
$CtripOrder = $this->input->get_post('CtripOrder');
//改签车次
$RescheduleTrainNumber = $this->input->get_post('RescheduleTrainNumber');
//改签出发站
$DepartStationName = $this->input->get_post('DepartStationName');
//改签到达站
$ArriveStationName = $this->input->get_post('ArriveStationName');
//改签车次票价
$RescheduleTicketPrice = $this->input->get_post('RescheduleTicketPrice');
//改签坐席
$RescheduleSeatName = $this->input->get_post('RescheduleSeatName');
//改签出发时间
$RescheduleDepartTime = $this->input->get_post('RescheduleDepartTime');
//改签到达时间
$RescheduleArriveTime = $this->input->get_post('RescheduleArriveTime');
//赋值测试
$CtripOrder = '488111988_1544754322';
$RescheduleTrainNumber = 'D8205';
$DepartStationName = '桂林';
$ArriveStationName = '南宁东';
$RescheduleTicketPrice = '128.5';
$RescheduleSeatName = '二等座';
$RescheduleDepartTime = '2019/01/01 10:38';
$RescheduleArriveTime = '2019/01/01 13:03';
$PostData = array();
$TimeStamp = time();
$time = date('Y-m-d H:i:s',$TimeStamp);
$PostData['Authentication']->TimeStamp = $time;
$PostData['Authentication']->ServiceName = 'order.partnerreschedule';
$PostData['Authentication']->PartnerName = ORDERUSER;
$MessageIdentity = md5($time.'order.partnerreschedule'.ORDERKEY);
$PostData['Authentication']->MessageIdentity = $MessageIdentity;
$PostData['TrainOrderService']->OrderNumber = $CtripOrder;
$PostData['TrainOrderService']->Operator = '陈宇超';
$PostData['TrainOrderService']->RescheduleTrainNumber = $RescheduleTrainNumber;
$PostData['TrainOrderService']->DepartStationName = $DepartStationName;
$PostData['TrainOrderService']->ArriveStationName = $ArriveStationName;
$PostData['TrainOrderService']->RescheduleDepartTime = $ArriveStationName;
$PostData['TrainOrderService']->RescheduleArriveTime = $ArriveStationName;
$PostData['TrainOrderService']->RescheduleTicketPrice = $RescheduleTicketPrice;
$PostData['TrainOrderService']->RescheduleSeatName = $RescheduleSeatName;
$PostData['TrainOrderService']->RescheduleTicketPassengerInfos = array();
$PostData['TrainOrderService']->RescheduleTicketPassengerInfos['0']['eOrderNumber'] = 'E1317265149';
$PostData['TrainOrderService']->RescheduleTicketPassengerInfos['0']['eOrderType'] = '1';
$PostData['TrainOrderService']->RescheduleTicketPassengerInfos['0']['realName'] = 'LISI';
$PostData['TrainOrderService']->RescheduleTicketPassengerInfos['0']['CarriageNo'] = '12';
$PostData['TrainOrderService']->RescheduleTicketPassengerInfos['0']['seatNumber'] = '877号';
$PostData['TrainOrderService']->RescheduleTicketPassengerInfos['0']['passportName'] = 'LISI';
$PostData['TrainOrderService']->RescheduleTicketPassengerInfos['0']['passport'] = '123456789';
$PostData['TrainOrderService']->RescheduleTicketPassengerInfos['1']['eOrderNumber'] = 'E1317265149';
$PostData['TrainOrderService']->RescheduleTicketPassengerInfos['1']['eOrderType'] = '1';
$PostData['TrainOrderService']->RescheduleTicketPassengerInfos['1']['realName'] = 'WANGWU';
$PostData['TrainOrderService']->RescheduleTicketPassengerInfos['1']['CarriageNo'] = '13';
$PostData['TrainOrderService']->RescheduleTicketPassengerInfos['1']['seatNumber'] = '878号';
$PostData['TrainOrderService']->RescheduleTicketPassengerInfos['1']['passportName'] = 'WANGWU';
$PostData['TrainOrderService']->RescheduleTicketPassengerInfos['1']['passport'] = '123456789';
//print_r(json_encode($PostData));die();
$Url = 'http://ws-ordercenter-train.fat.ctripqa.com/orderCore/api/json/PartnerReschedule';
$ResponseData = GetPost_http($Url,json_encode($PostData),'POST');
print_r($ResponseData);
}
//回调函数
public function ctrip_callback(){
$back_json = file_get_contents('php://input');
log_message('error','携程回调信息:'.$back_json);
/*$back_json = '{"Authentication":{"ServiceName":"web.order.returnTicketNotice","PartnerName":"tieyou","TimeStamp":"2019-1-18 11:35:22","MessageIdentity":"93F2BA3253829E8FAD29B5DEB7646A59"},"TrainOrderService":{"contactName":{},"contactMobile":{},"OrderNumber":"guilintravel1547778269","refundTicket":{"childBillId":{},"orderId":"8360041214","eOrderNumber":"EB59937931","eOrderType":"1","seatNumber":"01D\u53f7","passport":"544712454","passportName":"YANGFRANCISCHENG","realName":"YANGFRANCISCHENG","status":"1","reason":"\u9000\u7968\u6210\u529f\uff0c\u9000\u6b3e\u91d1\u989d:218.50\u5143"}}}';*/
$ctrip_backdata = json_decode($back_json);
//print_r($ctrip_backdata);
if(!empty($ctrip_backdata)){
$update_data = new stdClass();
$update_data->ServiceName = $ctrip_backdata->Authentication->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 = '';
if($update_data->ServiceName == 'web.order.notifyTicket'){
$update_data->OrderStatus = '4';
$update_data->ErrorMsg = '出票成功';
$update_data->ordernumber = $ctrip_backdata->TrainOrderService->OrderInfo->OrderNumber;
$update_data->OrderTotleFee = $ctrip_backdata->TrainOrderService->OrderInfo->OrderTotleFee;
$update_data->ElectronicOrderNumber = $ctrip_backdata->TrainOrderService->OrderInfo->ElectronicOrderNumber;
//新添加检票口信息
if(isset($ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->TicketCheck)){
if(!is_object($ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->TicketCheck)){
$update_data->TicketCheck = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->TicketCheck;
}
}
//获取总票数,由于携程接口单人和多人返回的数据结构不一致
$person_num = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->TicketCount;
//存储座位信息 转换为英文
$coach_arr = array();
$seats_arr = array();
$data_passager = new stdClass();
$string = '';
$i = 0;
if($person_num > 1){
foreach ($ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->DetailInfos->DetailInfo as $items){
if(strpos($items->SeatNo,'车厢')){
$coach = mb_substr($items->SeatNo,0,strpos($items->SeatNo,'车厢'));
array_push($coach_arr,$coach);
$seat = mb_substr($items->SeatNo,strpos($items->SeatNo,'车厢')+2,mb_strlen($items->SeatNo,'UTF8'));
$find = array('号');
$replace = array('');
$seat = str_replace($find,$replace,$seat);
array_push($seats_arr,$seat);
}
//对订票乘客进行存储
$data_passager->ordernumber = $ctrip_backdata->TrainOrderService->OrderInfo->OrderNumber;
$data_passager->realname = $items->PassengerName;
$data_passager->identitytype = $items->IdentityType;
$data_passager->numberid = $items->NumberID;
$data_passager->ticketype = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->TicketType;
$data_passager->ticketprice = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->OrderTicketPrice;
$data_passager->seatype = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->OrderTicketSeat;
$data_passager->seatdetail = $items->SeatNo;
$this->ctrip_train_model->add_passagers($data_passager);
$i++;
}
}else{
$seatinfo_html = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->DetailInfos->DetailInfo->SeatNo;
if(strpos($seatinfo_html,'车厢')){
$coach = mb_substr($seatinfo_html,0,strpos($seatinfo_html,'车厢'));
array_push($coach_arr,$coach);
$seat = mb_substr($seatinfo_html,strpos($seatinfo_html,'车厢')+2,mb_strlen($seatinfo_html,'UTF8'));
$find = array('号');
$replace = array('');
$seat = str_replace($find,$replace,$seat);
array_push($seats_arr,$seat);
}
//对订票乘客进行存储
$data_passager->ordernumber = $ctrip_backdata->TrainOrderService->OrderInfo->OrderNumber;
$data_passager->realname = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->DetailInfos->DetailInfo->PassengerName;
$data_passager->identitytype = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->DetailInfos->DetailInfo->IdentityType;
$data_passager->numberid = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->DetailInfos->DetailInfo->NumberID;
$data_passager->ticketype = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->TicketType;
$data_passager->ticketprice = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->OrderTicketPrice;
$data_passager->seatype = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->OrderTicketSeat;
$data_passager->seatdetail = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->DetailInfos->DetailInfo->SeatNo;
$this->ctrip_train_model->add_passagers($data_passager);
}
if(count(array_unique($coach_arr)) == 1){
$onlycoach = array_unique($coach_arr);
$update_data->seatsinfo .= 'Coach '.$onlycoach[0].',';
}else{
foreach (array_unique($coach_arr) as $item_coach){
$update_data->seatsinfo .= 'Coach '.$item_coach.',';
}
}
$update_data->seatsinfo .= 'Seat ';
foreach($seats_arr as $item_seat){
$update_data->seatsinfo .= $item_seat.',';
}
$update_data->seatsinfo = substr($update_data->seatsinfo,0,strlen($update_data->seatsinfo)-1);
$update_data->bookcallback = $back_json;
//添加支付记录
$add_train_payment_data->TOC_Memo = $update_data->ordernumber;
//根据订单号获取cold_sn
$order_info = $this->ctrip_train_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 = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfo->OrderTicketCheci;
$add_train_payment_data->TOC_DepartureDate = date('Y-m-d',strtotime($ctrip_backdata->TrainOrderService->OrderInfo->TicketInfo->OrderTicketYMD));
$add_train_payment_data->TOC_TicketCost = $update_data->OrderTotleFee;
$add_train_payment_data->poundage = ($person_num*5)."";//手续费,每人五块,转换成字符串
$add_train_payment_data->FOI_TrainNetOrderNo = $update_data->ElectronicOrderNumber;
//print_r($add_train_order_data);die();
$this->ctrip_train_model->add_train_payment($add_train_payment_data);
//记录供应商(瀚特)
$this->ctrip_train_model->update_cold_planvei_sn($cold_sn);
}else if($update_data->ServiceName == 'web.order.notifyNoTicket'){
$update_data->ordernumber = $ctrip_backdata->TrainOrderService->OrderInfo->OrderNumber;
$update_data->OrderStatus = '1';
$update_data->ErrorMsg = $ctrip_backdata->TrainOrderService->OrderInfo->NoTicketReasons;
$update_data->confirmcallback = $back_json;
}else if($update_data->ServiceName == 'web.order.returnTicketNotice'){
$update_data->ordernumber = $ctrip_backdata->TrainOrderService->OrderNumber;
$update_data->OrderStatus = '7';
$update_data->ErrorMsg = $ctrip_backdata->TrainOrderService->refundTicket->reason;
$update_data->returncallback = $back_json;
//退票时还需要单独对对每个乘客存储回调信息
$passpager_info = new stdClass();
$passpager_info->returncallback = $back_json;
$passpager_info->status = '7';
$passpager_info->ordernumber = $ctrip_backdata->TrainOrderService->OrderNumber;
$passpager_info->realname = $ctrip_backdata->TrainOrderService->refundTicket->realName;
$passpager_info->numberid = $ctrip_backdata->TrainOrderService->refundTicket->passport;
$this->ctrip_train_model->update_passpager_info($passpager_info);
}else if($update_data->ServiceName == 'web.order.requestRefund'){
$return_order = $ctrip_backdata->TrainOrderService->OrderInfo->OrderNumber;
$return_money = $ctrip_backdata->TrainOrderService->TotalRefundAmount;
//根据订单号获取cold_sn
$order_info = $this->ctrip_train_model->get_order_info($return_order);
$cold_sn = $order_info->ts_cold_sn;
//print_r($order_info);
$add_train_payment_data->TOC_Memo = $return_order.'_'.$ctrip_backdata->TrainOrderService->OrderInfo->OrderTid;
$add_train_payment_data->TOC_COLD_SN = $cold_sn;
$add_train_payment_data->TOC_TrainNumber = $order_info->ts_checi;
$add_train_payment_data->TOC_DepartureDate = $order_info->ts_startdate;
$add_train_payment_data->TOC_TicketCost = -$ctrip_backdata->TrainOrderService->TotalRefundAmount;
$add_train_payment_data->FOI_TrainNetOrderNo=null;
//print_r($add_train_payment_data);die();
$this->ctrip_train_model->add_train_payment($add_train_payment_data);
return false;
}
//更新订单信息(出票系统)
$this->ctrip_train_model->update_orders($update_data);
}
//print_r($update_data);
//print_r(json_decode($back_xml));
}
}

@ -23,7 +23,6 @@ class Index extends CI_Controller{
{
// header("Content-Type: text/html;charset=utf-8");
parent::__construct();
$this->config->load('config');
$this->order_status_msg=$this->config->item('train_order_status_msg');
$this->key=JUHE_TRAIN_API_KEY;
$this->cx_api=JUHE_TRAIN_CX_API;
@ -38,98 +37,46 @@ class Index extends CI_Controller{
$this->passportty=$this->config->item('train_passportty');
$this->load->model("BIZ_train_model");//加载模型
$this->load->model("order_people_model","op");
}
public function index()
public function index($coli_id=null){
header('Location: http://www.mycht.cn/info.php/apps/trainsystem/pages/');
$this->ht_train_order_info_test($coli_id);
// $this->load->view('bootstrap3/header');
// $this->load->view('welcome');
// $this->load->view('bootstrap3/footer');
}
public function index_test($coli_id=null)
{
$this->ht_train_order_info();
$this->ht_train_order_info_test($coli_id);
// $this->load->view('bootstrap3/header');
// $this->load->view('welcome');
// $this->load->view('bootstrap3/footer');
}
public function welcome(){
$this->load->view('bootstrap3/header');
$this->load->view('welcome');
$this->load->view('bootstrap3/footer');
}
public function export_bk(){
$from_date=$this->input->post("from_date");
$to_date=$this->input->post("to_date");
if(!empty($from_date) && !empty($to_date)){
$from_date=date("Y-m-d H:i",strtotime($from_date));
$to_date=date("Y-m-d H:i",strtotime($to_date));
$r="";//聚合返回的数据
$string_r="";//写入excel表格数据
$coli_id="";
$wl_name="";
$arr="";//整合完成的数组
$url=JUHE_TRAIN_EXPORT_API;//请求的url
$url.="?key=".$this->key;
$url.="&since=".$from_date;
$url.="&before=".$to_date;
$r=$this->get_data($url);
// $r=mb_convert_encoding($r, "utf-8", "gb2312");
$r=explode("\n",$r);
$excel_head='"记录编号","时间","火车票订单号","最新余额","信息","变化值","翰特订单号","外联"';
$excel_head=mb_convert_encoding($excel_head,"gbk","utf-8");
$string_r=$excel_head;
for($i=1;$i<count($r)-1;$i++){
$r_info=explode(",",$r[$i]);
$juhe_order=substr($r_info[4], 1,14);
$coli_id=$this->BIZ_train_model->jh_order_get_coli_id($juhe_order);
if($coli_id){
$r_info[6]=$coli_id[0]->COLI_ID;
$wl_name = $this->BIZ_train_model->get_operatorinfo($r_info[6]);
$r_info[7]=mb_convert_encoding($wl_name[0]->OPI_Name, "gbk", "utf-8");
// $r_info[7]=$wl_name[0]->OPI_Name;
}else{
$r_info[6]="";
$r_info[7]="";
}
$r_info[3]=mb_convert_encoding($r_info[3],"utf-8","gbk");
if(is_numeric(mb_strpos($r_info[3],"扣款"))){
$r_info[3]="票款";
}
if(is_numeric(mb_strpos($r_info[3],"扣手续费"))){
$r_info[3]="手续费";
}
if(is_numeric(mb_strpos($r_info[3],"线上退票成功"))){
$r_info[3]="退票费";
}
$r_info[3]=mb_convert_encoding($r_info[3],"gbk","utf-8");
$arr[]=$r_info;
}
$ht_order_sort = array();
$wl_name_sort = array();
foreach ($arr as $a) {
$wl_name_sort[] = $a[7];
}
foreach ($arr as $a) {
$ht_order_sort[] = $a[6];
}
array_multisort($wl_name_sort, $ht_order_sort,SORT_ASC, SORT_STRING, $arr);
foreach ($arr as $a) {
$ht_order_sort[] = $a[6];
$string_r.="\n"."$a[0],$a[2],$a[4],$a[5],$a[3],$a[1]".',"'.$a[6].'"'.',"'.$a[7].'"';
}
$string_r=mb_convert_encoding($string_r,"utf-8","gbk");
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:attachment;filename=juhe_train.csv");
echo $string_r;die;
}
$this->load->view('bootstrap3/header');
$this->load->view('export');
$this->load->view('bootstrap3/footer');
}
public function export(){
set_time_limit(0);
//创建跟踪号
$trackcode = $this->BIZ_train_model->getTrackingCode();
$from_date=$this->input->post("from_date");
$to_date=$this->input->post("to_date");
$examine=$this->input->post("examine");
//$operator=$this->input->post("operator");
$reback=array();//返回的数据
$reback["from_date"]=$from_date;
$reback["from_date"]=$from_date;
$reback["to_date"]=$to_date;
$reback["examine"]=$examine;
$group = array();
if(!empty($from_date) && !empty($to_date)){
$from_date=date("Y-m-d H:i",strtotime($from_date));
$to_date=date("Y-m-d H:i",strtotime($to_date));
@ -137,17 +84,44 @@ class Index extends CI_Controller{
$string_r="";//输出
$coli_id="";
$wl_name="";
$arr="";//整合完成的数组,写进excel表的数据
$arr = array();//整合完成的数组,写进excel表的数据
$url=JUHE_TRAIN_EXPORT_API;//请求的url
$url.="?key=".$this->key;
$url.="&since=".$from_date;
$url.="&before=".$to_date;
$r=$this->get_data($url);
$r=explode("\n",$r);
//print_r($r);
//die();
for($i=1;$i<count($r)-1;$i++){
$r_info=explode(",",$r[$i]);
$juhe_order=substr($r_info[4], 1,14);
$coli_id=$this->BIZ_train_model->jh_order_get_coli_id($juhe_order);
$juhe_order=substr($r_info[4], 1,strlen($r_info[4])-2);
$obj = $this->BIZ_train_model->jh_order_get_coli_id($juhe_order);
//print_r($obj);
if(!empty($obj)){
$coli_id = $obj[0]->COLI_ID;
$coli_sn = $obj[0]->COLI_SN;
}else{
echo $juhe_order;
}
$this->BIZ_train_model->linkTrackingCode($coli_sn,$trackcode);
/*if(empty($coli_sn) || empty($coli_sn)){
print_r($juhe_order);
}*/
/*
$flag = $this->BIZ_train_model->islink($coli_sn);
if($flag){
$this->BIZ_train_model->linkTrackingCode($coli_sn,$trackcode);
}else{
echo $coli_sn.'该订单还未关联财务表,不能导出账单。<br>';
die();
}
*/
//去掉数据两边的双引号
$r_info[2]=substr($r_info[2], stripos($r_info[2],'"')+1,strrpos($r_info[2],'"')-1);
$r_info[1]=substr($r_info[1], stripos($r_info[1],'"')+1,strrpos($r_info[1],'"')-1);
@ -156,10 +130,9 @@ class Index extends CI_Controller{
$r_info[7] = "";//储存外联名
$r_info[8] = "";//储存coli_id
if($coli_id){
$r_info[8] = $coli_id[0]->COLI_ID;
$r_info[8] = $coli_id;
$gri_no=$this->BIZ_train_model->get_gri_no($r_info[8]);//团名
$wl_name = $this->BIZ_train_model->get_operatorinfo($r_info[8]);
$wl_name = $this->BIZ_train_model->get_operatorinfo($r_info[8]);
if($gri_no){
$r_info[6] = $gri_no[0]->GRI_No;
}
@ -167,8 +140,9 @@ class Index extends CI_Controller{
$r_info[7] = $wl_name[0]->OPI_Name;
}
}
$r_info[3]=mb_convert_encoding($r_info[3],"utf-8","gbk");
//$r_info[3]=mb_convert_encoding($r_info[3],"utf-8","gbk");
if(is_numeric(mb_strpos($r_info[3],"充值"))){
if(is_numeric(mb_strpos($r_info[3],"扣款"))){
$r_info[3]="票款(有充值)";
@ -190,19 +164,39 @@ class Index extends CI_Controller{
$r_info[3]="退票费";
}
// $r_info[3]=mb_convert_encoding($r_info[3],"gbk","utf-8");
$r_info['trackcode'] = $trackcode;
$arr[]=$r_info;
/*
//根据外联的名字创建数组来存储对应外联的订单信息
if(!empty($r_info[7])){
if(!isset($group[$r_info[7]])){
$group[$r_info[7]] = array();
}
array_push($group[$r_info[7]],$r_info);
}*/
}
/*
//将存储好的分组重新循环出来。
foreach($group as $item){
foreach ($item as $value){
array_push($arr,$value);
}
}
*/
//die();
if(empty($examine)){
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:attachment;filename=juhe_train.xml");
header("Content-type:application/vnd.ms-excel;charset=utf-8");
header("Content-Disposition:attachment;filename=juhe_train.xls");
$string_r= $this->load->view("train_transaction_excel",array("arr"=>$arr),TRUE);
echo $string_r;die;
}else{
krsort($arr);//数组倒序
$reback["data"]=$arr;
}
}
$this->load->view('bootstrap3/header');
$this->load->view('export',$reback);
$this->load->view('bootstrap3/footer');
@ -220,6 +214,7 @@ class Index extends CI_Controller{
echo json_encode($reback);
return false;
}
public function search(){
$from=$this->input->post("from");
$to=$this->input->post("to");
@ -246,6 +241,7 @@ class Index extends CI_Controller{
die(json_encode(array("status"=>0,"mes"=>"站点名称错误")));
}
}
public function ch_train_search(){
$from=$this->input->get("from");
$to=$this->input->get("to");
@ -254,6 +250,7 @@ class Index extends CI_Controller{
$ticket=$this->post_data("http://op.juhe.cn/trainTickets/ticketsAvailable",$ticket_data);
$ticket=json_decode($ticket);
}
public function ch_train_search_t(){
// $seat_key = array(
@ -420,10 +417,12 @@ class Index extends CI_Controller{
$this->load->view('booking',$data);
$this->load->view('bootstrap3/footer');
}
//接收订单COLD_SN和客户BPE_SN 获取车次乘客信息拼接成聚合提交订单的url
public function get_sn_submit_juhe() {
$cold_sn=$this->input->get("order");
$bpe_sn=$this->input->get("people");
$selectseat=$this->input->get("selectseat");
$data = array();
$rebakc=array();//返回数据
$rebakc["status"]=0;
@ -465,12 +464,16 @@ class Index extends CI_Controller{
$train_zw = $this->config->item('train_zw');
$zwcode = $db_train_zw[$data['train']->Aircraft]; //座位简码
$zwname = $train_zw[$db_train_zw[$data['train']->Aircraft]]; //座位名称
$black_list = $this->config->item('black_list');
$passengers="";
foreach ($data['people_list'] as $key => $item) {
//乘客姓名
$passengersename = trim($item->BPE_FirstName) . trim($item->BPE_MiddleName) . trim($item->BPE_LastName);
//乘客类型
$passengersename = $item->BPE_FirstName.$item->BPE_MiddleName.$item->BPE_LastName;
//将特殊字符转换为正常字符以便于出票
$passengersename = $this->chk_sp_name($passengersename);
//乘客类型
switch ($item->BPE_GuestType) {
case 1:
$piaotype = 1;
@ -485,29 +488,89 @@ class Index extends CI_Controller{
$piaotypename = "成人票";
break;
}
$passporttypeseid = "B"; //护照
$passporttypeseidname = "护照";
$passportseno = $item->BPE_Passport;
$passengers.=',{"passengerid":' . ( ++$key) . ',"passengersename":"' . $passengersename . '","piaotype":"' . $piaotype . '","piaotypename":"' . $piaotypename . '","passporttypeseid":"' . $passporttypeseid . '","passporttypeseidname":"' . $passporttypeseidname . '","passportseno":"' . $passportseno . '","price":"1","zwcode":"' . $zwcode . '","zwname":"' . $zwname . '"}';
//证件类型
switch ($item->BPE_PassportType){
case 'Chinese ID':
$passporttypeseid = "1";
$passporttypeseidname = "二代身份证";
break;
case 'Travel Permit from Hong Kong / Macau':
$passporttypeseid = "C";
$passporttypeseidname = "港澳通行证";
break;
case 'Travel Permit from Taiwan':
$passporttypeseid = "G";
$passporttypeseidname = "台湾通行证";
break;
default :
$passporttypeseid = "B";
$passporttypeseidname = "护照";
break;
}
switch ($item->BPE_SEX){
case '100003':
$sex = 'F';
break;
case '100001':
$sex = 'M';
break;
}
$passportseno = str_replace(' ','',$item->BPE_Passport);
//添加一个判断护照号是否在黑名单
if(in_array($passportseno,$black_list)){
$rebakc["mes"]="乘客为黑名单用户";
echo json_encode($rebakc);
return false;
}
if($passporttypeseid == 'G'){
$passengers.=',{"passengerid":' . ( ++$key) . ',"passengersename":"' . $passengersename . '","piaotype":"' . $piaotype . '","piaotypename":"' . $piaotypename . '","passporttypeseid":"' . $passporttypeseid . '","passporttypeseidname":"' . $passporttypeseidname . '","passportseno":"' . $passportseno . '","price":"1","zwcode":"' . $zwcode . '","zwname":"' . $zwname . '","gatValidDateEnd":"'.$item->BPE_PassExpdate.'","gatBornDate":"'.$item->BPE_BirthDate.'","sexCode":"'.$sex.'"}';
}else{
$passengers.=',{"passengerid":' . ( ++$key) . ',"passengersename":"' . $passengersename . '","piaotype":"' . $piaotype . '","piaotypename":"' . $piaotypename . '","passporttypeseid":"' . $passporttypeseid . '","passporttypeseidname":"' . $passporttypeseidname . '","passportseno":"' . $passportseno . '","price":"1","zwcode":"' . $zwcode . '","zwname":"' . $zwname . '"}';
}
}
$passengers.="]";
$passengers = substr($passengers, 1);
$passengers = "[" . $passengers;
$url=$this->dp_api;
$post_data=array(
if(empty($selectseat)){
$post_data=array(
"key"=>$this->key,
"user_orderid"=>$cold_sn,//自定义订单号
"train_date"=>substr($data["train"]->DepartureDate, 0, 10),
"is_accept_standing"=>"no",
"from_station_name"=>$data["train"]->DepartAirport_cn,
"from_station_code"=>$data["train"]->DepartAirport,
"to_station_code"=>$data["train"]->ArrivalAirport,
"to_station_name"=>$data["train"]->ArrivalAirport_cn,
"passengers"=>$passengers,
"checi"=>$data["train"]->FlightsNo
);
);
}else{
$post_data=array(
"key"=>$this->key,
"user_orderid"=>$cold_sn,//自定义订单号
"train_date"=>substr($data["train"]->DepartureDate, 0, 10),
"is_accept_standing"=>"no",
"choose_seats"=>$selectseat,
"from_station_name"=>$data["train"]->DepartAirport_cn,
"from_station_code"=>$data["train"]->DepartAirport,
"to_station_code"=>$data["train"]->ArrivalAirport,
"to_station_name"=>$data["train"]->ArrivalAirport_cn,
"passengers"=>$passengers,
"checi"=>$data["train"]->FlightsNo
);
}
//print_r($post_data);
//die();
$bakc_json=$this->post_data($url,$post_data);
$bakc=json_decode($bakc_json);//json=>obj
$add_data=new StdClass();
$add_data->JOL_COLD_SN=(int)$cold_sn;
@ -530,15 +593,19 @@ class Index extends CI_Controller{
$rebakc["mes"]= $bakc_json;
$add_data->JOL_Status="e";
}
$add_back_data=$this->BIZ_train_model->add_biz_jol($add_data);
$isauto = false;
$add_back_data=$this->BIZ_train_model->add_biz_jol($add_data,$isauto);
echo json_encode($rebakc);
return false;
}
//根据汉特订单明细表SN来获取车次乘客信息拼接成聚合提交订单的url
public function submit_juhe_order() {
$cold_sn=$this->input->get("order");
$selectseat=$this->input->get("selectseat");
$data = array();
$rebakc=array();//返回数据
$rebakc["status"]=0;
@ -565,6 +632,7 @@ class Index extends CI_Controller{
echo json_encode($rebakc);
return false;
}
if (count($data['people_list']) > 5) {
//显示错误,用户超过五个
$rebakc["mes"]="乘客不能超过五个";
@ -574,14 +642,16 @@ class Index extends CI_Controller{
$db_train_zw = $this->config->item('db_train_zw');
$train_zw = $this->config->item('train_zw');
$black_list = $this->config->item('black_list');
$passengers='';
foreach ($data['people_list'] as $key => $item) {
$zwcode = $db_train_zw[$data['train']->Aircraft]; //座位简码
$zwname = $train_zw[$db_train_zw[$data['train']->Aircraft]]; //座位名称
//乘客姓名
$passengersename = trim($item->BPE_FirstName) . trim($item->BPE_MiddleName) . trim($item->BPE_LastName);
//乘客类型
$passengersename = $item->BPE_FirstName.$item->BPE_MiddleName.$item->BPE_LastName;
$passengersename = $this->chk_sp_name($passengersename);
//乘客类型
switch ($item->BPE_GuestType) {
case 1:
$piaotype = 1;
@ -596,9 +666,38 @@ class Index extends CI_Controller{
$piaotypename = "成人票";
break;
}
$passporttypeseid = "B"; //护照
$passporttypeseidname = "护照";
$passportseno = $item->BPE_Passport;
switch ($item->BPE_PassportType){
case 'Chinese ID':
$passporttypeseid = "1";
$passporttypeseidname = "二代身份证";
break;
case 'Travel Permit from Hong Kong / Macau':
$passporttypeseid = "C";
$passporttypeseidname = "港澳通行证";
break;
case 'Travel Permit from Taiwan':
$passporttypeseid = "G";
$passporttypeseidname = "台湾通行证";
break;
default :
$passporttypeseid = "B";
$passporttypeseidname = "护照";
break;
}
/*$passporttypeseid = "B"; //护照
$passporttypeseidname = "护照";*/
$passportseno = str_replace(' ','',$item->BPE_Passport);
//添加一个判断护照号是否在黑名单
if(in_array($passportseno,$black_list)){
$rebakc["mes"]="乘客为黑名单用";
echo json_encode($rebakc);
return false;
}
$passengers.=',{"passengerid":' . ( ++$key) . ',"passengersename":"' . $passengersename . '","piaotype":"' . $piaotype . '","piaotypename":"' . $piaotypename . '","passporttypeseid":"' . $passporttypeseid . '","passporttypeseidname":"' . $passporttypeseidname . '","passportseno":"' . $passportseno . '","price":"1","zwcode":"' . $zwcode . '","zwname":"' . $zwname . '"}';
}
$passengers.="]";
@ -609,13 +708,17 @@ class Index extends CI_Controller{
"key"=>$this->key,
"user_orderid"=>$cold_sn,//自定义订单号
"train_date"=>substr($data["train"]->DepartureDate, 0, 10),
"is_accept_standing"=>"no",
"choose_seats"=>$selectseat,
"from_station_name"=>$data["train"]->DepartAirport_cn,
"from_station_code"=>$data["train"]->DepartAirport,
"to_station_code"=>$data["train"]->ArrivalAirport,
"to_station_name"=>$data["train"]->ArrivalAirport_cn,
"passengers"=>$passengers,
"checi"=>$data["train"]->FlightsNo
);
);
//print_r($selectseat);
//die();
$bakc_json=$this->post_data($url,$post_data);
$bakc=json_decode($bakc_json);//json=>obj
@ -641,7 +744,8 @@ class Index extends CI_Controller{
$rebakc["mes"]= $bakc_json;
$add_data->JOL_Status="e";
}
$add_back_data=$this->BIZ_train_model->add_biz_jol($add_data);
$isauto = false;
$add_back_data=$this->BIZ_train_model->add_biz_jol($add_data,$isauto);
echo json_encode($rebakc);
return false;
@ -709,6 +813,7 @@ class Index extends CI_Controller{
"key"=>$this->key,
"user_orderid"=>$order,//自定义订单号
"train_date"=>substr($data->cold[0]->COLD_StartDate, 0, 10),
"is_accept_standing"=>"no",
"from_station_name"=>$data->cold[0]->LeaveStation,
"from_station_code"=>$data->cold[0]->DepartAirport,
"to_station_code"=>$data->cold[0]->ArrivalAirport,
@ -763,8 +868,51 @@ class Index extends CI_Controller{
die(json_encode($rebakc));
}
//测试支付
public function test_pay(){
$url=$this->dp_api;
$post_data=array(
"key"=>$this->key,
"user_orderid"=>'123456',//自定义订单号
"train_date"=>'2017-10-05',
"from_station_name"=>'桂林站',
"from_station_code"=>'GLZ',
"to_station_code"=>'GBZ',
"to_station_name"=>'桂林北',
"checi"=>"D8494",
"passengers"=>'[{
"passengerid":1,
"passengersename":"陈宇超",
"piaotype":"1",
"piaotypename":"成人票",
"passporttypeseid":"1",
"passporttypeseidname":"二代身份证",
"passportseno":"450302199208131039",
"price":"5.5",
"zwcode":"O",
"zwname":"二等座"
}]'
);
$bakc_json=$this->post_data($url,$post_data);
$bakc=json_decode($bakc_json);//json=>obj
print_r($bakc);
}
//测试
public function testjson(){
$post_data=array(
"key"=>$this->key,
"orderid"=>'JH150485160583226'
);
$back_json=$this->my_post($this->pay_api,$post_data);
print_r($back_json);
}
//回调控制
public function sub_callback(){
$data_post=$this->input->post();
log_message('error','聚合回调:'.json_encode($data_post));
$data=json_decode($data_post["data"]);
$this->load->model("order_people_model","op");
@ -780,9 +928,8 @@ class Index extends CI_Controller{
"orderid"=>$data->orderid
);
$back_json=$this->my_post($this->pay_api,$post_data);
$back=json_decode($back_json);
$update_data->JOL_BackTxt=$back_json;
$update_data->JOL_RebackMsg=$back->reason;
$update_data->JOL_BackTxt=json_encode($back_json);
$update_data->JOL_RebackMsg=$back_json['reason'];
}elseif($data->status=="4"){
//付款成功 写入TOC表
$add_train_order_data->TOC_Memo=$data->orderid;
@ -792,7 +939,45 @@ class Index extends CI_Controller{
$add_train_order_data->TOC_TicketCost=$data->orderamount;
$add_train_order_data->poundage=(count($data->passengers)*2)."";//手续费,每人两块,转换成字符串
$add_train_order_data->FOI_TrainNetOrderNo=$data->ordernumber;
$this->op->add_train_order($add_train_order_data);
$this->op->add_train_order($add_train_order_data);
$coach = array();
$seats = array();
$string = '';
$passagers = $data->passengers;
foreach($passagers as $item){
foreach(explode(',',$item->cxin) as $item){
if(strpos($item,'车厢')){
$item = str_replace('车厢','',$item);
array_push($coach,$item);
}else{
$find = array('座上铺','座中铺','座下铺','座');
$replace = array(' upper',' middle',' lower','');
$item = str_replace($find,$replace,$item);
array_push($seats,$item);
}
}
}
//判断车厢是否唯一,如果不唯一的话,分成两个车厢
if(count(array_unique($coach)) == 1){
$onlycoach = array_unique($coach);
$string .= 'Coach '.$onlycoach[0].',';
}else{
foreach (array_unique($coach) as $item_coach){
$string .= 'Coach '.$item_coach.',';
}
}
$string .= 'Seat ';
foreach($seats as $item_seat){
$string .= $item_seat.',';
}
$seatinfo = substr($string,0,strlen($string)-1);
$this->BIZ_train_model->addseatinfo($seatinfo,$add_train_order_data->TOC_COLD_SN);
//成功出票后对订单状态进行更新
//$this->update_state($add_train_order_data->TOC_COLD_SN,'4');
}elseif($data->status=="7"){
//退票成功 写入TOC表
$newtime="";//记录最新操作时间
@ -815,19 +1000,130 @@ class Index extends CI_Controller{
$add_train_order_data->TOC_DepartureDate=$data->train_date;
$add_train_order_data->TOC_TicketCost=-$refund_money;
$add_train_order_data->FOI_TrainNetOrderNo=null;//退票不用更新取票号,以此在模型里面判断是否为退票消息
//成功出票后对订单状态进行更新
//$this->update_state($add_train_order_data->TOC_COLD_SN,'7');
$this->op->add_train_order($add_train_order_data);
}
$this->op->update_cold_planvei_sn($data->user_orderid);
$this->op->update_jh_order($update_data);
echo "success";
}
//更新订单状态
public function update_state($cold_sn,$status){
//验证传参
if(empty($cold_sn) || empty($status)){
exit('传参错误');
}
$coli_sn = $this->BIZ_train_model->cold_sn_get_coli_sn($cold_sn);
$coli_sn = $coli_sn[0]->COLD_COLI_SN;
//获取订单站点
$web_code = $this->BIZ_train_model->get_order_webcode($coli_sn)->COLI_WebCode;
//判断CH的订单才做处理
if(strtoupper($web_code) == 'CHT'){
/*switch ($status){
case '4':
$status = '61';
break;
case '7':
$status = '64';
break;
default:
$status = '63';
break;
}*/
//先更新当前子订单
$this->BIZ_train_model->update_cold_state($status,$cold_sn);
//更新主订单状态
$this->BIZ_train_model->update_coli_state('63',$coli_sn);
/*
$all_train = $this->BIZ_train_model->get_alltrain($coli_sn);
$all_count = count($all_train);
$status_count = 0;
foreach($all_train as $value){
if($value->COLD_State == $status){
$status_count++;
}
}
//更新主订单状态
if($status_count >= $all_count){
$this->BIZ_train_model->update_coli_state($status,$coli_sn);
}else{
}*/
}
}
//发邮件给外联
public function send_mail_to_wl($subject,$body,$coli_id){
//$subject = 'autopay ticket';
//$body = 'this is autopay ticket';
$this->load->model("Sendmail_model");
$fromName = "cyc";
$fromEmail = "cyc@hainatravel.com";
//获取该订单的操作员的邮箱以及姓名
$info = $this->BIZ_train_model->get_operatorInfo($coli_id);
$toName = $info[0]->OPI_Name;
$toEmail = $info[0]->OPI_Email;
$this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
}
//发邮件给客人
public function send_mail_to_guest($coli_id,$jh_order){
$this->load->model("Sendmail_model");
$info = $this->BIZ_train_model->get_user_info($jh_order);
$guest = $this->BIZ_train_model->get_guest_info($coli_id);
$operator_info = $this->BIZ_train_model->get_operatorInfo($coli_id);
$fromName = $operator_info[0]->Name;
$fromEmail = $operator_info[0]->OPI_Email;
$toName = $guest[0]->GUT_LastName;
$toEmail = $guest[0]->GUT_Email;//
$data['coli_id'] = $coli_id;
$data['toname'] = $toName;
$data['adult'] = $info->COLD_PersonNum;
$data['chlid'] = $info->COLD_ChildNum;
$data['baby'] = $info->COLD_BabyNum;
$data['price'] = $this->BIZ_train_model->get_paypal($coli_id);
$data['allpeople'] = $this->BIZ_train_model->biz_people($info->COLD_SN);
$data['train_info'] = $this->BIZ_train_model->get_biz_foi($info->COLD_SN);
$data['juhe_info'] = json_decode($this->BIZ_train_model->get_biz_jol_info($info->COLD_SN,$jh_order)->JOL_BackTxt);
$data['operator'] = $operator_info;
$data['emailarr'] = explode(';',$operator_info[0]->Email);
/*$order = $jh_order;
$post_data=array(
"key"=>"79f03107b921ef31310bd40a1415c1cb",
"orderid"=>$order
);
$back_data=$this->my_post("http://op.juhe.cn/trainTickets/orderStatus",$post_data);
$data['result'] = $back_data['result'];
print_r($data['result']);*/
$subject = "Got payment and issued train ticket(s), Order No $coli_id";
$body = $this->load->view('email',$data,true);
//print_r($data);
//print_r($body);
//die();
//$this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
//测试阶段,将确认信发送一份给操作外联。
$this->Sendmail_model->SendMailToTable('cyc','cyc@hainatravel.com','cyc','cyc@hainatravel.com','确认信副本',$body);
}
//汉特&聚合 订单列表
public function ht_order_list(){
$this->load->model("order_people_model","op");
$page_size=10;
$page=$this->input->get("page");
$order=$this->input->get("order");
$web_code=$this->input->get("web_code");
$where="1=1";//搜索条件
$page_parameter="";//返回的分页条件参数
if(empty($page) or !is_numeric($page)){
@ -835,10 +1131,16 @@ class Index extends CI_Controller{
}
if(!empty($order)){
$where="BIZ_ConfirmLineInfo.COLI_ID='{$order}' OR JOL_JuheOrder='{$order}'";
$where2="where BIZ_ConfirmLineInfo.COLI_ID='{$order}' OR JOL_JuheOrder='{$order}'";
$list["order"]=$order;
$page_parameter="order=".$order."&";
$page_parameter="order=".$order;
}
if(!empty($web_code)){
$where="BIZ_ConfirmLineInfo.COLI_WebCode='{$web_code}'";
$page_parameter="web_code=".$web_code;
}
$data=$this->op->get_order($page_size,$page,$where);
//print_r($data);
$list["data"]=$data->list;
$this->load->library('pagination');
@ -860,8 +1162,7 @@ class Index extends CI_Controller{
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);
@ -889,9 +1190,13 @@ class Index extends CI_Controller{
$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");
public function ht_train_order_info($coli_id=null){
if($coli_id == null){
$cols_id=$this->input->post("ht_order");
}else{
$cols_id = $coli_id;
}
$list=new StdClass;
if(!empty($cols_id)){
$cold_sn=$this->BIZ_train_model->get_biz_cold($cols_id);
@ -921,6 +1226,45 @@ class Index extends CI_Controller{
$this->load->view('ht_train_order_info',$list);
$this->load->view('bootstrap3/footer');
}
//输入翰特订单号cols_id,获取火车订票的相关信息,模拟翰特订单详情页面
public function ht_train_order_info_test($coli_id=null){
if($coli_id == null){
$cols_id=$this->input->post("ht_order");
}else{
$cols_id = $coli_id;
}
$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";
}
//print_r($list);
$this->load->view('bootstrap3/header');
$this->load->view('ht_train_order_info_test',$list);
$this->load->view('bootstrap3/footer');
}
//订单信息填写
public function booking_write(){
$this->load->model("order_people_model","op");
@ -1088,13 +1432,17 @@ class Index extends CI_Controller{
$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"]
"JOL_RebackMsg"=>$back_data["result"]["msg"],
"JOL_Price"=>$back_data["result"]["orderamount"]
);
//print_r($back_data);
//die();
$this->load->model("BIZ_train_model");
//print_r($back_data);
//查询到订单最新情况,更新本地数据库
$this->BIZ_train_model->update_biz_jol(array("JOL_JuheOrder"=>$order),$data);
// var_dump($back_data);
@ -1103,6 +1451,8 @@ class Index extends CI_Controller{
$this->load->view('bootstrap3/footer');
}
}
//取消订单
public function cancel_order(){
if($order=$this->input->get("order")){
@ -1140,6 +1490,7 @@ class Index extends CI_Controller{
"JOL_Status"=>$back_data["result"]["status"],
"JOL_RebackMsg"=>$back_data["result"]["msg"]
);
//print_r($back_data);
$this->load->model("BIZ_train_model");
//查询到订单最新情况,更新本地数据库
$this->BIZ_train_model->update_biz_jol(array("JOL_JuheOrder"=>$order),$data);
@ -1155,6 +1506,20 @@ class Index extends CI_Controller{
$passporttypeseid=$this->input->get("passporttypeseid");
$ticket_no=$this->input->get("ticket_no");
$passengername=$this->input->get("name");
if(empty($ticket_no)){
$post_data=array(
"key"=>$this->key,
"orderid"=>$order
);
$back_data=$this->my_post($this->status_api,$post_data);
foreach($back_data['result']['passengers'] as $items){
if($items['passengersename'] == $passengername && $items['passportseno']){
$ticket_no = $items['ticket_no'];
$passporttypeseid = $items['passporttypeseid'];
}
}
}
if(!empty($order) && !empty($passportseno) && !empty($passporttypeseid) && !empty($ticket_no) && !empty($passengername)){
$post_data=array(
@ -1162,6 +1527,7 @@ class Index extends CI_Controller{
"orderid"=>$order,
"tickets"=>'[{"ticket_no":"'.$ticket_no.'","passengername":"'.$passengername.'","passporttypeseid":"'.$passporttypeseid.'","passportseno":"'.$passportseno.'"}]',
);
//print_r($post_data);die();
$back_data=$this->my_post($this->refund_api,$post_data);
if($back_data["error_code"]==0){
@ -1170,6 +1536,22 @@ class Index extends CI_Controller{
}
return;
}
public function get_mailinfo($m_sn=null){
if(!$m_sn){
exit('error!!请联系cyc');
}
$obj = $this->BIZ_train_model->get_mail($m_sn);
if($obj->M_State){
echo '<span style="color:green;">邮件发送成功</span><br>提交时间:'.$obj->M_AddTime.'<br>';
}else{
echo '<span style="color:red;">邮件已提交但还未发送成功10分钟后刷新查看最新状态</span><br>提交时间:'.$obj->M_AddTime.'<br>';
}
echo '<span>发件邮箱:'.$obj->M_ReplyToEmail.'</span>';
echo '<hr/>';
print_r($obj->M_Body);
}
function my_post($url,$post_data){
// $url = "http://op.juhe.cn/trainTickets/cityCode";
// $post_from = array("stationName" => $from,"key"=>"79f03107b921ef31310bd40a1415c1cb");
@ -1212,5 +1594,17 @@ class Index extends CI_Controller{
// $output=json_decode($output,TRUE);//json => array
return $output;
}
function chk_sp_name($name){
$name = str_replace(
array('á', 'é', 'è', 'í', 'ó', 'ú', 'ñ', 'Á', 'É', 'Í', 'Ó', 'Ú', 'Ñ',' ','/',' ',','),
array('a', 'e', 'e', 'i', 'o', 'u', 'n', 'A', 'E', 'I', 'O', 'U', 'N','','','',''),
$name
);
return substr(strtoupper($name),0,30);
}
public function test(){
$this->BIZ_train_model->test();
}
}

@ -0,0 +1,366 @@
<?php
/**
junjun.php
用于测试自动出票中出现的问题。
查询coli_sn来测试。
*/
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class junjun extends CI_Controller{
public function __construct() {
header("Content-Type: text/html;charset=utf-8");
parent::__construct();
$this->config->load('config');
$this->order_status_msg=$this->config->item('train_order_status_msg');
$this->key=JUHE_TRAIN_API_KEY;
$this->cx_api=JUHE_TRAIN_CX_API;
$this->dp_api=JUHE_TRAIN_DP_API;
$this->qxdd_api=JUHE_TRAIN_CANCEL_API;
$this->pay_api=JUHE_TRAIN_PAY_API;
$this->refund_api=JUHE_TRAIN_REFUND_API;
$this->status_api=JUHE_TRAIN_STATUS_API;
$this->code_zw=$this->config->item('train_zw');
$this->piaotype=$this->config->item('train_piaotype');
$this->passportty=$this->config->item('train_passportty');
$this->balance_api = "http://op.juhe.cn/trainTickets/balance.php";//余额
$this->load->model("BIZ_train_model");//加载模型
}
public function test(){
$arr = array('','');
print_r($arr);
echo count($arr);
if(!empty($arr)){
echo '123';
}
}
public function index(){
$this->ticketype = 1;
//筛选出能自动出票的订单
$auto_pool = $this->BIZ_train_model->auto_check_ticket();
//print_r($auto_pool);
$auto_pool = array('0'=>(object)array('COLD_SN'=>'488096935','coli_id'=>'180824444','COLI_State'=>'13'));
//print_r($auto_pool);
//创建一个不允许自动出票的国际火车票数组
$nation_train = array('K19', 'K23', 'Z8701', 'Z8702', 'Z97', 'Z98', 'Z99', 'Z100', 'K9795');
//创建黑名单
$black_list = $this->config->item('black_list');
$string = '';
foreach($auto_pool as $item){
$this->ticketype = 1;
$back_message = '';
$cold_sn = $item->COLD_SN;
$coli_id = $item->coli_id;
$back_data = 1;
$people_arr = $this->BIZ_train_model->biz_people($cold_sn);
$train_info = $this->BIZ_train_model->get_biz_foi($cold_sn);
/*
if($item->COLD_SPFS > 1){
//寄送票
$back_data = 0;
$back_message .= '-邮寄不自动出票';
}
*/
//乘客人数大于5人不出票
if(count($people_arr) > 5){
$back_data = 0;
$back_message .= '-乘客人数大于5不自动出票';
}
//护照号如果在黑名单的就不自动出票
foreach($people_arr as $people_info){
if(in_array($people_info->BPE_Passport,$black_list)){
$back_data = 0;
$back_message .= '-此用户为黑名单用户,不自动出票';
}
if(strlen($people_info->BPE_Passport) >= 18){
$back_data = 0;
$back_message .= '-护照位数大于18不自动出票';
}
}
//单张票价不能大于1000人民币
if($train_info[0]->adultcost > 1000){
$back_data = 0;
$back_message .= '-单价大于1000不自动出票';
}
//如果为国际火车票就不出票
if(in_array($train_info[0]->FlightsNo, $nation_train)){
$back_data = 0;
$back_message .= '-国际火车票不自动出票';
}
//无座的订单不做出票
if($train_info[0]->Aircraft == 'WZ'){
$back_data = 0;
$back_message .= '-无座不自动出票';
}
//香港火车不自动出票
if($train_info[0]->ArrivalAirport == 'XJA' || $train_info[0]->DepartAirport == 'XJA'){
$back_data = 0;
$back_message .= '-香港火车不自动出票';
}
//print_r($train_info);
//如果刚好是第三十天的订单
if(($item->COLI_State == '8' || $item->COLI_State == '63')){
$this->ticketype = 3;
$time_obj = $this->BIZ_train_model->get_saletime($train_info['0']->DepartAirport_cn);
if(!empty($time_obj)){
$saletime = strtotime($time_obj->TST_saletime);
$now_time = time();
$sale_diff = (time() - $saletime) / 3600;
if($sale_diff > 1){
$back_data = 0;
$back_message .= '-超过抢票时间';
}else if($sale_diff <0){
$back_data = 0;
$back_message .= '-未到抢票时间';
}
}
}
if($back_data == 0){
$string .= '<tr><td>汉特订单号:'.$coli_id.'('.$cold_sn.')'.$back_message.'</td></tr>';
}else{
//单个订单提交
//$this->submit_juhe_order($cold_sn,$coli_id);
$string .= '<tr><td>汉特订单号:'.$coli_id.'('.$cold_sn.')可以自动出票</td></tr>';
}
}
print_r('<table border="1">'.$string.'</table>');
}
public function submit_juhe_order($cold_sn,$coli_id) {
$this->load->model("BIZ_train_model");
$cold_sn='488079918';//488084043
//$cold_sn=$this->input->get("order");
//$bpe_sn=$this->input->get("people");
//$selectseat=$this->input->get("selectseat");
//$bpe_sn = '(473118360);
$data = array();
$rebakc=array();//返回数据
$rebakc["status"]=0;
$rebakc["mes"]="";
if(!is_numeric($cold_sn)){
$rebakc["mes"]="订单号是数字";
echo json_encode($rebakc);
return false;
}
if(empty($bpe_sn)){
$rebakc["mes"]="请选择乘客";
echo json_encode($rebakc);
return false;
}
$data['train'] = $this->BIZ_train_model->biz_order_detail($cold_sn);
$data['people_list']=$this->BIZ_train_model->in_bpesn_people_info($bpe_sn);
if (empty($data['train'])) {
//显示错误,找不到车次
$rebakc["mes"]="找不到车次";
echo json_encode($rebakc);
return false;
}
if (empty($data['people_list'])) {
//显示错误,找不到用户信息
$rebakc["mes"]="找不到乘客信息";
echo json_encode($rebakc);
return false;
}
if (count($data['people_list']) > 5) {
//显示错误,用户超过五个
$rebakc["mes"]="乘客不能超过五个";
echo json_encode($rebakc);
return false;
}
$db_train_zw = $this->config->item('db_train_zw');
$train_zw = $this->config->item('train_zw');
$zwcode = $db_train_zw[$data['train']->Aircraft]; //座位简码
$zwname = $train_zw[$db_train_zw[$data['train']->Aircraft]]; //座位名称
$black_list = $this->config->item('black_list');
$passengers="";
foreach ($data['people_list'] as $key => $item) {
//乘客姓名
$passengersename = $item->BPE_FirstName.$item->BPE_MiddleName.$item->BPE_LastName;
//将特殊字符转换为正常字符以便于出票
$passengersename = $this->chk_sp_name($passengersename);
//乘客类型
switch ($item->BPE_GuestType) {
case 1:
$piaotype = 1;
$piaotypename = "成人票";
break;
case 2:
$piaotype = 2;
$piaotypename = "儿童票";
break;
default://外国人应该就两种票吧
$piaotype = 1;
$piaotypename = "成人票";
break;
}
switch ($item->BPE_PassportType){
case 'Chinese ID':
$passporttypeseid = "1";
$passporttypeseidname = "二代身份证";
break;
case 'Travel Permit from Hong Kong / Macau':
$passporttypeseid = "C";
$passporttypeseidname = "港澳通行证";
break;
case 'Travel Permit from Taiwan':
$passporttypeseid = "G";
$passporttypeseidname = "台湾通行证";
break;
default :
$passporttypeseid = "B";
$passporttypeseidname = "护照";
break;
}
$passportseno = str_replace(' ','',$item->BPE_Passport);
//添加一个判断护照号是否在黑名单
if(in_array($passportseno,$black_list)){
$rebakc["mes"]="乘客为黑名单用户";
echo json_encode($rebakc);
return false;
}
$passengers.=',{"passengerid":' . ( ++$key) . ',"passengersename":"' . $passengersename . '","piaotype":"' . $piaotype . '","piaotypename":"' . $piaotypename . '","passporttypeseid":"' . $passporttypeseid . '","passporttypeseidname":"' . $passporttypeseidname . '","passportseno":"' . $passportseno . '","price":"1","zwcode":"' . $zwcode . '","zwname":"' . $zwname . '"}';
}
$passengers.="]";
$passengers = substr($passengers, 1);
$passengers = "[" . $passengers;
$url=$this->dp_api;
if(empty($selectseat)){
$post_data=array(
"key"=>$this->key,
"user_orderid"=>$cold_sn,//自定义订单号
"train_date"=>substr($data["train"]->DepartureDate, 0, 10),
"is_accept_standing"=>"no",
"from_station_name"=>$data["train"]->DepartAirport_cn,
"from_station_code"=>$data["train"]->DepartAirport,
"to_station_code"=>$data["train"]->ArrivalAirport,
"to_station_name"=>$data["train"]->ArrivalAirport_cn,
"passengers"=>$passengers,
"checi"=>$data["train"]->FlightsNo
);
}else{
$post_data=array(
"key"=>$this->key,
"user_orderid"=>$cold_sn,//自定义订单号
"train_date"=>substr($data["train"]->DepartureDate, 0, 10),
"is_accept_standing"=>"no",
"choose_seats"=>$selectseat,
"from_station_name"=>$data["train"]->DepartAirport_cn,
"from_station_code"=>$data["train"]->DepartAirport,
"to_station_code"=>$data["train"]->ArrivalAirport,
"to_station_name"=>$data["train"]->ArrivalAirport_cn,
"passengers"=>$passengers,
"checi"=>$data["train"]->FlightsNo
);
}
return $coli_id.'('.$cold_sn.')可以自动出票';
}
//
public function count_select(){
$obj = $this->BIZ_train_model->get_juhe_select();
//print_r($obj);
$html = '';
$html .= '<table border="1">';
$html .= '<tr><th>序号</th><th>聚合订单号</th><th>出票后信息</th><th>订单原信息</th><th>是否自动出票</th></tr>';
$i = 1;
foreach($obj as $item){
$html .= '<tr><td>'.$i.'</td><td>'.$item->JOL_JuheOrder.'</td>';
if(isset(json_decode($item->JOL_BackTxt)->passengers)){
$passengers = json_decode($item->JOL_BackTxt)->passengers;
}else{
$passengers = '';
}
$ex_obj = '';
if(!empty($passengers)){
foreach($passengers as $pass_tiem){
$ex_obj .= $pass_tiem->cxin;
}
}
if($item->JOL_IsAuto == '1'){
$item->JOL_IsAuto ='是';
}else{
$item->JOL_IsAuto ='否';
}
$html .= '<td>'.$ex_obj.'</td><td>'.$item->FOI_SelectedSeat.'</td><td>'.$item->JOL_IsAuto.'</td></tr>';
$i++;
}
$html .= '</table>';
echo $html;
}
public function update_juheorder(){
print_r($this->BIZ_train_model->test());
}
public function update_state($cold_sn){
//先更新当前订单
$flag = $this->BIZ_train_model->update_cold_state($cold_sn);
if(!$flag){
log_message('error','状态更新失败:'.$cold_sn);
}else{
$coli_sn = $this->BIZ_train_model->cold_sn_get_coli_sn($cold_sn);
$coli_sn = $coli_sn[0]->COLD_COLI_SN;
$all_train = $this->BIZ_train_model->get_alltrain($coli_sn);
$all_count = count($all_train);
$success_count = 0;
foreach($all_train as $value){
if($value->COLD_State == '61'){
$success_count++;
}
}
if($all_count == $success_count){
$this->BIZ_train_model->update_coli_state('61',$coli_sn);
}else{
$this->BIZ_train_model->update_coli_state('62',$coli_sn);
}
}
}
//测试发送邮件
public function test_send(){
$phone = '18677367018';
$name = 'sw';
$coli_id = '780258';
$email = 'sw@hainatravel.com';
$mail_data = array();
$mail_data['name'] = $name;
$mail_data['phone'] = $phone;
$mailtitle = 'Signup successfully on China Highlights Customer Center';
$mail_body = $this->load->view('train_help',$mail_data,true);
$fromName = 'China Highlights Customer Center';
$fromEmail = 'sharon@chinahighlights.net';
$toName = $name;
$toEmail = $email;
$this->load->model("Sendmail_model");
$this->Sendmail_model->SendMailToTable($fromName, $fromEmail, $toName, $toEmail, $mailtitle, $mail_body);
}
}
?>

@ -0,0 +1,251 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Tuniu_callback extends CI_Controller{
public function __construct(){
// header("Content-Type: text/html;charset=utf-8");
parent::__construct();
$this->load->library('Des');
$this->load->model("BIZ_train_model");
$this->load->model("tuniu_model");
}
/*
接收占位回调
*/
public function book(){
$back_json = file_get_contents('php://input');
log_message('error','预定占座回调:'.$back_json);
$back_data_one = json_decode(base64_decode($back_json));
$back_data = array();
$crypt = new DES();
$mstr = $crypt->decrypt($back_data_one->data,TUNIU_KEY);
$back_data_two = json_decode($mstr);
$back_data['errorMsg'] = $back_data_one->errorMsg;
$back_data['returnCode'] = $back_data_one->returnCode;
$back_data['retailOrderId'] = $back_data_two->retailOrderId;
$back_data['orderId'] = $back_data_two->orderId;
$back_data['orderAmount'] = $back_data_two->orderAmount;
$back_data['fromStationCode'] = $back_data_two->fromStationCode;
$back_data['fromStationName'] = $back_data_two->fromStationName;
$back_data['toStationCode'] = $back_data_two->toStationCode;
$back_data['toStationName'] = $back_data_two->toStationName;
$back_data['cheCi'] = $back_data_two->cheCi;
$back_data['backtxt'] = $mstr;
$back_data['status'] = '2';
//更新预定异步回调信息
$this->tuniu_model->book_tuniu_order($back_data);
if($back_data['returnCode'] == '231000'){
$url = 'http://www.mycht.cn/info.php/apps/train/tuniu_train/confirm_ticket/'.$back_data['retailOrderId'].'/'.$back_data['orderId'];
echo $url;
$this->get_http($url,'GET');
}
}
public function test(){
$back_json = "eyJlcnJvck1zZyI6IuihjOeoi+WGsueqgSIsInJldHVybkNvZGUiOjMwMywiZGF0YSI6IjBwZE4zaWlUWE1ISzFPRndGL2Evei9vZzc1dVZsSVpwVzBKTFdnS3dybUlaYWRUSnhEVmNZeW5ib1BZWFBNaWhJazVEVzBhYlBQbDhcbitXdWFCUUVsbmlzcWhBN1ZJSndEZEVvN0JCR0t4RXZ2K0wya090cEkvV01aK0JGTEFJc1hyYi9ZMWM5MTZnUjhIOUROYTdYdXpUV29cbkpzdmI0eTF6aUI5U3BIYWFPM2pQWXZyRHAvMUJCZndPanRuQVNVK2plcGNyMkZoekVJRDRMOHpRV0hMSFNRc2ZoVzVDeHpoQ1J0VUhcbmNFc0tpL212ZEVRcGFEb0diZE1JOWxlWUp4TFZWT0xrNUdCbEh0cGVSNTVBNTNtckVJbExiYU9TNGlRMURCQjUrUjAydzNDYldreHpcblcwWXFFT2U0Znc4R2U2QksyczFlVlYwc1VMSU90YzBZTU00TU4xeUpITHFMdGxieHFKclhjZTJjNi9WYTNjMnJDSk5DN1ltZ004NWVcbi9wYTk2VHNhaytoYUtSNUFncUQ4OXd4aUhETkNlQmEzRHpXMlh2NUZiYVRUc3RJcHRYbTZEaHo5U1Q3ZkJkcTlzYkhSMHdqMlY1Z25cbkV0VWVSR1F5a1hadTJqUDBaZjc5YTFHaCJ9";
//print_r(base64_encode($back_json));
$back_data = $this->tuniu_strdecrypt($back_json);
print_r($back_data);
//echo (count($back_data->data->passengers)*5);
}
/*
接收取消占位回调
*/
public function cancelbook(){
$back_json = file_get_contents('php://input');
$sn = 5830;
log_message('error','取消站位'.$back_json);
}
/*
接收确认出票回调
*/
public function confirm(){
$back_json = file_get_contents('php://input');
//$back_json = 'eyJlcnJvck1zZyI6IuWkhOeQhuaIluaTjeS9nOaIkOWKnyIsInJldHVybkNvZGUiOjIzMTAwMCwiZGF0YSI6eyJyZXRhaWxPcmRlcklkIjoiNDg4MDkzNDQ4XzE1MzM3OTQwMDIiLCJvcmRlcklkIjoiMTE4NDUxMjM5NyJ9fQ==';
$back_data = json_decode(base64_decode($back_json));
//print_r($back_data);
//die();
log_message('error','确认出票回调:'.$back_json);
$data = array();
$data['errorMsg'] = $back_data->errorMsg;
$data['returnCode'] = $back_data->returnCode;
$data['retailOrderId'] = $back_data->data->retailOrderId;
$data['orderId'] = $back_data->data->orderId;
$data['confirmtxt'] = $back_json;
if($back_data->returnCode != '231000'){
$data['status'] = '1';
}else{
$data['status'] = '4';
//通过订单号去获取预定时返回的信息
$bookobj = $this->tuniu_model->get_tuniuorder_info($data['retailOrderId'],$data['orderId']);
$bookinfo = json_decode($bookobj[0]->tol_booktxt);
$obj = explode('_',$back_data->data->retailOrderId);
$add_train_order_data->TOC_COLD_SN = $obj[0];
$add_train_order_data->TOC_Memo = $back_data->data->orderId;
$add_train_order_data->TOC_TrainNumber = $bookinfo->cheCi;
$add_train_order_data->TOC_DepartureDate = $bookinfo->trainDate;
$add_train_order_data->TOC_TicketCost = $bookinfo->orderAmount;
$add_train_order_data->FOI_TrainNetOrderNo = $bookinfo->orderNumber;
$add_train_order_data->poundage = (count($bookinfo->passengers)*3)."";
$this->tuniu_model->add_grab_order($add_train_order_data);
}
$this->tuniu_model->confirm_tuniu_order($data);
}
/*
接收退票回调
*/
public function return_ticket(){
$back_json = file_get_contents('php://input');
log_message('error','退票回调:'.$back_json);
$back_data = $this->tuniu_strdecrypt($back_json);
//更新途牛订单列表信息
$updata_data = array();
$updata_data['retailOrderId'] = $back_data->data->retailOrderId;
$updata_data['returnCode'] = $back_data->returnCode;
$updata_data['errorMsg'] = $back_data->errorMsg;
$updata_data['returntxt'] = json_encode($back_data);
$this->tuniu_model->return_tuniu_order($updata_data);
//添加瀚特信息(有问题)
/*$add_train_order_data = new stdClass();
$obj = explode('_',$back_data->data->retailOrderId);
$add_train_order_data->TOC_COLD_SN = $obj[0];
$add_train_order_data->TOC_Memo = $back_data->data->orderId." ".$back_data->data->returnTickets->passportNo;
$add_train_order_data->TOC_TrainNumber = $back_data->data->cheCi;
$add_train_order_data->TOC_TicketCost = $back_data->data->returnMoney;
$add_train_order_data->FOI_TrainNetOrderNo = null;
$this->tuniu_model->add_return_order($add_train_order_data);*/
}
/*
接收线下退款回调
*/
public function return_cash(){
echo '回调接收线下退款数据';
}
/*
接收抢票预定(占位)
*/
public function grabTicketBook(){
$back_json = file_get_contents('php://input');
$back_data = $this->tuniu_strdecrypt($back_json);
log_message('error','抢票预定:'.$back_json);
$update_data = array();
if($back_data->returnCode == '231000'){
$update_data['errorMsg'] = $back_data->errorMsg;
$update_data['returnCode'] = $back_data->returnCode;
$update_data['retailOrderId'] = $back_data->data->retailOrderId;
$update_data['orderId'] = $back_data->data->orderId;
$update_data['fromStationCode'] = $back_data->data->fromStationCode;
$update_data['fromStationName'] = $back_data->data->fromStationName;
$update_data['toStationCode'] = $back_data->data->toStationCode;
$update_data['toStationName'] = $back_data->data->toStationName;
$update_data['cheCi'] = $back_data->data->cheCi;
$update_data['orderAmount'] = $back_data->data->orderAmount;
$update_data['booktxt'] = json_encode($back_data);
//更新数据库信息
$this->tuniu_model->grab_tuniu_order($update_data);
//添加瀚特信息
$add_train_order_data = new stdClass();
$obj = explode('_',$back_data->data->retailOrderId);
$add_train_order_data->TOC_COLD_SN = $obj[0];
$add_train_order_data->TOC_Memo = $back_data->data->orderId;
$add_train_order_data->TOC_TrainNumber = $back_data->data->cheCi;
$add_train_order_data->TOC_DepartureDate = $back_data->data->trainDate;
$add_train_order_data->TOC_TicketCost = $back_data->data->orderAmount;
$add_train_order_data->FOI_TrainNetOrderNo = $back_data->data->orderNumber;
$add_train_order_data->poundage = (count($back_data->data->passengers)*5)."";
$this->tuniu_model->add_grab_order($add_train_order_data);
//print_r($update_data['booktxt']);
}else{
$update_data['retailOrderId'] = $back_data->data->retailOrderId;
$update_data['errorMsg'] = $back_data->errorMsg;
$update_data['returnCode'] = $back_data->returnCode;
$this->tuniu_model->update_status($update_data);
}
}
/*
接收取消抢票
*/
public function cancelTicketBook(){
$back_json = file_get_contents('php://input');
log_message('error','取消抢票:'.$back_json);
$back_data = json_decode(base64_decode($back_json));
$update_data = array();
$update_data['errorMsg'] = $back_data->errorMsg;
$update_data['returnCode'] = $back_data->returnCode;
$update_data['orderId'] = $back_data->data->orderId;
$update_data['retailOrderId'] = $back_data->data->retailOrderId;
$this->tuniu_model->cancelgragticket($update_data);
}
/*
接收改签预定
*/
public function change_occupy(){
echo '回调接收改签预定数据';
}
/*
接收改签确认
*/
public function change_confirm(){
echo '回调接收改签确认数据';
}
/*
接收改签预定
*/
public function change_cancel(){
echo '回调接收改签取消数据';
}
//解密方法
public function tuniu_strdecrypt($str){
$back_data_one = json_decode(base64_decode($str));
$back_data = array();
$crypt = new DES();
$mstr = $crypt->decrypt($back_data_one->data,TUNIU_KEY);
$back_data_one->data = json_decode($mstr);
return $back_data_one;
}
//发送请求函数
public function get_http($url, $data = '', $method = 'GET') {
$curl = curl_init(); // 启动一个CURL会话
curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转
curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer
if ($method == 'POST' && !empty($data)) {
curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
}
curl_setopt($curl, CURLOPT_TIMEOUT, 45); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
$tmpInfo = curl_exec($curl); // 执行操作
$errno = curl_errno($curl);
if ($errno !== 0) {
return false;
echo $errno . curl_error($curl); //记录错误日志
}
curl_close($curl); //关闭CURL会话
return $tmpInfo; //返回数据
}
}

@ -0,0 +1,778 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Tuniu_train extends CI_Controller{
private $order_status_msg;//订单状态说明
public function __construct(){
parent::__construct();
//header("Content-Type: text/html;charset=utf-8");
$this->load->library('Des');
$this->load->model("tuniu_model");
$this->load->model("order_people_model","op");
}
//途牛出票页面
public function index(){
$cols_id=$this->input->post("ht_order");
$list=new StdClass;
if(!empty($cols_id)){
$cold_sn=$this->tuniu_model->get_biz_cold($cols_id);
$list->wl=$this->tuniu_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->tuniu_model->biz_people($v->COLD_SN);
$list->info[$i]->train=$this->tuniu_model->get_biz_foi($v->COLD_SN);
$list->info[$i]->status=$this->tuniu_model->get_biz_jol($v->COLD_SN);
$i++;
}
$list->cols_id=$cols_id;
}
$this->load->view('bootstrap3/header');
$this->load->view('tuniu/ht_train_order_info',$list);
$this->load->view('bootstrap3/footer');
}
//订单列表
public function ht_order_list(){
$page_size=10;
$page=$this->input->get("page");
$order=$this->input->get("order");
$where="1=1";//搜索条件
$page_parameter="";//返回的分页条件参数
if(empty($page) or !is_numeric($page)){
$page=0;
}
if(!empty($order)){
$where="Tourmanager.dbo.BIZ_ConfirmLineInfo.COLI_ID='{$order}' OR tol_orderId='{$order}'";
$list["order"]=$order;
$page_parameter="order=".$order."&";
}
$data=$this->tuniu_model->get_order($page_size,$page,$where);
$list["data"]=$data->list;
$this->load->library('pagination');
$config['base_url'] = site_url("/apps/train/tuniu_train/ht_order_list?{$page_parameter}");
$config['total_rows'] = $data->count;
$config['per_page'] = $page_size;
$config['page_query_string']=TRUE;
$config['query_string_segment']="page";
$config['cur_tag_open'] = '<li class="active"><a href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['first_tag_open']=$config['last_tag_open']=$config['next_tag_open']=$config['prev_tag_open']=$config['num_tag_open']="<li>";
$config['first_tag_close']=$config['last_tag_close']=$config['next_tag_close']=$config['prev_tag_close']=$config['num_tag_close']="</li>";
$this->pagination->initialize($config);
$list["page_link"]=$this->pagination->create_links();
foreach ($list["data"] as $key => $value) {
if($value->tol_Status == '2'){
$value->info='预定'.$value->tol_errorMsg;//普通出票
}else if($value->tol_Status == '4'){
$value->info='出票'.$value->tol_errorMsg;//普通出票
}else if($value->tol_Status == '7'){
$value->info='退票'.$value->tol_errorMsg;//普通出票和抢票通用
}else if($value->tol_Status == '8'){
$value->info='抢票'.$value->tol_errorMsg;//取消抢票
}else if($value->tol_Status == '9'){
if($value->tol_returnCode == 231000){
$value->info='抢票成功';//抢票执行结果
}else{
$value->info=$value->tol_errorMsg;//抢票执行结果
}
}elseif($value->tol_Status == '6'){
$value->info='抢票中';//抢票
}elseif($value->tol_Status == '0'){
$value->info=$value->tol_errorMsg;//站位
}else{
$value->info = '';
}
}
$this->load->view('bootstrap3/header');
$this->load->view('/tuniu/ht_order_list.html',$list);
$this->load->view('bootstrap3/footer');
}
//选择乘客出票一个或多个不超过5个
public function get_sn_submit_tuniu() {
$cold_sn = $this->input->get("order");
$bpe_sn = $this->input->get("people");
$coli_id = $this->input->get('coli_id');
$selectseat = $this->input->get("selectseat");
$data = array();
$rebakc = array();//返回数据
$rebakc["status"]=0;
$rebakc["mes"]="";
if(!is_numeric($cold_sn)){
$rebakc["mes"]="订单号是数字";
echo json_encode($rebakc);
return false;
}
if(empty($bpe_sn)){
$rebakc["mes"]="请选择乘客";
echo json_encode($rebakc);
return false;
}
$data['train'] = $this->tuniu_model->biz_order_detail($cold_sn);
$data['people_list'] = $this->tuniu_model->in_bpesn_people_info($bpe_sn);
//$data['operator'] = $this->BIZ_train_model->get_operatorinfo($coli_id);
if (empty($data['train'])) {
//显示错误,找不到车次
$rebakc["mes"]="找不到车次";
echo json_encode($rebakc);
return false;
}
if (empty($data['people_list'])) {
//显示错误,找不到用户信息
$rebakc["mes"]="找不到乘客信息";
echo json_encode($rebakc);
return false;
}
if (count($data['people_list']) > 5) {
//显示错误,用户超过五个
$rebakc["mes"]="乘客不能超过五个";
echo json_encode($rebakc);
return false;
}
$db_train_zw = $this->config->item('db_train_zw');
$train_zw = $this->config->item('train_zw');
$ticketype = $this->config->item('train_piaotype');
$zwcode = $db_train_zw[$data['train']->Aircraft]; //座位简码
$zwname = $train_zw[$db_train_zw[$data['train']->Aircraft]]; //座位名称
$passengers="";
$cold_sn = $cold_sn.'_'.time();
//拼接车次信息
$tuniu_data = '{';
$tuniu_data .= '"retailOrderId":"'.$cold_sn.'",';
$tuniu_data .= '"cheCi": "'.$data['train']->FlightsNo.'", ';
$tuniu_data .= '"fromStationCode": "'.$data['train']->DepartAirport.'", ';
$tuniu_data .= '"fromStationName": "'.$data['train']->DepartAirport_cn.'", ';
$tuniu_data .= '"toStationCode": "'.$data['train']->ArrivalAirport.'", ';
$tuniu_data .= '"toStationName": "'.$data['train']->ArrivalAirport_cn.'", ';
$tuniu_data .= '"trainDate": "'.substr($data["train"]->DepartureDate, 0, 10).'", ';
$tuniu_data .= '"callBackUrl": "http://www.mycht.cn/info.php/apps/train/tuniu_callback/book",';
$tuniu_data .= '"hasSeat": true,';
$tuniu_data .= '"contact": "陈宇超",';
$tuniu_data .= '"phone": "18877381547",';
$tuniu_data .= '"isChooseSeats": true,';
$tuniu_data .= '"chooseSeats":"'.$selectseat.'",';
//循环乘客
$passengers = '';
foreach ($data['people_list'] as $key => $item) {
$passengers .= '{';
$passengers .= '"passengerId":'.$key.',';
$passengers .= '"ticketNo":"null",';
//乘客姓名
$passengersename = str_replace(' ','',$item->BPE_FirstName) . str_replace(' ','',$item->BPE_MiddleName) . str_replace(' ','',$item->BPE_LastName);
//将特殊字符转换为正常字符以便于出票
$passengersename = $this->chk_sp_name($passengersename);
$passengers .= '"passengerName":"'.$passengersename.'",';
$passportseno = str_replace(' ','',$item->BPE_Passport);
$passengers .= '"passportNo":"'.$passportseno.'",';
//证件类型
switch ($item->BPE_PassportType){
case 'Chinese ID':
$passporttypeseid = "1";
$passporttypeseidname = "二代身份证";
break;
case 'Travel Permit from Hong Kong / Macau':
$passporttypeseid = "C";
$passporttypeseidname = "港澳通行证";
break;
case 'Travel Permit from Taiwan':
$passporttypeseid = "G";
$passporttypeseidname = "台湾通行证";
break;
default :
$passporttypeseid = "B";
$passporttypeseidname = "护照";
break;
}
//乘客类型
switch ($item->BPE_GuestType) {
case 1:
$piaotype = 1;
$piaotypename = "成人票";
break;
case 2:
$piaotype = 2;
$piaotypename = "儿童票";
break;
default://外国人应该就两种票吧
$piaotype = 1;
$piaotypename = "成人票";
break;
}
$passengers .= '"passportTypeId":"'.$passporttypeseid.'",';
$passengers .= '"passportTypeName":"'.$passporttypeseidname.'",';
//票类型
$passengers .= '"piaoType":"'.$item->BPE_GuestType.'",';
$passengers .= '"piaoTypeName":"'.$ticketype[$item->BPE_GuestType].'",';
//座位类型piaoTypeName
$passengers .= '"zwCode":"'.$zwcode.'",';
$passengers .= '"zwName":"'.$zwname.'",';
$passengers .= '"cxin":"null",';
$passengers .= '"price":"'.$data['train']->adultcost.'",';
$passengers .= '"reason": 0';
$passengers .= '},';
}
$passengers = substr($passengers,0,strlen($passengers)-1);
$passengers = '['.$passengers.']';
$tuniu_data .= '"passengers": '.$passengers.'}';
//print_r($tuniu_data);
//die();
$crypt = new DES();
$mstr = $crypt->encrypt($tuniu_data,TUNIU_KEY);
$post_data = '{
"apiKey": "'.TUNIU_KEY.'",
"sign": "'.$this->create_sign().'",
"timestamp": "'.date('Y-m-d H:i:s',time()).'",
"data": "'.$mstr.'"
}';
$url = TUNIU_URL.'/train/book';
$back_json = $this->get_http($url,$post_data,'POST');
$back = json_decode($back_json);//json=>obj
//print_r($back_json);
if($back->success == 1){
$rebakc["mes"]="订单提交成功,等待回调";
}else{
$rebakc["mes"]= $bakc_json;
}
$add_data=new StdClass();
$add_data->tol_retailOrderId = $cold_sn;
if(isset($back->data->orderId)){
$add_data->tol_orderId = $back->data->orderId;
}else{
$add_data->tol_orderId = '';
}
$add_data->tol_status = '0';
$add_data->tol_fromStationName = $data['train']->DepartAirport_cn;
$add_data->tol_fromStationCode = $data['train']->DepartAirport;
$add_data->tol_toStationName = $data['train']->ArrivalAirport_cn;
$add_data->tol_toStationCode = $data['train']->ArrivalAirport;
$add_data->tol_errorMsg = $back->errorMsg;
$add_data->tol_cheCi = $data['train']->FlightsNo;
$isauto = false;
$add_back_data=$this->tuniu_model->tuniu_add_biz_jol($add_data,$isauto);
echo json_encode($rebakc);
return false;
}
//取消占座
public function cancel_book($retailOrderId,$orderId){
$url = TUNIU_URL.'/train/cancel';
$sign = $this->create_sign();
$time = date('Y-m-d H:i:s',time());
$crypt = new DES();
$tuniu_data = '{
"retailOrderId":"'.$retailOrderId.'",
"orderId":"'.$orderId.'",
"callBackUrl":"http://www.mycht.cn/info.php/apps/train/tuniu_callback/cancelbook"
}';
$mstr = $crypt->encrypt($tuniu_data,TUNIU_KEY);
$post_data = '{
"apiKey": "'.TUNIU_KEY.'",
"sign": "'.$sign.'",
"timestamp": "'.$time.'",
"data": "'.$mstr.'"
}';
$back_data = $this->get_http($url,$post_data,'POST');
print_r($back_data);
}
//确认出票
public function confirm_ticket($retailOrderId=null,$orderId=null){
$url = TUNIU_URL.'/train/confirm';
$sign = $this->create_sign();
$time = date('Y-m-d H:i:s',time());
$post_data = '{
"apiKey": "'.TUNIU_KEY.'",
"sign": "'.$sign.'",
"timestamp": "'.$time.'",
"data": {
"retailOrderId":"'.$retailOrderId.'",
"orderId":"'.$orderId.'",
"callBackUrl":"http://www.mycht.cn/info.php/apps/train/tuniu_callback/confirm"
}
}';
$back_data = $this->get_http($url,$post_data,'POST');
print_r($back_data);
}
//退票接口
public function cancel_ticket($retailOrderId,$orderId,$ticketNo=null){
$url = TUNIU_URL.'/train/return';
$sign = $this->create_sign();
$time = date('Y-m-d H:i:s',time());
$obj = $this->tuniu_model->get_tuniuorder_info($retailOrderId,$orderId);
$info = json_decode($obj[0]->tol_booktxt);
$orderNumber = $info->orderNumber;
$str = '[';
foreach($info->passengers as $item){
if(empty($ticketNo)){
$str .='{';
$str .= '"ticketNo":"'.$item->ticketNo.'",';
$str .= '"passengerName":"'.$item->passengerName.'",';
$str .= '"passportTypeId":"'.$item->passportTypeId.'",';
$str .= '"passportNo":"'.$item->passportNo.'"';
$str .= '},';
}else{
if($item->ticketNo == $ticketNo){
$str .='{';
$str .= '"ticketNo":"'.$item->ticketNo.'",';
$str .= '"passengerName":"'.$item->passengerName.'",';
$str .= '"passportTypeId":"'.$item->passportTypeId.'",';
$str .= '"passportNo":"'.$item->passportNo.'"';
$str .= '},';
}
}
}
$str = substr($str,0,strlen($str)-1);
$str .= ']';
$data = '{
"retailOrderId": "'.$retailOrderId.'",
"orderId": "'.$orderId.'",
"orderNumber": "'.$orderNumber.'",
"callBackUrl":"http://www.mycht.cn/info.php/apps/train/tuniu_callback/return_ticket",
"tickets":'.$str.'
}';
$crypt = new DES();
$mstr = $crypt->encrypt($data,TUNIU_KEY);
$post_data = '{
"apiKey": "'.TUNIU_KEY.'",
"sign": "'.$sign.'",
"timestamp": "'.$time.'",
"data": "'.$mstr.'"
}';
$back_data = $this->get_http($url,$post_data,'POST');
print_r($back_data);
}
//获取途牛订单信息
public function order(){
$retailOrderId=$this->input->get("retailOrderId");
$orderId=$this->input->get("orderId");
if($retailOrderId && $orderId){
$url = TUNIU_URL.'/train/orderStatusQuery';
$sign = $this->create_sign();
$time = date('Y-m-d H:i:s',time());
$post_data = '{
"apiKey": "'.TUNIU_KEY.'",
"sign": "'.$sign.'",
"timestamp": "'.$time.'",
"data": {
"retailOrderId":"'.$retailOrderId.'",
"orderId":"'.$orderId.'"
}
}';
$back_json = $this->get_http($url,$post_data,'POST');
//获取异步回调信息
$grab_callback = $this->tuniu_model->get_tuniuorder_info($retailOrderId,$orderId);
$back_data = json_decode($back_json);
//print_r($back_data);
$back_data->grab_callback = $grab_callback[0]->tol_booktxt;
//print_r($back_data);
$this->load->view('bootstrap3/header');
$this->load->view('tuniu/order',$back_data);
$this->load->view('bootstrap3/footer');
}else{
exit('订单信息不完整');
}
}
//抢票页面
public function grab_index(){
$cols_id=$this->input->post("ht_order");
$list=new StdClass;
if(!empty($cols_id)){
$cold_sn=$this->tuniu_model->get_biz_cold($cols_id);
$list->wl=$this->tuniu_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->tuniu_model->biz_people($v->COLD_SN);
$list->info[$i]->train=$this->tuniu_model->get_biz_foi($v->COLD_SN);
$list->info[$i]->status=$this->tuniu_model->get_biz_jol($v->COLD_SN);
$i++;
}
$list->cols_id=$cols_id;
}
$this->load->view('bootstrap3/header');
$this->load->view('tuniu/grabTicketBook',$list);
$this->load->view('bootstrap3/footer');
}
//抢票接口
public function grabTicketBook(){
$cold_sn = $this->input->get("order");
$bpe_sn = $this->input->get("people");
//$coli_id = $this->input->get('coli_id');
$deadline = $this->input->get('deadline');
$alternate_train = $this->input->get('alternate_train');
$alternate_seat = $this->input->get('alternate_seat');
$data = array();
$rebakc = array();//返回数据
$rebakc["status"]=0;
$rebakc["mes"]="";
if(!is_numeric($cold_sn)){
$rebakc["mes"]="订单号是数字";
echo json_encode($rebakc);
return false;
}
if(empty($bpe_sn)){
$rebakc["mes"]="请选择乘客";
echo json_encode($rebakc);
return false;
}
if(empty($deadline)){
$rebakc["mes"]="请填写截止日期";
echo json_encode($rebakc);
return false;
}
$data['train'] = $this->tuniu_model->biz_order_detail($cold_sn);
$data['people_list'] = $this->tuniu_model->in_bpesn_people_info($bpe_sn);
//$data['operator'] = $this->BIZ_train_model->get_operatorinfo($coli_id);
if (empty($data['train'])) {
//显示错误,找不到车次
$rebakc["mes"]="找不到车次";
echo json_encode($rebakc);
return false;
}
if (empty($data['people_list'])) {
//显示错误,找不到用户信息
$rebakc["mes"]="找不到乘客信息";
echo json_encode($rebakc);
return false;
}
if (count($data['people_list']) > 5) {
//显示错误,用户超过五个
$rebakc["mes"]="乘客不能超过五个";
echo json_encode($rebakc);
return false;
}
$db_train_zw = $this->config->item('db_train_zw');
$train_zw = $this->config->item('train_zw');
$ticketype = $this->config->item('train_piaotype');
$zwcode = $db_train_zw[$data['train']->Aircraft]; //座位简码
$zwname = $train_zw[$db_train_zw[$data['train']->Aircraft]]; //座位名称
$passengers="";
$cold_sn = $cold_sn.'_'.time();
//拼接抢票车次信息
$tuniu_data = '{';
$tuniu_data .= '"retailOrderId":"'.$cold_sn.'",';
$tuniu_data .= '"cheCi": "'.$data['train']->FlightsNo.'", ';
$tuniu_data .= '"fromStationCode": "'.$data['train']->DepartAirport.'", ';
$tuniu_data .= '"fromStationName": "'.$data['train']->DepartAirport_cn.'", ';
$tuniu_data .= '"toStationCode": "'.$data['train']->ArrivalAirport.'", ';
$tuniu_data .= '"toStationName": "'.$data['train']->ArrivalAirport_cn.'", ';
$tuniu_data .= '"trainDate": "'.substr($data["train"]->DepartureDate, 0, 10).'", ';
$tuniu_data .= '"deadLine": "'.$deadline.'", ';
$tuniu_data .= '"reserveCheCi": null, ';
$tuniu_data .= '"reserveZwCode": null, ';
$tuniu_data .= '"hasSeat": true,';
//$tuniu_data .= '"callBackUrl": "http://www.mycht.cn/info.php/apps/train/tuniu_callback/book",';
$tuniu_data .= '"contact": "陈宇超",';
$tuniu_data .= '"phone": "18877381547",';
$tuniu_data .= '"grabType": "1",';
$tuniu_data .= '"grabFrequency": "common",';
$tuniu_data .= '"grabQueue": "common",';
$tuniu_data .= '"grabEntryway": "single",';
//循环乘客
$passengers = '';
foreach ($data['people_list'] as $key => $item) {
$passengers .= '{';
$passengers .= '"passengerId":'.$key.',';
$passengers .= '"ticketNo":"null",';
//乘客姓名
$passengersename = str_replace(' ','',$item->BPE_FirstName) . str_replace(' ','',$item->BPE_MiddleName) . str_replace(' ','',$item->BPE_LastName);
//将特殊字符转换为正常字符以便于出票
$passengersename = $this->chk_sp_name($passengersename);
$passengers .= '"passengerName":"'.$passengersename.'",';
$passportseno = str_replace(' ','',$item->BPE_Passport);
$passengers .= '"passportNo":"'.$passportseno.'",';
//证件类型
switch ($item->BPE_PassportType){
case 'Chinese ID':
$passporttypeseid = "1";
$passporttypeseidname = "二代身份证";
break;
case 'Travel Permit from Hong Kong / Macau':
$passporttypeseid = "C";
$passporttypeseidname = "港澳通行证";
break;
case 'Travel Permit from Taiwan':
$passporttypeseid = "G";
$passporttypeseidname = "台湾通行证";
break;
default :
$passporttypeseid = "B";
$passporttypeseidname = "护照";
break;
}
$passengers .= '"passportTypeId":"'.$passporttypeseid.'",';
$passengers .= '"passportTypeName":"'.$passporttypeseidname.'",';
//票类型
$passengers .= '"piaoType":"'.$item->BPE_GuestType.'",';
$passengers .= '"piaoTypeName":"'.$ticketype[$item->BPE_GuestType].'",';
//座位类型piaoTypeName
$passengers .= '"zwCode":"'.$zwcode.'",';
$passengers .= '"zwName":"'.$zwname.'",';
$passengers .= '"cxin":"null",';
$passengers .= '"price":"'.$data['train']->adultcost.'",';
$passengers .= '"reason": 0';
$passengers .= '},';
}
$passengers = substr($passengers,0,strlen($passengers)-1);
$passengers = '['.$passengers.']';
$tuniu_data .= '"passengers": '.$passengers.'}';
$crypt = new DES();
$mstr = $crypt->encrypt($tuniu_data,TUNIU_KEY);
$post_data = '{
"apiKey": "'.TUNIU_KEY.'",
"sign": "'.$this->create_sign().'",
"timestamp": "'.date('Y-m-d H:i:s',time()).'",
"data": "'.$mstr.'"
}';
$url = TUNIU_URL.'/train/grabTicketBook';
$back_json=$this->get_http($url,$post_data,'POST');
$back=json_decode($back_json);//json=>obj
log_message('error','抢票预定同步:'.$back_json);
if($back->success == 1){
$rebakc["mes"]="订单提交成功,等待回调";
}else{
$rebakc["mes"]= $bakc_json;
}
$add_data=new StdClass();
$add_data->tol_retailOrderId = $back->data->retailOrderId;
if(isset($back->data->orderId)){
$add_data->tol_orderId = $back->data->orderId;
}else{
$add_data->tol_orderId = '';
}
$add_data->tol_fromStationName = $data['train']->DepartAirport_cn;
$add_data->tol_fromStationCode = $data['train']->DepartAirport;
$add_data->tol_toStationName = $data['train']->ArrivalAirport_cn;
$add_data->tol_toStationCode = $data['train']->ArrivalAirport;
$add_data->tol_cheCi = $data['train']->FlightsNo;
$add_data->tol_status = '6';
$isauto = false;
$add_back_data=$this->tuniu_model->tuniu_add_biz_jol($add_data,$isauto);
print_r($back);
echo $cold_sn;
echo json_encode($rebakc);
return false;
}
//取消抢票
public function cancelgrabTicket($retailOrderId,$orderId){
$url = TUNIU_URL.'/train/cancelGrabTicket';
$sign = $this->create_sign();
$time = date('Y-m-d H:i:s',time());
$tuniu_data = '{
"orderId":"'.$orderId.'",
"retailOrderId":"'.$retailOrderId.'",
"userName":null,
"userPassword":null
}';
$crypt = new DES();
$mstr = $crypt->encrypt($tuniu_data,TUNIU_KEY);
$post_data = '{
"apiKey": "'.TUNIU_KEY.'",
"sign": "'.$sign.'",
"timestamp": "'.$time.'",
"data": "'.$mstr.'"
}';
$back_data = $this->get_http($url,$post_data,'POST');
print_r($back_data);
}
//导出途牛账单
public function export(){
$this->load->model("BIZ_train_model");//加载模型
$trackcode = $this->BIZ_train_model->getTrackingCode();
$record = $this->tuniu_model->get_transaction_record();
/*print_r($record);
die();*/
//创建一个数组进行数据格式化
$r_info = array();
foreach ($record as $item){
if(empty($item->tne_ordernumber)){
continue;
}
//print_r($item);
//订单时间
$r_info[0] = $item->tne_jydate;
//订单操作类型(分为付款和收款)
$r_info[1] = $item->tne_jytype;
//途牛订单号
$r_info[2] = $item->tne_ordernumber;
//订单交易金额
if($item->tne_jytype == '付款'){
$r_info[3] = '-'.$item->tne_jyprice;
}else{
$r_info[3] = $item->tne_jyprice;
}
//获取订单cold_sn
$order_info = $this->tuniu_model->get_order_info($item->tne_ordernumber);
//echo $item->tne_ordernumber.'////';
//print_r($order_info);
$obj = explode('_',$order_info[0]->tol_retailOrderId);
$cold_sn = $obj[0];
//获取订单coli_Id
$order_obj = $this->tuniu_model->get_coli_id($cold_sn);
//print_r($coli_id);
$coli_id = $order_obj[0]->COLI_ID;
$coli_sn = $order_obj[0]->COLI_SN;
//echo $coli_id[0]->coli_id;
//$coli_sn = $coli_id[0]->coli_sn;
//echo $coli_id[0]->coli_sn;;
$this->BIZ_train_model->linkTrackingCode($coli_sn,$trackcode);
//获取团号
$gri_no = $this->tuniu_model->get_gri_no($coli_id);//团名
if($gri_no){
$r_info[4] = $gri_no[0]->GRI_No;
}
//获取外联名
$wl_name = $this->tuniu_model->get_operatorinfo($coli_id);
if($wl_name){
$r_info[5] = $wl_name[0]->OPI_Name;
}
$r_info['trackcode'] = $trackcode;
$arr[]=$r_info;
}
header("Content-type:application/vnd.ms-excel;charset=utf-8");
header("Content-Disposition:attachment;filename=tuniu_train.xls");
$string_r= $this->load->view("tuniu/train_transaction_excel",array("arr"=>$arr),TRUE);
echo $string_r;die;
}
//发送请求函数
public function get_http($url, $data = '', $method = 'GET') {
$curl = curl_init(); // 启动一个CURL会话
curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转
curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer
if ($method == 'POST' && !empty($data)) {
curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json;charset=UTF-8'));
}
curl_setopt($curl, CURLOPT_TIMEOUT, 45); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
$tmpInfo = curl_exec($curl); // 执行操作
$errno = curl_errno($curl);
if ($errno !== 0) {
return false;
echo $errno . curl_error($curl); //记录错误日志
}
curl_close($curl); //关闭CURL会话
return $tmpInfo; //返回数据
}
function vpost($url,$data){ // 模拟提交数据函数
$curl = curl_init(); // 启动一个CURL会话
curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1); // 从证书中检查SSL加密算法是否存在
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转
curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer
curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
$tmpInfo = curl_exec($curl); // 执行操作
if (curl_errno($curl)) {
$tmpInfo = 'Errno'.curl_error($curl);//捕抓异常
}
curl_close($curl); // 关闭CURL会话
return $tmpInfo; // 返回数据
}
//国际姓名特殊字符转换
function chk_sp_name($name){
$name = str_replace(
array('á', 'é', 'í', 'ó', 'ú', 'ñ', 'Á', 'É', 'Í', 'Ó', 'Ú', 'Ñ'),
array('a', 'e', 'i', 'o', 'u', 'n', 'A', 'E', 'I', 'O', 'U', 'N'),
$name
);
return substr(strtoupper($name),0,30);
}
//途牛接口创建请求签名
public function create_sign(){
$time = date('Y-m-d H:i:s',time());
$secretKey = 'qvHMJVywEQqsd4EneHQl';
$id = 'retailId25';
$timeStamp = 'timestamp'.$time;
$sign = $secretKey.$id.'apiKey'.TUNIU_KEY.$timeStamp.$secretKey;
return strtoupper(md5($sign));
}
}

@ -0,0 +1,40 @@
<?php
//特殊字符转换
function chk_sp_name($name){
$name = str_replace(
array('á', 'é', 'í', 'ó', 'ú', '?', 'á', 'é', 'í', 'ó', 'ú', '?',' ','/',' ',','),
array('a', 'e', 'i', 'o', 'u', 'n', 'A', 'E', 'I', 'O', 'U', 'N','','','',''),
$name
);
return substr(strtoupper($name),0,30);
}
//发送请求函数
function GetPost_http($url, $data = '', $method = 'GET') {
$curl = curl_init(); // 启动一个CURL会话
curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转
curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer
if ($method == 'POST' && !empty($data)) {
curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
}
curl_setopt($curl, CURLOPT_TIMEOUT, 40); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_TIMEOUT_MS, 40000); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
$tmpInfo = curl_exec($curl); // 执行操作
$errno = curl_errno($curl);
if ($errno !== 0) {
log_message('error', 'ctripost'.$errno.curl_error($curl));
}
curl_close($curl); //关闭CURL会话
return $tmpInfo; //返回数据
}
?>

@ -0,0 +1,59 @@
<?php
class Des
{
function encrypt($string,$key)
{
$size = mcrypt_get_block_size('des','ecb');
//$string = mb_convert_encoding($string, 'GBK', 'UTF-8');
$string = $this->pkcs5_pad($string, $size);
$td = mcrypt_module_open('des', '', 'ecb', '');
$iv = @mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
@mcrypt_generic_init($td, $key, $iv);
$data = mcrypt_generic($td, $string);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
$data = base64_encode($data);
return $data;
}
function decrypt($string,$key)
{
$string = base64_decode($string);
$td = mcrypt_module_open('des', '', 'ecb', '');
//使用MCRYPT_DES算法,cbc模式
$iv = @mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
$ks = mcrypt_enc_get_key_size($td);
@mcrypt_generic_init($td, $key, $iv);
//初始处理
$decrypted = mdecrypt_generic($td, $string);
//解密
mcrypt_generic_deinit($td);
//结束
mcrypt_module_close($td);
$result = $this->pkcs5_unpad($decrypted);
//$result = mb_convert_encoding($result, 'UTF-8', 'GBK');
return $result;
}
function pkcs5_pad($text, $blocksize)
{
$pad = $blocksize - (strlen($text) % $blocksize);
return $text . str_repeat(chr($pad), $pad);
}
function pkcs5_unpad($text)
{
$pad = ord($text{strlen($text) - 1});
if ($pad > strlen($text)) {
return false;
}
if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) {
return false;
}
return substr($text, 0, -1 * $pad);
}
}
?>

@ -5,72 +5,167 @@ class BIZ_train_model extends CI_Model {
function __construct() {
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
$this->INFO = $this->load->database('INFO', TRUE);
$this->INFO = $this->load->database('INFO', TRUE);
}
//新增或更新缓存
public function addOrUpdate($tpc_from_station,$tpc_to_station,$tpc_content){
$sql = "IF NOT EXISTS(
SELECT 1
FROM TrainPriceCache
WHERE
tpc_from_station = '$tpc_from_station'
AND tpc_to_station = '$tpc_to_station'
) BEGIN
INSERT INTO TrainPriceCache
(
tpc_from_station,
tpc_to_station,
tpc_content,
tpc_datetime,
tpc_source
)
VALUES
(
'$tpc_from_station','$tpc_to_station','$tpc_content',GETDATE(),'juhe'
)
END
ELSE
BEGIN
UPDATE TrainPriceCache
SET tpc_from_station = '$tpc_from_station',
tpc_to_station = '$tpc_to_station',
tpc_content = '$tpc_content',
tpc_datetime = GETDATE(),
tpc_source = 'juhe'
WHERE
tpc_from_station = '$tpc_from_station'
AND tpc_to_station = '$tpc_to_station'
END
";
$query = $this->INFO->query($sql);
return $query;
//测试
function test_myslef(){
$sql = "UPDATE BIZ_JuheOrderList SET JOL_SendMail = 1";
$query = $this->HT->query($sql);
//eturn $query->result();
}
//获取缓存的火车信息
//如果读取到缓存是7天以前的数据就不返回任何数据并且将其删除。
public function get_train_cache($tpc_from_station,$tpc_to_station){
$sql = "SELECT
*
FROM
TrainPriceCache
//自动获取符合自动出票要求的订单的coli_sn
function auto_check_ticket(){
$sql = "SELECT distinct COLD_SN ,coli_id,COLD_SPFS,COLI_State
FROM BIZ_ConfirmLineInfo bcli
inner join BIZ_ConfirmLineDetail bcld on COLD_COLI_SN=COLI_SN
LEFT JOIN BIZ_GroupAccountInfo bgai
ON bcli.COLI_SN = bgai.GAI_COLI_SN
WHERE bcli.COLI_ServiceType = '2'
AND bcli.COLI_State in ('11','13','8','63')
AND bcli.COLI_WebCode in ('cht', 'JP', 'train_it', 'VC', 'train_ru','GM-Train','SHT','CT')
AND (bcli.COLI_Price - bgai.GAI_SQJE) <= 20
AND (bcli.COLI_Price - bgai.GAI_SQJE) >= 0
AND bcli.DeleteFlag = 0
AND bgai.DeleteFlag = 0
AND bcld.DeleteFlag = 0
--AND COLD_SPFS<=2
AND NOT EXISTS (
SELECT TOP 1 1
FROM BIZ_JuheOrderList
WHERE JOL_COLD_SN = COLD_SN
)
and (((COLI_State<>8 and COLI_State<>63) and COLD_StartDate < CONVERT(varchar(100),GETDATE()+29,23)) or ((COLI_State=8 or COLI_State=63) and COLD_StartDate between CONVERT(varchar(100),GETDATE()+29,23) and CONVERT(varchar(100),GETDATE()+29,23)+' 23:59'))
";
$query = $this->HT->query($sql);
return $query->result();
}
//筛选符合发送邮件的订单
public function auto_sendmail(){
$sql = "SELECT
JOL_COLD_SN,
JOL_JuheOrder,
JOL_Status,
JOL_RebackMsg
FROM
BIZ_JuheOrderList bjo
left join
BIZ_ConfirmLineDetail bcld
on
bcld.COLD_SN = bjo.JOL_COLD_SN
left join
BIZ_ConfirmLineInfo bcli
on
bcld.COLD_COLI_SN = bcli.COLI_SN
WHERE
tpc_from_station = '$tpc_from_station'
AND
tpc_to_station = '$tpc_to_station'";
$query = $this->INFO->query($sql);
return $query->row();
JOL_SendMail = 0
AND
JOL_IsAuto = 1
AND
JOL_Status != '0'
AND
JOL_Status != 'e'
AND
JOL_Status != '2'
AND
bcli.COLI_WebCode = 'cht'";
$query = $this->HT->query($sql);
return $query->result();
}
//删除缓存操作
function delete_traincache($tpc_from_station,$tpc_to_station){
$sql = "DELETE FROM
TrainPriceCache
//筛选符合发送邮件的订单
public function auto_sendmailtest(){
$sql = "SELECT
JOL_COLD_SN,
JOL_JuheOrder,
JOL_Status,
JOL_RebackMsg
FROM
BIZ_JuheOrderList bjo
left join
BIZ_ConfirmLineDetail bcld
on
bcld.COLD_SN = bjo.JOL_COLD_SN
left join
BIZ_ConfirmLineInfo bcli
on
bcld.COLD_COLI_SN = bcli.COLI_SN
WHERE
tpc_from_station = '$tpc_from_station'
JOL_SendMail = 0
AND
JOL_IsAuto = 1
AND
tpc_to_station = '$tpc_to_station'";
$query = $this->INFO->query($sql);
bcli.COLI_WebCode = 'cht'";
$query = $this->HT->query($sql);
return $query->result();
}
//获取失败的订单请求了多少次接口
/*
状态4为成功出票
状态2为等待回调
状态7为线上退票
*/
function get_count_jol($cold_sn){
$sql = "select
count(JOL_JuheOrder) as count
from
BIZ_JuheOrderList
where
JOL_COLD_SN = ?
and
JOL_Status not in (4,2,7)";
$query = $this->HT->query($sql,$cold_sn);
return $query->row();
}
//成功出票后更新汉特订单中special request的值
function update_special_request($coli_id){
$sql = "update
BIZ_ConfirmLineInfo
set
COLI_OrderDetailText = '已经自动出票---' + (select COLI_OrderDetailText from BIZ_ConfirmLineInfo where COLI_ID = '$coli_id')
where
COLI_ID = '$coli_id'";
$query = $this->HT->query($sql);
return $query;
}
//邮件使用
function get_user_info($jh_order){
$sql = "select
*
from
BIZ_ConfirmLineDetail
where
COLD_SN = (
select
top 1 JOL_COLD_SN
from
BIZ_JuheOrderList
where
JOL_JuheOrder = ?
)";
$query = $query = $this->HT->query($sql, $jh_order);
if ($query->num_rows() > 0) {
return $query->row();
} else {
return false;
}
}
//获取paypal付款记录
function get_paypal($coli_id){
$sql = "select top 1 GAI_SQJE from BIZ_GroupAccountInfo where GAI_COLI_ID = ?";
$query = $query = $this->HT->query($sql, $coli_id);
if ($query->num_rows() > 0) {
return $query->row();
} else {
return false;
}
}
function biz_order_detail($cold_sn) {
@ -82,16 +177,24 @@ class BIZ_train_model extends CI_Model {
,bfoi.FlightsNo
,bfoi.Aircraft
,bfoi.DepartureDate
,bfoi.FOI_SelectedSeat
,(
SELECT TOP 1 TRS_StationCN
FROM TrainStation
WHERE TRS_Code = DepartAirport
and ISNULL(TRS_StationCN,'')<>''
) AS DepartAirport_cn
,(
SELECT TOP 1 TRS_StationCN
FROM TrainStation
WHERE TRS_Code = ArrivalAirport
) AS ArrivalAirport_cn
and ISNULL(TRS_StationCN,'')<>''
) AS ArrivalAirport_cn,
FOI_TrainNetOrderNo,
bfoi.adultcost,
bfoi.childcost,
ArrivalTime,
DepartureTime
FROM BIZ_FlightsOrderInfo bfoi
WHERE bfoi.FOI_COLD_SN = ?
";
@ -111,6 +214,10 @@ class BIZ_train_model extends CI_Model {
,bbp.BPE_LastName
,bbp.BPE_GuestType
,bbp.BPE_Passport
,bbp.BPE_PassportType
,bbp.BPE_SEX
,bbp.BPE_BirthDate
,bbp.BPE_PassExpdate
FROM BIZ_BookPeople bbp
WHERE BPE_SN in(".$bpe_sn.")
";
@ -126,6 +233,7 @@ class BIZ_train_model extends CI_Model {
,bbp.BPE_LastName
,bbp.BPE_GuestType
,bbp.BPE_Passport
,bbp.BPE_PassportType
FROM BIZ_BookPeople bbp
WHERE EXISTS(
SELECT TOP 1 1
@ -139,24 +247,25 @@ class BIZ_train_model extends CI_Model {
}
//添加聚合订单记录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
function add_biz_jol($data,$isauto){
$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,
JOL_IsAuto
)
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,$isauto
));
return $query;
}
@ -179,12 +288,28 @@ class BIZ_train_model extends CI_Model {
SELECT FOI_COLD_SN,
FlightsNo,
Cabin,
Aircraft,
DepartureCity,
DepartAirport,
ArrivalAirport,
ArrivalCity,
DepartureDate,
DepartureTime,
ArrivalTime,
adultcost
adultcost,
FOI_SelectedSeat,
FOI_TrainNetOrderNo,
FOI_SaleDate,
(
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
WHERE FOI_COLD_SN = ?
";
@ -196,24 +321,39 @@ class BIZ_train_model extends CI_Model {
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();
if($query->num_rows() == 0){
return true;
}else{
return false;
}
}
//传入COLI_ID获取外联名
function get_operatorinfo($cols_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 = ?
)
SELECT
Name,
OPI_Name,
case when OPI_SN=375 then OPI_EmailBak else OPI_Email end as OPI_Email,
tel,
Mobile,
Email
FROM OperatorInfo
left join agenter_user
on AU_OPI_SN = OPI_SN
WHERE OPI_SN = (
SELECT COLI_OPI_ID
FROM BIZ_ConfirmLineInfo bcli
WHERE bcli.COLI_ID = ?
)
and agenter in ('cht', 'train_vac', 'jp', 'train_it', 'vc', 'ru')
";
$query = $this->HT->query($sql, $cols_id);
return $query->result();
}
/* 以上为get_ht_order优化代码 */
//修改BIZ_JuheOrderList
@ -229,13 +369,19 @@ class BIZ_train_model extends CI_Model {
//接收聚合订单号获取翰特订单号即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();
$sql="SELECT
COLI_ID,COLI_SN,COLI_OPI_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
@ -246,6 +392,89 @@ class BIZ_train_model extends CI_Model {
$query = $this->HT->query($sql, $coli_id);
return $query->result();
}
//获取跟踪号
public function getTrackingCode(){
include('c:/database_conn.php');
$connection = array(
'UID' => $db['HT']['username'],
'PWD' => $db['HT']['password'],
'Database' => 'tourmanager',
'ConnectionPooling' => 1,
'CharacterSet' => 'utf-8',
'ReturnDatesAsStrings' => 1
);
$conn = sqlsrv_connect($db['HT']['hostname'], $connection);
$stmt = sqlsrv_query($conn, "exec dbo.SP_getTrackingCode;");
if ($stmt === false) {
echo "Error in executing statement 3.\n";
die(print_r(sqlsrv_errors(), true));
}else{
//存储过程中每一个select都会产生一个结果集取某个结果集就需要从第一个移动到需要的那个结果集
//如果结果集为空就移到下一个
while (sqlsrv_has_rows($stmt) !== TRUE) {
sqlsrv_next_result($stmt);
}
$result_object = array();
while ($row = sqlsrv_fetch_object($stmt)) {
$result_object[] = $row;
}
sqlsrv_free_stmt($stmt);
sqlsrv_close($conn);
return($result_object[0]->TrackingCode);
}
}
//根据coli_sn判断订单是否关联
public function islink($coli_sn){
$sql = "select * from CK_GroupInfo left join BIZ_ConfirmLineInfo on CGI_GRI_SN=COLI_GRI_SN where COLI_SN = '$coli_sn'";
$query = $this->HT->query($sql);
if($query->num_rows() > 0){
return true;
}else{
return false;
}
}
//跟踪号与订单关联
public function linkTrackingCode($coli_sn,$TrackCode){
include('c:/database_conn.php');
$connection = array(
'UID' => $db['HT']['username'],
'PWD' => $db['HT']['password'],
'Database' => 'tourmanager',
'ConnectionPooling' => 1,
'CharacterSet' => 'utf-8',
'ReturnDatesAsStrings' => 1
);
$conn = sqlsrv_connect($db['HT']['hostname'], $connection);
$stmt = sqlsrv_query($conn, "exec dbo.SP_recordTrackingCode '$coli_sn', '$TrackCode'");
if ($stmt === false) {
echo "Error in executing statement 3.\n";
die(print_r(sqlsrv_errors(), true));
}else{
//存储过程中每一个select都会产生一个结果集取某个结果集就需要从第一个移动到需要的那个结果集
//如果结果集为空就移到下一个
/*
while (sqlsrv_has_rows($stmt) !== TRUE) {
sqlsrv_next_result($stmt);
}
$result_object = array();
while ($row = sqlsrv_fetch_object($stmt)) {
$result_object[] = $row;
}
*/
sqlsrv_free_stmt($stmt);
sqlsrv_close($conn);
}
}
//通过COLI_ID获取我的支付 BIZ_TrainOrderCost
function get_train_order_cost($coli_id){
$sql="SELECT TOC_Memo,TOC_TrainNumber,TOC_DepartureDate,TOC_TicketCost
@ -269,7 +498,7 @@ class BIZ_train_model extends CI_Model {
}
//用于自动出票,传入主订单翰特订单号 COLI_ID ,获取客人的姓名和邮箱
public function get_guest_info($COLI_ID){
$sql = "SELECT GUT_LastName,GUT_Email FROM BIZ_GUEST bg WHERE bg.GUT_SN =
$sql = "SELECT GUT_FirstName,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);
@ -296,11 +525,11 @@ class BIZ_train_model extends CI_Model {
WHERE JOL_COLD_SN = ? AND JOL_JuheOrder = ?
";
$query = $this->HT->query($sql,array($cold_sn,$jol_jo));
return $query->result();
return $query->row();
}
// 传入coli_sn获取订单号
public function coli_sn_get_coli_id($coli_sn){
$sql="SELECT COLI_ID FROM BIZ_ConfirmLineInfo WHERE COLI_SN = ? ";
$sql="SELECT COLI_ID,COLI_WebCode FROM BIZ_ConfirmLineInfo WHERE COLI_SN = ? ";
$query = $this->HT->query($sql,array($coli_sn));
return $query->result();
}
@ -332,5 +561,141 @@ class BIZ_train_model extends CI_Model {
echo $query;
//return $query;
}
public function get_mail($m_sn){
$sql = "SELECT * FROM Email_AutomaticSend WHERE M_SN = ?";
$query = $this->HT->query($sql,$m_sn);
return $query->row();
}
public function get_ht_order(){
$sql = "select
COLI_ID,
COLD_SN,
FOI_SelectedSeat
from
BIZ_ConfirmLineInfo bcli
left join BIZ_ConfirmLineDetail bgai on COLI_SN = COLD_COLI_SN
left join BIZ_FlightsOrderInfo bfoi on FOI_COLD_SN = COLD_SN
where
COLI_ServiceType = '2'
AND
COLI_WebCode in ('cht')
and
COLI_ApplyDate > '2018-02-01'
AND bcli.DeleteFlag = 0
AND bgai.DeleteFlag = 0
and COLI_State != 30
and COLI_State != 50
and COLI_State != 40
and COLI_State != 60
and FOI_SelectedSeat != 'NULL'
and FOI_SelectedSeat != ''
order by COLI_ApplyDate asc ";
$query = $this->HT->query($sql);
return $query->result();
}
public function get_juhe_select(){
$sql = "select
FOI_SelectedSeat,
JOL_BackTxt,
JOL_JuheOrder,
JOL_IsAuto
from
BIZ_JuheOrderList
left join BIZ_FlightsOrderInfo on FOI_COLD_SN = JOL_COLD_SN
where JOL_SubTime > '2018-02-01'
and JOL_Status = '4'
and FOI_SelectedSeat != 'NULL'
and FOI_SelectedSeat != ''
";
$query = $this->HT->query($sql);
return $query->result();
}
//更新当前订单
public function update_cold_state($state,$cold_sn){
$sql="update BIZ_ConfirmLineDetail set COLD_State = ? where COLD_SN = ?";
$query = $this->HT->query($sql,array($state,$cold_sn));
return $query;
}
public function update_coli_state($state,$coli_sn){
$sql="update BIZ_ConfirmLineInfo set COLI_State = ? where COLI_SN = ?";
$query = $this->HT->query($sql,array($state,$coli_sn));
}
public function cold_sn_get_coli_sn($cold_sn){
$sql = "select COLD_COLI_SN from BIZ_ConfirmLineDetail where COLD_SN = ?";
$query = $this->HT->query($sql,$cold_sn);
return $query->result();
}
public function get_alltrain($coli_sn){
$sql = "select * from BIZ_ConfirmLineDetail where COLD_COLI_SN = ?";
$query = $this->HT->query($sql,$coli_sn);
return $query->result();
}
public function get_order_webcode($coli_sn){
$sql = "select COLI_WebCode from BIZ_ConfirmLineInfo where COLI_SN = ?";
$query = $this->HT->query($sql,$coli_sn);
return $query->row();
}
public function sale_time_station($station,$time){
$sql = 'INSERT INTO TrainSaleTime (TST_station_cn,TST_saletime) VALUES (?,?) ';
$query = $this->HT->query($sql,array($station,$time));
return $query;
}
public function update_sale_time($time,$update_time){
$sql = "update TrainSaleTime set TST_saletime = '{$time}' WHERE TST_saletime = '{$update_time}'";
$query = $this->HT->query($sql);
return $query;
}
public function get_saletime($station){
$sql = 'select TST_saletime from TrainSaleTime where TST_station_cn = ?';
$query = $this->HT->query($sql,$station);
return $query->row();
}
//
public function addseatinfo($seat_info,$cold_sn){
$sql = "if EXISTS(select FOI_BookSeat from BIZ_FlightsOrderInfo where FOI_COLD_SN = '{$cold_sn}' and FOI_BookSeat = '{$seat_info}' or FOI_BookSeat = 'NULL')
update BIZ_FlightsOrderInfo set FOI_BookSeat = '{$seat_info}' where FOI_COLD_SN = '{$cold_sn}'
else
if(select CHARINDEX('{$seat_info}',FOI_BookSeat) from BIZ_FlightsOrderInfo where FOI_COLD_SN = '{$cold_sn}') = 0
update BIZ_FlightsOrderInfo set FOI_BookSeat = (select FOI_BookSeat from BIZ_FlightsOrderInfo where FOI_COLD_SN = '{$cold_sn}') + ',{$seat_info}' where FOI_COLD_SN = '{$cold_sn}'";
$query = $this->HT->query($sql,array($seat_info,$cold_sn));
}
public function test(){
$seat_info = 'Coach 09,Seat 05A,05C';
$cold_sn = '488110751';
//$sql = "update BIZ_FlightsOrderInfo set FOI_BookSeat = '{$seat_info}' where FOI_COLD_SN = '{$cold_sn}'";
/*$sql = "IF (select FOI_BookSeat from BIZ_FlightsOrderInfo where FOI_COLD_SN = '{$cold_sn}' and FOI_BookSeat like '%{$seat_info}%')
update BIZ_FlightsOrderInfo set FOI_BookSeat = '{$seat_info}' where FOI_COLD_SN = '{$cold_sn}'
else
update BIZ_FlightsOrderInfo set FOI_BookSeat = (select FOI_BookSeat from BIZ_FlightsOrderInfo where FOI_COLD_SN = '{$cold_sn}') + ',{$seat_info}' where FOI_COLD_SN = '{$cold_sn}'
";*/
$sql = "if EXISTS(select FOI_BookSeat from BIZ_FlightsOrderInfo where FOI_COLD_SN = '{$cold_sn}' and FOI_BookSeat = '{$seat_info}' or FOI_BookSeat = 'NULL')
update BIZ_FlightsOrderInfo set FOI_BookSeat = '{$seat_info}' where FOI_COLD_SN = '{$cold_sn}'
else
if(select CHARINDEX('{$seat_info}',FOI_BookSeat) from BIZ_FlightsOrderInfo where FOI_COLD_SN = '{$cold_sn}') = 0
update BIZ_FlightsOrderInfo set FOI_BookSeat = (select FOI_BookSeat from BIZ_FlightsOrderInfo where FOI_COLD_SN = '{$cold_sn}') + ',{$seat_info}' where FOI_COLD_SN = '{$cold_sn}'
";
$query = $this->HT->query($sql);
}
}

@ -0,0 +1,301 @@
<?php
class ctrip_train_model extends CI_Model {
function __construct() {
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
$this->INFO = $this->load->database('INFO', TRUE);
}
//获取订单详情
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
,bfoi.FOI_SelectedSeat
,(
SELECT TOP 1 TRS_StationCN
FROM TrainStation
WHERE TRS_Code = DepartAirport
and ISNULL(TRS_StationCN,'')<>''
) AS DepartAirport_cn
,(
SELECT TOP 1 TRS_StationCN
FROM TrainStation
WHERE TRS_Code = ArrivalAirport
and ISNULL(TRS_StationCN,'')<>''
) AS ArrivalAirport_cn,
FOI_TrainNetOrderNo,
bfoi.adultcost,
bfoi.childcost,
ArrivalTime,
DepartureTime,
DepartureDate
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
,bbp.BPE_PassportType
FROM BIZ_BookPeople bbp
WHERE BPE_SN in(".$bpe_sn.")
order by BPE_GuestType asc
";
$query = $this->HT->query($sql);
return $query->result();
}
function add_passagers($data){
$sql = "IF EXISTS (select * from trainsystem_tickets where tst_ordernumber = '{$data->ordernumber}' and tst_numberid = '{$data->numberid}')
update
trainsystem_tickets
set
tst_identitytype = '{$data->identitytype}',
tst_numberid = '{$data->numberid}',
tst_ticketype = '{$data->ticketype}',
tst_ticketprice = '{$data->ticketprice}',
tst_seatstype = '{$data->seatype}',
tst_seatdetail = '{$data->seatdetail}'
where
tst_ordernumber = '{$data->ordernumber}'
and
tst_numberid = '{$data->numberid}'
else
INSERT INTO trainsystem_tickets (
tst_ordernumber,
tst_realname,
tst_identitytype,
tst_numberid,
tst_ticketype,
tst_ticketprice,
tst_seatstype,
tst_seatdetail
)VALUES(
'{$data->ordernumber}',
'{$data->realname}',
'{$data->identitytype}',
'{$data->numberid}',
'{$data->ticketype}',
'{$data->ticketprice}',
'{$data->seatype}',
'{$data->seatdetail}'
)
";
$query =$this->INFO->query($sql);
}
function add_orders($data){
$sql="
INSERT INTO trainsystem(
ts_cold_sn,
ts_ordernumber,
ts_subtime,
ts_returncode,
ts_status,
ts_errormsg,
ts_fromstationame,
ts_fromstationcode,
ts_tostationame,
ts_tostationcode,
ts_startdate,
ts_startime,
ts_endtime,
ts_runtime,
ts_checi,
ts_channel,
ts_isauto
)
VALUES(
'{$data->cold_sn}',
'{$data->ordernumber}',
getdate(),
'{$data->returncode}',
'{$data->status}',
'{$data->errormsg}',
'{$data->fromstationame}',
'{$data->fromstationcode}',
'{$data->tostationame}',
'{$data->tostationcode}',
'{$data->startdate}',
'{$data->startime}',
'{$data->endtime}',
'{$data->runtime}',
'{$data->checi}',
'{$data->channel}',
'{$data->isauto}'
)
";
//echo $sql;
$query = $this->INFO->query($sql);
}
public function update_orders($data){
$where = '';
if(!empty($data->bookcallback)){
$where .= "
ts_seatsinfo = '{$data->seatsinfo}',
ts_checkdoor = '{$data->TicketCheck}',
ts_elecnumber = '{$data->ElectronicOrderNumber}',
ts_orderamount = '{$data->OrderTotleFee}',
ts_bookcallback = '{$data->bookcallback}',";
}else if(!empty($data->confirmcallback)){
$where .= "ts_confirmcallback = '{$data->confirmcallback}',";
}else if(!empty($data->returncallback)){
$where .= "ts_returncallback = '{$data->returncallback}',";
}else if(!empty($data->reschedulecallback)){
$where .= "ts_reschedulecallback = '{$data->reschedulecallback}',";
}
$sql ="
update trainsystem
set
ts_status = '{$data->OrderStatus}',
ts_errormsg = '{$data->ErrorMsg}',
".substr($where,0,strlen($where)-1)."
where
ts_ordernumber = '{$data->ordernumber}'
";
//echo $sql;die();
$query = $this->INFO->query($sql);
}
public function get_order_info($ordernumber){
$sql = "select * from trainsystem where ts_ordernumber = '$ordernumber'";
$query = $this->INFO->query($sql);
return $query->row();
}
public function get_passager_info($ctriporder,$PassagerId=null){
if(empty($PassagerId)){
$where = "";
}else{
$where = "and tst_id = $PassagerId";
}
$sql = "select * from trainsystem_tickets left join trainsystem on tst_ordernumber = ts_ordernumber where tst_ordernumber = '{$ctriporder}' $where";
$query = $this->INFO->query($sql);
return $query->result();
}
//更新供应商
public function update_cold_planvei_sn($cold_sn){
$sql = "update BIZ_ConfirmLineDetail set COLD_PlanVEI_SN=30427 where COLD_SN = ?";
$query = $this->HT->query($sql,$cold_sn);
}
//新增支付记录
public function add_train_payment($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;
//删除多余支付记录
$sql = "delete from BIZ_TrainOrderCost where TOC_COLI_SN = '{$CCSN}' and TOC_TicketCost is null";
$query=$this->HT->query($sql);
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,更新取票号
/*
UPDATE BIZ_FlightsOrderInfo
SET
FOI_TrainNetOrderNo=?
WHERE
FOI_COLD_SN=?
*/
$sql="IF EXISTS(
select * from BIZ_FlightsOrderInfo where FOI_COLD_SN = '$data->TOC_COLD_SN' and (FOI_TrainNetOrderNo is null or FOI_TrainNetOrderNo = '' or FOI_TrainNetOrderNo like '%$data->FOI_TrainNetOrderNo%'))
UPDATE BIZ_FlightsOrderInfo
SET
FOI_TrainNetOrderNo='$data->FOI_TrainNetOrderNo'
WHERE
FOI_COLD_SN='$data->TOC_COLD_SN'
ELSE
UPDATE BIZ_FlightsOrderInfo
SET
FOI_TrainNetOrderNo=(select FOI_TrainNetOrderNo from BIZ_FlightsOrderInfo where FOI_COLD_SN = '$data->TOC_COLD_SN') + '&' + '$data->FOI_TrainNetOrderNo'
WHERE
FOI_COLD_SN='$data->TOC_COLD_SN'";
$this->HT->query($sql);
$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 update_passpager_info($data){
$sql = "update
trainsystem_tickets
set
tst_status = '{$data->status}',
tst_returncallback = '{$data->returncallback}',
tst_lasteditdate = getdate()
where
tst_ordernumber = '{$data->ordernumber}'
and
tst_realname = '{$data->realname}'
and
tst_numberid = '{$data->numberid}'
";
$query = $this->INFO->query($sql);
}
}
?>

@ -106,8 +106,12 @@ class Order_people_model extends CI_Model {
$query = $this->HT->query($sql,array($data->JOL_RebackMsg,$data->JOL_BackTxt,$data->JOL_Status,$data->JOL_Price,$data->JOL_JuheOrder));
return $query;
}
public function update_cold_planvei_sn($cold_sn){
$sql = "update BIZ_ConfirmLineDetail set COLD_PlanVEI_SN=30427 where COLD_SN = ?";
$query = $this->HT->query($sql,$cold_sn);
}
//BIZ_TrainOrderCost,我的支付
//BIZ_FlightsOrderInfo.FOI_TrainNetOrderNo,更新取票号
public function add_train_order($data){
@ -116,6 +120,9 @@ class Order_people_model extends CI_Model {
$query=$this->HT->query($sql,$data->TOC_COLD_SN);
$query=$query->result();
$CCSN=$query[0]->COLD_COLI_SN;
//删除多余支付记录
$sql = "delete from BIZ_TrainOrderCost where TOC_COLI_SN = '{$CCSN}' and TOC_TicketCost is null";
$query=$this->HT->query($sql);
if(empty($data->FOI_TrainNetOrderNo)){
//退票
$sql="IF NOT EXISTS(
@ -137,12 +144,29 @@ class Order_people_model extends CI_Model {
}else{
//出票
//BIZ_FlightsOrderInfo.FOI_TrainNetOrderNo,更新取票号
$sql="UPDATE BIZ_FlightsOrderInfo
/*
UPDATE BIZ_FlightsOrderInfo
SET
FOI_TrainNetOrderNo=?
WHERE
FOI_COLD_SN=?";
$this->HT->query($sql,array($data->FOI_TrainNetOrderNo,$data->TOC_COLD_SN));
FOI_COLD_SN=?
*/
$sql="IF EXISTS(
select * from BIZ_FlightsOrderInfo where FOI_COLD_SN = '$data->TOC_COLD_SN' and (FOI_TrainNetOrderNo is null or FOI_TrainNetOrderNo = '' or FOI_TrainNetOrderNo like '%$data->FOI_TrainNetOrderNo%'))
UPDATE BIZ_FlightsOrderInfo
SET
FOI_TrainNetOrderNo='$data->FOI_TrainNetOrderNo'
WHERE
FOI_COLD_SN='$data->TOC_COLD_SN'
ELSE
UPDATE BIZ_FlightsOrderInfo
SET
FOI_TrainNetOrderNo=(select FOI_TrainNetOrderNo from BIZ_FlightsOrderInfo where FOI_COLD_SN = '$data->TOC_COLD_SN') + '&' + '$data->FOI_TrainNetOrderNo'
WHERE
FOI_COLD_SN='$data->TOC_COLD_SN'";
$this->HT->query($sql);
$sql="IF NOT EXISTS(
SELECT TOP 1 1 FROM BIZ_TrainOrderCost
WHERE TOC_COLD_SN = ? AND TOC_Memo like ?
@ -188,7 +212,11 @@ class Order_people_model extends CI_Model {
BIZ_JuheOrderList.JOL_ToStation,
BIZ_JuheOrderList.JOL_TrainCode,
BIZ_JuheOrderList.JOL_Price,
BIZ_ConfirmLineInfo.COLI_ID
BIZ_JuheOrderList.JOL_IsAuto,
BIZ_JuheOrderList.JOL_SendMail,
BIZ_JuheOrderList.JOL_M_SN,
BIZ_ConfirmLineInfo.COLI_ID,
BIZ_ConfirmLineInfo.COLI_WebCode
FROM
BIZ_JuheOrderList
LEFT JOIN
@ -196,10 +224,21 @@ class Order_people_model extends CI_Model {
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)
BIZ_JuheOrderList.JOL_SN NOT IN(
SELECT
TOP {$page} JOL_SN
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}
ORDER BY JOL_SubTime DESC)
AND
{$where}
ORDER BY BIZ_JuheOrderList.JOL_SubTime DESC";
$query = $this->HT->query($sql);
$data->list=$query->result();
return $data;
@ -323,5 +362,22 @@ class Order_people_model extends CI_Model {
}
/*以上为get_ht_order优化代码*/
public function test($data){
$sql="IF EXISTS(
select * from BIZ_FlightsOrderInfo where FOI_COLD_SN = '$data->TOC_COLD_SN' and (FOI_TrainNetOrderNo is null or FOI_TrainNetOrderNo = '' or FOI_TrainNetOrderNo = '$data->FOI_TrainNetOrderNo'))
UPDATE BIZ_FlightsOrderInfo
SET
FOI_TrainNetOrderNo='$data->FOI_TrainNetOrderNo'
WHERE
FOI_COLD_SN='$data->TOC_COLD_SN'
ELSE
UPDATE BIZ_FlightsOrderInfo
SET
FOI_TrainNetOrderNo=(select FOI_TrainNetOrderNo from BIZ_FlightsOrderInfo where FOI_COLD_SN = '$data->TOC_COLD_SN') + '&' + '$data->FOI_TrainNetOrderNo'
WHERE
FOI_COLD_SN='$data->TOC_COLD_SN'";
print_r($sql);
$this->HT->query($sql);
}
}

@ -10,6 +10,7 @@ class Sendmail_model extends CI_Model {
function SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body)
{
$time = date('Y-m-d H:i:s',time());
if($this->validEmail($toEmail))
{
$data = array(
@ -22,9 +23,36 @@ class Sendmail_model extends CI_Model {
"M_Web" => "CHT", //所属站点
"M_FromName" => "Chinahighlights.com", //站点名称
"M_State" => 0,
"M_AddTime" => $time
);
$this->HT->insert('Email_AutomaticSend',$data);
return TRUE;
$m_sn = $this->HT->insert_id('Email_AutomaticSend');
return $m_sn;
}else{
return FALSE;
}
}
function SendMailToTabletest($fromName,$fromEmail,$toName,$toEmail,$subject,$body)
{
$time = date('Y-m-d H:i:s',time());
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,
"M_AddTime" => $time,
);
$this->HT->insert('Email_AutomaticSend',$data);
$m_sn = $this->HT->insert_id('Email_AutomaticSend');
return $m_sn;
}else{
return FALSE;
}
@ -41,6 +69,55 @@ class Sendmail_model extends CI_Model {
$local = substr($email, 0, $atIndex);
$localLen = strlen($local);
$domainLen = strlen($domain);
$domain = str_replace(' ','',$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;
}
public function validEmailtest($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);
$domain = str_replace(' ','',$domain);
print_r(preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain));
if ($localLen < 1 || $localLen > 64){
// local part length exceeded
$isValid = false;

@ -0,0 +1,461 @@
<?php
class tuniu_model extends CI_Model {
function __construct() {
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
$this->INFO = $this->load->database('INFO', TRUE);
}
//传入主订单翰特订单号COLI_ID161014006M获取子订单中火车订单的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();
}
//传入COLI_ID获取外联名
function get_operatorinfo($cols_id) {
$sql = "
SELECT
Name,
OPI_Name,
OPI_Email,
tel,
Mobile,
Email
FROM OperatorInfo
left join agenter_user
on AU_OPI_SN = OPI_SN
WHERE OPI_SN = (
SELECT COLI_OPI_ID
FROM BIZ_ConfirmLineInfo bcli
WHERE bcli.COLI_ID = ?
)
and agenter in ('cht', 'train_vac', 'jp', 'train_it', 'vc', 'ru')
";
$query = $this->HT->query($sql, $cols_id);
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();
}
//传入COLD_SN获取火车车次等信息
function get_biz_foi($cold_sn) {
$sql = "
SELECT FOI_COLD_SN,
FlightsNo,
Cabin,
Aircraft,
DepartureCity,
ArrivalCity,
DepartureDate,
DepartureTime,
ArrivalTime,
adultcost,
FOI_SelectedSeat,
FOI_TrainNetOrderNo,
FOI_SaleDate,
(
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
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);
if($query->num_rows() == 0){
return true;
}else{
return false;
}
}
public function get_order($pagesize=2,$page=0,$where="1=1"){
$data=new StdClass();
//获取总条数
$sql="SELECT COUNT(*) AS count FROM TuniuOrderList
LEFT JOIN
Tourmanager.dbo.BIZ_ConfirmLineInfo
ON
Tourmanager.dbo.BIZ_ConfirmLineInfo.COLI_SN=(SELECT COLD_COLI_SN FROM Tourmanager.dbo.BIZ_ConfirmLineDetail WHERE COLD_SN=substring(tol_retailOrderId,0,charindex('_',tol_retailOrderId)))
WHERE
{$where}
";
$query = $this->INFO->query($sql);
$count=$query->result();
$data->count=$count[0]->count;
$sql="SELECT TOP {$pagesize} TuniuOrderList.tol_subtime,
TuniuOrderList.tol_orderId,
TuniuOrderList.tol_returnCode,
TuniuOrderList.tol_retailOrderId,
TuniuOrderList.tol_Status,
TuniuOrderList.tol_errorMsg,
TuniuOrderList.tol_fromStationName,
TuniuOrderList.tol_toStationName,
TuniuOrderList.tol_cheCi,
TuniuOrderList.tol_orderAmount,
TuniuOrderList.tol_isauto,
TuniuOrderList.tol_sendmail,
Tourmanager.dbo.BIZ_ConfirmLineInfo.COLI_ID,
Tourmanager.dbo.BIZ_ConfirmLineInfo.COLI_WebCode
FROM
TuniuOrderList
LEFT JOIN
Tourmanager.dbo.BIZ_ConfirmLineInfo
ON
Tourmanager.dbo.BIZ_ConfirmLineInfo.COLI_SN=(SELECT COLD_COLI_SN FROM Tourmanager.dbo.BIZ_ConfirmLineDetail WHERE COLD_SN=substring(tol_retailOrderId,0,charindex('_',tol_retailOrderId)))
WHERE
TuniuOrderList.tol_orderId NOT IN(SELECT TOP {$page} TuniuOrderList.tol_orderId FROM TuniuOrderList ORDER BY TuniuOrderList.tol_sn DESC)
AND
{$where}
ORDER BY TuniuOrderList.tol_sn DESC";
$query = $this->INFO->query($sql);
$data->list=$query->result();
return $data;
}
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,
FOI_TrainNetOrderNo,
bfoi.adultcost
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
,bbp.BPE_PassportType
FROM BIZ_BookPeople bbp
WHERE BPE_SN in(".$bpe_sn.")
";
$query = $this->HT->query($sql);
return $query->result();
}
//添加途牛订单记录
function tuniu_add_biz_jol($data,$isauto){
if($isauto){
$isauto = 1;
}else{
$isauto = 0;
}
$sql="
INSERT INTO TuniuOrderList(
tol_subTime,
tol_cheCi,
tol_fromStationName,
tol_fromStationCode,
tol_toStationName,
tol_toStationCode,
tol_retailOrderId,
tol_orderId,
tol_status,
tol_errorMsg,
tol_isauto
)
VALUES(getdate(),?,?,?,?,?,?,?,?,?,?)
";
$query = $this->INFO->query($sql,array($data->tol_cheCi,$data->tol_fromStationName,$data->tol_fromStationCode,$data->tol_toStationName,$data->tol_toStationCode,$data->tol_retailOrderId,$data->tol_orderId,$data->tol_status,$data->tol_errorMsg,$isauto));
return $query;
}
//途牛预定处理
function book_tuniu_order($data){
$sql = "
UPDATE TuniuOrderList
set
tol_orderId = '{$data['orderId']}',
tol_returnCode = '{$data['returnCode']}',
tol_status = '2',
tol_errorMsg = '{$data['errorMsg']}',
--tol_fromStationCode = '{$data['fromStationCode']}',
--tol_fromStationName = '{$data['fromStationName']}',
--tol_toStationCode = '{$data['toStationCode']}',
--tol_toStationName = '{$data['toStationName']}',
--tol_cheCi = '{$data['cheCi']}',
tol_orderAmount = '{$data['orderAmount']}',
tol_booktxt = '{$data['backtxt']}'
WHERE
tol_retailOrderId = '{$data['retailOrderId']}'
";
$query = $this->INFO->query($sql);
return $query;
}
//确认出票更新
public function confirm_tuniu_order($data){
$sql = "
UPDATE TuniuOrderList
set
tol_orderId = '{$data['orderId']}',
tol_returnCode = '{$data['returnCode']}',
tol_status = '4',
tol_errorMsg = '{$data['errorMsg']}',
tol_confirmtxt = '{$data['confirmtxt']}'
WHERE
tol_retailOrderId = '{$data['retailOrderId']}'
";
$query = $this->INFO->query($sql);
return $query;
}
//退票更新
public function return_tuniu_order($data){
$sql = "
UPDATE TuniuOrderList
set
tol_returnCode = '{$data['returnCode']}',
tol_status = '7',
tol_errorMsg = '{$data['errorMsg']}',
tol_returntxt = '{$data['returntxt']}'
WHERE
tol_retailOrderId = '{$data['retailOrderId']}'
";
$query = $this->INFO->query($sql);
return $query;
}
//抢票更新
public function grab_tuniu_order($data){
$sql = "
UPDATE TuniuOrderList
set
tol_returnCode = '{$data['returnCode']}',
tol_status = '9',
tol_errorMsg = '{$data['errorMsg']}',
tol_fromStationCode = '{$data['fromStationCode']}',
tol_fromStationName = '{$data['fromStationName']}',
tol_toStationCode = '{$data['toStationCode']}',
tol_toStationName = '{$data['toStationName']}',
tol_cheCi = '{$data['cheCi']}',
tol_orderAmount = '{$data['orderAmount']}',
tol_booktxt = '{$data['booktxt']}'
WHERE
tol_retailOrderId = '{$data['retailOrderId']}'
";
$query = $this->INFO->query($sql);
return $query;
}
//取消抢票更新
public function cancelgragticket($data){
$sql = "
UPDATE TuniuOrderList
set
tol_errorMsg = '{$data['errorMsg']}',
tol_returnCode = '{$data['returnCode']}',
tol_status = '8',
tol_orderId = '{$data['orderId']}'
WHERE
tol_retailOrderId = '{$data['retailOrderId']}'
";
$query = $this->INFO->query($sql);
return $query;
}
//获取途牛订单信息
public function get_tuniuorder_info($retailOrderId,$orderId){
$sql = 'select tol_booktxt from TuniuOrderList where tol_retailOrderId = ? and tol_orderId =?';
$query = $this->INFO->query($sql,array($retailOrderId,$orderId));
return $query->result();
}
//BIZ_TrainOrderCost,我的支付
//BIZ_FlightsOrderInfo.FOI_TrainNetOrderNo,更新取票号
public function add_grab_order($data){
$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;
//删除多余支付记录
$sql = "delete from BIZ_TrainOrderCost where TOC_COLI_SN = '{$CCSN}' and TOC_TicketCost is null";
$query=$this->HT->query($sql);
$sql="IF EXISTS(
select * from BIZ_FlightsOrderInfo where FOI_COLD_SN = '$data->TOC_COLD_SN' and (FOI_TrainNetOrderNo is null or FOI_TrainNetOrderNo = '' or FOI_TrainNetOrderNo like '%$data->FOI_TrainNetOrderNo%'))
UPDATE BIZ_FlightsOrderInfo
SET
FOI_TrainNetOrderNo='$data->FOI_TrainNetOrderNo'
WHERE
FOI_COLD_SN='$data->TOC_COLD_SN'
ELSE
UPDATE BIZ_FlightsOrderInfo
SET
FOI_TrainNetOrderNo=(select FOI_TrainNetOrderNo from BIZ_FlightsOrderInfo where FOI_COLD_SN = '$data->TOC_COLD_SN') + '&' + '$data->FOI_TrainNetOrderNo'
WHERE
FOI_COLD_SN='$data->TOC_COLD_SN'";
$this->HT->query($sql);
$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 add_return_order($data){
$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;
$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_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_TicketCost));
return $query;
}
public function update_status($data){
$sql = "update
TuniuOrderList
set
tol_status = '9',
tol_returnCode = '{$data['returnCode']}',
tol_errorMsg = '{$data['errorMsg']}'
where
tol_retailOrderId = '{$data['retailOrderId']}'
";
$query = $this->INFO->query($sql);
return $query;
}
public function get_transaction_record(){
$sql = "select * from TuniuExcel";
$query = $this->INFO->query($sql);
return $query->result();
}
public function get_order_info($order){
$sql = "SELECT tol_retailOrderId,tol_orderId FROM TuniuOrderList WHERE tol_orderId = '{$order}'";
$query = $this->INFO->query($sql);
return $query->result();
}
public function get_coli_id($cold_sn){
$sql = "select * from BIZ_ConfirmLineInfo where coli_sn = (select cold_coli_sn from BIZ_ConfirmLineDetail where COLD_SN = '{$cold_sn}')";
$query = $this->HT->query($sql);
return $query->result();
}
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();
}
public function test(){
$sql = "delete from TuniuOrderList where tol_sn in (18,20)";
$query = $this->INFO->query($sql);
return $query;
}
}
?>

@ -0,0 +1,16 @@
<?php
class tuniuprice_model extends CI_Model {
function __construct() {
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
}
}
?>

@ -1,70 +1,33 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
*{ font-family:Verdana, Geneva, sans-serif;}
h1{ font-size:18px; text-align:center; color:#545454; margin:0 0 10px 0!important;}
p{ font-size:14px; color:#545454; line-height:22px; margin-bottom:12px!important;}
table.table{ width:90%; border-width:1px 1px 0 1px; border-color:#d1d1d1; border-style: solid; margin-bottom:15px;}
table.table th{ background:#f1f1f1; color:#666; border-bottom:1px solid #d1d1d1; width:180px; font-size:14px; text-align:left; padding:8px 10px 8px 10px;}
table.table td{ padding:8px 0 8px 10px; border-bottom:1px solid #d1d1d1; font-size:14px; color:#545454;}
</style>
</head>
<body>
<h1>China Highlights Booking Confirmation</h1>
<p>Dear <?php echo $user[0]->GUT_LastName?>,</p>
<p>Thanks for payment US$145 . The train tickets have already been issued. </p>
<p> You can collect the paper ticket(s) from now at any train station in mainland China. </p>
<p> Please present all passenger(s) original passport(s) and Ticket Pick Up No.E601014106 &nbsp;at any ticket collecting counters (in Chinese 取票窗口)of any railway stations in mainland China. They will then issue your paper train ticket(s). </p>
<table border="0" cellpadding="0" cellspacing="0" class="table">
<tr>
<th>Passenger(s)</th>
<td><p>2 adult(s)
</p>
<p> 1. ALEXANDER JAMES JOHNSON , passport number 503406354<br />
2. SIAN MARIE JOHNSON , passport number 528876517</p></td>
</tr>
</table>
<p>Train 1:</p>
<table border="0" cellpadding="0" cellspacing="0" class="table">
<tr>
<th><strong>Ticket Pick Up No.</strong></th>
<td>E601014106&nbsp; </td>
</tr>
<tr>
<th><strong>Train No.</strong></th>
<td>Z19</td>
</tr>
<tr>
<th><strong>Departure</strong></th>
<td>20:40 Jun.06 Beijing Xi (West) Station(in Chinese 北京西火车站)</td>
</tr>
<tr>
<th><strong>Arrival</strong></th>
<td>08:31AM Jun.07 Xi'an Station(in Chinese 西安火车站) </td>
</tr>
<tr>
<th><strong>Class</strong></th>
<td>Soft Sleeper </td>
</tr>
</table>
<p>Kindly note below:</p>
<p> 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.</p>
<p> 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.</p>
<p> 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.<br />
If you&rsquo;ve already collected before the departure day, it is also wise to be at the station at least 40 minutes ahead. </p>
<p> 4. Download railway station instructions, maps and tips at <a href="http://www.chinahighlights.com/china-trains/station-map.htm">http://www.chinahighlights.com/china-trains/station-map.htm</a> <br />
<br />
5.Terms &amp; Conditions. <a href="http://www.chinahighlights.com/china-trains/booking-policy.htm">http://www.chinahighlights.com/china-trains/booking-policy.htm</a></p>
<p> Best Regards!<br />
Iris Wang, Travel Advisor<br />
Tel: +86-773-2801368 &nbsp;Mobile:+86-18775900313 <br />
Fax: 86-773-2827424, 86-773-2885308 <br />
E-mail: <a href="mailto:iris@chinahighlights.me">iris@chinahighlights.me</a><br />
<a href="http://www.chinahighlights.com">www.chinahighlights.com</a> <br />
Address: Building 6, Chuangyi Business Park, 70 Qilidian Road, Guilin, Guangxi, 541004, China<br />
If you wish to share anything with my supervisor (Ms. Alex Yang), please feel free to send your email to <a href="mailto:alex@chinahighlights.net">alex@chinahighlights.net</a>. </p>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>China train ticket(s) confirmed, Booking Number <?php echo $coli_id;?></title><style>*{ font-family:Verdana, Geneva, sans-serif; color:#545454;}</style></head><body style="font-family:Verdana, Geneva, sans-serif; border-left:1px solid #d1d1d1; border-right:1px solid #d1d1d1;"><h1 style="font-size:20px; text-align:center;">China Highlights Booking Confirmation</h1><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Dear <?php echo $toname?>,</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Thank you for your payment of US$<?php echo $price->GAI_SQJE?> . The train tickets have already been issued. </p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> You can collect the paper ticket(s) from now on at any train station in mainland China.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"><strong>Please note:</strong></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">1.Please present the <strong>original passport(s) of all the passenger(s)</strong> and the ticket pick-up number(s) <span style="color:#33F"><?php echo $juhe_info->ordernumber;?></span> at ticket collection counters. The counter will then issue your paper train ticket(s). </p>
<p>See the <a style="color:#33F" href="https://www.chinahighlights.com/travelguide/transportation/how-to-board-train.htm">video</a> about how to collect the ticket(s) in China.
</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">2.Please double check the train(s) information and passport information. Let us know AT ONCE if you see any mistakes below. We can try to cancel tickets to minimize your loss. A 20% cancellation fee is charged by China Railway.</p><table border="0" cellpadding="0" cellspacing="0" style="width:100%; border-top:3px solid #a31022; border-left:1px solid #d1d1d1; margin-bottom:15px;"><tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;width: 293px;">Ticket collection sentences</th><td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;"><p>The bilingual note below might help you pick up tickets at the ticket collection counter more easily.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 1.Please show me which window for picking up the train ticket. 你好,请问哪个是取票窗?</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">2.Please issue the paper tickets for me. The following is the pick up numbers.请帮我出票,电子取票号如下.</p></td></tr></table>
<?php
$j = 0;
foreach($train_info as $item){
echo '<table border="0" cellpadding="0" cellspacing="0" style="width:100%; border-top:3px solid #a31022; border-left:1px solid #d1d1d1; margin-bottom:15px;">
<tr>
<th style="width: 293px;text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Pick up number</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;"><span style="color:#33F">'.$item->FOI_TrainNetOrderNo.'</span></td>';
echo '</tr><tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Train No.</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->FlightsNo.'</td></tr><tr>';
echo '<th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Departure</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->DepartureTime.' '.$item->DepartureCity.' Station(in Chinese '.$item->DepartAirport_cn.'火车站)</td></tr>';
echo '<tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Arrival</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->ArrivalTime.' '.$item->ArrivalCity.' Station(in Chinese '.$item->ArrivalAirport_cn.'火车站)</td></tr>';
echo '<tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Class</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->Cabin.' ('.$seatinfo.')</td></tr></table>';
}
?>
<table border="0" cellpadding="0" cellspacing="0" style="width:100%; border-top:3px solid #a31022; border-left:1px solid #d1d1d1; margin-bottom:15px;"><tr><th style="width: 293px;text-align:left; padding:10px; font-size:14px; background:#f1f1f1;">Passenger(s)</th><td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;"><p><?php
if($adult>0){echo $adult.' adult(s) ';}
if($chlid>0){echo $chlid.' chlid(s) ';}
if($baby>0){echo $baby.' baby(s) ';}
?></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> <?php
$i=0;
foreach($allpeople as $item){
echo ++$i.'.'.$item->BPE_FirstName.$item->BPE_MiddleName.$item->BPE_LastName.' , passport number '.$item->BPE_Passport.'<br>';
}
?></p></td></tr></table>
<p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 3.On your departure day, please time your arrival at the station wisely. If you are going to collect your train ticket(s) on the departure day, allow enough time waiting in the queue of the ticket collection counter, for the security x-ray check of your luggage, and for the ticket check before entering the passenger lounge. Tickets will stop being issued 30 minutes prior to departure. We suggest you be at the station at least 1.5 hours ahead of the stated departure time. Please leave at least 2.5 hours during public holidays.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 4.If youve already collected your ticket before the departure day, we recommend that you be at the station at least 40 minutes ahead of time. Please be at the station at least 1.5 hours during a public holiday. </p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 5.Please don't throw your ticket(s) away because you'll need it to exit the station.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">6.If you cancel the ticket(s) at a train station yourself, the money will be refunded to our account. Please cancel the tickets before the train departure. And email us then we will refund you accordingly.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">7.<a style="color:#33F" href="https://www.chinahighlights.com/china-trains/booking-policy.htm">China Highlights train ticket booking policy </a></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Should you have any questions about your train ticket bookings, please do not hesitate to contact me.</p>
<p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Best Regards!</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"><?php echo $operator[0]->Name?>, Travel Advisor</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Tel: <?php echo $operator[0]->tel;?> Mobile: <?php echo $operator[0]->Mobile;?> </p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Fax: 86-773-2827424, 86-773-2885308 </p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> E-mail: <a href="mailto:<?php echo $emailarr[0]?>"><?php echo $emailarr[0]?>;</a><a href="mailto:<?php echo $emailarr[1]?>"><?php echo $emailarr[1]?>;</a></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">WeChat: CH_train<p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"><a href="http://www.chinahighlights.com">www.chinahighlights.com</a></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Address: Building 6, Chuangyi Business Park, 70 Qilidian Road, Guilin, Guangxi, 541004, China</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> If you wish to share anything with my supervisor (Ms. ethel), please feel free to send your email to <a href="mailto:ethel@chinahighlights.net">ethel@chinahighlights.net</a>.</p></body></html>

@ -0,0 +1,48 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>China Highlights Booking Confirmation</title><style>*{ font-family:Verdana, Geneva, sans-serif; color:#545454;}</style></head><body style="font-family:Verdana, Geneva, sans-serif; border-left:1px solid #d1d1d1; border-right:1px solid #d1d1d1;"><h1 style="font-size:20px; text-align:center;">China Highlights Booking Confirmation</h1><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Dear <?php echo $toname?>,</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Thanks for payment US$<?php echo $price->GAI_SQJE?> . The train tickets have already been issued. </p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> You can collect the paper ticket(s) from now at any train station in mainland China.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 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.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Please collect your paper tickets from a ticket counter in the train station. Tickets will stop being printed 30 minutes prior to departure. On departure day, please time your arrival wisely. If you are going to collect your tickets on departure day, allow for time waiting in queue at the ticket-counter, for security checks and for ticket checks. We suggest you be at the station at least 1.5 hours ahead of the stated departure time.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">If youve already collected before the departure day, it is also wise to be at the station at least 40 minutes ahead. </p><table border="0" cellpadding="0" cellspacing="0" style="width:100%; border-top:3px solid #a31022; border-left:1px solid #d1d1d1; margin-bottom:15px;"><tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;">Passenger(s)</th><td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;"><p><?php
if($adult>0){echo $adult.' adult(s) ';}
if($chlid>0){echo $chlid.' chlid(s) ';}
if($baby>0){echo $baby.' baby(s) ';}
?></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> <?php
$i=0;
foreach($allpeople as $item){
echo ++$i.'.'.$item->BPE_FirstName.$item->BPE_MiddleName.$item->BPE_LastName.' , passport number '.$item->BPE_Passport.'<br>';
}
?></p></td></tr></table>
<?php
$j = 0;
foreach($train_info as $item){
echo '<p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Train'.++$j.':</p>';
echo '<table border="0" cellpadding="0" cellspacing="0" style="width:100%; border-top:3px solid #a31022; border-left:1px solid #d1d1d1; margin-bottom:15px;">
<tr>
<th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Ticket Pick Up No.</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;"><span style="color:#33F">'.$item->FOI_TrainNetOrderNo.'</span></td>';
echo '</tr><tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Train No.</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->FlightsNo.'</td></tr><tr>';
echo '<th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Departure</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->DepartureTime.' '.$item->DepartureCity.' Station(in Chinese '.$item->DepartAirport_cn.'火车站)</td></tr>';
echo '<tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Arrival</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->ArrivalTime.' '.$item->ArrivalCity.' Station(in Chinese '.$item->ArrivalAirport_cn.'火车站)</td></tr>';
echo '<tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Class</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->Cabin.'</td></tr></table>';
}
?>
<p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Kindly note below:</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">1.Please present all passenger(s) original passport(s) and Ticket Pick Up No.<span style="color:#33F"><?php echo $item->FOI_TrainNetOrderNo?></span>at any ticket counters of any railway stations. They will then issue your paper train ticket(s). You can find more instruction of collecting tickets enclosure.
</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 2.You can show screenshot of the paper tickets to the railway station counter. It helps get paper tickets easily.</p>
<?php
foreach($train_info as $obj){
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
echo '<tr style="background:#f0f0f0; color:#545454; font-weight:100; font-size:20px; ">';
echo ' <th style="font-weight:100; font-size:18px; text-align:left;padding:8px 10px; border-top:3px solid #ad1818;">'.substr($obj->DepartureDate,0,10).'&nbsp;&nbsp;&nbsp;'.$obj->FlightsNo.'&nbsp;&nbsp;&nbsp;'.$obj->FOI_TrainNetOrderNo.'</th></tr><tr>';
echo '<td style=" padding:8px 10px; font-size:15px; color:#545454; border-bottom:1px solid #d1d1d1;"><p>'.$obj->DepartAirport_cn.'('.$obj->DepartureCity.')<span style=" font-size:12px;">'.$obj->DepartureTime.'</span> To '.$obj->ArrivalAirport_cn.'('.$obj->ArrivalCity.')<span style=" font-size:12px;">'.$obj->ArrivalTime.'</span></p></td></tr>';
foreach($juhe_info->passengers as $people){
echo '<tr><td style=" padding:8px 10px; font-size:15px; color:#545454; border-bottom:1px solid #d1d1d1;">';
echo '<p>'.$people->passengersename.'('.$people->piaotypename.') ';
echo $people->cxin.' 票价:¥'.$people->price.'</p>';
echo '</td></tr>';
}
echo '<tr><td style=" padding:8px 10px; font-size:15px; color:#545454; border-bottom:1px solid #d1d1d1;"><p>出票成功</p></td></tr></table>';
}
?>
<p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 3. 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 the ticket counter at other stations. Return tickets are treated separately. 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.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 4. Please keep your ticket(s) and don't throw your ticket(s) away once you've boarded your train, you'll need it to exit the station.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 5.Download railway station instructions, maps and tips at <a href="https://www.chinahighlights.com/china-trains/station-map.htm">https://www.chinahighlights.com/china-trains/station-map.htm</a></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">6.Terms & Conditions. <a href="https://www.chinahighlights.com/china-trains/booking-policy.htm">https://www.chinahighlights.com/china-trains/booking-policy.htm</a></p><p>&nbsp;</p>
<p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Best Regards!</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"><?php echo $operator[0]->Name?>, Travel Advisor</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Tel: <?php echo $operator[0]->tel;?> Mobile: <?php echo $operator[0]->Mobile;?> </p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Fax: 86-773-2827424, 86-773-2885308 </p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> E-mail: <a href="mailto:<?php echo $emailarr[0]?>"><?php echo $emailarr[0]?>;</a><a href="mailto:<?php echo $emailarr[1]?>"><?php echo $emailarr[1]?>;</a></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"><a href="http://www.chinahighlights.com">www.chinahighlights.com</a></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Address: Building 6, Chuangyi Business Park, 70 Qilidian Road, Guilin, Guangxi, 541004, China</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> If you wish to share anything with my supervisor (Ms. Alex Yang), please feel free to send your email to <a href="mailto:alex@chinahighlights.net">alex@chinahighlights.net</a>.</p></body></html>

@ -0,0 +1,26 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title></head><body><p style="font-family:Verdana, Geneva, sans-serif; font-size:14px; line-height:24px; margin-bottom:12px;">Dear <?php echo $toname?>,</p><p style="font-family:Verdana, Geneva, sans-serif; font-size:14px; line-height:24px; margin-bottom:12px;"> Thank you for your booking (order number <?php echo $coli_id?>), we have received your payment of USD<?php echo $price->GAI_SQJE?>.&nbsp;</p><p style="font-family:Verdana, Geneva, sans-serif; font-size:14px; line-height:24px; margin-bottom:12px;"> Due to the heavy traffic flow of data, the system failed to automatically issue your ticket(s).</p><p style="font-family:Verdana, Geneva, sans-serif; font-size:14px; line-height:24px; margin-bottom:12px;">Your travel advisor will purchase your train ticket(s) manually. &nbsp;You will receive an email within half a working day (Our time now:&nbsp;<strong><?php echo date('H:i').' '.date('a');?></strong>, <?php echo date('D');?>,<?php echo date('F').' '.date('d').','.date('Y');?> GMT+8).Should you have any questions or concerns with regards to your train booking, please do not hesitate to contact me at <a href="mailto:<?php echo $emailarr[0]?>"><?php echo $emailarr[0]?></a>;<a href="mailto:<?php echo $emailarr[1]?>"><?php echo $emailarr[1]?></a> or telephone <?php echo $operator[0]->tel;?>. </p>
<?php foreach($train_info as $item){
echo '<table border="0" cellspacing="0" cellpadding="0" width="60%">';
echo '<tr><th width="17%" style="font-family:Verdana, Geneva, sans-serif;font-size:14px; color:#a31022; background:#e6e6e6; text-align:left; padding:10px;">Train No. </th>';
echo '<td width="83%" style="font-family:Verdana, Geneva, sans-serif;font-size:14px; text-align:left; padding:10px; border-bottom:1px solid #d1d1d1;">'.$item->FlightsNo.'</td></tr>';
echo '<tr><th style="font-family:Verdana, Geneva, sans-serif; font-size:14px; color:#a31022; background:#e6e6e6; text-align:left; padding:10px;">Departure </th>';
echo '<td style="font-family:Verdana, Geneva, sans-serif; font-size:14px; text-align:left; padding:10px; border-bottom:1px solid #d1d1d1;">'.$item->DepartureTime.', '.$item->DepartureCity.' Station(in Chinese '.$item->DepartAirport_cn.'火车站)&nbsp;</td></tr>';
echo '<tr><th style="font-family:Verdana, Geneva, sans-serif; font-size:14px; color:#a31022; background:#e6e6e6; text-align:left; padding:10px;">Arrival </th><td style="font-family:Verdana, Geneva, sans-serif; font-size:14px; text-align:left; padding:10px; border-bottom:1px solid #d1d1d1;">'.$item->ArrivalTime.', '.$item->ArrivalCity.'(in Chinese'. $item->ArrivalAirport_cn.'火车站)&nbsp; </td></tr>';
echo '<tr><th style="font-family:Verdana, Geneva, sans-serif; font-size:14px; color:#a31022; background:#e6e6e6; text-align:left; padding:10px;">Class </th><td style="font-family:Verdana, Geneva, sans-serif; font-size:14px; text-align:left; padding:10px; border-bottom:1px solid #d1d1d1;">'.$item->Cabin.'</td></tr>';
echo '<tr><th style="font-family:Verdana, Geneva, sans-serif; font-size:14px; color:#a31022; background:#e6e6e6; text-align:left; padding:10px;">Passenger(s) </th>';
echo '<td style="font-family:Verdana, Geneva, sans-serif; font-size:14px; text-align:left; padding:10px; border-bottom:1px solid #d1d1d1;">';
if($adult>0){echo $adult.' adult(s)<br/> ';}
if($chlid>0){echo $chlid.' chlid(s)<br/> ';}
if($baby>0){echo $baby.' baby(s)<br/> ';}
$i=0;
foreach($allpeople as $item){
echo ++$i.'.'.$item->BPE_FirstName.$item->BPE_MiddleName.$item->BPE_LastName.' , passport number '.$item->BPE_Passport.'<br>';
}
echo '</tr></table>';
echo '<p style="font-family:Verdana, Geneva, sans-serif; font-size:14px; line-height:24px; margin-bottom:12px;">Regards <br />';
echo $operator[0]->Name.'<br/>Travel Advisor<br/>';
echo 'Telephone:&nbsp;(Office)'.$operator[0]->tel.', M: '.$operator[0]->Mobile.',';
echo 'Email: <a href="mailto:'.$emailarr[0].'">'.$emailarr[0].'</a>;<a href="mailto:'.$emailarr[1].'">'.$emailarr[1].'</a>;&nbsp</p>';
}?>
</body>
</html>

@ -0,0 +1,33 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>China train ticket(s) confirmed, Booking Number <?php echo $coli_id;?></title><style>*{ font-family:Verdana, Geneva, sans-serif; color:#545454;}</style></head><body style="font-family:Verdana, Geneva, sans-serif; border-left:1px solid #d1d1d1; border-right:1px solid #d1d1d1;"><h1 style="font-size:20px; text-align:center;">China Highlights Booking Confirmation</h1><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Dear <?php echo $toname?>,</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Thank you for your payment of US$<?php echo $price->GAI_SQJE?> . The train tickets have already been issued. </p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> You can collect the paper ticket(s) from now on at any train station in mainland China.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"><strong>Please note:</strong></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">1.Please present the <strong>original passport(s) of all the passenger(s)</strong> and the ticket pick-up number(s) <span style="color:#33F"><?php echo $juhe_info->ordernumber;?></span> at ticket collection counters. The counter will then issue your paper train ticket(s). </p>
<p>See the <a style="color:#33F" href="https://www.chinahighlights.com/travelguide/transportation/how-to-board-train.htm">video</a> about how to collect the ticket(s) in China.
</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">2.Please double check the train(s) information and passport information. Let us know AT ONCE if you see any mistakes below. We can try to cancel tickets to minimize your loss. A 20% cancellation fee is charged by China Railway.</p><table border="0" cellpadding="0" cellspacing="0" style="width:100%; border-top:3px solid #a31022; border-left:1px solid #d1d1d1; margin-bottom:15px;"><tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;width: 293px;">Ticket collection sentences</th><td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;"><p>The bilingual note below might help you pick up tickets at the ticket collection counter more easily.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 1.Please show me which window for picking up the train ticket. 你好,请问哪个是取票窗?</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">2.Please issue the paper tickets for me. The following is the pick up numbers.请帮我出票,电子取票号如下.</p></td></tr></table>
<?php
$j = 0;
foreach($train_info as $item){
echo '<table border="0" cellpadding="0" cellspacing="0" style="width:100%; border-top:3px solid #a31022; border-left:1px solid #d1d1d1; margin-bottom:15px;">
<tr>
<th style="width: 293px;text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Pick up number</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;"><span style="color:#33F">'.$item->FOI_TrainNetOrderNo.'</span></td>';
echo '</tr><tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Train No.</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->FlightsNo.'</td></tr><tr>';
echo '<th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Departure</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->DepartureTime.' '.$item->DepartureCity.' Station(in Chinese '.$item->DepartAirport_cn.'火车站)</td></tr>';
echo '<tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Arrival</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->ArrivalTime.' '.$item->ArrivalCity.' Station(in Chinese '.$item->ArrivalAirport_cn.'火车站)</td></tr>';
echo '<tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Class</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->Cabin.' ('.$seatinfo.')</td></tr></table>';
}
?>
<table border="0" cellpadding="0" cellspacing="0" style="width:100%; border-top:3px solid #a31022; border-left:1px solid #d1d1d1; margin-bottom:15px;"><tr><th style="width: 293px;text-align:left; padding:10px; font-size:14px; background:#f1f1f1;">Passenger(s)</th><td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;"><p><?php
if($adult>0){echo $adult.' adult(s) ';}
if($chlid>0){echo $chlid.' chlid(s) ';}
if($baby>0){echo $baby.' baby(s) ';}
?></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> <?php
$i=0;
foreach($allpeople as $item){
echo ++$i.'.'.$item->BPE_FirstName.$item->BPE_MiddleName.$item->BPE_LastName.' , passport number '.$item->BPE_Passport.'<br>';
}
?></p></td></tr></table>
<p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 3.On your departure day, please time your arrival at the station wisely. If you are going to collect your train ticket(s) on the departure day, allow enough time waiting in the queue of the ticket collection counter, for the security x-ray check of your luggage, and for the ticket check before entering the passenger lounge. Tickets will stop being issued 30 minutes prior to departure. We suggest you be at the station at least 1.5 hours ahead of the stated departure time. Please leave at least 2.5 hours during public holidays.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 4.If youve already collected your ticket before the departure day, we recommend that you be at the station at least 40 minutes ahead of time. Please be at the station at least 1.5 hours during a public holiday. </p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 5.Please don't throw your ticket(s) away because you'll need it to exit the station.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">6.If you cancel the ticket(s) at a train station yourself, the money will be refunded to our account. Please cancel the tickets before the train departure. And email us then we will refund you accordingly.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">7.<a style="color:#33F" href="https://www.chinahighlights.com/china-trains/booking-policy.htm">China Highlights train ticket booking policy </a></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Should you have any questions about your train ticket bookings, please do not hesitate to contact me.</p>
<p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Best Regards!</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"><?php echo $operator[0]->Name?>, Travel Advisor</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Tel: <?php echo $operator[0]->tel;?> Mobile: <?php echo $operator[0]->Mobile;?> </p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Fax: 86-773-2827424, 86-773-2885308 </p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> E-mail: <a href="mailto:<?php echo $emailarr[0]?>"><?php echo $emailarr[0]?>;</a><a href="mailto:<?php echo $emailarr[1]?>"><?php echo $emailarr[1]?>;</a></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">WeChat: CH_train<p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"><a href="http://www.chinahighlights.com">www.chinahighlights.com</a></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Address: Building 6, Chuangyi Business Park, 70 Qilidian Road, Guilin, Guangxi, 541004, China</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> If you wish to share anything with my supervisor (Ms. ethel), please feel free to send your email to <a href="mailto:ethel@chinahighlights.net">ethel@chinahighlights.net</a>.</p></body></html>

@ -0,0 +1,23 @@
<div style="width:90%;margin:30px auto;">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">交易记录导出&nbsp;<a style="margin-left:50px;" target='_blank' href="<?php echo site_url('apps/train/index/ht_order_list');?>">订单列表>></a> </h3>
</div>
<div class="panel-body">
<form style="width: 500px;float: left;" action="" method="post">
<input type="text" name="from_date" class="date" value="">
<input type="text" name="to_date" class="date" value="">
<button type="submit" id="sub" class="btn btn-warning btn-sm"><span class="glyphicon glyphicon-download-alt"></span> 导出</button>
</form>
<p style="margin: 0 0 10px; width: 200px; float: left; line-height: 30px;">
</div>
</div>
</div>
<script>
$(".date").datepicker({
'format': 'yyyy-m-d',
'autoclose': true
});
</script>

@ -9,6 +9,22 @@
<div class="col-md-6">
<input class="form-control" type="text" placeholder="汉特订单号或聚合订单号" name="order" value="<?php echo !empty($order)?"$order":"";?>">
</div>
<div class="col-md-4">
<select class="form-control" name="web_code">
<option value ="分站点查询,默认商旅" disabled="disabled" selected>分站点查询,默认全站</option>
<option value ="CHT">商旅</option>
<option value ="jp">日本</option>
<option value="train_vac">西班牙</option>
<option value="train_it">意大利</option>
<option value="train_ru">俄罗斯</option>
<option value="train_vc">法国</option>
</select>
</div>
<!--<div class="col-md-5">
<input type="text" name="from_date" class="date" value="" class="">
<input type="text" name="to_date" class="date" value="">
</div>-->
<div class="col-md-5">
<button type="submit" id="sub" class="btn btn-success btn-sm"><span class="glyphicon glyphicon-search"></span> 搜索</button>
</div>
@ -25,7 +41,7 @@
<thead>
<tr>
<th style="text-align:center;">序号</th>
<th style="text-align:center;">汉特订单号</th>
<th style="text-align:center;">汉特订单号(商家订单号)</th>
<th style="text-align:center;">聚合订单号</th>
<th style="text-align:center;">车次</th>
<th style="text-align:center;">出发</th>
@ -33,6 +49,9 @@
<th style="text-align:center;">状态</th>
<th style="text-align:center;">价格</th>
<th style="text-align:center;">提交时间</th>
<th style="text-align:center;">所属部门</th>
<th style="text-align:center;">出票方式</th>
<th style="text-align:center;">是否发送邮件</th>
<th style="text-align:center;">操作</th>
</tr>
</thead>
@ -40,7 +59,7 @@
<?php $num=0; foreach($data as $v):?>
<tr>
<td><?php echo ++$num;?></td>
<td><?php echo $v->COLI_ID;?></td>
<td><?php echo $v->COLI_ID.'('.$v->JOL_COLD_SN.')';?></td>
<td><?php echo $v->JOL_JuheOrder;?></td>
<td><?php echo $v->JOL_TrainCode;?></td>
<td><?php echo $v->JOL_FromStation;?></td>
@ -48,6 +67,27 @@
<td><?php echo $v->info;?></td>
<td><?php echo $v->JOL_Price;?></td>
<td><?php echo $v->JOL_SubTime;?></td>
<td><?php echo $v->COLI_WebCode;?></td>
<?php
if($v->JOL_IsAuto == 1){
echo '<td>自动</td>';
}elseif($v->JOL_IsAuto == 0){
echo '<td>手动</td>';
}elseif($v->JOL_IsAuto == 3){
echo '<td>抢票</td>';
}
?>
<?php
if($v->JOL_SendMail == 1){
if($v->JOL_M_SN){
echo '<td><a target="_blank" href="http://www.mycht.cn/info.php/apps/train/index/get_mailinfo/'.$v->JOL_M_SN.'"></a></td>';
}else{
echo '<td></td>';
}
}else{
echo '<td></td>';
}
?>
<td><a target="_blank" href="order?order=<?php echo $v->JOL_JuheOrder;?>">详情</a></td>
</tr>
<?php endforeach;?>

@ -1,7 +1,83 @@
<style>
.clear {clear: both;}
.train-summary{ font-size:12px; margin-bottom:10px;}
.train-summary span{ color:#9a0918;}
a:link.seat-a{background-image:url(/css/images/train/a-seat.jpg); background-repeat:no-repeat; width:131px; display:block; height:42px; float:left;}
a:hover.seat-a{background-image:url(/css/images/train/a-seath.jpg);}
.selected_seat-a{background-image:url(/css/images/train/a-seata.jpg)!important; background-repeat:no-repeat; width:55px; display:block; height:42px; float:left;}
a:link.seat-b{background-image:url(/css/images/train/b-seat.jpg); background-repeat:no-repeat; text-decoration:none; width:55px; display:block; height:42px; float:left;}
a:hover.seat-b{background-image:url(/css/images/train/b-seath.jpg);}
.selected_seat-b{background-image:url(/css/images/train/b-seata.jpg)!important; background-repeat:no-repeat; width:55px; display:block; height:42px; float:left;}
a:link.seat-c{background-image:url(/css/images/train/c-seat.jpg); background-repeat:no-repeat; width:131px; display:block; height:42px; float:left;}
a:hover.seat-c{background-image:url(/css/images/train/c-seath.jpg);}
.selected_seat-c{background-image:url(/css/images/train/c-seata.jpg)!important; background-repeat:no-repeat; width:55px; display:block; height:42px; float:left;}
a:link.seat-d{background-image:url(/css/images/train/d-seat.jpg); background-repeat:no-repeat; width:55px; display:block; height:42px; float:left;}
a:hover.seat-d{background-image:url(/css/images/train/d-seath.jpg);}
.selected_seat-d{background-image:url(/css/images/train/d-seata.jpg)!important; background-repeat:no-repeat; width:136px; display:block; height:42px; float:left;}
a:link.seat-f{background-image:url(/css/images/train/f-seat.jpg); background-repeat:no-repeat; width:136px; display:block; height:42px; float:left;}
a:hover.seat-f{background-image:url(/css/images/train/f-seath.jpg);}
.selected_seat-f{background-image:url(/css/images/train/f-seata.jpg)!important; background-repeat:no-repeat; width:136px; display:block; height:42px; float:left;}
a:link.sleep-a {background-image:url(/css/images/train/l-up.jpg); background-repeat:no-repeat; width:163px; display:block; height:38px; float:left; }
a:hover.sleep-a { background-image:url(/css/images/train/l-upa.jpg); }
.selected_sleep-a { background-image:url(/css/images/train/l-upa.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-b {background-image:url(/css/images/train/r-up.jpg); background-repeat:no-repeat; width:104px; display:block; height:38px; float:left; }
a:hover.sleep-b { background-image:url(/css/images/train/r-upa.jpg); }
.selected_sleep-b { background-image:url(/css/images/train/r-upa.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-c {background-image:url(/css/images/train/l-mid.jpg); background-repeat:no-repeat; width:163px; display:block; height:38px; float:left; }
a:hover.sleep-c { background-image:url(/css/images/train/l-mida.jpg); }
.selected_sleep-c { background-image:url(/css/images/train/l-mida.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-d {background-image:url(/css/images/train/r-mid.jpg); background-repeat:no-repeat; width:104px; display:block; height:38px; float:left; }
a:hover.sleep-d { background-image:url(/css/images/train/r-mida.jpg); }
.selected_sleep-d { background-image:url(/css/images/train/r-mida.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-e {background-image:url(/css/images/train/l-low.jpg); background-repeat:no-repeat; width:163px; display:block; height:38px; float:left; }
a:hover.sleep-e { background-image:url(/css/images/train/l-lowa.jpg); }
.selected_sleep-e { background-image:url(/css/images/train/l-lowa.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-f {background-image:url(/css/images/train/r-low.jpg); background-repeat:no-repeat; width:104px; display:block; height:38px; float:left; }
a:hover.sleep-f { background-image:url(/css/images/train/r-lowa.jpg); }
.selected_sleep-f { background-image:url(/css/images/train/r-lowa.jpg)!important; width:104px; display:block; height:38px; float:left; }
</style>
<script>
$(function(){
//var selected = $('.selectticket').find('.selected').length;
//$('.selected_People').html(selected);
});
function selseat(seat){
var type = $(seat).attr('type');
var total = $(seat).parent().parent().find('.train-summary .seat_TotalPeople').html();
if(total>=5){
total = 5;
$('.seat_TotalPeople').html(total);
}
var count = $(seat).parent().parent().find('.selected').length;
console.log('执行之前的数量'+count);
//处理选座事件
if($(seat).hasClass('selected_'+type)){
$(seat).removeClass('selected');
$(seat).removeClass('selected_'+type);
count = $(seat).parent().parent().find('.selected').length;
$('.selected_People').html(count);
console.log('减掉之后'+count);
}else{
if(count >= total){
alert('You already chose seats for all the passengers.');
}else{
$(seat).addClass('selected_'+type);
$(seat).addClass('selected');
count = $(seat).parent().parent().find('.selected').length;
$('.selected_People').html(count);
console.log('增加之后'+count);
}
}
}
</script>
<div style="width:90%;margin:30px auto;">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">翰特订单号&nbsp;<a style="margin-left:50px;" target='_blank' href="<?php echo site_url('apps/train/index/ht_order_list');?>">订单列表>></a><a style="margin-left:50px;" target='_blank' href="<?php echo site_url('apps/train/index/export');?>">导出交易记录>></a> <span style="margin-left:200px;">版本V2.0</span><span class="pull-right">聚合余额(RMB)<?php echo $balance;?></span></h3>
<h3 class="panel-title">翰特订单号&nbsp;<a style="margin-left:50px;" target='_blank' href="<?php echo site_url('apps/train/index/ht_order_list');?>">订单列表>></a><a style="margin-left:50px;" target='_blank' href="<?php echo site_url('apps/train/tuniu_train/ht_order_list');?>">抢票订单列表>></a><a style="margin-left:50px;" target='_blank' href="<?php echo site_url('apps/train/index/export');?>">导出交易记录>></a> <span style="margin-left:200px;">版本V2.0</span><span class="pull-right">聚合余额(RMB)<?php echo $balance;?></span></h3>
</div>
<div class="panel-body">
<form style="width: 300px;float: left;" action="" method="post">
@ -46,7 +122,7 @@
<td><?php echo $v->train[0]->DepartureTime;?></td>
<td><?php echo $v->train[0]->ArrivalTime;?></td>
<td><?php echo $v->train[0]->adultcost;?></td>
<td><?php echo !empty($v->status)?"<span style='color:red;'>是</span>":"否";?></td>
<td><?php echo !empty($v->status)?"否":"<span style='color:green;'>是</span>";?></td>
<td><button type="button" class="btn btn-success pay_api" data-order="<?php echo $v->train[0]->FOI_COLD_SN;?>" title="超过五个乘客不可用" >快捷订票</button></td>
</tr>
<tr>
@ -71,6 +147,145 @@
<td><?php echo $p->BPE_GuestType==1?"成人":($p->BPE_GuestType==2?"儿童":"婴儿");?></td>
</tr>
<?php endforeach;?>
<tr style="text-align:;">
<td colspan="11" class="selectticket">
<?php
$traintype = substr($v->train[0]->FlightsNo,0,1);
$arr = array('C','D','G');
$sel_count = 0;
if(in_array($traintype,$arr)){
$selectseat = '';
$train_select = $v->train[0]->FOI_SelectedSeat;
$a1=$b1=$c1=$d1=$f1=$a2=$b2=$c2=$d2=$f2=false;
if($train_select){
$obj = explode(',',$train_select);
foreach($obj as $value){
switch($value){
case '1A':
$a1 = true;
$sel_count++;
break;
case '1B':
$b1 = true;
$sel_count++;
break;
case '1C':
$c1 = true;
$sel_count++;
break;
case '1D':
$d1 = true;
$sel_count++;
break;
case '1F':
$f1 = true;
$sel_count++;
break;
case '2A':
$a2 = true;
$sel_count++;
break;
case '2B':
$b2 = true;
$sel_count++;
break;
case '2C':
$c2 = true;
$sel_count++;
break;
case '2D':
$d2 = true;
$sel_count++;
break;
case '2F':
$f2 = true;
$sel_count++;
break;
}
}
}
$html = '';
$html .= '<div class="train-summary">'.$v->train[0]->Cabin.' for '.$v->train[0]->FlightsNo.' <span>(<span class="selected_People">'.$sel_count.'</span> of <span class="seat_TotalPeople">'.count($v->people).'</span> Seats)</span></div>';
$html .= '<div class="seatPick">';
if($a1){
$html .= '<a class="seat-a selected_seat-a selected" type="seat-a" href="javascript:void(0);" data="1A" onclick ="selseat(this)";></a>';
}else{
$html .= '<a class="seat-a" type="seat-a" href="javascript:void(0);" data="1A" onclick ="selseat(this)";></a>';
}
if($v->train[0]->Aircraft == 'O' || $v->train[0]->Aircraft == '8'){
if($b1){
$html .= '<a class="seat-b selected_seat-b selected" type="seat-b" href="javascript:void(0);" data="1B" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-b" type="seat-b" href="javascript:void(0);" data="1B" onclick ="selseat(this);"></a>';
}
}
if($c1){
$html .= '<a class="seat-c selected_seat-c selected" type="seat-c" href="javascript:void(0);" data="1C" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-c" type="seat-c" href="javascript:void(0);" data="1C" onclick ="selseat(this);"></a>';
}
if($v->train[0]->Aircraft != '9'){
if($d1){
$html .= '<a class="seat-d selected_seat-d selected" type="seat-d" href="javascript:void(0);" data="1D" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-d" type="seat-d" href="javascript:void(0);" data="1D" onclick ="selseat(this);"></a>';
}
}
if($f1){
$html .= '<a class="seat-f selected_seat-f selected" type="seat-f" href="javascript:void(0);" data="1F" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-f" type="seat-f" href="javascript:void(0);" data="1F" onclick ="selseat(this);"></a>';
}
$html .= '<div class="clear"></div></div>';
$html .= '<div class="seatPick">';
if($a2){
$html .= '<a class="seat-a selected_seat-a selected" type="seat-a" href="javascript:void(0);" data="2A" onclick ="selseat(this)";></a>';
}else{
$html .= '<a class="seat-a" type="seat-a" href="javascript:void(0);" data="2A" onclick ="selseat(this)";></a>';
}
if($v->train[0]->Aircraft == 'O' || $v->train[0]->Aircraft == '8'){
if($b2){
$html .= '<a class="seat-b selected_seat-b selected" type="seat-b" href="javascript:void(0);" data="2B" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-b" type="seat-b" href="javascript:void(0);" data="2B" onclick ="selseat(this);"></a>';
}
}
if($c2){
$html .= '<a class="seat-c selected_seat-c selected" type="seat-c" href="javascript:void(0);" data="2C" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-c" type="seat-c" href="javascript:void(0);" data="2C" onclick ="selseat(this);"></a>';
}
if($v->train[0]->Aircraft != '9'){
if($d2){
$html .= '<a class="seat-d selected_seat-d selected" type="seat-d" href="javascript:void(0);" data="2D" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-d" type="seat-d" href="javascript:void(0);" data="2D" onclick ="selseat(this);"></a>';
}
}
if($f2){
$html .= '<a class="seat-f selected_seat-f selected" type="seat-f" href="javascript:void(0);" data="2F" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-f" type="seat-f" href="javascript:void(0);" data="2F" onclick ="selseat(this);"></a>';
}
$html .= '<div class="clear"></div></div>';
if($v->train[0]->Aircraft != 'F'){
echo $html;
}
}
?>
</td>
</tr>
<tr style="text-align:;">
<td>
<button type="button" class="btn btn-success checked_pay" data-order="<?php echo $v->train[0]->FOI_COLD_SN;?>">订票</button>
@ -78,18 +293,35 @@
<td colspan="4" class="biaoqian"><span class="back_mes" style="color:red;line-height: 30px;"></span>
</td>
</tr>
<tr style="text-align:;">
<td>
<button type="button" class="btn btn-success grab_ticket" data-order="<?php echo $v->train[0]->FOI_COLD_SN;?>">抢票</button>
</td>
<td colspan="4">
<span class="grab_config"><a style="text-decoration:none;cursor:pointer;">点击打开配置清单</a></span>
<p class="grab_mes" style="color:red;line-height: 30px;"></p>
<table class="table table-condensed table-bordered grab_config_table hidden">
<tbody>
<tr>
<td colspan="2"><span style="float:left">截止时间 : <input type="text" name="deadline" class="date"/> 示例2018-03-22 17:00:00(必填)</span></td>
<td colspan="2"><span style="float:left">备选车次 : <input type="text" name="alternate_train"/> 示例:["k10","G10"]</span></td>
<td colspan="2"><span style="float:left">备选座位 : <input type="text" name="alternate_seat"/> 示例:["1","2"]</span></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr id="back_<?php echo $v->train[0]->FOI_COLD_SN;?>" style="display:none;">
<td colspan="5">
快捷订票处理结果:<span style="color:red;"></span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<?php endforeach;endif;?>
@ -105,8 +337,14 @@
// alert(url+$(this).attr("data-order"));
var THIS=$(this);
var order=$(this).attr("data-order");
var selectseat = '';
$(this).parent().parent().next().find('.selected').each(function(){
if($(this).hasClass('selected')){
selectseat += $(this).attr('data');
}
});
$.ajax({
url:url+$(this).attr("data-order"),
url:url+$(this).attr("data-order")+'&selectseat='+selectseat,
beforeSend:function(data){
THIS.html("处理中...");
THIS.attr("disabled","disabled")
@ -142,8 +380,15 @@
checkbox.each(function(i){
people_sn+=","+$(this).val();
});
var selectseat = '';
$(this).parent().parent().prev().find('.selected').each(function(){
if($(this).hasClass('selected')){
selectseat += $(this).attr('data');
}
});
people_sn=people_sn.substring(1);
url2+=$(this).attr("data-order")+"&people="+people_sn;
url2+=$(this).attr("data-order")+"&people="+people_sn+"&selectseat="+selectseat;
var THIS=$(this);
THIS.parent().parent().find(".back_mes").html(" ");//清空提示
@ -163,6 +408,52 @@
dataType: "json",
});
return false;
});
//抢票清单
$('.grab_config').click(function(){
var table = $(this).next().next('.grab_config_table');
if(table.hasClass('hidden')){
table.removeClass('hidden');
}else{
table.addClass('hidden');
}
});
//开始抢票
$('.grab_ticket').click(function(){
var url2="<?php echo site_url('apps/train/tuniu_train/grabTicketBook?').'order=';?>";
var checkbox=$(this).parent().parent().parent().find(":checked");
var people_sn="";
checkbox.each(function(i){
people_sn+=","+$(this).val();
});
people_sn=people_sn.substring(1);
// var coli_id = $('input[name="ht_order"]').val();
var deadline = $(this).parent().next().find('.date').val();
var alternate_train = $('input[name="alternate_train"]').val();
var alternate_seat = $('input[name="alternate_seat"]').val();
url2+=$(this).attr("data-order")+"&people="+people_sn+"&deadline="+deadline+"&alternate_train="+alternate_train+"&alternate_seat="+alternate_seat;
var THIS=$(this);
THIS.parent().parent().find(".back_mes").html(" ");//清空提示
$.ajax({
url:url2,
beforeSend:function(data){
THIS.html("处理中...");
THIS.attr("disabled","disabled");
},
success:function(data){
THIS.removeAttr("disabled");
THIS.html("抢票");
THIS.parent().next().find(".grab_mes").html(data.mes);
},
dataType: "json",
});
return false;
});

@ -0,0 +1,509 @@
<style>
.clear {clear: both;}
.train-summary{ font-size:12px; margin-bottom:10px;}
.train-summary span{ color:#9a0918;}
a:link.seat-a{background-image:url(/css/images/train/a-seat.jpg); background-repeat:no-repeat; width:131px; display:block; height:42px; float:left;}
a:hover.seat-a{background-image:url(/css/images/train/a-seath.jpg);}
.selected_seat-a{background-image:url(/css/images/train/a-seata.jpg)!important; background-repeat:no-repeat; width:55px; display:block; height:42px; float:left;}
a:link.seat-b{background-image:url(/css/images/train/b-seat.jpg); background-repeat:no-repeat; text-decoration:none; width:55px; display:block; height:42px; float:left;}
a:hover.seat-b{background-image:url(/css/images/train/b-seath.jpg);}
.selected_seat-b{background-image:url(/css/images/train/b-seata.jpg)!important; background-repeat:no-repeat; width:55px; display:block; height:42px; float:left;}
a:link.seat-c{background-image:url(/css/images/train/c-seat.jpg); background-repeat:no-repeat; width:131px; display:block; height:42px; float:left;}
a:hover.seat-c{background-image:url(/css/images/train/c-seath.jpg);}
.selected_seat-c{background-image:url(/css/images/train/c-seata.jpg)!important; background-repeat:no-repeat; width:55px; display:block; height:42px; float:left;}
a:link.seat-d{background-image:url(/css/images/train/d-seat.jpg); background-repeat:no-repeat; width:55px; display:block; height:42px; float:left;}
a:hover.seat-d{background-image:url(/css/images/train/d-seath.jpg);}
.selected_seat-d{background-image:url(/css/images/train/d-seata.jpg)!important; background-repeat:no-repeat; width:136px; display:block; height:42px; float:left;}
a:link.seat-f{background-image:url(/css/images/train/f-seat.jpg); background-repeat:no-repeat; width:136px; display:block; height:42px; float:left;}
a:hover.seat-f{background-image:url(/css/images/train/f-seath.jpg);}
.selected_seat-f{background-image:url(/css/images/train/f-seata.jpg)!important; background-repeat:no-repeat; width:136px; display:block; height:42px; float:left;}
a:link.sleep-a {background-image:url(/css/images/train/l-up.jpg); background-repeat:no-repeat; width:163px; display:block; height:38px; float:left; }
a:hover.sleep-a { background-image:url(/css/images/train/l-upa.jpg); }
.selected_sleep-a { background-image:url(/css/images/train/l-upa.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-b {background-image:url(/css/images/train/r-up.jpg); background-repeat:no-repeat; width:104px; display:block; height:38px; float:left; }
a:hover.sleep-b { background-image:url(/css/images/train/r-upa.jpg); }
.selected_sleep-b { background-image:url(/css/images/train/r-upa.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-c {background-image:url(/css/images/train/l-mid.jpg); background-repeat:no-repeat; width:163px; display:block; height:38px; float:left; }
a:hover.sleep-c { background-image:url(/css/images/train/l-mida.jpg); }
.selected_sleep-c { background-image:url(/css/images/train/l-mida.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-d {background-image:url(/css/images/train/r-mid.jpg); background-repeat:no-repeat; width:104px; display:block; height:38px; float:left; }
a:hover.sleep-d { background-image:url(/css/images/train/r-mida.jpg); }
.selected_sleep-d { background-image:url(/css/images/train/r-mida.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-e {background-image:url(/css/images/train/l-low.jpg); background-repeat:no-repeat; width:163px; display:block; height:38px; float:left; }
a:hover.sleep-e { background-image:url(/css/images/train/l-lowa.jpg); }
.selected_sleep-e { background-image:url(/css/images/train/l-lowa.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-f {background-image:url(/css/images/train/r-low.jpg); background-repeat:no-repeat; width:104px; display:block; height:38px; float:left; }
a:hover.sleep-f { background-image:url(/css/images/train/r-lowa.jpg); }
.selected_sleep-f { background-image:url(/css/images/train/r-lowa.jpg)!important; width:104px; display:block; height:38px; float:left; }
</style>
<script>
$(function(){
//var selected = $('.selectticket').find('.selected').length;
//$('.selected_People').html(selected);
});
function selseat(seat){
var type = $(seat).attr('type');
var total = $(seat).parent().parent().find('.train-summary .seat_TotalPeople').html();
if(total>=5){
total = 5;
$('.seat_TotalPeople').html(total);
}
var count = $(seat).parent().parent().find('.selected').length;
console.log('执行之前的数量'+count);
//处理选座事件
if($(seat).hasClass('selected_'+type)){
$(seat).removeClass('selected');
$(seat).removeClass('selected_'+type);
count = $(seat).parent().parent().find('.selected').length;
$('.selected_People').html(count);
console.log('减掉之后'+count);
}else{
if(count >= total){
alert('You already chose seats for all the passengers.');
}else{
$(seat).addClass('selected_'+type);
$(seat).addClass('selected');
count = $(seat).parent().parent().find('.selected').length;
$('.selected_People').html(count);
console.log('增加之后'+count);
}
}
}
</script>
<div style="width:90%;margin:30px auto;">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">翰特订单号&nbsp;<a style="margin-left:50px;" target='_blank' href="<?php echo site_url('apps/train/index/ht_order_list');?>">订单列表>></a><a style="margin-left:50px;" target='_blank' href="<?php echo site_url('/apps/trainsystem/pages/order_list');?>">携程订单列表>></a><a style="margin-left:50px;" target='_blank' href="<?php echo site_url('apps/trainsystem/pages/order_list');?>">抢票订单列表>></a><a style="margin-left:50px;" target='_blank' href="<?php echo site_url('apps/train/index/export');?>">导出交易记录>></a> <span style="margin-left:200px;">版本V2.0</span><span class="pull-right">聚合余额(RMB)<?php echo $balance;?></span></h3>
</div>
<div class="panel-body">
<form style="width: 300px;float: left;" action="" method="post">
<input type="text" name="ht_order" value="<?php echo isset($cols_id)?$cols_id:""; ?>">
<button type="submit" id="sub" class="btn btn-warning btn-sm"><span class="glyphicon glyphicon-download-alt"></span> 获取信息</button>
</form>
<p style="margin: 0 0 10px; width: 200px; float: left; line-height: 30px;">外联:<span><?php if(!empty($wl)){echo $wl[0]->OPI_Name;}?></span></p>
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">火车订单信息</h3>
</div>
<div class="panel-body">
<?php if(!empty($info)):?>
<?php $num=1; foreach($info as $v):?>
<table class="table table-bordered table-hover" style="text-align:center;">
<thead>
<tr>
<th style="text-align:center;">序号</th>
<th style="text-align:center;">车次</th>
<th style="text-align:center;">座位</th>
<th style="text-align:center;">出发城市</th>
<th style="text-align:center;">抵达城市</th>
<th style="text-align:center;">发车日期</th>
<th style="text-align:center;">发车时间</th>
<th style="text-align:center;">抵达时间</th>
<th style="text-align:center;">票价</th>
<th style="text-align:center;">是否提交过</th>
<th style="text-align:center;">操作</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $num++;?></td>
<td><?php echo $v->train[0]->FlightsNo;?></td>
<td><?php echo $v->train[0]->Cabin;?></td>
<td><?php echo $v->train[0]->DepartureCity;?></td>
<td><?php echo $v->train[0]->ArrivalCity;?></td>
<td><?php echo $v->train[0]->DepartureDate;?></td>
<td><?php echo $v->train[0]->DepartureTime;?></td>
<td><?php echo $v->train[0]->ArrivalTime;?></td>
<td><?php echo $v->train[0]->adultcost;?></td>
<td><?php echo !empty($v->status)?"否":"<span style='color:green;'>是</span>";?></td>
<td><button type="button" class="btn btn-success pay_api" data-order="<?php echo $v->train[0]->FOI_COLD_SN;?>" title="超过五个乘客不可用" >快捷订票</button></td>
</tr>
<tr>
<td colspan="11">
<table class="table table-condensed table-bordered">
<thead>
<tr>
<th style="text-align:center;"><input class="check_people" type="checkbox" /></th>
<th style="text-align:center;">序号</th>
<th style="text-align:center;">姓名</th>
<th style="text-align:center;">护照</th>
<th style="text-align:center;">年龄类型</th>
</tr>
</thead>
<tbody>
<?php foreach($v->people as $key=>$p): ?>
<tr>
<td><input name="" type="checkbox" value="<?php echo $p->BPE_SN;?>" /></td>
<td><?php echo $key+1;?></td>
<td class="people_name"><?php echo $p->BPE_FirstName." ".$p->BPE_MiddleName." ".$p->BPE_LastName;?></td>
<td><?php echo $p->BPE_Passport;?></td>
<td><?php echo $p->BPE_GuestType==1?"成人":($p->BPE_GuestType==2?"儿童":"婴儿");?></td>
</tr>
<?php endforeach;?>
<tr style="text-align:;">
<td colspan="11" class="selectticket">
<?php
$traintype = substr($v->train[0]->FlightsNo,0,1);
$arr = array('C','D','G');
$sel_count = 0;
if(in_array($traintype,$arr)){
$selectseat = '';
$train_select = $v->train[0]->FOI_SelectedSeat;
$a1=$b1=$c1=$d1=$f1=$a2=$b2=$c2=$d2=$f2=false;
if($train_select){
$obj = explode(',',$train_select);
foreach($obj as $value){
switch($value){
case '1A':
$a1 = true;
$sel_count++;
break;
case '1B':
$b1 = true;
$sel_count++;
break;
case '1C':
$c1 = true;
$sel_count++;
break;
case '1D':
$d1 = true;
$sel_count++;
break;
case '1F':
$f1 = true;
$sel_count++;
break;
case '2A':
$a2 = true;
$sel_count++;
break;
case '2B':
$b2 = true;
$sel_count++;
break;
case '2C':
$c2 = true;
$sel_count++;
break;
case '2D':
$d2 = true;
$sel_count++;
break;
case '2F':
$f2 = true;
$sel_count++;
break;
}
}
}
$html = '';
$html .= '<div class="train-summary">'.$v->train[0]->Cabin.' for '.$v->train[0]->FlightsNo.' <span>(<span class="selected_People">'.$sel_count.'</span> of <span class="seat_TotalPeople">'.count($v->people).'</span> Seats)</span></div>';
$html .= '<div class="seatPick">';
if($a1){
$html .= '<a class="seat-a selected_seat-a selected" type="seat-a" href="javascript:void(0);" data="1A" onclick ="selseat(this)";></a>';
}else{
$html .= '<a class="seat-a" type="seat-a" href="javascript:void(0);" data="1A" onclick ="selseat(this)";></a>';
}
if($v->train[0]->Aircraft == 'O' || $v->train[0]->Aircraft == '8'){
if($b1){
$html .= '<a class="seat-b selected_seat-b selected" type="seat-b" href="javascript:void(0);" data="1B" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-b" type="seat-b" href="javascript:void(0);" data="1B" onclick ="selseat(this);"></a>';
}
}
if($c1){
$html .= '<a class="seat-c selected_seat-c selected" type="seat-c" href="javascript:void(0);" data="1C" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-c" type="seat-c" href="javascript:void(0);" data="1C" onclick ="selseat(this);"></a>';
}
if($v->train[0]->Aircraft != '9'){
if($d1){
$html .= '<a class="seat-d selected_seat-d selected" type="seat-d" href="javascript:void(0);" data="1D" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-d" type="seat-d" href="javascript:void(0);" data="1D" onclick ="selseat(this);"></a>';
}
}
if($f1){
$html .= '<a class="seat-f selected_seat-f selected" type="seat-f" href="javascript:void(0);" data="1F" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-f" type="seat-f" href="javascript:void(0);" data="1F" onclick ="selseat(this);"></a>';
}
$html .= '<div class="clear"></div></div>';
$html .= '<div class="seatPick">';
if($a2){
$html .= '<a class="seat-a selected_seat-a selected" type="seat-a" href="javascript:void(0);" data="2A" onclick ="selseat(this)";></a>';
}else{
$html .= '<a class="seat-a" type="seat-a" href="javascript:void(0);" data="2A" onclick ="selseat(this)";></a>';
}
if($v->train[0]->Aircraft == 'O' || $v->train[0]->Aircraft == '8'){
if($b2){
$html .= '<a class="seat-b selected_seat-b selected" type="seat-b" href="javascript:void(0);" data="2B" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-b" type="seat-b" href="javascript:void(0);" data="2B" onclick ="selseat(this);"></a>';
}
}
if($c2){
$html .= '<a class="seat-c selected_seat-c selected" type="seat-c" href="javascript:void(0);" data="2C" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-c" type="seat-c" href="javascript:void(0);" data="2C" onclick ="selseat(this);"></a>';
}
if($v->train[0]->Aircraft != '9'){
if($d2){
$html .= '<a class="seat-d selected_seat-d selected" type="seat-d" href="javascript:void(0);" data="2D" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-d" type="seat-d" href="javascript:void(0);" data="2D" onclick ="selseat(this);"></a>';
}
}
if($f2){
$html .= '<a class="seat-f selected_seat-f selected" type="seat-f" href="javascript:void(0);" data="2F" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-f" type="seat-f" href="javascript:void(0);" data="2F" onclick ="selseat(this);"></a>';
}
$html .= '<div class="clear"></div></div>';
if($v->train[0]->Aircraft != 'F'){
echo $html;
}
}
?>
</td>
</tr>
<tr style="text-align:;">
<td>
<button type="button" class="btn btn-success checked_pay" data-order="<?php echo $v->train[0]->FOI_COLD_SN;?>">聚合订票</button>
</td>
<td colspan="4" class="biaoqian"><span class="back_mes" style="color:red;line-height: 30px;"></span>
</td>
</tr>
<tr style="text-align:;">
<td>
<button type="button" class="btn btn-success ctrip_pay" data-order="<?php echo $v->train[0]->FOI_COLD_SN;?>">携程订票</button>
</td>
<td colspan="4" class="biaoqian"><span class="ctrip_back_mes" style="color:red;line-height: 30px;"></span>
</td>
</tr>
<tr style="text-align:;">
<td>
<button type="button" class="btn btn-success grab_ticket" data-order="<?php echo $v->train[0]->FOI_COLD_SN;?>">抢票</button>
</td>
<td colspan="4">
<span class="grab_config"><a style="text-decoration:none;cursor:pointer;">点击打开配置清单</a></span>
<p class="grab_mes" style="color:red;line-height: 30px;"></p>
<table class="table table-condensed table-bordered grab_config_table hidden">
<tbody>
<tr>
<td colspan="2"><span style="float:left">截止时间 : <input type="text" name="deadline" class="date"/> 示例2018-03-22 17:00:00(必填)</span></td>
<td colspan="2"><span style="float:left">备选车次 : <input type="text" name="alternate_train"/> 示例:["k10","G10"]</span></td>
<td colspan="2"><span style="float:left">备选座位 : <input type="text" name="alternate_seat"/> 示例:["1","2"]</span></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr id="back_<?php echo $v->train[0]->FOI_COLD_SN;?>" style="display:none;">
<td colspan="5">
快捷订票处理结果:<span style="color:red;"></span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<?php endforeach;endif;?>
</div>
</div>
</div>
<script>
var url="<?php echo site_url('apps/train/index/submit_juhe_order?').'order=';?>";
var order_ul="<?php echo site_url('apps/train/index/order?').'order=';?>";//订单详情页面
$(".pay_api").click(function(){
// alert(url+$(this).attr("data-order"));
var THIS=$(this);
var order=$(this).attr("data-order");
var selectseat = '';
$(this).parent().parent().next().find('.selected').each(function(){
if($(this).hasClass('selected')){
selectseat += $(this).attr('data');
}
});
$.ajax({
url:url+$(this).attr("data-order")+'&selectseat='+selectseat,
beforeSend:function(data){
THIS.html("处理中...");
THIS.attr("disabled","disabled")
},
success:function(data){
THIS.removeAttr("disabled");
THIS.html("快捷订票");
if(data.status==1){
THIS.parent().html("<a href='"+order_ul+data.order+"' target='_blank'>订单详情</a>");
}
$("#back_"+order+" span").html(data.mes);
$("#back_"+order).show();
},
dataType: "json",
});
return false;
});
$(".check_people").click(function(){
if($(this).is(":checked")){
$(this).parent().parent().parent().parent().find("input[type=checkbox]").attr("checked","checked");
}else{
$(this).parent().parent().parent().parent().find("input[type=checkbox]").removeAttr("checked");
}
});
//聚合出票
$(".checked_pay").click(function(){
var url2="<?php echo site_url('apps/train/index/get_sn_submit_juhe?').'order=';?>";
var checkbox=$(this).parent().parent().parent().find(":checked");
var people_sn="";
checkbox.each(function(i){
people_sn+=","+$(this).val();
});
var selectseat = '';
$(this).parent().parent().prev().find('.selected').each(function(){
if($(this).hasClass('selected')){
selectseat += $(this).attr('data');
}
});
people_sn=people_sn.substring(1);
url2+=$(this).attr("data-order")+"&people="+people_sn+"&selectseat="+selectseat;
var THIS=$(this);
THIS.parent().parent().find(".back_mes").html(" ");//清空提示
$.ajax({
url:url2,
beforeSend:function(data){
THIS.html("处理中...");
THIS.attr("disabled","disabled")
},
success:function(data){
THIS.removeAttr("disabled");
THIS.html("订票");
THIS.parent().parent().find(".back_mes").html(data.mes);
},
dataType: "json",
});
return false;
});
//携程出票
$(".ctrip_pay").click(function(){
var ctrip_url="<?php echo site_url('apps/train/ctrip_train/addorders?').'order=';?>";
var checkbox=$(this).parent().parent().parent().find(":checked");
var people_sn="";
checkbox.each(function(i){
people_sn+=","+$(this).val();
});
var selectseat = '';
$(this).parent().parent().prev().prev().find('.selected').each(function(){
if($(this).hasClass('selected')){
selectseat += $(this).attr('data')+',';
}
});
selectseat=selectseat.substr(0,selectseat.length-1);
people_sn=people_sn.substring(1);
ctrip_url+=$(this).attr("data-order")+"&people="+people_sn+"&selectseat="+selectseat;
var THIS=$(this);
THIS.parent().parent().find(".ctrip_back_mes").html(" ");//清空提示
$.ajax({
url:ctrip_url,
beforeSend:function(data){
THIS.html("处理中...");
THIS.attr("disabled","disabled")
},
success:function(data){
THIS.removeAttr("disabled");
THIS.html("携程订票");
THIS.parent().parent().find(".ctrip_back_mes").html(data.mes);
},
dataType: "json",
});
return false;
});
//抢票清单
$('.grab_config').click(function(){
var table = $(this).next().next('.grab_config_table');
if(table.hasClass('hidden')){
table.removeClass('hidden');
}else{
table.addClass('hidden');
}
});
//开始抢票
$('.grab_ticket').click(function(){
var url2="<?php echo site_url('apps/train/tuniu_train/grabTicketBook?').'order=';?>";
var checkbox=$(this).parent().parent().parent().find(":checked");
var people_sn="";
checkbox.each(function(i){
people_sn+=","+$(this).val();
});
people_sn=people_sn.substring(1);
// var coli_id = $('input[name="ht_order"]').val();
var deadline = $(this).parent().next().find('.date').val();
var alternate_train = $('input[name="alternate_train"]').val();
var alternate_seat = $('input[name="alternate_seat"]').val();
url2+=$(this).attr("data-order")+"&people="+people_sn+"&deadline="+deadline+"&alternate_train="+alternate_train+"&alternate_seat="+alternate_seat;
var THIS=$(this);
THIS.parent().parent().find(".back_mes").html(" ");//清空提示
$.ajax({
url:url2,
beforeSend:function(data){
THIS.html("处理中...");
THIS.attr("disabled","disabled");
},
success:function(data){
THIS.removeAttr("disabled");
THIS.html("抢票");
THIS.parent().next().find(".grab_mes").html(data.mes);
},
dataType: "json",
});
return false;
});
</script>

@ -1,3 +1,4 @@
<script type="text/javascript" src="https://data.chinahighlights.com/js/train/StationInfo.js"></script>
<div style="width:90%;margin:30px auto;">
<div class="panel panel-primary" style="width:60%;margin:0 auto;">
<div class="panel-heading">
@ -5,7 +6,7 @@
</div>
<div class="panel-body">
<?php if((int)$result["status"]>1):?>
<p><?php echo $result["from_station_name"];?><span class="glyphicon glyphicon-arrow-right"></span><?php echo $result["to_station_name"];?></p>
<p style="display:inline-block"><?php echo $result["from_station_name"];?><span class="from_station_en"> </span><br><span class="start_time"></span></p><span class="glyphicon glyphicon-arrow-right"> </span><p style="display:inline-block"> <?php echo $result["to_station_name"];?><span class="to_station_en"> </span><br><span class="arrive_time"></span></p>
<?php foreach ($result["passengers"] as $v):?>
<p style="border-top:1px dashed #000; height:1px;margin-top:10px;" ></p>
<p><?php echo @$v["passengersename"]."({$v['piaotypename']})&nbsp;&nbsp;&nbsp;&nbsp;{$v['zwname']}&nbsp;&nbsp;{$v['cxin']}&nbsp;&nbsp;&nbsp;&nbsp;票价:¥{$v['price']}";?></p>
@ -46,6 +47,29 @@
<?php endif;?>
</div>
</div>
</div>
</div>
<script>
var StationInfoArr = StationInfo.split("@");
var StationNameArr = new Array();
var code_name = new Array();
var station_cn_en = new Array();
var form_data = {};
for (var i = 0; i < StationInfoArr.length; ++i) {
StationNameArr.push(StationInfoArr[i].split("|"));
code_name[StationNameArr[i][1]] = [StationNameArr[i][2]];
station_cn_en[StationNameArr[i][3]] = StationNameArr[i][2];
}
$(function(){
var from_station_en = code_name['<?php echo $result['from_station_code']?>'];
var to_station_en = code_name['<?php echo $result['to_station_code']?>'];
var start_time = '<?php echo $result['start_time']?>';
var arrive_time = '<?php echo $result['arrive_time']?>';
//console.log(code_name);
$('.from_station_en').html('('+from_station_en+') ');
$('.to_station_en').html('('+to_station_en+')');
$('.start_time').html('('+start_time.substring(0,start_time.length-3)+')');
$('.arrive_time').html('('+arrive_time.substring(0,arrive_time.length-3)+')');
});
</script>

@ -0,0 +1,2 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title></head><body><p style="font-family:Verdana, Geneva, sans-serif; font-size:14px; line-height:24px; margin-bottom:12px;">Dear <?php echo $name?>,</p><p style="font-family:Verdana, Geneva, sans-serif; font-size:14px; line-height:24px; margin-bottom:12px;">Thank you for your interest in China Highlights.</p><p style="font-family:Verdana, Geneva, sans-serif; font-size:14px; line-height:24px; margin-bottom:12px;">Your account has been created with your phone number : <?php echo $phone?></p><p style="font-family:Verdana, Geneva, sans-serif; font-size:14px; line-height:24px; margin-bottom:12px;">If you have any questions, please don't hesitate to contact us : <a href="https://www.chinahighlights.com/contactus/">https://www.chinahighlights.com/contactus/</a></p><p style="font-family:Verdana, Geneva, sans-serif; font-size:14px; line-height:24px; margin-bottom:12px;">Thanks,</p><p style="font-family:Verdana, Geneva, sans-serif; font-size:14px; line-height:24px; margin-bottom:12px;">The China Highlights Team</p>
</body></html>

@ -0,0 +1,178 @@
<?xml version="1.0" encoding="utf-8"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>c21</Author>
<LastAuthor>c21</LastAuthor>
<Created>2016-12-23T01:21:46Z</Created>
<LastSaved>2016-12-23T01:38:10Z</LastSaved>
<Version>12.00</Version>
</DocumentProperties>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>9630</WindowHeight>
<WindowWidth>21555</WindowWidth>
<WindowTopX>0</WindowTopX>
<WindowTopY>90</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Center"/>
<Borders/>
<Font ss:FontName="宋体" x:CharSet="134" ss:Size="11" ss:Color="#000000"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="m58993952">
<Alignment ss:Horizontal="Right" ss:Vertical="Center" ss:WrapText="1"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
<Font ss:FontName="微软雅黑" x:CharSet="134" x:Family="Swiss" ss:Size="11"
ss:Color="#000000"/>
</Style>
<Style ss:ID="m58993972">
<Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
<Font ss:FontName="微软雅黑" x:CharSet="134" x:Family="Swiss" ss:Size="20"
ss:Color="#000000" ss:Bold="1"/>
</Style>
<Style ss:ID="m58993992">
<Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
<Font ss:FontName="微软雅黑" x:CharSet="134" x:Family="Swiss" ss:Size="11"
ss:Color="#000000"/>
</Style>
<Style ss:ID="s78">
<Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
<Font ss:FontName="微软雅黑" x:CharSet="134" x:Family="Swiss" ss:Color="#000000"/>
</Style>
<Style ss:ID="s79">
<Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
<Font ss:FontName="微软雅黑" x:CharSet="134" x:Family="Swiss" ss:Color="#000000"/>
<NumberFormat ss:Format="General Date"/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<?php $num=count($arr);?>
<Table ss:ExpandedColumnCount="6" ss:ExpandedRowCount="<?php echo $num+6;?>" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="13.5">
<Column ss:AutoFitWidth="0" ss:Width="115.5"/>
<Column ss:AutoFitWidth="0" ss:Width="111"/>
<Column ss:AutoFitWidth="0" ss:Width="111"/>
<Column ss:AutoFitWidth="0" ss:Width="100.5"/>
<Column ss:AutoFitWidth="0" ss:Width="62.25"/>
<Column ss:AutoFitWidth="0" ss:Width="203.25"/>
<Row ss:AutoFitHeight="0">
<Cell ss:MergeAcross="5" ss:MergeDown="1" ss:StyleID="m58993952"><Data
ss:Type="String">苏州新科兰德科技有限公司&#10;地址苏州市园区启月街288号紫金东方307室&#10;联系电话051262391880&#10;开户银行:浙商银行苏州分行&#10;公司名称:苏州新科兰德科技有限公司&#10;银行账号3050020010120100129207&#10;跟踪号:<?php echo $arr[0]['trackcode'];?></Data></Cell>
</Row>
<Row ss:AutoFitHeight="0" ss:Height="99.75"/>
<Row ss:AutoFitHeight="0" ss:Height="42">
<Cell ss:MergeAcross="5" ss:StyleID="m58993972"><Data ss:Type="String">桂林海纳国际旅行社有限公司火车票对账文件</Data></Cell>
</Row>
<Row ss:AutoFitHeight="0" ss:Height="16.5">
<Cell ss:StyleID="s78"><Data ss:Type="String">时间</Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String">信息</Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String">购票人</Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String">团名</Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String">变化值</Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String">最新余额</Data></Cell>
</Row>
<?php for($i=$num-1;$i>=0;$i--){?>
<Row ss:AutoFitHeight="0" ss:Height="16.5">
<Cell ss:StyleID="s79"><Data ss:Type="String"><?php echo $arr[$i][2];?></Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String"><?php echo $arr[$i][3];?></Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String"><?php echo $arr[$i][7];?></Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String"><?php echo $arr[$i][6];?></Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="Number"><?php echo $arr[$i][1];?></Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="Number"><?php echo $arr[$i][5];?></Data></Cell>
</Row>
<?php }?>
<Row ss:AutoFitHeight="0" ss:Height="36">
<Cell ss:MergeAcross="5" ss:StyleID="m58993992"><Data ss:Type="String">苏州新科兰德科技有限公司©版权所有 苏ICP备14006450号-3 增值电信业务经营许可证苏B2-20140496</Data></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Unsynced/>
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>4</ActiveRow>
<ActiveCol>4</ActiveCol>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name="Sheet2">
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="13.5">
<Row ss:AutoFitHeight="0"/>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Unsynced/>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name="Sheet3">
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="13.5">
<Row ss:AutoFitHeight="0"/>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Unsynced/>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>

@ -0,0 +1,137 @@
<div style="width:90%;margin:30px auto;">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">翰特订单号&nbsp;<a style="margin-left:50px;" target='_blank' href="<?php echo site_url('apps/train/tuniu_train/ht_order_list');?>">订单列表>></a><a style="margin-left:50px;" target='_blank' href="<?php echo site_url('apps/train/index/export');?>">导出交易记录>></a> <span style="margin-left:200px;">途牛抢票测试版</span></h3>
</div>
<div class="panel-body">
<form style="width: 300px;float: left;" action="" method="post">
<input type="text" name="ht_order" value="<?php echo isset($cols_id)?$cols_id:""; ?>">
<button type="submit" id="sub" class="btn btn-warning btn-sm"><span class="glyphicon glyphicon-download-alt"></span> 获取信息</button>
</form>
<p style="margin: 0 0 10px; width: 200px; float: left; line-height: 30px;">外联:<span><?php if(!empty($wl)){echo $wl[0]->OPI_Name;}?></span></p>
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">火车订单信息</h3>
</div>
<div class="panel-body">
<?php if(!empty($info)):?>
<?php $num=1; foreach($info as $v):?>
<table class="table table-bordered table-hover" style="text-align:center;">
<thead>
<tr>
<th style="text-align:center;">序号</th>
<th style="text-align:center;">车次</th>
<th style="text-align:center;">座位</th>
<th style="text-align:center;">出发城市</th>
<th style="text-align:center;">抵达城市</th>
<th style="text-align:center;">发车日期</th>
<th style="text-align:center;">发车时间</th>
<th style="text-align:center;">抵达时间</th>
<th style="text-align:center;">票价</th>
<th style="text-align:center;">是否提交过</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $num++;?></td>
<td><?php echo $v->train[0]->FlightsNo;?></td>
<td><?php echo $v->train[0]->Cabin;?></td>
<td><?php echo $v->train[0]->DepartureCity;?></td>
<td><?php echo $v->train[0]->ArrivalCity;?></td>
<td><?php echo $v->train[0]->DepartureDate;?></td>
<td><?php echo $v->train[0]->DepartureTime;?></td>
<td><?php echo $v->train[0]->ArrivalTime;?></td>
<td><?php echo $v->train[0]->adultcost;?></td>
<td><?php echo !empty($v->status)?"否":"<span style='color:green;'>是</span>";?></td>
</tr>
<tr>
<td colspan="11">
<table class="table table-condensed table-bordered">
<thead>
<tr>
<th style="text-align:center;"><input class="check_people" type="checkbox" /></th>
<th style="text-align:center;">序号</th>
<th style="text-align:center;">姓名</th>
<th style="text-align:center;">护照</th>
<th style="text-align:center;">年龄类型</th>
</tr>
</thead>
<tbody>
<?php foreach($v->people as $key=>$p): ?>
<tr>
<td><input name="" type="checkbox" value="<?php echo $p->BPE_SN;?>" /></td>
<td><?php echo $key+1;?></td>
<td class="people_name"><?php echo $p->BPE_FirstName." ".$p->BPE_MiddleName." ".$p->BPE_LastName;?></td>
<td><?php echo $p->BPE_Passport;?></td>
<td><?php echo $p->BPE_GuestType==1?"成人":($p->BPE_GuestType==2?"儿童":"婴儿");?></td>
</tr>
<?php endforeach;?>
<tr style="text-align:;">
<td>
<button type="button" class="btn btn-success checked_pay" data-order="<?php echo $v->train[0]->FOI_COLD_SN;?>">抢票</button>
</td>
<td colspan="4" class="biaoqian"><span class="back_mes" style="color:red;line-height: 30px;"></span>
</td>
</tr>
<tr id="back_<?php echo $v->train[0]->FOI_COLD_SN;?>" style="display:none;">
<td colspan="5">
快捷订票处理结果:<span style="color:red;"></span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<?php endforeach;endif;?>
</div>
</div>
</div>
<script>
$(".check_people").click(function(){
if($(this).is(":checked")){
$(this).parent().parent().parent().parent().find("input[type=checkbox]").attr("checked","checked");
}else{
$(this).parent().parent().parent().parent().find("input[type=checkbox]").removeAttr("checked");
}
});
$(".checked_pay").click(function(){
var url2="<?php echo site_url('apps/train/tuniu_train/grabTicketBook?').'order=';?>";
var checkbox=$(this).parent().parent().parent().find(":checked");
var people_sn="";
checkbox.each(function(i){
people_sn+=","+$(this).val();
});
people_sn=people_sn.substring(1);
var coli_id = $('input[name="ht_order"]').val();
url2+=$(this).attr("data-order")+"&people="+people_sn+"&coli_id="+coli_id;
var THIS=$(this);
THIS.parent().parent().find(".back_mes").html(" ");//清空提示
$.ajax({
url:url2,
beforeSend:function(data){
//THIS.html("处理中...");
//THIS.attr("disabled","disabled")
},
success:function(data){
//THIS.removeAttr("disabled");
//THIS.html("订票");
//THIS.parent().parent().find(".back_mes").html(data.mes);
},
dataType: "json",
});
return false;
});
</script>

@ -0,0 +1,82 @@
<div style="width:90%;margin:30px auto;">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">订单搜索</h3>
</div>
<div class="panel-body">
<div class="row">
<form style="" action="" method="get">
<div class="col-md-6">
<input class="form-control" type="text" placeholder="汉特订单号或聚合订单号" name="order" value="<?php echo !empty($order)?"$order":"";?>">
</div>
<div class="col-md-5">
<button type="submit" id="sub" class="btn btn-success btn-sm"><span class="glyphicon glyphicon-search"></span> 搜索</button>
</div>
</form>
</div>
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">订单列表</h3>
</div>
<div class="panel-body">
<table class="table table-striped" style="text-align:center;">
<thead>
<tr>
<th style="text-align:center;">序号</th>
<th style="text-align:center;">汉特订单号</th>
<th style="text-align:center;">途牛订单号</th>
<th style="text-align:center;">车次</th>
<th style="text-align:center;">出发</th>
<th style="text-align:center;">到达</th>
<th style="text-align:center;">状态</th>
<th style="text-align:center;">价格</th>
<th style="text-align:center;">提交时间</th>
<th style="text-align:center;">所属部门</th>
<!--<th style="text-align:center;">自动出票</th>
<th style="text-align:center;">是否发送邮件</th>
<th style="text-align:center;">操作</th>-->
</tr>
</thead>
<tbody>
<?php $num=0; foreach($data as $v):?>
<tr>
<td><?php echo ++$num;?></td>
<td><?php echo $v->COLI_ID;?></td>
<td><?php echo $v->tol_orderId;?></td>
<td><?php echo $v->tol_cheCi;?></td>
<td><?php echo $v->tol_fromStationName;?></td>
<td><?php echo $v->tol_toStationName;?></td>
<td><?php echo $v->info;?></td>
<td><?php echo $v->tol_orderAmount;?></td>
<td><?php echo $v->tol_subtime;?></td>
<td><?php echo $v->COLI_WebCode;?></td>
<?php
if($v->tol_isauto){
echo '<td></td>';
}else{
echo '<td></td>';
}
?>
<?php
if($v->tol_sendmail == 1){
if($v->JOL_M_SN){
echo '<td><a target="_blank" href="http://www.mycht.cn/info.php/apps/train/index/get_mailinfo/'.$v->JOL_M_SN.'"></a></td>';
}else{
echo '<td></td>';
}
}else{
echo '<td></td>';
}
?>
<td><a target="_blank" href="order?retailOrderId=<?php echo $v->tol_retailOrderId;?>&orderId=<?php echo $v->tol_orderId;?>">详情</a></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<div style="text-align:right;"><ul class="pagination"><?php echo $page_link;?></ul></div>
</div>
</div>
</div>

@ -0,0 +1,392 @@
<style>
.clear {clear: both;}
.train-summary{ font-size:12px; margin-bottom:10px;}
.train-summary span{ color:#9a0918;}
a:link.seat-a{background-image:url(/css/images/train/a-seat.jpg); background-repeat:no-repeat; width:131px; display:block; height:42px; float:left;}
a:hover.seat-a{background-image:url(/css/images/train/a-seath.jpg);}
.selected_seat-a{background-image:url(/css/images/train/a-seata.jpg)!important; background-repeat:no-repeat; width:55px; display:block; height:42px; float:left;}
a:link.seat-b{background-image:url(/css/images/train/b-seat.jpg); background-repeat:no-repeat; text-decoration:none; width:55px; display:block; height:42px; float:left;}
a:hover.seat-b{background-image:url(/css/images/train/b-seath.jpg);}
.selected_seat-b{background-image:url(/css/images/train/b-seata.jpg)!important; background-repeat:no-repeat; width:55px; display:block; height:42px; float:left;}
a:link.seat-c{background-image:url(/css/images/train/c-seat.jpg); background-repeat:no-repeat; width:131px; display:block; height:42px; float:left;}
a:hover.seat-c{background-image:url(/css/images/train/c-seath.jpg);}
.selected_seat-c{background-image:url(/css/images/train/c-seata.jpg)!important; background-repeat:no-repeat; width:55px; display:block; height:42px; float:left;}
a:link.seat-d{background-image:url(/css/images/train/d-seat.jpg); background-repeat:no-repeat; width:55px; display:block; height:42px; float:left;}
a:hover.seat-d{background-image:url(/css/images/train/d-seath.jpg);}
.selected_seat-d{background-image:url(/css/images/train/d-seata.jpg)!important; background-repeat:no-repeat; width:136px; display:block; height:42px; float:left;}
a:link.seat-f{background-image:url(/css/images/train/f-seat.jpg); background-repeat:no-repeat; width:136px; display:block; height:42px; float:left;}
a:hover.seat-f{background-image:url(/css/images/train/f-seath.jpg);}
.selected_seat-f{background-image:url(/css/images/train/f-seata.jpg)!important; background-repeat:no-repeat; width:136px; display:block; height:42px; float:left;}
a:link.sleep-a {background-image:url(/css/images/train/l-up.jpg); background-repeat:no-repeat; width:163px; display:block; height:38px; float:left; }
a:hover.sleep-a { background-image:url(/css/images/train/l-upa.jpg); }
.selected_sleep-a { background-image:url(/css/images/train/l-upa.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-b {background-image:url(/css/images/train/r-up.jpg); background-repeat:no-repeat; width:104px; display:block; height:38px; float:left; }
a:hover.sleep-b { background-image:url(/css/images/train/r-upa.jpg); }
.selected_sleep-b { background-image:url(/css/images/train/r-upa.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-c {background-image:url(/css/images/train/l-mid.jpg); background-repeat:no-repeat; width:163px; display:block; height:38px; float:left; }
a:hover.sleep-c { background-image:url(/css/images/train/l-mida.jpg); }
.selected_sleep-c { background-image:url(/css/images/train/l-mida.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-d {background-image:url(/css/images/train/r-mid.jpg); background-repeat:no-repeat; width:104px; display:block; height:38px; float:left; }
a:hover.sleep-d { background-image:url(/css/images/train/r-mida.jpg); }
.selected_sleep-d { background-image:url(/css/images/train/r-mida.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-e {background-image:url(/css/images/train/l-low.jpg); background-repeat:no-repeat; width:163px; display:block; height:38px; float:left; }
a:hover.sleep-e { background-image:url(/css/images/train/l-lowa.jpg); }
.selected_sleep-e { background-image:url(/css/images/train/l-lowa.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-f {background-image:url(/css/images/train/r-low.jpg); background-repeat:no-repeat; width:104px; display:block; height:38px; float:left; }
a:hover.sleep-f { background-image:url(/css/images/train/r-lowa.jpg); }
.selected_sleep-f { background-image:url(/css/images/train/r-lowa.jpg)!important; width:104px; display:block; height:38px; float:left; }
</style>
<script>
$(function(){
//var selected = $('.selectticket').find('.selected').length;
//$('.selected_People').html(selected);
});
function selseat(seat){
var type = $(seat).attr('type');
var total = $(seat).parent().parent().find('.train-summary .seat_TotalPeople').html();
if(total>=5){
total = 5;
$('.seat_TotalPeople').html(total);
}
var count = $(seat).parent().parent().find('.selected').length;
console.log('执行之前的数量'+count);
//处理选座事件
if($(seat).hasClass('selected_'+type)){
$(seat).removeClass('selected');
$(seat).removeClass('selected_'+type);
count = $(seat).parent().parent().find('.selected').length;
$('.selected_People').html(count);
console.log('减掉之后'+count);
}else{
if(count >= total){
alert('You already chose seats for all the passengers.');
}else{
$(seat).addClass('selected_'+type);
$(seat).addClass('selected');
count = $(seat).parent().parent().find('.selected').length;
$('.selected_People').html(count);
console.log('增加之后'+count);
}
}
}
</script>
<div style="width:90%;margin:30px auto;">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">翰特订单号&nbsp;<a style="margin-left:50px;" target='_blank' href="<?php echo site_url('apps/train/tuniu_train/ht_order_list');?>">订单列表>></a><a style="margin-left:50px;" target='_blank' href="<?php echo site_url('apps/train/index/export');?>">导出交易记录>></a> <span style="margin-left:200px;">途牛出票测试版</span></h3>
</div>
<div class="panel-body">
<form style="width: 300px;float: left;" action="" method="post">
<input type="text" name="ht_order" value="<?php echo isset($cols_id)?$cols_id:""; ?>">
<button type="submit" id="sub" class="btn btn-warning btn-sm"><span class="glyphicon glyphicon-download-alt"></span> 获取信息</button>
</form>
<p style="margin: 0 0 10px; width: 200px; float: left; line-height: 30px;">外联:<span><?php if(!empty($wl)){echo $wl[0]->OPI_Name;}?></span></p>
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">火车订单信息</h3>
</div>
<div class="panel-body">
<?php if(!empty($info)):?>
<?php $num=1; foreach($info as $v):?>
<table class="table table-bordered table-hover" style="text-align:center;">
<thead>
<tr>
<th style="text-align:center;">序号</th>
<th style="text-align:center;">车次</th>
<th style="text-align:center;">座位</th>
<th style="text-align:center;">出发城市</th>
<th style="text-align:center;">抵达城市</th>
<th style="text-align:center;">发车日期</th>
<th style="text-align:center;">发车时间</th>
<th style="text-align:center;">抵达时间</th>
<th style="text-align:center;">票价</th>
<th style="text-align:center;">是否提交过</th>
<th style="text-align:center;">操作</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $num++;?></td>
<td><?php echo $v->train[0]->FlightsNo;?></td>
<td><?php echo $v->train[0]->Cabin;?></td>
<td><?php echo $v->train[0]->DepartureCity;?></td>
<td><?php echo $v->train[0]->ArrivalCity;?></td>
<td><?php echo $v->train[0]->DepartureDate;?></td>
<td><?php echo $v->train[0]->DepartureTime;?></td>
<td><?php echo $v->train[0]->ArrivalTime;?></td>
<td><?php echo $v->train[0]->adultcost;?></td>
<td><?php echo !empty($v->status)?"否":"<span style='color:green;'>是</span>";?></td>
<td><button type="button" class="btn btn-success pay_api" data-order="<?php echo $v->train[0]->FOI_COLD_SN;?>" title="超过五个乘客不可用" >快捷订票</button></td>
</tr>
<tr>
<td colspan="11">
<table class="table table-condensed table-bordered">
<thead>
<tr>
<th style="text-align:center;"><input class="check_people" type="checkbox" /></th>
<th style="text-align:center;">序号</th>
<th style="text-align:center;">姓名</th>
<th style="text-align:center;">护照</th>
<th style="text-align:center;">年龄类型</th>
</tr>
</thead>
<tbody>
<?php foreach($v->people as $key=>$p): ?>
<tr>
<td><input name="" type="checkbox" value="<?php echo $p->BPE_SN;?>" /></td>
<td><?php echo $key+1;?></td>
<td class="people_name"><?php echo $p->BPE_FirstName." ".$p->BPE_MiddleName." ".$p->BPE_LastName;?></td>
<td><?php echo $p->BPE_Passport;?></td>
<td><?php echo $p->BPE_GuestType==1?"成人":($p->BPE_GuestType==2?"儿童":"婴儿");?></td>
</tr>
<?php endforeach;?>
<tr style="text-align:;">
<td colspan="11" class="selectticket">
<?php
$traintype = substr($v->train[0]->FlightsNo,0,1);
$arr = array('C','D','G');
$sel_count = 0;
if(in_array($traintype,$arr)){
$selectseat = '';
$train_select = $v->train[0]->FOI_SelectedSeat;
$a1=$b1=$c1=$d1=$f1=$a2=$b2=$c2=$d2=$f2=false;
if($train_select){
$obj = explode(',',$train_select);
foreach($obj as $value){
switch($value){
case '1A':
$a1 = true;
$sel_count++;
break;
case '1B':
$b1 = true;
$sel_count++;
break;
case '1C':
$c1 = true;
$sel_count++;
break;
case '1D':
$d1 = true;
$sel_count++;
break;
case '1F':
$f1 = true;
$sel_count++;
break;
case '2A':
$a2 = true;
$sel_count++;
break;
case '2B':
$b2 = true;
$sel_count++;
break;
case '2C':
$c2 = true;
$sel_count++;
break;
case '2D':
$d2 = true;
$sel_count++;
break;
case '2F':
$f2 = true;
$sel_count++;
break;
}
}
}
$html = '';
$html .= '<div class="train-summary">'.$v->train[0]->Cabin.' for '.$v->train[0]->FlightsNo.' <span>(<span class="selected_People">'.$sel_count.'</span> of <span class="seat_TotalPeople">'.count($v->people).'</span> Seats)</span></div>';
$html .= '<div class="seatPick">';
if($a1){
$html .= '<a class="seat-a selected_seat-a selected" type="seat-a" href="javascript:void(0);" data="1A" onclick ="selseat(this)";></a>';
}else{
$html .= '<a class="seat-a" type="seat-a" href="javascript:void(0);" data="1A" onclick ="selseat(this)";></a>';
}
if($v->train[0]->Aircraft == 'O' || $v->train[0]->Aircraft == '8'){
if($b1){
$html .= '<a class="seat-b selected_seat-b selected" type="seat-b" href="javascript:void(0);" data="1B" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-b" type="seat-b" href="javascript:void(0);" data="1B" onclick ="selseat(this);"></a>';
}
}
if($c1){
$html .= '<a class="seat-c selected_seat-c selected" type="seat-c" href="javascript:void(0);" data="1C" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-c" type="seat-c" href="javascript:void(0);" data="1C" onclick ="selseat(this);"></a>';
}
if($v->train[0]->Aircraft != '9'){
if($d1){
$html .= '<a class="seat-d selected_seat-d selected" type="seat-d" href="javascript:void(0);" data="1D" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-d" type="seat-d" href="javascript:void(0);" data="1D" onclick ="selseat(this);"></a>';
}
}
if($f1){
$html .= '<a class="seat-f selected_seat-f selected" type="seat-f" href="javascript:void(0);" data="1F" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-f" type="seat-f" href="javascript:void(0);" data="1F" onclick ="selseat(this);"></a>';
}
$html .= '<div class="clear"></div></div>';
$html .= '<div class="seatPick">';
if($a2){
$html .= '<a class="seat-a selected_seat-a selected" type="seat-a" href="javascript:void(0);" data="2A" onclick ="selseat(this)";></a>';
}else{
$html .= '<a class="seat-a" type="seat-a" href="javascript:void(0);" data="2A" onclick ="selseat(this)";></a>';
}
if($v->train[0]->Aircraft == 'O' || $v->train[0]->Aircraft == '8'){
if($b2){
$html .= '<a class="seat-b selected_seat-b selected" type="seat-b" href="javascript:void(0);" data="2B" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-b" type="seat-b" href="javascript:void(0);" data="2B" onclick ="selseat(this);"></a>';
}
}
if($c2){
$html .= '<a class="seat-c selected_seat-c selected" type="seat-c" href="javascript:void(0);" data="2C" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-c" type="seat-c" href="javascript:void(0);" data="2C" onclick ="selseat(this);"></a>';
}
if($v->train[0]->Aircraft != '9'){
if($d2){
$html .= '<a class="seat-d selected_seat-d selected" type="seat-d" href="javascript:void(0);" data="2D" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-d" type="seat-d" href="javascript:void(0);" data="2D" onclick ="selseat(this);"></a>';
}
}
if($f2){
$html .= '<a class="seat-f selected_seat-f selected" type="seat-f" href="javascript:void(0);" data="2F" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-f" type="seat-f" href="javascript:void(0);" data="2F" onclick ="selseat(this);"></a>';
}
$html .= '<div class="clear"></div></div>';
if($v->train[0]->Aircraft != 'F'){
echo $html;
}
}
?>
</td>
</tr>
<tr style="text-align:;">
<td>
<button type="button" class="btn btn-success checked_pay" data-order="<?php echo $v->train[0]->FOI_COLD_SN;?>">订票</button>
</td>
<td colspan="4" class="biaoqian"><span class="back_mes" style="color:red;line-height: 30px;"></span>
</td>
</tr>
<tr id="back_<?php echo $v->train[0]->FOI_COLD_SN;?>" style="display:none;">
<td colspan="5">
快捷订票处理结果:<span style="color:red;"></span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<?php endforeach;endif;?>
</div>
</div>
</div>
<script>
var url="<?php echo site_url('apps/train/index/submit_juhe_order?').'order=';?>";
var order_ul="<?php echo site_url('apps/train/index/order?').'order=';?>";//订单详情页面
$(".pay_api").click(function(){
// alert(url+$(this).attr("data-order"));
var THIS=$(this);
var order=$(this).attr("data-order");
$.ajax({
url:url+$(this).attr("data-order"),
beforeSend:function(data){
THIS.html("处理中...");
THIS.attr("disabled","disabled")
},
success:function(data){
THIS.removeAttr("disabled");
THIS.html("快捷订票");
if(data.status==1){
THIS.parent().html("<a href='"+order_ul+data.order+"' target='_blank'>订单详情</a>");
}
$("#back_"+order+" span").html(data.mes);
$("#back_"+order).show();
},
dataType: "json",
});
return false;
});
$(".check_people").click(function(){
if($(this).is(":checked")){
$(this).parent().parent().parent().parent().find("input[type=checkbox]").attr("checked","checked");
}else{
$(this).parent().parent().parent().parent().find("input[type=checkbox]").removeAttr("checked");
}
});
$(".checked_pay").click(function(){
var url2="<?php echo site_url('apps/train/tuniu_train/get_sn_submit_tuniu?').'order=';?>";
var checkbox=$(this).parent().parent().parent().find(":checked");
var people_sn="";
checkbox.each(function(i){
people_sn+=","+$(this).val();
});
var selectseat = '';
$(this).parent().parent().prev().find('.selected').each(function(){
if($(this).hasClass('selected')){
selectseat += $(this).attr('data');
}
});
people_sn=people_sn.substring(1);
var coli_id = $('input[name="ht_order"]').val();
url2+=$(this).attr("data-order")+"&people="+people_sn+"&coli_id="+coli_id+'&selectseat='+selectseat;
var THIS=$(this);
THIS.parent().parent().find(".back_mes").html(" ");//清空提示
$.ajax({
url:url2,
beforeSend:function(data){
THIS.html("处理中...");
THIS.attr("disabled","disabled")
},
success:function(data){
THIS.removeAttr("disabled");
THIS.html("订票");
THIS.parent().parent().find(".back_mes").html(data.mes);
},
dataType: "json",
});
return false;
});
</script>

@ -0,0 +1,113 @@
<script type="text/javascript" src="/js/StationInfo.js"></script>
<!-- 调用接口查询订单信息 -->
<div style="width:90%;margin:30px auto;">
<div class="panel panel-primary" style="width:60%;margin:0 auto;">
<div class="panel-heading">
<h3 class="panel-title">订单状态</h3>
</div>
<div class="panel-body">
<p>途牛订单号:<?php echo $data->orderId?>&nbsp;&nbsp;&nbsp;&nbsp;途牛订单状态:<?php echo $data->orderStatus?></p>
<p style="border-top:1px dashed #000; height:1px;margin-top:10px;" ></p>
</div>
</div>
</div>
<?php
//调用订单异步返回的信息
//途牛订单状态接口查询不返回订单详细信息,只能在异步返回中查看,非常蛋疼。
$info = json_decode($grab_callback);
//print_r($info);
//print_r($data);
if($data->orderStatus == '抢票中'){ ?>
<div style="width:90%;margin:30px auto;">
<div class="panel panel-primary" style="width:60%;margin:0 auto;">
<div class="panel-heading">
<h3 class="panel-title">途牛操作</h3>
</div>
<div class="panel-body">
<p style="text-align:center;"><a href="#" tuniu_url="/cancelgrabTicket/<?php echo $data->retailOrderId.'/'.$data->orderId?>" style="padding:5px 15px;" class="btn btn-warning btn-sm cancelgrab">取消抢票 <span class="glyphicon glyphicon-forward"></span></a></p>
</div>
</div>
</div>
<?php }else if($data->orderStatus == '出票成功'){ ?>
<div style="width:90%;margin:30px auto;">
<div class="panel panel-primary" style="width:60%;margin:0 auto;">
<div class="panel-heading">
<h3 class="panel-title"><?php echo $info->trainDate;?>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $info->cheCi;?>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo isset($info->orderNumber)?$info->orderNumber:"";?></h3>
</div>
<div class="panel-body">
<p style="display:inline-block"><?php echo $info->fromStationName;?><span class="from_station_en"> </span><br><span class="start_time"></span></p><span class="glyphicon glyphicon-arrow-right"> </span><p style="display:inline-block"> <?php echo $info->toStationName;?><span class="to_station_en"> </span><br><span class="arrive_time"></span></p>
<?php foreach ($info->passengers as $value){
echo '<p style="border-top:1px dashed #000; height:1px;margin-top:10px;" ></p>';
echo '<p>'.$value->passengerName.'('.$value->piaoTypeName.')&nbsp;&nbsp;&nbsp;&nbsp;'.$value->zwName.'&nbsp;&nbsp;&nbsp;'.$value->cxin.'&nbsp;&nbsp;&nbsp;&nbsp;票价:¥'.$value->price.'<a href="#" tuniu_url="/cancel_ticket/'.$info->retailOrderId.'/'.$info->orderId.'/'.$value->ticketNo.'/" style="padding:5px 15px;" class="btn btn-warning btn-sm cancelticket pull-right">单人退票 <span class="glyphicon glyphicon-forward"></span></a></p>';
}?>
<p style="border-top:1px dashed #000; height:1px;margin-top:10px;" ></p>
<p style="text-align:center;"><a href="#" tuniu_url="/cancel_ticket/<?php echo $info->retailOrderId.'/'.$info->orderId?>" style="padding:5px 15px;" class="btn btn-warning btn-sm cancelticket">一键全退 <span class="glyphicon glyphicon-forward"></span></a></p>
</div>
</div>
</div>
<script>
var StationInfoArr = StationInfo.split("@");
var StationNameArr = new Array();
var code_name = new Array();
var station_cn_en = new Array();
var form_data = {};
for (var i = 0; i < StationInfoArr.length; ++i) {
StationNameArr.push(StationInfoArr[i].split("|"));
code_name[StationNameArr[i][1]] = [StationNameArr[i][2]];
station_cn_en[StationNameArr[i][3]] = StationNameArr[i][2];
}
$(function(){
var from_station_en = code_name['<?php echo $info->data->fromStationCode;?>'];
var to_station_en = code_name['<?php echo $info->data->toStationCode;?>'];
var start_time = '<?php echo $info->data->trainDate.' '.$info->data->startTime;?>';
var arrive_time = '<?php echo $info->data->trainDate.' '.$info->data->arriveTime;?>';
$('.from_station_en').html('('+from_station_en+') ');
$('.to_station_en').html('('+to_station_en+')');
$('.start_time').html('('+start_time.substring(0,start_time.length-3)+')');
$('.arrive_time').html('('+arrive_time.substring(0,arrive_time.length-3)+')');
});
</script>
<?php }?>
<script>
$(function(){
$('.cancelgrab').click(function(){
var cancel_url = $(this).attr('tuniu_url');
var url = "<?php echo site_url('apps/train/tuniu_train')?>"+cancel_url;
var THIS=$(this);
$.ajax({
url:url,
beforeSend:function(data){
THIS.html("处理中...");
THIS.attr("disabled","disabled");
},
success:function(data){
THIS.removeAttr("disabled");
THIS.html("取消成功");
},
dataType: "json",
});
});
$('.cancelticket').click(function(){
var cancel_url = $(this).attr('tuniu_url');
var url = "<?php echo site_url('apps/train/tuniu_train')?>"+cancel_url;
var THIS=$(this);
$.ajax({
url:url,
beforeSend:function(data){
THIS.html("处理中...");
THIS.attr("disabled","disabled");
},
success:function(data){
THIS.removeAttr("disabled");
THIS.html("退票成功");
},
dataType: "json",
});
});
});
</script>

@ -0,0 +1,176 @@
<?xml version="1.0" encoding="utf-8"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>c21</Author>
<LastAuthor>c21</LastAuthor>
<Created>2016-12-23T01:21:46Z</Created>
<LastSaved>2016-12-23T01:38:10Z</LastSaved>
<Version>12.00</Version>
</DocumentProperties>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>9630</WindowHeight>
<WindowWidth>21555</WindowWidth>
<WindowTopX>0</WindowTopX>
<WindowTopY>90</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Center"/>
<Borders/>
<Font ss:FontName="宋体" x:CharSet="134" ss:Size="11" ss:Color="#000000"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="m58993952">
<Alignment ss:Horizontal="Right" ss:Vertical="Center" ss:WrapText="1"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
<Font ss:FontName="微软雅黑" x:CharSet="134" x:Family="Swiss" ss:Size="11"
ss:Color="#000000"/>
</Style>
<Style ss:ID="m58993972">
<Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
<Font ss:FontName="微软雅黑" x:CharSet="134" x:Family="Swiss" ss:Size="20"
ss:Color="#000000" ss:Bold="1"/>
</Style>
<Style ss:ID="m58993992">
<Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
<Font ss:FontName="微软雅黑" x:CharSet="134" x:Family="Swiss" ss:Size="11"
ss:Color="#000000"/>
</Style>
<Style ss:ID="s78">
<Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
<Font ss:FontName="微软雅黑" x:CharSet="134" x:Family="Swiss" ss:Color="#000000"/>
</Style>
<Style ss:ID="s79">
<Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
<Font ss:FontName="微软雅黑" x:CharSet="134" x:Family="Swiss" ss:Color="#000000"/>
<NumberFormat ss:Format="General Date"/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<?php $num=count($arr);?>
<Table ss:ExpandedColumnCount="6" ss:ExpandedRowCount="<?php echo $num+6;?>" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="13.5">
<Column ss:AutoFitWidth="0" ss:Width="115.5"/>
<Column ss:AutoFitWidth="0" ss:Width="111"/>
<Column ss:AutoFitWidth="0" ss:Width="111"/>
<Column ss:AutoFitWidth="0" ss:Width="100.5"/>
<Column ss:AutoFitWidth="0" ss:Width="62.25"/>
<Column ss:AutoFitWidth="0" ss:Width="203.25"/>
<Row ss:AutoFitHeight="0">
<Cell ss:MergeAcross="5" ss:MergeDown="1" ss:StyleID="m58993952"><Data
ss:Type="String">苏州新科兰德科技有限公司&#10;地址苏州市园区启月街288号紫金东方307室&#10;联系电话051262391880&#10;开户银行:浙商银行苏州分行&#10;公司名称:苏州新科兰德科技有限公司&#10;银行账号3050020010120100129207&#10;跟踪号:<?php echo $arr[0]['trackcode'];?></Data></Cell>
</Row>
<Row ss:AutoFitHeight="0" ss:Height="99.75"/>
<Row ss:AutoFitHeight="0" ss:Height="42">
<Cell ss:MergeAcross="5" ss:StyleID="m58993972"><Data ss:Type="String">桂林海纳国际旅行社有限公司火车票对账文件</Data></Cell>
</Row>
<Row ss:AutoFitHeight="0" ss:Height="16.5">
<Cell ss:StyleID="s78"><Data ss:Type="String">时间</Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String">信息</Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String">购票人</Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String">团名</Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String">变化值</Data></Cell>
</Row>
<?php for($i=$num-1;$i>=0;$i--){?>
<Row ss:AutoFitHeight="0" ss:Height="16.5">
<Cell ss:StyleID="s79"><Data ss:Type="String"><?php echo $arr[$i][0];?></Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String"><?php echo $arr[$i][1];?></Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String"><?php echo $arr[$i][5];?></Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String"><?php echo $arr[$i][4];?></Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="Number"><?php echo $arr[$i][3];?></Data></Cell>
</Row>
<?php }?>
<Row ss:AutoFitHeight="0" ss:Height="36">
<Cell ss:MergeAcross="5" ss:StyleID="m58993992"><Data ss:Type="String">苏州新科兰德科技有限公司©版权所有 苏ICP备14006450号-3 增值电信业务经营许可证苏B2-20140496</Data></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Unsynced/>
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>4</ActiveRow>
<ActiveCol>4</ActiveCol>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name="Sheet2">
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="13.5">
<Row ss:AutoFitHeight="0"/>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Unsynced/>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name="Sheet3">
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="13.5">
<Row ss:AutoFitHeight="0"/>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Unsynced/>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>

@ -0,0 +1,53 @@
TOC_ID 自增ID
TOC_COLI_SN 商务主表COLI_SN
TOC_GroupName 团名
TOC_COLD_SN 商务明细表COLD_SN
TOC_TrainNumber 火车车次
TOC_DepartureDate 出发日期
TOC_TicketCost 价格
TOC_OtherCost 其它成本标识
TOC_NBBZ 是否内部报账标识
TOC_BCM_Bill 交通银行账单标识
TOC_WL 外联
TOC_SFBZ 是否已报账标识
TOC_Order 排序号
TOC_Memo 备注
TOC_PicName 上传图片名称(已不用)
TOC_Creator 创建者
TOC_CreateDate 创建日期
TOC_LastEditor 最后修改者
TOC_LastEditDate 最后修改日期
TOC_DeleteFlag 删除标识
TOC_ListOrder 查询排序字段
TOC_MoveFlag 是否移动标识
TOC_GetTicket 是否已取票
TOC_Billing 是否已做账标识
TOC_BZDate 报账日期
TOC_NeedTicketFee 是否寄送状态
https://open-sbox.sf-express.com/rest/v1.0/route/query/access_token/15D008266E5E90964EC3C2F7B98C0A9F/sf_appid/00000111/sf_appkey/B21FA8B875514EBCEFEC7285A33E3000
//令牌
https://open-sbox.sf-express.com/public/v1.0/security/access_token/sf_appid/00021240/sf_appkey/2458B56F2B5C3E24B9C1AF1823458DDC
//查询
https://open-sbox.sf-express.com/public/v1.1.2/security/access_token/query/sf_appid/00021240/sf_appkey/2458B56F2B5C3E24B9C1AF1823458DDC
{"from_station_name":"桂林","from_station_code":"GLZ","to_station_name":"桂林北","to_station_code":"GBZ","train_date":"2016-11-30","orderid":"1476686669783H","user_orderid":"488015272","orderamount":"5.50","ordernumber":"E903359160","checi":"D8238","msg":"有乘客退票成功,相关款项已退还至您的账户","status":"7","passengers":[{"passengerid":1,"passengersename":"CSK","piaotype":"1","piaotypename":"成人票","passporttypeseid":"B","passporttypeseidname":"护照","passportseno":"E127233","price":"5.5","zwcode":"O","zwname":"二等座","ticket_no":"E903359160107001A","cxin":"07车厢,01A座","reason":0,"returntickets":{"ticket_no":"E903359160107001A","passengername":"CSK","passporttypeseid":"B","passportseno":"E127233","refund_apply_time":"2016-10-17 14:49:17","returnsuccess":true,"returnmoney":"5.5","returntime":"2016-10-17 14:52:05","returnfailid":"","returnfailmsg":"","returntype":"1"},"refundTimeline":[{"time":"2016-10-17 14:49:17","msg":"线上申请退票"},{"time":"2016-10-17 14:52:05","msg":"线上退票成功","detail":{"returnsuccess":true,"returnmoney":"5.5","returntime":"2016-10-17 14:52:05","returnfailid":"","returnfailmsg":"","returntype":"1","ticket_no":"E903359160107001A","passengername":"CSK","passporttypeseid":"B","passportseno":"E127233"}}]}],"refund_money":"5.50","sign":"49121a3cada0af88b2ce64746dc7b13f"}
{"from_station_name":"桂林","from_station_code":"GLZ","to_station_name":"桂林北","to_station_code":"GBZ","train_date":"2016-11-30","orderid":"1476935104693H","user_orderid":"488015272","orderamount":"8.50","ordernumber":"E974154132","checi":"D8238","msg":"有乘客退票成功,相关款项已退还至您的账户","status":"7","passengers":[{"passengerid":1,"passengersename":"CSK","piaotype":"1","piaotypename":"成人票","passporttypeseid":"B","passporttypeseidname":"护照","passportseno":"E127233","price":"5.5","zwcode":"O","zwname":"二等座","ticket_no":"E974154132107001A","cxin":"07车厢,01A座","reason":0,"returntickets":{"ticket_no":"E974154132107001A","passengername":"CSK","passporttypeseid":"B","passportseno":"E127233","refund_apply_time":"2016-10-21 14:51:00","returnsuccess":true,"returnmoney":"5.5","returntime":"2016-10-21 14:52:06","returnfailid":"","returnfailmsg":"","returntype":"1"},"refundTimeline":[{"time":"2016-10-21 14:51:00","msg":"线上申请退票"},{"time":"2016-10-21 14:52:06","msg":"线上退票成功","detail":{"returnsuccess":true,"returnmoney":"5.5","returntime":"2016-10-21 14:52:06","returnfailid":"","returnfailmsg":"","returntype":"1","ticket_no":"E974154132107001A","passengername":"CSK","passporttypeseid":"B","passportseno":"E127233"}}]},{"passengerid":2,"passengersename":"test k","piaotype":"2","piaotypename":"儿童票","passporttypeseid":"B","passporttypeseidname":"护照","passportseno":"E127234","price":"3.0","zwcode":"O","zwname":"二等座","ticket_no":"E974154132107001D","cxin":"07车厢,01D座","reason":0,"returntickets":{"ticket_no":"E974154132107001D","passengername":"test k","passporttypeseid":"B","passportseno":"E127234","refund_apply_time":"2016-10-21 14:51:04"},"refundTimeline":[{"time":"2016-10-21 14:51:04","msg":"线上申请退票"}]}],"refund_money":"5.50","sign":"9671aa6b0bf8378403473d3a6452ac94"}
$data_post["data"]='{"from_station_name":"桂林","from_station_code":"GLZ","to_station_name":"桂林北","to_station_code":"GBZ","train_date":"2016-11-30","orderid":"1476343928878H","user_orderid":"488015272","orderamount":"5.50","ordernumber":"E098614072","checi":"D8888","msg":"出票成功","status":"4","passengers":[{"passengerid":1,"passengersename":"csk","piaotype":"1","piaotypename":"成人票","passporttypeseid":"B","passporttypeseidname":"护照","passportseno":"E11021322","price":"5.5","zwcode":"O","zwname":"二等座","ticket_no":"E098614072107001C","cxin":"07车厢,01C座","reason":0}],"refund_money":null,"sign":"9cd116f3c333a43e396c0acb115adc3f"}'
1、出票成功
{"from_station_name":"桂林","from_station_code":"GLZ","to_station_name":"桂林北","to_station_code":"GBZ","train_date":"2017-01-22","orderid":"1482737845760H","user_orderid":"488020631","orderamount":"11.00","ordernumber":"E179703891","checi":"D8238","msg":"出票成功","status":"4","passengers":[{"passengerid":1,"passengersename":"CSK","piaotype":"1","piaotypename":"成人票","passporttypeseid":"B","passporttypeseidname":"护照","passportseno":"E132124","price":"5.5","zwcode":"O","zwname":"二等座","ticket_no":"E179703891106014C","cxin":"06车厢,14C座","reason":0},{"passengerid":2,"passengersename":"TW","piaotype":"1","piaotypename":"成人票","passporttypeseid":"B","passporttypeseidname":"护照","passportseno":"E02030609","price":"5.5","zwcode":"O","zwname":"二等座","ticket_no":"E179703891106014D","cxin":"06车厢,14D座","reason":0}],"refund_money":null,"sign":"a38d8ac11d00f800ae5b5753a693becd"}
2、CSK退票
{"from_station_name":"桂林","from_station_code":"GLZ","to_station_name":"桂林北","to_station_code":"GBZ","train_date":"2017-01-22","orderid":"1482737845760H","user_orderid":"488020631","orderamount":"11.00","ordernumber":"E179703891","checi":"D8238","msg":"有乘客退票成功,相关款项已退还至您的账户","status":"7","passengers":[{"passengerid":1,"passengersename":"CSK","piaotype":"1","piaotypename":"成人票","passporttypeseid":"B","passporttypeseidname":"护照","passportseno":"E132124","price":"5.5","zwcode":"O","zwname":"二等座","ticket_no":"E179703891106014C","cxin":"06车厢,14C座","reason":0,"returntickets":{"ticket_no":"E179703891106014C","passengername":"CSK","passporttypeseid":"B","passportseno":"E132124","refund_apply_time":"2016-12-26 15:50:11","returnsuccess":true,"returnmoney":"5.5","returntime":"2016-12-26 15:52:06","returnfailid":"","returnfailmsg":"","returntype":"1"},"refundTimeline":[{"time":"2016-12-26 15:50:11","msg":"线上申请退票"},{"time":"2016-12-26 15:52:06","msg":"线上退票成功","detail":{"returnsuccess":true,"returnmoney":"5.5","returntime":"2016-12-26 15:52:06","returnfailid":"","returnfailmsg":"","returntype":"1","ticket_no":"E179703891106014C","passengername":"CSK","passporttypeseid":"B","passportseno":"E132124"}}]},{"passengerid":2,"passengersename":"TW","piaotype":"1","piaotypename":"成人票","passporttypeseid":"B","passporttypeseidname":"护照","passportseno":"E02030609","price":"5.5","zwcode":"O","zwname":"二等座","ticket_no":"E179703891106014D","cxin":"06车厢,14D座","reason":0}],"refund_money":"5.50","sign":"a38d8ac11d00f800ae5b5753a693becd"}
{"from_station_name":"桂林","from_station_code":"GLZ","to_station_name":"桂林北","to_station_code":"GBZ","train_date":"2017-01-22","orderid":"1482737845760H","user_orderid":"488020631","orderamount":"11.00","ordernumber":"E179703891","checi":"D8238","msg":"有乘客退票成功,相关款项已退还至您的账户","status":"7","passengers":[{"passengerid":1,"passengersename":"CSK","piaotype":"1","piaotypename":"成人票","passporttypeseid":"B","passporttypeseidname":"护照","passportseno":"E132124","price":"5.5","zwcode":"O","zwname":"二等座","ticket_no":"E179703891106014C","cxin":"06车厢,14C座","reason":0,"returntickets":{"ticket_no":"E179703891106014C","passengername":"CSK","passporttypeseid":"B","passportseno":"E132124","refund_apply_time":"2016-12-26 15:50:11","returnsuccess":true,"returnmoney":"5.5","returntime":"2016-12-26 15:52:06","returnfailid":"","returnfailmsg":"","returntype":"1"},"refundTimeline":[{"time":"2016-12-26 15:50:11","msg":"线上申请退票"},{"time":"2016-12-26 15:52:06","msg":"线上退票成功","detail":{"returnsuccess":true,"returnmoney":"5.5","returntime":"2016-12-26 15:52:06","returnfailid":"","returnfailmsg":"","returntype":"1","ticket_no":"E179703891106014C","passengername":"CSK","passporttypeseid":"B","passportseno":"E132124"}}]},{"passengerid":2,"passengersename":"TW","piaotype":"1","piaotypename":"成人票","passporttypeseid":"B","passporttypeseidname":"护照","passportseno":"E02030609","price":"5.5","zwcode":"O","zwname":"二等座","ticket_no":"E179703891106014D","cxin":"06车厢,14D座","reason":0}],"refund_money":"5.50","sign":"a38d8ac11d00f800ae5b5753a693becd"}

@ -0,0 +1,107 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//途牛apiurl (测试)
//define("TUNIU_URL","218.94.82.118:13532");
//define("TUNIU_KEY","Te56CBQmorzJGeYIIK");
//途牛apiurl (正式)
define("TUNIU_URL","https://open.tuniu.cn");
define("TUNIU_KEY","AILvoDj8El7KCSMe25");
define("ORDERUSER","guilintravel");
define("ORDERKEY","07f811fe29f04008a8fcc86e81c012b9");
//聚合火车订票API key
define("JUHE_TRAIN_API_KEY","79f03107b921ef31310bd40a1415c1cb");
//聚合火车订票---查询api
define("JUHE_TRAIN_CX_API","http://op.juhe.cn/trainTickets/ticketsAvailable");
//聚合火车订票---订票api
define("JUHE_TRAIN_DP_API","http://op.juhe.cn/trainTickets/submit");
//聚合火车订票---状态查询api
define("JUHE_TRAIN_STATUS_API","http://op.juhe.cn/trainTickets/orderStatus");
//聚合火车订票---取消订单api
define("JUHE_TRAIN_CANCEL_API","http://op.juhe.cn/trainTickets/cancel");
//聚合火车订票---请求出票支付api
define("JUHE_TRAIN_PAY_API","http://op.juhe.cn/trainTickets/pay");
//聚合火车订票---线上退票api
define("JUHE_TRAIN_REFUND_API","http://op.juhe.cn/trainTickets/refund");
//聚合火车订票---导出记录api
define("JUHE_TRAIN_EXPORT_API","http://op.juhe.cn/trainTickets/exportAccountChange");
//http://op.juhe.cn/trainTickets/exportAccountChange?key=79f03107b921ef31310bd40a1415c1cb&since=2016-10-01 00:00&before=2016-10-30 00:00
//订单状态说明
$config["train_order_status_msg"]=array(
"0"=>"待处理",
"1"=>"失效订单",
"2"=>"待支付",
"3"=>"已支付,待出票",
"4"=>"出票成功",
"5"=>"出票失败",
"6"=>"线上退票处理中",
"7"=>"有乘客退票(改签)成功",
"8"=>"乘客退票失败",
"e"=>"数据错误,提交失败"
);
//座次配对
$config["train_zw"]=array(
"O"=>"二等座",
"9"=>"商务座",
"P"=>"特等座",
"6"=>"高级软卧",
"M"=>"一等座",
"4"=>"软卧",
"2"=>"软座",
"3"=>"硬卧",
"1"=>"硬座",
"F"=>"动卧"
);
//数据库座次配对,包厢硬卧(5),无座(WZ),聚合没有
$config["db_train_zw"]=array(
"9"=>"9",
"P"=>"P",
"M"=>"M",
"7"=>"M",
"O"=>"O",
"8"=>"O",
"6"=>"6",
"A"=>"6",
"S"=>"4",
"4"=>"4",
"F"=>"F",
"3"=>"3",
"2"=>"2",
"1"=>"1"
);
//票种配对
$config["train_piaotype"]=array(
"1"=>"成人票",
"2"=>"儿童票",
"3"=>"学生票",
"4"=>"残军票"
);
//证件类型配对
$config["train_passportty"]=array(
"B"=>"护照",
"1"=>"二代身份证",
"2"=>"一代身份证",
"C"=>"港澳通行证",
"G"=>"台湾通行证"
);
//黑名单用户
$config['black_list'] = array('209582910','539152642','506157109','E66735489','E66735492','E80377215','G23001338','E95287649','345276546','PA4286015','G09382769','G26113116','G25996274','572309763','506620366','505897939','E71156367','E21961674','v716898','561669436','EL657289','533300106','482225223','514815909','592108236','370682199509218814','130924199003161572','410728199011287038','372324199503253215','ED6234008');
//设置session 2592000
$config['sess_cookie_name'] = 'trainsystem';
$config['sess_expiration'] = 2592000;

@ -0,0 +1,4 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
define("JUHE_API_KEY","123");

@ -0,0 +1,692 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class addorders extends CI_Controller{
public function __construct(){
parent::__construct();
$this->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->isauto = 0;
$this->istanding = 'false';
}
public function index(){
echo 'api manager';
}
//自动出票
public function auto_pay_ticket(){
//log_message('error','auto ticket');
date_default_timezone_set('Asia/Shanghai');
//判断账户余额如果小于1000自动退出。
$post_data = array("key"=>JUHE_TRAIN_API_KEY);
$back_data = GetPost_http("http://op.juhe.cn/trainTickets/balance.php",$post_data);
$price = json_decode($back_data)->result;
print_r('账户余额:'.$price);
if($price < 1000){
exit('账户余额不足');
}
//筛选出能自动出票的订单
$auto_pool = $this->BIZ_train_model->auto_check_ticket();
//创建一个不允许自动出票的国际火车票数组
$nation_train = array('K19', 'K23', 'Z8701', 'Z8702', 'Z97', 'Z98', 'Z99', 'Z100', 'K9795');
//创建黑名单
$black_list = $this->config->item('black_list');
$string = '';
foreach($auto_pool as $item){
$this->isauto = 1;
$bpe_sn = '';
$back_message = '';
$cold_sn = $item->COLD_SN;
$coli_id = $item->coli_id;
$back_data = 1;
$people_arr = $this->BIZ_train_model->biz_people($cold_sn);
$train_info = $this->BIZ_train_model->get_biz_foi($cold_sn);
if($item->COLD_SPFS > 1){
//寄送票
$back_data = 0;
$back_message .= '-邮寄不自动出票';
}
//乘客人数大于5人不出票
if(count($people_arr) > 5){
$back_data = 0;
$back_message .= '-乘客人数大于5不自动出票';
}
//护照号如果在黑名单的就不自动出票
foreach($people_arr as $people_info){
if(in_array($people_info->BPE_Passport,$black_list)){
$back_data = 0;
$back_message .= '-此用户为黑名单用户,不自动出票';
}
if(strlen($people_info->BPE_Passport) >= 18){
$back_data = 0;
$back_message .= '-护照位数大于18不自动出票';
}
$bpe_sn .= $people_info->BPE_SN.',';
}
$bpe_sn = substr($bpe_sn,0,strlen($bpe_sn)-1);
//单张票价不能大于1000人民币
if($train_info[0]->adultcost > 1000){
$back_data = 0;
$back_message .= '-单价大于1000不自动出票';
}
//如果为国际火车票就不出票
if(in_array($train_info[0]->FlightsNo, $nation_train)){
$back_data = 0;
$back_message .= '-国际火车票不自动出票';
}
//无座的订单不做出票
if($train_info[0]->Aircraft == 'WZ'){
$back_data = 0;
$back_message .= '-无座不自动出票';
}
//香港火车不自动出票
if($train_info[0]->DepartAirport == 'XJA'){
$back_data = 0;
$back_message .= '-香港火车不自动出票';
}
$DepartureDate = strtotime($train_info[0]->DepartureDate);
$time = time();
$depart_diff = ($DepartureDate - $time) / 86400;
if($train_info[0]->ArrivalAirport == 'XJA' && $train_info[0]->adultcost > 500 && $depart_diff > 5){
$back_data = 0;
$back_message .= '-内地香港火车金额大于500超过五天不自动出票';
}
//print_r($train_info);
//如果刚好是第三十天的订单
echo $item->COLI_State;
if(($item->COLI_State == '8' || $item->COLI_State == '63')){
$this->isauto = 3;
$time_obj = $this->BIZ_train_model->get_saletime($train_info['0']->DepartAirport_cn);
//print_r($time_obj);
if(!empty($time_obj)){
$saletime = strtotime($time_obj->TST_saletime);
//echo $saletime;
$sale_diff = (time() - $saletime) / 3600;
if($sale_diff > 1){
$back_data = 0;
$back_message .= '-超过抢票时间';
}else if($sale_diff <0){
$back_data = 0;
$back_message .= '-未到抢票时间';
}
}
}
if($back_data == 0){
$string .= '<tr><td>汉特订单号:'.$coli_id.'('.$cold_sn.')'.$back_message.'</td></tr>';
}else{
//单个订单提交
echo $cold_sn.'<br>';
$this->booktickets($cold_sn,$bpe_sn,'','juhe');
//$string .= '<tr><td>汉特订单号:'.$coli_id.'('.$cold_sn.')可以自动出票</td></tr>';
}
}
print_r('<table border="1">'.$string.'</table>');
}
//创建一个方法用于接收所有的出票请求
public function booktickets($cold_sn=null,$bpe_sn=null,$selectseat=null,$type=null){
if(empty($cold_sn) && empty($bpe_sn)){
//接收子表订单号
$cold_sn = $this->input->get_post('order');
//接收客人表sn
$bpe_sn = $this->input->get_post("people");
//接收选座字符串
$selectseat = $this->input->get_post("selectseat");
//接收出票接口
$type = $this->input->get_post("type");
//接受是否有站票
$this->istanding = $this->input->get_post("istanding");
}
//测试数据
/*$cold_sn = '488121613';
$bpe_sn = '473183645,473183646,473183647';
$selectseat = '';
$type = 'juhe';*/
if(!is_numeric($cold_sn)){
$reback["mes"]="订单号是数字";
echo json_encode($reback);
return false;
}
if(empty($bpe_sn)){
$reback["mes"]="请选择乘客";
echo json_encode($reback);
return false;
}
$data['train'] = $this->BIZ_train_model->biz_order_detail($cold_sn);
$data['people_list']=$this->BIZ_train_model->in_bpesn_people_info($bpe_sn);
if($selectseat == ''){
$selectseat = '';
$train_select = $data['train']->FOI_SelectedSeat;
$obj = explode(',',$train_select);
foreach($obj as $value){
$selectseat .= $value;
}
}
if (empty($data['train'])) {
//显示错误,找不到车次
$reback["mes"]="找不到车次";
echo json_encode($reback);
return false;
}
if (empty($data['people_list'])) {
//显示错误,找不到用户信息
$reback["mes"]="找不到乘客信息";
echo json_encode($reback);
return false;
}
if (count($data['people_list']) > 5) {
//显示错误,用户超过五个
$reback["mes"]="乘客不能超过五个";
echo json_encode($reback);
return false;
}
switch ($type){
case 'juhe':
$this->juheModel($data,$selectseat,$cold_sn);
break;
case 'tuniu':
$this->tuniuModel($data,$selectseat,$cold_sn);
break;
case 'ctrip':
$this->ctripModel($data,$selectseat,$cold_sn);
break;
}
}
function juheModel($data=null,$selectseat=null,$cold_sn=null){
$zwcode = $this->db_train_zw[$data['train']->Aircraft]; //座位简码
$zwname = $this->train_zw[$this->db_train_zw[$data['train']->Aircraft]]; //座位名称
//进行提交字符串的拼接
$passengers = "";
foreach ($data['people_list'] as $key => $item) {
//乘客姓名
$passengersename = $item->BPE_FirstName.$item->BPE_MiddleName.$item->BPE_LastName;
//将特殊字符转换为正常字符以便于出票
$passengersename = chk_sp_name($passengersename);
//乘客类型
switch ($item->BPE_GuestType) {
case 1:
$piaotype = 1;
$piaotypename = "成人票";
break;
case 2:
$piaotype = 2;
$piaotypename = "儿童票";
break;
default://外国人应该就两种票吧
$piaotype = 1;
$piaotypename = "成人票";
break;
}
//证件类型
switch ($item->BPE_PassportType){
case 'Chinese ID':
$passporttypeseid = "1";
$passporttypeseidname = "二代身份证";
break;
case 'Travel Permit from Hong Kong / Macau':
$passporttypeseid = "C";
$passporttypeseidname = "港澳通行证";
break;
case 'Travel Permit from Taiwan':
$passporttypeseid = "G";
$passporttypeseidname = "台湾通行证";
break;
default :
$passporttypeseid = "B";
$passporttypeseidname = "护照";
break;
}
switch ($item->BPE_SEX){
case '100003':
$sex = 'F';
break;
case '100001':
$sex = 'M';
break;
}
$passportseno = str_replace(' ','',$item->BPE_Passport);
//添加一个判断护照号是否在黑名单
if(in_array($passportseno,$this->black_list)){
$reback["mes"] = "乘客为黑名单用户";
echo json_encode($reback);
return false;
}
if($passporttypeseid == 'G'){
$passengers .= ',{"passengerid":' . (++$key) . ',"passengersename":"' . $passengersename . '","piaotype":"' . $piaotype . '","piaotypename":"' . $piaotypename . '","passporttypeseid":"' . $passporttypeseid . '","passporttypeseidname":"' . $passporttypeseidname . '","passportseno":"' . $passportseno . '","price":"1","zwcode":"' . $zwcode . '","zwname":"' . $zwname . '","gatValidDateEnd":"'.$item->BPE_PassExpdate.'","gatBornDate":"'.$item->BPE_BirthDate.'","sexCode":"'.$sex.'"}';
}else{
$passengers .= ',{"passengerid":' . ( ++$key) . ',"passengersename":"' . $passengersename . '","piaotype":"' . $piaotype . '","piaotypename":"' . $piaotypename . '","passporttypeseid":"' . $passporttypeseid . '","passporttypeseidname":"' . $passporttypeseidname . '","passportseno":"' . $passportseno . '","price":"1","zwcode":"' . $zwcode . '","zwname":"' . $zwname . '"}';
}
}
$passengers .= "]";
$passengers = substr($passengers, 1);
$passengers = "[" . $passengers;
$is_accept_standing = 'no';
if($this->istanding == 'true'){
$is_accept_standing = 'yes';
}
if(empty($selectseat)){
$post_data=array(
"key"=>JUHE_TRAIN_API_KEY,
"user_orderid"=>$cold_sn,//自定义订单号
"train_date"=>substr($data["train"]->DepartureDate, 0, 10),
"is_accept_standing"=>$is_accept_standing,
"from_station_name"=>$data["train"]->DepartAirport_cn,
"from_station_code"=>$data["train"]->DepartAirport,
"to_station_code"=>$data["train"]->ArrivalAirport,
"to_station_name"=>$data["train"]->ArrivalAirport_cn,
"passengers"=>$passengers,
"checi"=>$data["train"]->FlightsNo
);
}else{
$post_data=array(
"key"=>JUHE_TRAIN_API_KEY,
"user_orderid"=>$cold_sn,//自定义订单号
"train_date"=>substr($data["train"]->DepartureDate, 0, 10),
"is_accept_standing"=>$is_accept_standing,
"choose_seats"=>$selectseat,
"from_station_name"=>$data["train"]->DepartAirport_cn,
"from_station_code"=>$data["train"]->DepartAirport,
"to_station_code"=>$data["train"]->ArrivalAirport,
"to_station_name"=>$data["train"]->ArrivalAirport_cn,
"passengers"=>$passengers,
"checi"=>$data["train"]->FlightsNo
);
}
//发起请求
$add_data = new stdClass();
$back_json = GetPost_http('http://op.juhe.cn/trainTickets/submit',$post_data);
$back_data = json_decode($back_json);
if(!$back_data->error_code){
$add_data->ordernumber = $back_data->result->orderid;
$reback["status"] = 1;
$reback["order"] = $back_data->result->orderid;
$reback["mes"] = "订单提交成功,等待回调";
}else{
$add_data->ordernumber=null;
$reback["mes"] = $back_json;
$add_data->status = "e";
}
//本地订单入库
$add_data->cold_sn = $cold_sn;
$add_data->returncode = $back_data->error_code;
$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 = 'juhe';
$add_data->isauto = $this->isauto;
$this->train_system_model->add_orders($add_data);
echo json_encode($reback);
return false;
}
function tuniuModel($data,$selectseat,$cold_sn){
$this->load->library('Des');
$zwcode = $this->db_train_zw[$data['train']->Aircraft]; //座位简码
$zwname = $this->train_zw[$this->db_train_zw[$data['train']->Aircraft]]; //座位名称
$passengers="";
//$cold_sn = $cold_sn.'_'.time();
//拼接车次信息
$tuniu_data = '{';
$tuniu_data .= '"retailOrderId":"'.$cold_sn.'",';
$tuniu_data .= '"cheCi": "'.$data['train']->FlightsNo.'", ';
$tuniu_data .= '"fromStationCode": "'.$data['train']->DepartAirport.'", ';
$tuniu_data .= '"fromStationName": "'.$data['train']->DepartAirport_cn.'", ';
$tuniu_data .= '"toStationCode": "'.$data['train']->ArrivalAirport.'", ';
$tuniu_data .= '"toStationName": "'.$data['train']->ArrivalAirport_cn.'", ';
$tuniu_data .= '"trainDate": "'.substr($data["train"]->DepartureDate, 0, 10).'", ';
$tuniu_data .= '"callBackUrl": "http://www.mycht.cn/info.php/apps/train/tuniu_callback/book",';
$tuniu_data .= '"hasSeat": true,';
$tuniu_data .= '"contact": "陈宇超",';
$tuniu_data .= '"phone": "18877381547",';
$tuniu_data .= '"isChooseSeats": true,';
$tuniu_data .= '"chooseSeats":"'.$selectseat.'",';
//循环乘客
$passengers = '';
foreach ($data['people_list'] as $key => $item) {
$passengers .= '{';
$passengers .= '"passengerId":'.$key.',';
$passengers .= '"ticketNo":"null",';
//乘客姓名
$passengersename = str_replace(' ','',$item->BPE_FirstName) . str_replace(' ','',$item->BPE_MiddleName) . str_replace(' ','',$item->BPE_LastName);
//将特殊字符转换为正常字符以便于出票
$passengersename = chk_sp_name($passengersename);
$passengers .= '"passengerName":"'.$passengersename.'",';
$passportseno = str_replace(' ','',$item->BPE_Passport);
$passengers .= '"passportNo":"'.$passportseno.'",';
//证件类型
switch ($item->BPE_PassportType){
case 'Chinese ID':
$passporttypeseid = "1";
$passporttypeseidname = "二代身份证";
break;
case 'Travel Permit from Hong Kong / Macau':
$passporttypeseid = "C";
$passporttypeseidname = "港澳通行证";
break;
case 'Travel Permit from Taiwan':
$passporttypeseid = "G";
$passporttypeseidname = "台湾通行证";
break;
default :
$passporttypeseid = "B";
$passporttypeseidname = "护照";
break;
}
//乘客类型
switch ($item->BPE_GuestType) {
case 1:
$piaotype = 1;
$piaotypename = "成人票";
break;
case 2:
$piaotype = 2;
$piaotypename = "儿童票";
break;
default://外国人应该就两种票吧
$piaotype = 1;
$piaotypename = "成人票";
break;
}
$passengers .= '"passportTypeId":"'.$passporttypeseid.'",';
$passengers .= '"passportTypeName":"'.$passporttypeseidname.'",';
//票类型
$passengers .= '"piaoType":"'.$item->BPE_GuestType.'",';
$passengers .= '"piaoTypeName":"'.$piaotypename.'",';
//座位类型piaoTypeName
$passengers .= '"zwCode":"'.$zwcode.'",';
$passengers .= '"zwName":"'.$zwname.'",';
$passengers .= '"cxin":"null",';
$passengers .= '"price":"'.$data['train']->adultcost.'",';
$passengers .= '"reason": 0';
$passengers .= '},';
}
$passengers = substr($passengers,0,strlen($passengers)-1);
$passengers = '['.$passengers.']';
$tuniu_data .= '"passengers": '.$passengers.'}';
//print_r($tuniu_data);
$crypt = new DES();
$mstr = $crypt->encrypt($tuniu_data,TUNIU_KEY);
$post_data = '{
"apiKey": "'.TUNIU_KEY.'",
"sign": "'.create_sign().'",
"timestamp": "'.date('Y-m-d H:i:s',time()).'",
"data": "'.$mstr.'"
}';
$url = TUNIU_URL.'/train/book';
$book_back_json = GetPost_http($url,$post_data,'POST','json');
$book_back_data = json_decode($book_back_json);
$orderId = $book_back_data->data->orderId;
$retailOrderId = $book_back_data->data->retailOrderId;
if($book_back_data->success == 1){
$confirm_url = TUNIU_URL.'/train/confirm';
$sign = create_sign();
$time = date('Y-m-d H:i:s',time());
$post_data = '{
"apiKey": "'.TUNIU_KEY.'",
"sign": "'.$sign.'",
"timestamp": "'.$time.'",
"data": {
"retailOrderId":"'.$retailOrderId.'",
"orderId":"'.$orderId.'",
"callBackUrl":"http://www.mycht.cn/info.php/apps/train/tuniu_callback/confirm"
}
}';
//请求出票
$confirm_back_json = GetPost_http($confirm_url,$post_data,'POST','json');
$confirm_back_data = json_decode($confirm_back_json);
$reback["status"] = 1;
$reback["order"] = $orderId;
$reback["mes"] = "订单提交成功,等待回调";
}else{
$reback["mes"] = $confirm_back_json;
$add_data->status = "e";
}
//本地订单入库
$add_data = new stdClass();
$add_data->cold_sn = $retailOrderId;
$add_data->ordernumber = $orderId;
$add_data->returncode = $confirm_back_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 = 'tuniu';
$add_data->isauto = 0;
$this->train_system_model->add_orders($add_data);
echo json_encode($reback);
return false;
}
function ctripModel($data,$selectseat,$cold_sn){
$zwcode = $this->db_train_zw[$data['train']->Aircraft]; //座位简码
$zwname = $this->train_zw[$this->db_train_zw[$data['train']->Aircraft]]; //座位名称
$OrderNumber = ORDERUSER.time();
//拼接发送的报文
$PostData = array();
$TimeStamp = time();
$time = date('Y-m-d H:i:s',$TimeStamp);
$PostData['Authentication']->TimeStamp = $time;
$PostData['Authentication']->ServiceName = 'order.PartnerAddOrder';
$PostData['Authentication']->PartnerName = ORDERUSER;
$MessageIdentity = md5($time.'order.PartnerAddOrder'.ORDERKEY);
$PostData['Authentication']->MessageIdentity = $MessageIdentity;
$PostData['TrainOrderService']->PartnerName = ORDERUSER;
$PostData['TrainOrderService']->Operation = '';
$PostData['TrainOrderService']->OrderType = '电子';
$PostData['TrainOrderService']->OrderTicketType = '0';
$PostData['TrainOrderService']->OrderNumber = $OrderNumber;
$PostData['TrainOrderService']->ChannelName = ORDERUSER;
$PostData['TrainOrderService']->Order->OrderTime = $time;
$PostData['TrainOrderService']->Order->OrderMedia = 'pc';
$PostData['TrainOrderService']->Order->Insurance = 'N';
$PostData['TrainOrderService']->Order->Invoice = 'N';
$PostData['TrainOrderService']->Order->PrivateCustomization = '0';
$PostData['TrainOrderService']->Order->TicketItem->FromStationName = $data['train']->DepartAirport_cn;
$PostData['TrainOrderService']->Order->TicketItem->ToStationName = $data['train']->ArrivalAirport_cn;
$PostData['TrainOrderService']->Order->TicketItem->TicketTime = date('Y-m-d H:i:s',strtotime($data['train']->DepartureTime));
$PostData['TrainOrderService']->Order->TicketItem->TrainNumber = $data['train']->FlightsNo;
$PostData['TrainOrderService']->Order->TicketItem->ArrivalDateTime = date('Y-m-d H:i:s',strtotime($data['train']->ArrivalTime));
$PostData['TrainOrderService']->Order->TicketItem->TicketPrice = $data['train']->adultcost;
$PostData['TrainOrderService']->Order->TicketItem->TicketCount = count($data['people_list']);
$AdultNum = 0;
$ChildNum = 0;
$Passport = '';
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 'Travel Permit from Hong Kong / Macau':
$PassportTypeseidName = "港澳通行证";
break;
case 'Travel Permit from Taiwan':
$PassportTypeseId = "G";
$PassportTypeseidName = "台湾通行证";
break;
default :
$PassportTypeseId = "B";
$PassportTypeseidName = "护照";
break;
}
//$Passport .= chk_sp_name($PassagerInfo->BPE_FirstName.$PassagerInfo->BPE_MiddleName.$PassagerInfo->BPE_LastName).','.$PassportTypeseidName.','.$PassagerInfo->BPE_Passport.','.$PiaoTypeName.','.''.',0|';
if($PiaoType == 1){
$RelatioNme = chk_sp_name($PassagerInfo->BPE_FirstName.$PassagerInfo->BPE_MiddleName.$PassagerInfo->BPE_LastName);
$Passport .= chk_sp_name($PassagerInfo->BPE_FirstName.$PassagerInfo->BPE_MiddleName.$PassagerInfo->BPE_LastName).','.$PassportTypeseidName.','.$PassagerInfo->BPE_Passport.','.$PiaoTypeName.','.''.',0|';
}elseif($PiaoType == 2){
$Passport .= $RelatioNme.','.$PassportTypeseidName.','.$PassagerInfo->BPE_Passport.','.$PiaoTypeName.','.''.',0,'.chk_sp_name($PassagerInfo->BPE_FirstName.$PassagerInfo->BPE_MiddleName.$PassagerInfo->BPE_LastName).'|';
}
}
$PostData['TrainOrderService']->Order->TicketItem->AuditTicketCount = $AdultNum;
$PostData['TrainOrderService']->Order->TicketItem->ChildTicketCount = $ChildNum;
$PostData['TrainOrderService']->Order->TicketItem->SeatName = $this->train_zw[$this->db_train_zw[$data['train']->Aircraft]];
$PostData['TrainOrderService']->Order->TicketItem->SelectedSeat = $selectseat;
$is_accept_standing = '';
if($this->istanding == 'true'){
$is_accept_standing = '无座';
}
$PostData['TrainOrderService']->Order->TicketItem->AcceptSeat = $is_accept_standing;
$PostData['TrainOrderService']->Order->TicketItem->passport = substr($Passport,0,strlen($Passport)-1);
$PostData['TrainOrderService']->Order->TicketItem->OrderPrice = $data['train']->adultcost * $AdultNum + $data['train']->childcost * $ChildNum;
$PostData['TrainOrderService']->Order->FrontSeatFlag = '0';
$PostData['TrainOrderService']->Order->User->UserID = '';
$PostData['TrainOrderService']->Order->User->UserName = 'guilintravel';
$PostData['TrainOrderService']->Order->User->userLoginName = 'guilintravel';
$PostData['TrainOrderService']->Order->User->UserMobile = '18877381547';
//print_r($PostData);die();
//本地添加记录
$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 = 'ctrip';
$add_data->isauto = 0;
//存储到数据库
$this->train_system_model->add_orders($add_data);
$Url = 'http://m.ctrip.com/restapi/soa2/11009/json/PartnerAddOrder';
$ResponseJson = GetPost_http($Url,json_encode($PostData),'POST');
$ResponseData = json_decode($ResponseJson);
//echo '预定';
//print_r($ResponseData);
//预定请求成功后执行支付
if($ResponseData->Status == 'SUCCESS'){
//计算订单总价,进行支付
$total_price = $AdultNum * $data['train']->adultcost + $ChildNum * $data['train']->childcost;
$this->payorders($OrderNumber,$total_price);
$reback["status"] = 1;
$reback["order"] = $OrderNumber;
$reback["mes"] = "订单提交成功,等待回调";
}else{
$reback["mes"] = $ResponseJson;
$add_data->status = "e";
}
echo json_encode($reback);
}
}

@ -0,0 +1,339 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class api extends CI_Controller{
public function __construct(){
parent::__construct();
$this->load->helper('train');
$this->load->model("BIZ_train_model");
$this->load->model("train_system_model");
$this->load->model("Sendmail_model");
}
public function index(){
echo 'api manager';
}
//获取订单出票状态
public function isbooktickets(){
$cold_sn = $this->input->get('cold_sn');
$tickets_info = $this->train_system_model->get_tickets_info($cold_sn);
//print_r($tickets_info);
if(!empty($tickets_info)){
$return_data = array();
$i = 0;
foreach($tickets_info as $items){
$return_data[$i] = new stdClass();
$return_data[$i]->cold_sn = (int) $items->ts_cold_sn;
$return_data[$i]->ordernumber = $items->ts_ordernumber;
$return_data[$i]->status = $items->tst_status;
$return_data[$i]->passengersename = $items->tst_realname;
$return_data[$i]->passportseno = $items->tst_numberid;
$i++;
}
print_r(json_encode($return_data));
}else{
return null;
}
}
//用于自动发送确认信
public function send_confirmmail(){
//log_message('error','auto sendmail');
$mailarr = $this->BIZ_train_model->auto_sendmail();
foreach($mailarr as $obj){
$coli_id = $this->BIZ_train_model->cold_sn_get_coli_id($obj->ts_cold_sn);
$coli_id = $coli_id[0]->COLI_ID;
$juhe_order = $obj->ts_ordernumber;
$this->send_mail_to_guest($coli_id,$juhe_order);
}
}
//发邮件给客人
function send_mail_to_guest($coli_id,$jh_order){
$info = $this->BIZ_train_model->get_user_info($jh_order);
$guest = $this->BIZ_train_model->get_guest_info($coli_id);
//print_r($guest);
$operator_info = $this->BIZ_train_model->get_operatorInfo($coli_id);
$fromName = $operator_info[0]->Name;
$fromEmail = $operator_info[0]->OPI_Email;
$toName = $guest[0]->GUT_LastName.$guest[0]->GUT_FirstName;
$toEmail = $guest[0]->GUT_Email;//
$data['coli_id'] = $coli_id;
$data['toname'] = $toName;
$data['adult'] = $info->COLD_PersonNum;
$data['chlid'] = $info->COLD_ChildNum;
$data['baby'] = $info->COLD_BabyNum;
$data['price'] = $this->BIZ_train_model->get_paypal($coli_id);
$data['allpeople'] = $this->BIZ_train_model->biz_people($info->COLD_SN);
$data['train_info'] = $this->BIZ_train_model->get_biz_foi($info->COLD_SN);
$differtime = (strtotime($data['train_info'][0]->DepartureTime) - time()) / 3600;
$obj = $this->BIZ_train_model->get_biz_jol_info($info->COLD_SN,$jh_order);
$data['ordernumber'] = $obj->ts_elecnumber;
$status = $obj->ts_status;
$data['operator'] = $operator_info;
$data['emailarr'] = explode(';',$operator_info[0]->Email);
$data['seatinfo'] = $obj->ts_seatsinfo;
if($status == '4' && $differtime > 0){
$subject = "Got payment and issued train ticket(s), Order No $coli_id";
$body = $this->load->view('email',$data,true);
$this->send_mail_to_wl("订单:{$coli_id} 出票成功","翰特订单号:{$coli_id};聚合订单号:{$jh_order}",$coli_id);
//发送邮件给客人
$flag = $this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
$this->BIZ_train_model->update_biz_jol(array("ts_ordernumber"=>$jh_order),array("ts_sendmail"=>1,"ts_m_sn"=>$flag));
}else if($status == '1'){
$subject = "The train ticket(s) will be issued manually, Order No $coli_id";
$body = $this->load->view('email_fault',$data,true);
$this->send_mail_to_wl("订单:{$coli_id} 出票失败","翰特订单号:{$coli_id};聚合订单号:{$jh_order}",$coli_id);
//测试阶段,将失败邮件发送一份给操作外联。
$flag = $this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$fromName,$fromEmail,$subject,$body);
//测试阶段,将失败邮件发送一份给操作外联。
$this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
$this->BIZ_train_model->update_biz_jol(array("ts_ordernumber"=>$jh_order),array("ts_sendmail"=>1,"ts_m_sn"=>$flag));
}
}
//发邮件给外联
function send_mail_to_wl($subject,$body,$coli_id){
$fromName = "cyc";
$fromEmail = "cyc@hainatravel.com";
//获取该订单的操作员的邮箱以及姓名
$info = $this->BIZ_train_model->get_operatorInfo($coli_id);
$toName = $info[0]->OPI_Name;
$toEmail = $info[0]->OPI_Email;
$this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
}
//导出账单api
public function export_excel(){
set_time_limit(0);
//创建跟踪号
$trackcode = $this->BIZ_train_model->getTrackingCode();
$from_date = $this->input->post("from_date");
$to_date = $this->input->post("to_date");
$examine = $this->input->post("examine");
//$operator=$this->input->post("operator");
$reback=array();//返回的数据
$reback["from_date"] = $from_date;
$reback["to_date"] = $to_date;
$reback["examine"] = $examine;
$group = array();
if(!empty($from_date) && !empty($to_date)){
$from_date = date("Y-m-d H:i",strtotime($from_date));
$to_date = date("Y-m-d H:i",strtotime($to_date));
$r = "";//聚合返回的数据
$string_r = "";//输出
$coli_id = "";
$wl_name = "";
$arr = array();//整合完成的数组,写进excel表的数据
$url = JUHE_TRAIN_EXPORT_API;//请求的url
$url .= "?key=".JUHE_TRAIN_API_KEY;
$url .= "&since=".$from_date;
$url .= "&before=".$to_date;
$r = GetPost_http($url);
$r = explode("\n",$r);
//print_r($r);
//die();
for($i=1;$i<count($r)-1;$i++){
$r_info=explode(",",$r[$i]);
$juhe_order=substr($r_info[4], 1,strlen($r_info[4])-2);
$obj = $this->BIZ_train_model->jh_order_get_coli_id($juhe_order);
//print_r($obj);
if(!empty($obj)){
$coli_id = $obj[0]->COLI_ID;
$coli_sn = $obj[0]->COLI_SN;
}else{
echo $juhe_order;
}
$this->BIZ_train_model->linkTrackingCode($coli_sn,$trackcode);
/*if(empty($coli_sn) || empty($coli_sn)){
print_r($juhe_order);
}*/
/*
$flag = $this->BIZ_train_model->islink($coli_sn);
if($flag){
$this->BIZ_train_model->linkTrackingCode($coli_sn,$trackcode);
}else{
echo $coli_sn.'该订单还未关联财务表,不能导出账单。<br>';
die();
}
*/
//去掉数据两边的双引号
$r_info[2]=substr($r_info[2], stripos($r_info[2],'"')+1,strrpos($r_info[2],'"')-1);
$r_info[1]=substr($r_info[1], stripos($r_info[1],'"')+1,strrpos($r_info[1],'"')-1);
$r_info[5]=substr($r_info[5], stripos($r_info[5],'"')+1,strrpos($r_info[5],'"')-1);
$r_info[6]="";//储存团名
$r_info[7] = "";//储存外联名
$r_info[8] = "";//储存coli_id
if($coli_id){
$r_info[8] = $coli_id;
$gri_no=$this->BIZ_train_model->get_gri_no($r_info[8]);//团名
$wl_name = $this->BIZ_train_model->get_operatorInfo($r_info[8]);
if($gri_no){
$r_info[6] = $gri_no[0]->GRI_No;
}
if($wl_name){
$r_info[7] = $wl_name[0]->OPI_Name;
}
}
//$r_info[3]=mb_convert_encoding($r_info[3],"utf-8","gbk");
if(is_numeric(mb_strpos($r_info[3],"充值"))){
if(is_numeric(mb_strpos($r_info[3],"扣款"))){
$r_info[3]="票款(有充值)";
}
if(is_numeric(mb_strpos($r_info[3],"扣手续费"))){
$r_info[3]="手续费(有充值)";
}
if(is_numeric(mb_strpos($r_info[3],"线上退票成功"))){
$r_info[3]="退票费(有充值)";
}
}
if(is_numeric(mb_strpos($r_info[3],"扣款"))){
$r_info[3]="票款";
}
if(is_numeric(mb_strpos($r_info[3],"扣手续费"))){
$r_info[3]="手续费";
}
if(is_numeric(mb_strpos($r_info[3],"线上退票成功"))){
$r_info[3]="退票费";
}
// $r_info[3]=mb_convert_encoding($r_info[3],"gbk","utf-8");
$r_info['trackcode'] = $trackcode;
$arr[]=$r_info;
/*
//根据外联的名字创建数组来存储对应外联的订单信息
if(!empty($r_info[7])){
if(!isset($group[$r_info[7]])){
$group[$r_info[7]] = array();
}
array_push($group[$r_info[7]],$r_info);
}*/
}
/*
//将存储好的分组重新循环出来。
foreach($group as $item){
foreach ($item as $value){
array_push($arr,$value);
}
}
*/
//die();
if(empty($examine)){
header("Content-type:application/vnd.ms-excel;charset=utf-8");
header("Content-Disposition:attachment;filename=juhe_train.xls");
$string_r= $this->load->view("train_transaction_excel",array("arr"=>$arr),TRUE);
echo $string_r;die;
}else{
krsort($arr);//数组倒序
$reback["data"]=$arr;
}
}
}
//登录验证
public function check_login(){
$code = $this->input->get('code');
$signature = getDingSignature();
$urlencode_signature = urlencode($signature);
$personInfoUrl = 'https://oapi.dingtalk.com/sns/getuserinfo_bycode?signature='.$urlencode_signature.'&timestamp='.time().'&accessKey=dingoaystremzlahfew1tb';
$post_data = '{"tmp_auth_code":"'.$code.'"}';
$returnJson = GetPost_http($personInfoUrl,$post_data,'json');
$returnData = json_decode($returnJson);
if(!empty($returnData->user_info)){
//创建session
$this->session->set_userdata('dingname', $returnData->user_info->nick);
$this->session->set_userdata('dingunionid', $returnData->user_info->unionid);
redirect('http://www.mycht.cn/info.php/apps/trainsystem/pages/');
}else{
redirect('http://www.mycht.cn/info.php/apps/trainsystem/pages/login');
}
}
public function check_session(){
print_r($this->session->userdata('dingunionid'));
}
//订单同步到trainsystem
public function sync_orders(){
die();
//获取聚合订单
$juhe_orders = $this->train_system_model->getallorders();
$add_data = new stdClass();
foreach ($juhe_orders as $items){
$add_data->ordernumber = $items->JOL_JuheOrder;
$add_data->cold_sn = $items->JOL_COLD_SN;
$add_data->status = $items->JOL_Status;
$add_data->returncode = '';
$add_data->errormsg = $items->JOL_RebackMsg;
$add_data->checi = $items->JOL_TrainCode;
$add_data->fromstationame = $items->JOL_FromStation;
$add_data->fromstationcode = $items->JOL_FromStationCode;
$add_data->tostationame = $items->JOL_ToStation;
$add_data->tostationcode = $items->JOL_ToStationCode;
$trains = json_decode($items->JOL_BackTxt);
//print_r($trains->passengers);
if(isset($trains->train_date)){
$add_data->startdate = $trains->train_date;
}else{
$add_data->startdate = '';
}
foreach ($trains->passengers as $passengers){
//对订票乘客进行存储
$data_passager->ordernumber = $items->JOL_JuheOrder;
$data_passager->realname = $passengers->passengersename;
$data_passager->identitytype = $passengers->passporttypeseidname;
$data_passager->numberid = $passengers->passportseno;
$data_passager->ticketype = $passengers->piaotypename;
$data_passager->ticketprice = $passengers->price;
$data_passager->seatype = $passengers->zwname;
$data_passager->seatdetail = $passengers->cxin;
$data_passager->status = $items->JOL_Status;
//print_r($data_passager);
$this->train_system_model->add_passagers($data_passager);
}
$add_data->startime = '';
$add_data->endtime = '';
$add_data->runtime = '';
$add_data->channel = 'juhe';
$add_data->isauto = $items->JOL_IsAuto;
$this->train_system_model->add_orders($add_data);
//print_r($add_data);
}
}
public function update_order(){
$juhe_orders = $this->train_system_model->getallorders();
foreach ($juhe_orders as $tickets_info){
$ordernumber = $tickets_info->JOL_JuheOrder;
$subtime = $tickets_info->JOL_SubTime;
$price = $tickets_info->JOL_Price;
$this->train_system_model->update_juheorder($ordernumber,$subtime,$price);
}
}
}

@ -0,0 +1,320 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class callback extends CI_Controller{
public function __construct(){
parent::__construct();
$this->load->helper('train');
$this->load->model("train_system_model");
$this->load->model("BIZ_train_model");
}
public function juhecallback(){
$data_post = $this->input->post();
if(empty($data_post)){
header("HTTP/1.1 404 Not Found");
exit('{"reason":"empty infos","status":"404"}');
}
//调试代码
/*$test_post = '{"data":"{\"from_station_name\":\"\u6b66\u6c49\",\"from_station_code\":\"WHN\",\"to_station_name\":\"\u897f\u5b89\u5317\",\"to_station_code\":\"EAY\",\"train_date\":\"2019-04-13\",\"orderid\":\"JH155317715892154\",\"user_orderid\":\"488123754\",\"orderamount\":\"1363.50\",\"ordernumber\":\"E946949845\",\"checi\":\"G856\",\"msg\":\"\u51fa\u7968\u6210\u529f\",\"status\":\"4\",\"passengers\":[{\"passengerid\":1,\"passengersename\":\"VENOSLEONARDA\",\"piaotype\":\"1\",\"piaotypename\":\"\u6210\u4eba\u7968\",\"passporttypeseid\":\"B\",\"passporttypeseidname\":\"\u62a4\u7167\",\"passportseno\":\"086925694\",\"price\":\"454.5\",\"zwcode\":\"O\",\"zwname\":\"\u4e8c\u7b49\u5ea7\",\"ticket_no\":\"E946949845102006A\",\"cxin\":\"02\u8f66\u53a2,06A\u5ea7\",\"reason\":0},{\"passengerid\":2,\"passengersename\":\"WAGENSTALLERSANDRA\",\"piaotype\":\"1\",\"piaotypename\":\"\u6210\u4eba\u7968\",\"passporttypeseid\":\"B\",\"passporttypeseidname\":\"\u62a4\u7167\",\"passportseno\":\"CF7NR17M7\",\"price\":\"454.5\",\"zwcode\":\"O\",\"zwname\":\"\u4e8c\u7b49\u5ea7\",\"ticket_no\":\"E946949845102006B\",\"cxin\":\"02\u8f66\u53a2,06B\u5ea7\",\"reason\":0},{\"passengerid\":3,\"passengersename\":\"WALDMANNSOPHIE\",\"piaotype\":\"1\",\"piaotypename\":\"\u6210\u4eba\u7968\",\"passporttypeseid\":\"B\",\"passporttypeseidname\":\"\u62a4\u7167\",\"passportseno\":\"CF26Y6FVK\",\"price\":\"454.5\",\"zwcode\":\"O\",\"zwname\":\"\u4e8c\u7b49\u5ea7\",\"ticket_no\":\"E946949845102006C\",\"cxin\":\"02\u8f66\u53a2,06C\u5ea7\",\"reason\":0}],\"refund_money\":null,\"sign\":\"f74013fa24115eeb9a807aa237054920\"}"}';
$data_post["data"] = json_decode($test_post)->data;*/
log_message('error','聚合回调:'.json_encode($data_post));
$data = json_decode($data_post["data"]);
$update_data = new StdClass();
$update_data->OrderStatus = $data->status;
$update_data->ordernumber = $data->orderid;
$update_data->OrderTotleFee = $data->orderamount;
$update_data->seatsinfo = '';
$update_data->TicketCheck = '';
$update_data->bookcallback = '';
$update_data->confirmcallback = '';
$update_data->returncallback = '';
$update_data->ElectronicOrderNumber = $data->ordernumber;
$update_data->reschedulecallback = '';
$update_data->ErrorMsg = $data->msg;
//如果返回2则发送出票请求
if($data->status == "1"){
$update_data->bookcallback = $data_post["data"];
}elseif($data->status == "2"){
$coach = array();
$seats = array();
$string = '';
$passagers = $data->passengers;
foreach($passagers as $item){
foreach(explode(',',$item->cxin) as $item_seat){
if(strpos($item_seat,'车厢')){
$item_seat = str_replace('车厢','',$item_seat);
array_push($coach,$item_seat);
}else{
$find = array('座上铺','座中铺','座下铺','座');
$replace = array(' upper',' middle',' lower','');
$item_seat = str_replace($find,$replace,$item_seat);
array_push($seats,$item_seat);
}
}
//对订票乘客进行存储
$data_passager->ordernumber = $data->orderid;
$data_passager->realname = $item->passengersename;
$data_passager->identitytype = $item->passporttypeseidname;
$data_passager->numberid = $item->passportseno;
$data_passager->ticketype = $item->piaotypename;
$data_passager->ticketprice = $item->price;
$data_passager->seatype = $item->zwname;
$data_passager->seatdetail = $item->cxin;
$data_passager->status = '4';
$this->train_system_model->add_passagers($data_passager);
}
//判断车厢是否唯一,如果不唯一的话,分成两个车厢
if(count(array_unique($coach)) == 1){
$onlycoach = array_unique($coach);
$string .= 'Coach '.$onlycoach[0].',';
}else{
foreach (array_unique($coach) as $item_coach){
$string .= 'Coach '.$item_coach.',';
}
}
$string .= 'Seat ';
foreach($seats as $item_seat){
$string .= $item_seat.',';
}
$seatinfo = substr($string,0,strlen($string)-1);
$update_data->seatsinfo = $seatinfo;
$post_data = array(
"key"=>JUHE_TRAIN_API_KEY,
"orderid"=>$data->orderid
);
$back_json = GetPost_http(JUHE_TRAIN_PAY_API,$post_data);
$update_data->bookcallback = $data_post["data"];
}elseif($data->status == "4"){
$add_train_order_data->TOC_Memo = $data->orderid." 聚合出票";
$add_train_order_data->TOC_COLD_SN = $data->user_orderid;
$add_train_order_data->TOC_TrainNumber = $data->checi;
$add_train_order_data->TOC_DepartureDate = $data->train_date;
$add_train_order_data->TOC_TicketCost = $data->orderamount;
$add_train_order_data->poundage = (count($data->passengers)*2)."";//手续费,每人两块,转换成字符串
$add_train_order_data->FOI_TrainNetOrderNo = $data->ordernumber;
$this->BIZ_train_model->add_train_payment($add_train_order_data);
$update_data->confirmcallback = $data_post["data"];
$this->BIZ_train_model->update_cold_planvei_sn($data->user_orderid);
}elseif($data->status=="7"){
//退票成功 写入TOC表
$newtime = "";//记录最新操作时间
$refund_passportseno = "";//退票人护照号
$refund_money = "";//退票金额
foreach ($data->passengers as $p) {
if(isset($p->returntickets)){
$refund_passportseno = $p->refundTimeline[count($p->refundTimeline)-1]->detail->passportseno;
$refund_money = $p->refundTimeline[count($p->refundTimeline)-1]->detail->returnmoney;
//退票时还需要单独对对每个乘客存储回调信息
$passpager_info = new stdClass();
$passpager_info->returncallback = $data_post["data"];
$passpager_info->status = '7';
$passpager_info->ordernumber = $data->orderid;
$passpager_info->realname = $p->refundTimeline[count($p->refundTimeline)-1]->detail->passengername;
$passpager_info->numberid = $refund_passportseno;
print_r($passpager_info);
$this->train_system_model->update_passpager_info($passpager_info);
//添加退款记录
$add_train_order_data->TOC_COLD_SN = $data->user_orderid;
$add_train_order_data->TOC_Memo = $data->orderid." ".$refund_passportseno;
$add_train_order_data->ordernumber = $data->user_orderid;
$add_train_order_data->TOC_TrainNumber = $data->checi;
$add_train_order_data->TOC_DepartureDate = $data->train_date;
$add_train_order_data->TOC_TicketCost = -$refund_money;
$add_train_order_data->FOI_TrainNetOrderNo = null;//退票不用更新取票号,以此在模型里面判断是否为退票消息
$this->BIZ_train_model->add_train_payment($add_train_order_data);
}else{
//有可能提交了退票或者还没有退票
}
}
$update_data->returncallback = $data_post["data"];
}
//print_r($update_data);die();
//更新订单信息(出票系统)
$this->train_system_model->update_orders($update_data);
}
public function ctripcallback(){
$back_json = file_get_contents('php://input');
log_message('error','携程回调信息:'.$back_json);
/*$back_json = '{"Authentication":{"ServiceName":"web.order.returnTicketNotice","PartnerName":"tieyou","TimeStamp":"2019-1-18 11:35:22","MessageIdentity":"93F2BA3253829E8FAD29B5DEB7646A59"},"TrainOrderService":{"contactName":{},"contactMobile":{},"OrderNumber":"guilintravel1547778269","refundTicket":{"childBillId":{},"orderId":"8360041214","eOrderNumber":"EB59937931","eOrderType":"1","seatNumber":"01D\u53f7","passport":"544712454","passportName":"YANGFRANCISCHENG","realName":"YANGFRANCISCHENG","status":"1","reason":"\u9000\u7968\u6210\u529f\uff0c\u9000\u6b3e\u91d1\u989d:218.50\u5143"}}}';*/
$ctrip_backdata = json_decode($back_json);
//print_r($ctrip_backdata);
if(!empty($ctrip_backdata)){
$update_data = new stdClass();
$update_data->ServiceName = $ctrip_backdata->Authentication->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 = '';
if($update_data->ServiceName == 'web.order.notifyTicket'){
$update_data->OrderStatus = '4';
$update_data->ErrorMsg = '出票成功';
$update_data->ordernumber = $ctrip_backdata->TrainOrderService->OrderInfo->OrderNumber;
$update_data->OrderTotleFee = $ctrip_backdata->TrainOrderService->OrderInfo->OrderTotleFee;
$update_data->ElectronicOrderNumber = $ctrip_backdata->TrainOrderService->OrderInfo->ElectronicOrderNumber;
//新添加检票口信息
if(isset($ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->TicketCheck)){
if(!is_object($ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->TicketCheck)){
$update_data->TicketCheck = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->TicketCheck;
}
}
//获取总票数,由于携程接口单人和多人返回的数据结构不一致
$person_num = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->TicketCount;
//存储座位信息 转换为英文
$coach_arr = array();
$seats_arr = array();
$data_passager = new stdClass();
$string = '';
$i = 0;
if($person_num > 1){
foreach ($ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->DetailInfos->DetailInfo as $items){
if(strpos($items->SeatNo,'车厢')){
$coach = mb_substr($items->SeatNo,0,strpos($items->SeatNo,'车厢'));
array_push($coach_arr,$coach);
$seat = mb_substr($items->SeatNo,strpos($items->SeatNo,'车厢')+2,mb_strlen($items->SeatNo,'UTF8'));
$find = array('号');
$replace = array('');
$seat = str_replace($find,$replace,$seat);
array_push($seats_arr,$seat);
}
//对订票乘客进行存储
$data_passager->ordernumber = $ctrip_backdata->TrainOrderService->OrderInfo->OrderNumber;
$data_passager->realname = $items->PassengerName;
$data_passager->identitytype = $items->IdentityType;
$data_passager->numberid = $items->NumberID;
$data_passager->ticketype = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->TicketType;
$data_passager->ticketprice = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->OrderTicketPrice;
$data_passager->seatype = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->OrderTicketSeat;
$data_passager->seatdetail = $items->SeatNo;
$this->train_system_model->add_passagers($data_passager);
$i++;
}
}else{
$seatinfo_html = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->DetailInfos->DetailInfo->SeatNo;
if(strpos($seatinfo_html,'车厢')){
$coach = mb_substr($seatinfo_html,0,strpos($seatinfo_html,'车厢'));
array_push($coach_arr,$coach);
$seat = mb_substr($seatinfo_html,strpos($seatinfo_html,'车厢')+2,mb_strlen($seatinfo_html,'UTF8'));
$find = array('号');
$replace = array('');
$seat = str_replace($find,$replace,$seat);
array_push($seats_arr,$seat);
}
//对订票乘客进行存储
$data_passager->ordernumber = $ctrip_backdata->TrainOrderService->OrderInfo->OrderNumber;
$data_passager->realname = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->DetailInfos->DetailInfo->PassengerName;
$data_passager->identitytype = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->DetailInfos->DetailInfo->IdentityType;
$data_passager->numberid = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->DetailInfos->DetailInfo->NumberID;
$data_passager->ticketype = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->TicketType;
$data_passager->ticketprice = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->OrderTicketPrice;
$data_passager->seatype = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->OrderTicketSeat;
$data_passager->seatdetail = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfoFinal->Tickets->Ticket->DetailInfos->DetailInfo->SeatNo;
$this->train_system_model->add_passagers($data_passager);
}
if(count(array_unique($coach_arr)) == 1){
$onlycoach = array_unique($coach_arr);
$update_data->seatsinfo .= 'Coach '.$onlycoach[0].',';
}else{
foreach (array_unique($coach_arr) as $item_coach){
$update_data->seatsinfo .= 'Coach '.$item_coach.',';
}
}
$update_data->seatsinfo .= 'Seat ';
foreach($seats_arr as $item_seat){
$update_data->seatsinfo .= $item_seat.',';
}
$update_data->seatsinfo = substr($update_data->seatsinfo,0,strlen($update_data->seatsinfo)-1);
$update_data->bookcallback = $back_json;
//添加支付记录
$add_train_payment_data->TOC_Memo = $update_data->ordernumber;
//根据订单号获取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 = $ctrip_backdata->TrainOrderService->OrderInfo->TicketInfo->OrderTicketCheci;
$add_train_payment_data->TOC_DepartureDate = date('Y-m-d',strtotime($ctrip_backdata->TrainOrderService->OrderInfo->TicketInfo->OrderTicketYMD));
$add_train_payment_data->TOC_TicketCost = $update_data->OrderTotleFee;
$add_train_payment_data->poundage = ($person_num*5)."";//手续费,每人五块,转换成字符串
$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);
}else if($update_data->ServiceName == 'web.order.notifyNoTicket'){
$update_data->ordernumber = $ctrip_backdata->TrainOrderService->OrderInfo->OrderNumber;
$update_data->OrderStatus = '1';
$update_data->ErrorMsg = $ctrip_backdata->TrainOrderService->OrderInfo->NoTicketReasons;
$update_data->confirmcallback = $back_json;
}else if($update_data->ServiceName == 'web.order.returnTicketNotice'){
$update_data->ordernumber = $ctrip_backdata->TrainOrderService->OrderNumber;
$update_data->OrderStatus = '7';
$update_data->ErrorMsg = $ctrip_backdata->TrainOrderService->refundTicket->reason;
$update_data->returncallback = $back_json;
//退票时还需要单独对对每个乘客存储回调信息
$passpager_info = new stdClass();
$passpager_info->returncallback = $back_json;
$passpager_info->status = '7';
$passpager_info->ordernumber = $ctrip_backdata->TrainOrderService->OrderNumber;
$passpager_info->realname = $ctrip_backdata->TrainOrderService->refundTicket->realName;
$passpager_info->numberid = $ctrip_backdata->TrainOrderService->refundTicket->passport;
$this->train_system_model->update_passpager_info($passpager_info);
}else if($update_data->ServiceName == 'web.order.requestRefund'){
$return_order = $ctrip_backdata->TrainOrderService->OrderInfo->OrderNumber;
$return_money = $ctrip_backdata->TrainOrderService->TotalRefundAmount;
//根据订单号获取cold_sn
$order_info = $this->train_system_model->get_order_info($return_order);
$cold_sn = $order_info->ts_cold_sn;
//print_r($order_info);
$add_train_payment_data->TOC_Memo = $return_order.'_'.$ctrip_backdata->TrainOrderService->OrderInfo->OrderTid;
$add_train_payment_data->TOC_COLD_SN = $cold_sn;
$add_train_payment_data->TOC_TrainNumber = $order_info->ts_checi;
$add_train_payment_data->TOC_DepartureDate = $order_info->ts_startdate;
$add_train_payment_data->TOC_TicketCost = -$ctrip_backdata->TrainOrderService->TotalRefundAmount;
$add_train_payment_data->FOI_TrainNetOrderNo=null;
//print_r($add_train_payment_data);die();
$this->BIZ_train_model->add_train_payment($add_train_payment_data);
return false;
}
//更新订单信息(出票系统)
$this->train_system_model->update_orders($update_data);
}
}
}

@ -0,0 +1,528 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class check extends CI_Controller{
public function __construct(){
parent::__construct();
$this->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->isauto = 0;
}
public function index(){
//$this->BIZ_train_model->delete_other();
}
//1903241050
public function check_autotickets(){
log_message('error','auto ticket');
date_default_timezone_set('Asia/Shanghai');
//判断账户余额如果小于1000自动退出。
$post_data = array("key"=>JUHE_TRAIN_API_KEY);
$back_data = GetPost_http("http://op.juhe.cn/trainTickets/balance.php",$post_data);
$price = json_decode($back_data)->result;
print_r('账户余额:'.$price);
if($price < 1000){
exit('账户余额不足');
}
//筛选出能自动出票的订单
$auto_pool = $this->BIZ_train_model->auto_check_ticket();
//创建一个不允许自动出票的国际火车票数组
$nation_train = array('K19', 'K23', 'Z8701', 'Z8702', 'Z97', 'Z98', 'Z99', 'Z100', 'K9795');
//创建黑名单
$black_list = $this->config->item('black_list');
$string = '';
foreach($auto_pool as $item){
$this->isauto = 1;
$bpe_sn = '';
$back_message = '';
$cold_sn = $item->COLD_SN;
$coli_id = $item->coli_id;
$back_data = 1;
$people_arr = $this->BIZ_train_model->biz_people($cold_sn);
$train_info = $this->BIZ_train_model->get_biz_foi($cold_sn);
if($item->COLD_SPFS > 1){
//寄送票
$back_data = 0;
$back_message .= '-邮寄不自动出票';
}
//乘客人数大于5人不出票
if(count($people_arr) > 5){
$back_data = 0;
$back_message .= '-乘客人数大于5不自动出票';
}
//护照号如果在黑名单的就不自动出票
foreach($people_arr as $people_info){
if(in_array($people_info->BPE_Passport,$black_list)){
$back_data = 0;
$back_message .= '-此用户为黑名单用户,不自动出票';
}
if(strlen($people_info->BPE_Passport) >= 18){
$back_data = 0;
$back_message .= '-护照位数大于18不自动出票';
}
$bpe_sn .= $people_info->BPE_SN.',';
}
$bpe_sn = substr($bpe_sn,0,strlen($bpe_sn)-1);
//单张票价不能大于1000人民币
if($train_info[0]->adultcost > 1000){
$back_data = 0;
$back_message .= '-单价大于1000不自动出票';
}
//如果为国际火车票就不出票
if(in_array($train_info[0]->FlightsNo, $nation_train)){
$back_data = 0;
$back_message .= '-国际火车票不自动出票';
}
//无座的订单不做出票
if($train_info[0]->Aircraft == 'WZ'){
$back_data = 0;
$back_message .= '-无座不自动出票';
}
//香港火车不自动出票
if($train_info[0]->DepartAirport == 'XJA'){
$back_data = 0;
$back_message .= '-香港火车不自动出票';
}
$DepartureDate = strtotime($train_info[0]->DepartureDate);
$time = time();
$depart_diff = ($DepartureDate - $time) / 86400;
if($train_info[0]->ArrivalAirport == 'XJA' && $train_info[0]->adultcost > 500 && $depart_diff > 5){
$back_data = 0;
$back_message .= '-内地香港火车金额大于500超过五天不自动出票';
}
//print_r($train_info);
//如果刚好是第三十天的订单
if(($item->COLI_State == '8' || $item->COLI_State == '63')){
$this->isauto = 3;
$time_obj = $this->BIZ_train_model->get_saletime($train_info['0']->DepartAirport_cn);
if(!empty($time_obj)){
$saletime = strtotime(date('Y-m-d').' '.$time_obj->TST_saletime);
//echo $saletime;
$sale_diff = (time() - $saletime) / 3600;
echo $cold_sn.'_'.date('Y-m-d').' '.$time_obj->TST_saletime.'/'.$saletime.'<br>';
if($sale_diff > 1){
$back_data = 0;
$back_message .= '-超过抢票时间';
}else if($sale_diff <0){
$back_data = 0;
$back_message .= '-未到抢票时间';
}
}
}
if($back_data == 0){
$string .= '<tr><td>汉特订单号:'.$coli_id.'('.$cold_sn.'/'.$this->isauto.')'.$back_message.'</td></tr>';
}else{
//单个订单提交
echo $cold_sn.'<br>';
//$this->booktickets($cold_sn,$bpe_sn,'','juhe');
//$string .= '<tr><td>汉特订单号:'.$coli_id.'('.$cold_sn.')可以自动出票</td></tr>';
}
}
print_r('<table border="1">'.$string.'</table>');
}
//创建一个方法用于接收所有的出票请求
public function booktickets($cold_sn=null,$bpe_sn=null,$selectseat=null,$type=null){
if(empty($cold_sn) && empty($bpe_sn)){
//接收子表订单号
$cold_sn = $this->input->get_post('order');
//接收客人表sn
$bpe_sn = $this->input->get_post("people");
//接收选座字符串
$selectseat = $this->input->get_post("selectseat");
//接收出票接口
$type = $this->input->get_post("type");
}
//测试数据
/*$cold_sn = '488121613';
$bpe_sn = '473183645,473183646,473183647';
$selectseat = '';
$type = 'juhe';*/
if(!is_numeric($cold_sn)){
$reback["mes"]="订单号是数字";
echo json_encode($reback);
return false;
}
if(empty($bpe_sn)){
$reback["mes"]="请选择乘客";
echo json_encode($reback);
return false;
}
$data['train'] = $this->BIZ_train_model->biz_order_detail($cold_sn);
$data['people_list']=$this->BIZ_train_model->in_bpesn_people_info($bpe_sn);
if($selectseat == ''){
$selectseat = '';
$train_select = $data['train']->FOI_SelectedSeat;
$obj = explode(',',$train_select);
foreach($obj as $value){
$selectseat .= $value;
}
}
if (empty($data['train'])) {
//显示错误,找不到车次
$reback["mes"]="找不到车次";
echo json_encode($reback);
return false;
}
if (empty($data['people_list'])) {
//显示错误,找不到用户信息
$reback["mes"]="找不到乘客信息";
echo json_encode($reback);
return false;
}
if (count($data['people_list']) > 5) {
//显示错误,用户超过五个
$reback["mes"]="乘客不能超过五个";
echo json_encode($reback);
return false;
}
switch ($type){
case 'juhe':
$this->juheModel($data,$selectseat,$cold_sn);
break;
case 'tuniu':
$this->tuniuModel($data,$selectseat,$cold_sn);
break;
case 'ctrip':
$this->ctripModel($data,$selectseat,$cold_sn);
break;
}
}
function juheModel($data=null,$selectseat=null,$cold_sn=null){
$zwcode = $this->db_train_zw[$data['train']->Aircraft]; //座位简码
$zwname = $this->train_zw[$this->db_train_zw[$data['train']->Aircraft]]; //座位名称
//进行提交字符串的拼接
$passengers = "";
foreach ($data['people_list'] as $key => $item) {
//乘客姓名
$passengersename = $item->BPE_FirstName.$item->BPE_MiddleName.$item->BPE_LastName;
//将特殊字符转换为正常字符以便于出票
$passengersename = chk_sp_name($passengersename);
//乘客类型
switch ($item->BPE_GuestType) {
case 1:
$piaotype = 1;
$piaotypename = "成人票";
break;
case 2:
$piaotype = 2;
$piaotypename = "儿童票";
break;
default://外国人应该就两种票吧
$piaotype = 1;
$piaotypename = "成人票";
break;
}
//证件类型
switch ($item->BPE_PassportType){
case 'Chinese ID':
$passporttypeseid = "1";
$passporttypeseidname = "二代身份证";
break;
case 'Travel Permit from Hong Kong / Macau':
$passporttypeseid = "C";
$passporttypeseidname = "港澳通行证";
break;
case 'Travel Permit from Taiwan':
$passporttypeseid = "G";
$passporttypeseidname = "台湾通行证";
break;
default :
$passporttypeseid = "B";
$passporttypeseidname = "护照";
break;
}
switch ($item->BPE_SEX){
case '100003':
$sex = 'F';
break;
case '100001':
$sex = 'M';
break;
}
$passportseno = str_replace(' ','',$item->BPE_Passport);
//添加一个判断护照号是否在黑名单
if(in_array($passportseno,$this->black_list)){
$reback["mes"] = "乘客为黑名单用户";
echo json_encode($reback);
return false;
}
if($passporttypeseid == 'G'){
$passengers .= ',{"passengerid":' . (++$key) . ',"passengersename":"' . $passengersename . '","piaotype":"' . $piaotype . '","piaotypename":"' . $piaotypename . '","passporttypeseid":"' . $passporttypeseid . '","passporttypeseidname":"' . $passporttypeseidname . '","passportseno":"' . $passportseno . '","price":"1","zwcode":"' . $zwcode . '","zwname":"' . $zwname . '","gatValidDateEnd":"'.$item->BPE_PassExpdate.'","gatBornDate":"'.$item->BPE_BirthDate.'","sexCode":"'.$sex.'"}';
}else{
$passengers .= ',{"passengerid":' . ( ++$key) . ',"passengersename":"' . $passengersename . '","piaotype":"' . $piaotype . '","piaotypename":"' . $piaotypename . '","passporttypeseid":"' . $passporttypeseid . '","passporttypeseidname":"' . $passporttypeseidname . '","passportseno":"' . $passportseno . '","price":"1","zwcode":"' . $zwcode . '","zwname":"' . $zwname . '"}';
}
}
$passengers .= "]";
$passengers = substr($passengers, 1);
$passengers = "[" . $passengers;
if(empty($selectseat)){
$post_data=array(
"key"=>JUHE_TRAIN_API_KEY,
"user_orderid"=>$cold_sn,//自定义订单号
"train_date"=>substr($data["train"]->DepartureDate, 0, 10),
"is_accept_standing"=>"no",
"from_station_name"=>$data["train"]->DepartAirport_cn,
"from_station_code"=>$data["train"]->DepartAirport,
"to_station_code"=>$data["train"]->ArrivalAirport,
"to_station_name"=>$data["train"]->ArrivalAirport_cn,
"passengers"=>$passengers,
"checi"=>$data["train"]->FlightsNo
);
}else{
$post_data=array(
"key"=>JUHE_TRAIN_API_KEY,
"user_orderid"=>$cold_sn,//自定义订单号
"train_date"=>substr($data["train"]->DepartureDate, 0, 10),
"is_accept_standing"=>"no",
"choose_seats"=>$selectseat,
"from_station_name"=>$data["train"]->DepartAirport_cn,
"from_station_code"=>$data["train"]->DepartAirport,
"to_station_code"=>$data["train"]->ArrivalAirport,
"to_station_name"=>$data["train"]->ArrivalAirport_cn,
"passengers"=>$passengers,
"checi"=>$data["train"]->FlightsNo
);
}
//发起请求
/*$add_data = new stdClass();
$back_json = GetPost_http('http://op.juhe.cn/trainTickets/submit',$post_data);
$back_data = json_decode($back_json);
if(!$back_data->error_code){
$add_data->ordernumber = $back_data->result->orderid;
$reback["status"] = 1;
$reback["order"] = $back_data->result->orderid;
$reback["mes"] = "订单提交成功,等待回调";
}else{
$add_data->ordernumber=null;
$reback["mes"] = $back_json;
$add_data->status = "e";
}*/
//本地订单入库
$add_data->cold_sn = $cold_sn;
$add_data->returncode = $back_data->error_code;
$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 = 'juhe';
$add_data->isauto = $this->isauto;
print_r($add_data);
/*$this->train_system_model->add_orders($add_data);
echo json_encode($reback);
return false;*/
}
public function test_add(){
$add_data->cold_sn = '123123';
$add_data->returncode = '123123';
$add_data->status = '2';
$add_data->errormsg = '预定中';
$add_data->checi = 'G89';
$add_data->fromstationame = '北京';
$add_data->fromstationcode = 'BJP';
$add_data->tostationame = '上海';
$add_data->tostationcode = 'SHH';
$add_data->startdate = '2019-02-09';
$add_data->startime = '14:00';
$add_data->endtime = '19:00';
$add_data->runtime = '300';
$add_data->channel = 'juhe';
$add_data->isauto = 3;
print_r($add_data);
$this->train_system_model->add_orders($add_data);
}
public function juhecallback(){
/*$data_post = $this->input->post();
if(empty($data_post)){
header("HTTP/1.1 404 Not Found");
exit('{"reason":"empty infos","status":"404"}');
}*/
//调试代码
$test_post = '{"data":"{\"from_station_name\":\"\u5e7f\u5dde\u5357\",\"from_station_code\":\"IZQ\",\"to_station_name\":\"\u9999\u6e2f\u897f\u4e5d\u9f99\",\"to_station_code\":\"XJA\",\"train_date\":\"2019-04-29\",\"orderid\":\"JH155651319519711\",\"user_orderid\":\"488132483\",\"orderamount\":\"374.00\",\"ordernumber\":\"E244376926\",\"checi\":\"G6537\",\"msg\":\"\u51fa\u7968\u6210\u529f\",\"status\":\"4\",\"passengers\":[{\"passengerid\":1,\"passengersename\":\"PRIETORAMOSJORGECLAUDIO\",\"piaotype\":\"1\",\"piaotypename\":\"\u6210\u4eba\u7968\",\"passporttypeseid\":\"B\",\"passporttypeseidname\":\"\u62a4\u7167\",\"passportseno\":\"AAC408307\",\"price\":\"187.0\",\"zwcode\":\"O\",\"zwname\":\"\u4e8c\u7b49\u5ea7\",\"ticket_no\":\"E244376926111013D\",\"cxin\":\"11\u8f66\u53a2,13D\u5ea7\",\"reason\":0},{\"passengerid\":2,\"passengersename\":\"SALAZARNATALIAGISELA\",\"piaotype\":\"1\",\"piaotypename\":\"\u6210\u4eba\u7968\",\"passporttypeseid\":\"B\",\"passporttypeseidname\":\"\u62a4\u7167\",\"passportseno\":\"AAC419811\",\"price\":\"187.0\",\"zwcode\":\"O\",\"zwname\":\"\u4e8c\u7b49\u5ea7\",\"ticket_no\":\"E244376926111013F\",\"cxin\":\"11\u8f66\u53a2,13F\u5ea7\",\"reason\":0}],\"refund_money\":null,\"sign\":\"831c146e2ce223a5437ed78db0ec8c25\"}"}';
$data_post["data"] = json_decode($test_post)->data;
log_message('error','聚合回调:'.json_encode($data_post));
$data = json_decode($data_post["data"]);
$update_data = new StdClass();
$update_data->OrderStatus = $data->status;
$update_data->ordernumber = $data->orderid;
$update_data->OrderTotleFee = $data->orderamount;
$update_data->seatsinfo = '';
$update_data->TicketCheck = '';
$update_data->bookcallback = '';
$update_data->confirmcallback = '';
$update_data->returncallback = '';
$update_data->ElectronicOrderNumber = $data->ordernumber;
$update_data->reschedulecallback = '';
$update_data->ErrorMsg = $data->msg;
//如果返回2则发送出票请求
if($data->status == "1"){
$update_data->bookcallback = $data_post["data"];
}elseif($data->status == "2"){
$coach = array();
$seats = array();
$string = '';
$passagers = $data->passengers;
foreach($passagers as $item){
foreach(explode(',',$item->cxin) as $item_seat){
if(strpos($item_seat,'车厢')){
$item_seat = str_replace('车厢','',$item_seat);
array_push($coach,$item_seat);
}else{
$find = array('座上铺','座中铺','座下铺','座');
$replace = array(' upper',' middle',' lower','');
$item_seat = str_replace($find,$replace,$item_seat);
array_push($seats,$item_seat);
}
}
//对订票乘客进行存储
$data_passager->ordernumber = $data->orderid;
$data_passager->realname = $item->passengersename;
$data_passager->identitytype = $item->passporttypeseidname;
$data_passager->numberid = $item->passportseno;
$data_passager->ticketype = $item->piaotypename;
$data_passager->ticketprice = $item->price;
$data_passager->seatype = $item->zwname;
$data_passager->seatdetail = $item->cxin;
$data_passager->status = '4';
$this->train_system_model->add_passagers($data_passager);
}
//判断车厢是否唯一,如果不唯一的话,分成两个车厢
if(count(array_unique($coach)) == 1){
$onlycoach = array_unique($coach);
$string .= 'Coach '.$onlycoach[0].',';
}else{
foreach (array_unique($coach) as $item_coach){
$string .= 'Coach '.$item_coach.',';
}
}
$string .= 'Seat ';
foreach($seats as $item_seat){
$string .= $item_seat.',';
}
$seatinfo = substr($string,0,strlen($string)-1);
$update_data->seatsinfo = $seatinfo;
$post_data = array(
"key"=>JUHE_TRAIN_API_KEY,
"orderid"=>$data->orderid
);
$back_json = GetPost_http(JUHE_TRAIN_PAY_API,$post_data);
$update_data->bookcallback = $data_post["data"];
}elseif($data->status == "4"){
$add_train_order_data->TOC_Memo = $data->orderid." 聚合出票";
$add_train_order_data->TOC_COLD_SN = $data->user_orderid;
$add_train_order_data->TOC_TrainNumber = $data->checi;
$add_train_order_data->TOC_DepartureDate = $data->train_date;
$add_train_order_data->TOC_TicketCost = $data->orderamount;
$add_train_order_data->poundage = (count($data->passengers)*2)."";//手续费,每人两块,转换成字符串
$add_train_order_data->FOI_TrainNetOrderNo = $data->ordernumber;
$this->BIZ_train_model->add_train_payment($add_train_order_data);
$update_data->confirmcallback = $data_post["data"];
$this->BIZ_train_model->update_cold_planvei_sn($data->user_orderid);
}elseif($data->status=="7"){
//退票成功 写入TOC表
$newtime = "";//记录最新操作时间
$refund_passportseno = "";//退票人护照号
$refund_money = "";//退票金额
foreach ($data->passengers as $p) {
if(isset($p->returntickets)){
$refund_passportseno = $p->refundTimeline[count($p->refundTimeline)-1]->detail->passportseno;
$refund_money = $p->refundTimeline[count($p->refundTimeline)-1]->detail->returnmoney;
//退票时还需要单独对对每个乘客存储回调信息
$passpager_info = new stdClass();
$passpager_info->returncallback = $data_post["data"];
$passpager_info->status = '7';
$passpager_info->ordernumber = $data->orderid;
$passpager_info->realname = $p->refundTimeline[count($p->refundTimeline)-1]->detail->passengername;
$passpager_info->numberid = $refund_passportseno;
print_r($passpager_info);
$this->train_system_model->update_passpager_info($passpager_info);
//添加退款记录
$add_train_order_data->TOC_COLD_SN = $data->user_orderid;
$add_train_order_data->TOC_Memo = $data->orderid." ".$refund_passportseno;
$add_train_order_data->ordernumber = $data->user_orderid;
$add_train_order_data->TOC_TrainNumber = $data->checi;
$add_train_order_data->TOC_DepartureDate = $data->train_date;
$add_train_order_data->TOC_TicketCost = -$refund_money;
$add_train_order_data->FOI_TrainNetOrderNo = null;//退票不用更新取票号,以此在模型里面判断是否为退票消息
$this->BIZ_train_model->add_train_payment($add_train_order_data);
}else{
//有可能提交了退票或者还没有退票
}
}
$update_data->returncallback = $data_post["data"];
}
//print_r($update_data);die();
//更新订单信息(出票系统)
$this->train_system_model->update_orders($update_data);
}
}

@ -0,0 +1,18 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class orders extends CI_Controller{
public function __construct(){
parent::__construct();
}
public function index(){
echo 'orders manager';
}
}

@ -0,0 +1,208 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class pages extends CI_Controller{
public function __construct(){
parent::__construct();
$this->load->model("train_system_model");
$this->load->model("BIZ_train_model");
$this->load->helper('train');
$this->order_status_msg = $this->config->item('train_order_status_msg');
}
public function index($coli_id = null){
if($this->session->userdata('dingname') == '' && $this->session->userdata('dingunionid') == ''){
dingLogin();
}
if($coli_id == null){
$cols_id = $this->input->post("ht_order");
}else{
$cols_id = $coli_id;
}
$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;
}
//查询聚合余额
$back_data = GetPost_http("http://op.juhe.cn/trainTickets/balance.php?key=79f03107b921ef31310bd40a1415c1cb");
$back_data = json_decode($back_data);
if(!empty($back_data->result)){
$list->balance = $back_data->result;
}else{
$list->balance = "NULL";
}
//print_r($list);
$this->load->view('common/header');
$this->load->view('homepage',$list);
$this->load->view('common/footer');
}
//系统列表页面
public function order_list(){
if($this->session->userdata('dingname') == '' && $this->session->userdata('dingunionid') == ''){
dingLogin();
}
$page_size = 10;
$page = $this->input->get("page");
$order = $this->input->get("order");
$web_code = $this->input->get("web_code");
$where = "1=1";//搜索条件
$page_parameter = "";//返回的分页条件参数
if(empty($page) or !is_numeric($page)){
$page=0;
}
if(!empty($order)){
$where = "BIZ_ConfirmLineInfo.COLI_ID='{$order}' OR InfoManager.dbo.trainsystem.ts_ordernumber='{$order}'";
//$where2 = "where BIZ_ConfirmLineInfo.COLI_ID='{$order}' OR JOL_JuheOrder='{$order}'";
$list["order"] = $order;
$page_parameter = "order=".$order;
}
if(!empty($web_code)){
$where = "BIZ_ConfirmLineInfo.COLI_WebCode='{$web_code}'";
$page_parameter = "web_code=".$web_code;
}
//获取订单数据
$data = $this->train_system_model->get_order($page_size,$page,$where);
//print_r($data);die();
$list["data"]=$data->list;
$this->load->library('pagination');
$config['base_url'] = site_url("/apps/trainsystem/pages/order_list?{$page_parameter}");
$config['total_rows'] = $data->count;
$config['per_page'] = $page_size;
$config['page_query_string']=TRUE;
$config['query_string_segment']="page";
$config['cur_tag_open'] = '<li class="active"><a href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['first_tag_open']=$config['last_tag_open']=$config['next_tag_open']=$config['prev_tag_open']=$config['num_tag_open']="<li>";
$config['first_tag_close']=$config['last_tag_close']=$config['next_tag_close']=$config['prev_tag_close']=$config['num_tag_close']="</li>";
$this->pagination->initialize($config);
$list["page_link"]=$this->pagination->create_links();
foreach ($list["data"] as $key => $value) {
$value->info = $this->order_status_msg[$value->ts_status];//自定义说明信息;
}
$this->load->view('header');
$this->load->view('order_list',$list);
$this->load->view('footer');
}
//订单详情页面
public function order(){
if($this->session->userdata('dingname') == '' && $this->session->userdata('dingunionid') == ''){
dingLogin();
}
$ordernumber = $order=$this->input->get("order");
if(empty($ordernumber)){
exit('参数错误');
}
//根据订单号查询订单信息
$data = array();
$train_infos = $this->train_system_model->get_train_infos($ordernumber);
$passpager_detail = $this->train_system_model->get_passager_details($ordernumber);
//构造详情数组
$data['status'] = $train_infos->ts_status;
$data['ordernumber'] = $train_infos->ts_ordernumber;
$data['train_date'] = $train_infos->ts_startdate;
$data['checi'] = $train_infos->ts_checi;
$data['elecnumber'] = $train_infos->ts_elecnumber;
$data['from_station_name'] = $train_infos->ts_fromstationame;
$data['from_station_code'] = $train_infos->ts_fromstationcode;
$data['to_station_name'] = $train_infos->ts_tostationame;
$data['to_station_code'] = $train_infos->ts_tostationcode;
$data['start_time'] = $train_infos->ts_startime;
$data['arrive_time'] = $train_infos->ts_endtime;
$data['channel'] = $train_infos->ts_channel;
$data['msg'] = $train_infos->ts_errormsg;
$data['passengers'] = $passpager_detail;
//聚合订单可以查询实时数据
if($train_infos->ts_channel == 'juhe'){
$post_data=array(
"key"=>"79f03107b921ef31310bd40a1415c1cb",
"orderid"=>$train_infos->ts_ordernumber
);
$back_data = GetPost_http("http://op.juhe.cn/trainTickets/orderStatus",$post_data);
$data['train_date'] = '';
$data['start_time'] = json_decode($back_data)->result->start_time;
$data['arrive_time'] = json_decode($back_data)->result->arrive_time;
}
$this->load->view('bootstrap3/header');
$this->load->view('order',$data);
$this->load->view('bootstrap3/footer');
}
//退票页面
public function refund(){
if($this->session->userdata('dingname') == '' && $this->session->userdata('dingunionid') == ''){
dingLogin();
}
$ordernumber = $order=$this->input->get("order");
if(empty($ordernumber)){
exit('参数错误');
}
//根据订单号查询订单信息
$data = array();
$train_infos = $this->train_system_model->get_train_infos($ordernumber);
$passpager_detail = $this->train_system_model->get_passager_details($ordernumber);
//构造详情数组
$data['ordernumber'] = $train_infos->ts_ordernumber;
$data['cold_sn'] = $train_infos->ts_cold_sn;
$data['train_date'] = $train_infos->ts_startdate;
$data['checi'] = $train_infos->ts_checi;
$data['elecnumber'] = $train_infos->ts_elecnumber;
$data['from_station_name'] = $train_infos->ts_fromstationame;
$data['from_station_code'] = $train_infos->ts_fromstationcode;
$data['to_station_name'] = $train_infos->ts_tostationame;
$data['to_station_code'] = $train_infos->ts_tostationcode;
$data['start_time'] = $train_infos->ts_startime;
$data['arrive_time'] = $train_infos->ts_endtime;
$data['channel'] = $train_infos->ts_channel;
$data['msg'] = $train_infos->ts_errormsg;
$data['return_json'] = $train_infos->ts_returncallback;
$data['passengers'] = $passpager_detail;
//print_r($data);
$this->load->view('header');
$this->load->view('refund',$data);
$this->load->view('footer');
}
public function export(){
if($this->session->userdata('dingname') == '' && $this->session->userdata('dingunionid') == ''){
dingLogin();
}
$this->load->view('header');
$this->load->view('export');
$this->load->view('footer');
}
}

@ -0,0 +1,186 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class returnorders extends CI_Controller{
public function __construct(){
parent::__construct();
$this->load->helper('train');
$this->load->model("train_system_model");
$this->load->model("Sendmail_model");
$this->load->model('BIZ_train_model');
$this->usercenter = 'yes';
}
public function index(){
echo 'return tickets';
}
public function returntickets(){
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:POST, GET');
header('Access-Control-Max-Age:0');
header('Access-Control-Allow-Headers:x-requested-with, Content-Type');
header('Access-Control-Allow-Credentials:true');
//第三方订单号(为了避免一个子订单乘客分开出票而产生错误)
$ordernumber = $this->input->get_post('ordernumber');
//护照姓名
$passportname = $this->input->get_post('passportname');
//护照号
$passportno = $this->input->get_post('passportno');
//判断是否为用户中心操作
$this->usercenter = $this->input->get_post('usercenter');
if(!$ordernumber || !$passportname || !$passportno){
header("HTTP/1.1 404 Not Found");
exit('{"reason":"传参错误","status":"404"}');
}
//网前提交的姓名没有做处理
$passportname = chk_sp_name($passportname);
$ticket_data = $this->train_system_model->ticketfrom($ordernumber);
$passenger_data = $this->train_system_model->get_passenger_info($ordernumber,$passportname,$passportno);
if(empty($passenger_data)){
header("HTTP/1.1 404 Not Found");
exit('{"reason":"乘客信息为空无法退票","status":"404"}');
exit('');
}
$channel = $ticket_data->ts_channel;
switch ($channel){
case 'juhe':
$this->juheModel($ticket_data,$passenger_data);
break;
case 'ctrip':
$this->ctripModel($ticket_data,$passenger_data);
break;
}
}
function juheModel($ticket_data,$data){
$post_data = array(
"key"=>JUHE_TRAIN_API_KEY,
"orderid"=>$ticket_data->ts_ordernumber
);
$back_json = GetPost_http(JUHE_TRAIN_STATUS_API,$post_data);
$back_detail_data = json_decode($back_json);
//print_r($back_data);die();
foreach($back_detail_data->result->passengers as $items){
if($items->passengersename == $data->tst_realname && $items->passportseno == $data->tst_numberid){
$ticket_no = $items->ticket_no;
}
}
//发起退票
$post_data1 = array(
"key"=>JUHE_TRAIN_API_KEY,
"orderid"=>$ticket_data->ts_ordernumber,
"tickets"=>'[{"ticket_no":"'.$ticket_no.'","passengername":"'.$data->tst_realname.'","passporttypeseid":"'.strexchangeid($data->tst_ticketype).'","passportseno":"'.$data->tst_numberid.'"}]',
);
//print_r($post_data1);die();
$back_json = GetPost_http(JUHE_TRAIN_REFUND_API,$post_data1);
//print_r($post_data1);
log_message('error','聚合退票:'.$ticket_data->ts_ordernumber.'|'.$back_json);
$back_data = json_decode($back_json);
$fromName = 'trainsystem';
$fromEmail = 'cyc@hainatravel.com';
$coli_id = $this->BIZ_train_model->cold_sn_get_coli_id($ticket_data->ts_cold_sn);
$coli_id = $coli_id['0']->COLI_ID;
$info = $this->BIZ_train_model->get_operatorInfo($coli_id);
$toName = $info[0]->Name;
$toEmail = $info[0]->OPI_Email;
$Mobile = $info[0]->Mobile;
$subject = '退票请求';
if($back_data->error_code == '0'){
//退票成功后发送邮件
$body = $back_detail_data->result->ordernumber.' 提出退票,乘客:'.$data->tst_realname.', '.$back_detail_data->result->start_time.' '.$back_detail_data->result->checi;
//发送邮件给外联
$this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
if($this->usercenter == 'yes'){
//发送邮件给客人
$customer_subject = 'China Train Ticket(s) Cancelation';
$customer_body = '<p>Dear '.$data->tst_realname.',</p><p>Your tickets (ticket number '.$back_detail_data->result->ordernumber.', for name '.$data->tst_realname.', train No. '.$back_detail_data->result->checi.') have been cancelled online successfully. Your travel advisor ('.$toName.', email address: '.$toEmail.', phone number '.$Mobile.') will contact you with the refund details via email within 24 hours.';
$customer_email = $this->BIZ_train_model->get_guest_info($coli_id);
$customer_email = $customer_email[0]->GUT_Email;
$this->Sendmail_model->SendMailToTable($toName,$toEmail,$data->tst_realname,$customer_email,$customer_subject,$customer_body);
}
echo '{"reason":"退票成功","status":"200"}';
}else{
//退票失败后发送邮件
$body = $ticket_data->ts_ordernumber.'退票失败';
//发送邮件给外联
$this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
if($this->usercenter == 'yes'){
//发送邮件给客人
$customer_subject = 'China Train Ticket(s) Cancelation';
$customer_body = '<p>Dear '.$data->tst_realname.',</p><p>Your application for online ticket cancellation (ticket number '.$back_detail_data->result->ordernumber.', for name '.$data->tst_realname.', train No.'.$back_detail_data->result->checi.') has failed.Your travel advisor('.$toName.', email address: '.$toEmail.', phone number '.$Mobile.') will contact you via email within 24 hours. Please call us if you need to contact us urgently.</p>';
$customer_email = $this->BIZ_train_model->get_guest_info($coli_id);
$customer_email = $customer_email[0]->GUT_Email;
$this->Sendmail_model->SendMailToTable($toName,$toEmail,$data->tst_realname,$customer_email,$customer_subject,$customer_body);
}
header("HTTP/1.1 404 Not Found");
echo '{"reason":"退票失败","status":"404"}';
}
}
function ctripModel($ticket_data,$passenger_data){
$PostData = array();
$TimeStamp = time();
$time = date('Y-m-d H:i:s',$TimeStamp);
$PostData['Authentication']->TimeStamp = $time;
$PostData['Authentication']->ServiceName = 'order.ticketReturn';
$PostData['Authentication']->PartnerName = ORDERUSER;
$MessageIdentity = md5($time.'order.ticketReturn'.ORDERKEY);
$PostData['Authentication']->MessageIdentity = $MessageIdentity;
$PostData['TrainOrderService']->contactName = '陈宇超';
$PostData['TrainOrderService']->contactMobile = '18877381547';
$PostData['TrainOrderService']->OrderNumber = $ticket_data->ts_ordernumber;
$PostData['TrainOrderService']->OperatorType = '0';
$PostData['TrainOrderService']->TicketInfo = '';
$PostData['TrainOrderService']->TicketInfo = array();
$i = 0;
$PostData['TrainOrderService']->TicketInfo[$i]['eOrderNumber'] = $passenger_data->ts_elecnumber;
if($passenger_data->tst_ticketype == '儿童票'){
$PostData['TrainOrderService']->TicketInfo[$i]['eOrderType'] = '2';
}else{
$PostData['TrainOrderService']->TicketInfo[$i]['eOrderType'] = '1';
}
$PostData['TrainOrderService']->TicketInfo[$i]['seatNumber'] = $passenger_data->tst_seatdetail;
$PostData['TrainOrderService']->TicketInfo[$i]['passportName'] = $passenger_data->tst_realname;
$PostData['TrainOrderService']->TicketInfo[$i]['passport'] = $passenger_data->tst_numberid;
$PostData['TrainOrderService']->TicketInfo[$i]['realName'] = $passenger_data->tst_realname;
//发起退票请求
$Url = 'http://m.ctrip.com/restapi/soa2/11009/json/PartnerReturnTicket';
$ResponseJson = GetPost_http($Url,json_encode($PostData),'POST');
$ResponseData = json_decode($ResponseJson);
if($ResponseData->Status == 'SUCCESS'){
$fromName = 'trainsystem';
$fromEmail = 'cyc@hainatravel.com';
$coli_id = $this->BIZ_train_model->cold_sn_get_coli_id($ticket_data->ts_cold_sn);
$coli_id = $coli_id['0']->COLI_ID;
$info = $this->BIZ_train_model->get_operatorInfo($coli_id);
$toName = $info[0]->OPI_Name;
$toEmail = $info[0]->OPI_Email;
$Mobile = $info[0]->Mobile;
$subject = '退票请求';
$body = '乘客:'.$data->tst_realname.' 对订单:'.$data->ts_ordernumber.'发起退票请求!!!';
//发送邮件给外联
$this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
echo '{"reason":"退票成功","status":"200"}';
}else{
header("HTTP/1.1 404 Not Found");
echo '{"reason":"退票失败","status":"404"}';
}
}
}

@ -0,0 +1,89 @@
<?php
//途牛接口创建请求签名
function create_sign(){
$time = date('Y-m-d H:i:s',time());
$secretKey = 'qvHMJVywEQqsd4EneHQl';
$id = 'retailId25';
$timeStamp = 'timestamp'.$time;
$sign = $secretKey.$id.'apiKey'.TUNIU_KEY.$timeStamp.$secretKey;
return strtoupper(md5($sign));
}
//证件名称转id
function strexchangeid($name){
if($name != ''){
switch ($name){
case '二代身份证':
return '1';
break;
case '护照':
return 'B';
break;
case '台湾通行证':
return 'G';
break;
case '港澳通行证':
return 'C';
break;
default :
return 'B';
break;
}
}
}
//特殊字符转换
function chk_sp_name($name){
$name = str_replace(
array('á', 'é', 'è', 'í', 'ó', 'ú', '?', 'á', 'é', 'í', 'ó', 'ú', '?',' ','/',' ',','),
array('a', 'e', 'e', 'i', 'o', 'u', 'n', 'A', 'E', 'I', 'O', 'U', 'N','','','',''),
$name
);
return substr(strtoupper($name),0,30);
}
//发送请求函数
function GetPost_http($url, $data = '',$format='') {
if(!isset($_SERVER['HTTP_USER_AGENT'])){
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.104 Safari/537.36 Core/1.53.2372.400 QQBrowser/9.5.10548.400';
}
$curl = curl_init(); // 启动一个CURL会话
curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转
curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer
if (!empty($data)) {
curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
if($format == 'json'){
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
}
}
curl_setopt($curl, CURLOPT_TIMEOUT, 40); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_TIMEOUT_MS, 40000); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
$tmpInfo = curl_exec($curl); // 执行操作
$errno = curl_errno($curl);
if ($errno !== 0) {
log_message('error', 'ctripost'.$errno.curl_error($curl));
}
curl_close($curl); //关闭CURL会话
return $tmpInfo; //返回数据
}
function getDingSignature(){
$timestamp = time();
$signature = hash_hmac('sha256',$timestamp,'emCK5vYFJc-HtMNNgbyGpmbYaNyPkNXn_ayoFd6q2m6rpljhxBn2JQEx9gy8H6DQ',true);
$signature = base64_encode($signature);
return $signature;
}
function dingLogin(){
redirect('https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoaystremzlahfew1tb&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=http://www.mycht.cn/info.php/apps/trainsystem/api/check_login');
}
?>

@ -0,0 +1,59 @@
<?php
class Des
{
function encrypt($string,$key)
{
$size = mcrypt_get_block_size('des','ecb');
//$string = mb_convert_encoding($string, 'GBK', 'UTF-8');
$string = $this->pkcs5_pad($string, $size);
$td = mcrypt_module_open('des', '', 'ecb', '');
$iv = @mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
@mcrypt_generic_init($td, $key, $iv);
$data = mcrypt_generic($td, $string);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
$data = base64_encode($data);
return $data;
}
function decrypt($string,$key)
{
$string = base64_decode($string);
$td = mcrypt_module_open('des', '', 'ecb', '');
//使用MCRYPT_DES算法,cbc模式
$iv = @mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
$ks = mcrypt_enc_get_key_size($td);
@mcrypt_generic_init($td, $key, $iv);
//初始处理
$decrypted = mdecrypt_generic($td, $string);
//解密
mcrypt_generic_deinit($td);
//结束
mcrypt_module_close($td);
$result = $this->pkcs5_unpad($decrypted);
//$result = mb_convert_encoding($result, 'UTF-8', 'GBK');
return $result;
}
function pkcs5_pad($text, $blocksize)
{
$pad = $blocksize - (strlen($text) % $blocksize);
return $text . str_repeat(chr($pad), $pad);
}
function pkcs5_unpad($text)
{
$pad = ord($text{strlen($text) - 1});
if ($pad > strlen($text)) {
return false;
}
if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) {
return false;
}
return substr($text, 0, -1 * $pad);
}
}
?>

@ -0,0 +1,492 @@
<?php
class BIZ_train_model extends CI_Model {
function __construct() {
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
$this->INFO = $this->load->database('INFO', TRUE);
}
//获取订单信息
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
,bfoi.FOI_SelectedSeat
,(
SELECT TOP 1 TRS_StationCN
FROM TrainStation
WHERE TRS_Code = DepartAirport
and ISNULL(TRS_StationCN,'')<>''
) AS DepartAirport_cn
,(
SELECT TOP 1 TRS_StationCN
FROM TrainStation
WHERE TRS_Code = ArrivalAirport
and ISNULL(TRS_StationCN,'')<>''
) AS ArrivalAirport_cn,
FOI_TrainNetOrderNo,
bfoi.adultcost,
bfoi.childcost,
ArrivalTime,
DepartureTime
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
,bbp.BPE_PassportType
,bbp.BPE_SEX
,bbp.BPE_BirthDate
,bbp.BPE_PassExpdate
FROM BIZ_BookPeople bbp
WHERE BPE_SN in(".$bpe_sn.")
";
$query = $this->HT->query($sql);
return $query->result();
}
//传入主订单翰特订单号COLI_ID161014006M获取子订单中火车订单的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 biz_people($cold_sn) {
$sql = "
SELECT bbp.BPE_SN
,bbp.BPE_FirstName
,bbp.BPE_MiddleName
,bbp.BPE_LastName
,bbp.BPE_GuestType
,bbp.BPE_Passport
,bbp.BPE_PassportType
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();
}
//传入COLD_SN获取火车车次等信息
function get_biz_foi($cold_sn) {
$sql = "
SELECT FOI_COLD_SN,
FlightsNo,
Cabin,
Aircraft,
DepartureCity,
DepartAirport,
ArrivalAirport,
ArrivalCity,
DepartureDate,
DepartureTime,
ArrivalTime,
adultcost,
FOI_SelectedSeat,
FOI_TrainNetOrderNo,
FOI_SaleDate,
(
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
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);
if($query->num_rows() == 0){
return true;
}else{
return false;
}
}
//传入COLI_ID获取外联名
function get_operatorInfo($cols_id) {
$sql = "
SELECT
Name,
OPI_Name,
case when OPI_SN=375 then OPI_EmailBak else OPI_Email end as OPI_Email,
tel,
Mobile,
Email
FROM OperatorInfo
left join agenter_user
on AU_OPI_SN = OPI_SN
WHERE OPI_SN = (
SELECT COLI_OPI_ID
FROM BIZ_ConfirmLineInfo bcli
WHERE bcli.COLI_ID = ?
)
and agenter in ('cht', 'train_vac', 'jp', 'train_it', 'vc', 'ru')
";
$query = $this->HT->query($sql, $cols_id);
return $query->result();
}
//新增支付记录
public function add_train_payment($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;
//删除多余支付记录
$sql = "delete from BIZ_TrainOrderCost where TOC_COLI_SN = '{$CCSN}' and TOC_TicketCost is null";
$query=$this->HT->query($sql);
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,更新取票号
/*
UPDATE BIZ_FlightsOrderInfo
SET
FOI_TrainNetOrderNo=?
WHERE
FOI_COLD_SN=?
*/
$sql="IF EXISTS(
select * from BIZ_FlightsOrderInfo where FOI_COLD_SN = '$data->TOC_COLD_SN' and (FOI_TrainNetOrderNo is null or FOI_TrainNetOrderNo = '' or FOI_TrainNetOrderNo = '$data->FOI_TrainNetOrderNo'))
UPDATE BIZ_FlightsOrderInfo
SET
FOI_TrainNetOrderNo='$data->FOI_TrainNetOrderNo'
WHERE
FOI_COLD_SN='$data->TOC_COLD_SN'
ELSE
IF NOT EXISTS(select * from BIZ_FlightsOrderInfo where FOI_COLD_SN = '$data->TOC_COLD_SN' and FOI_TrainNetOrderNo LIKE '%$data->FOI_TrainNetOrderNo%')
UPDATE BIZ_FlightsOrderInfo
SET
FOI_TrainNetOrderNo=(select FOI_TrainNetOrderNo from BIZ_FlightsOrderInfo where FOI_COLD_SN = '$data->TOC_COLD_SN') + '&' + '$data->FOI_TrainNetOrderNo'
WHERE
FOI_COLD_SN='$data->TOC_COLD_SN'";
$this->HT->query($sql);
$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 isnull(COLI_OPI_ID,29) FROM BIZ_ConfirmLineInfo WHERE COLI_SN={$CCSN}),null),(?,getdate(),{$CCSN},?,?,?,?,(SELECT isnull(COLI_OPI_ID,29) 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 update_cold_planvei_sn($cold_sn){
$sql = "update BIZ_ConfirmLineDetail set COLD_PlanVEI_SN=30427 where COLD_SN = ?";
$query = $this->HT->query($sql,$cold_sn);
}
//自动获取符合自动出票要求的订单的coli_sn
function auto_check_ticket(){
$sql = "SELECT distinct top 50 COLD_SN ,coli_id,COLD_SPFS,COLI_State
FROM BIZ_ConfirmLineInfo bcli
inner join BIZ_ConfirmLineDetail bcld on COLD_COLI_SN=COLI_SN
LEFT JOIN BIZ_GroupAccountInfo bgai
ON bcli.COLI_SN = bgai.GAI_COLI_SN
WHERE bcli.COLI_ServiceType = '2'
AND bcli.COLI_State in ('11','13','8','63')
AND bcli.COLI_WebCode in ('cht', 'JP', 'train_it', 'VC', 'train_ru','GM-Train','SHT','CT','WebMob-biz','WeChat-biz')
AND (bcli.COLI_Price - bgai.GAI_SQJE) <= 20
AND (bcli.COLI_Price - bgai.GAI_SQJE) >= 0
AND bcli.DeleteFlag = 0
AND bgai.DeleteFlag = 0
AND bcld.DeleteFlag = 0
--AND COLD_SPFS<=2
AND NOT EXISTS (
SELECT TOP 1 1
FROM InfoManager.dbo.trainsystem
WHERE ts_cold_sn = COLD_SN
)
and (((COLI_State<>8 and COLI_State<>63) and COLD_StartDate < CONVERT(varchar(100),GETDATE()+29,23)) or ((COLI_State=8 or COLI_State=63) and COLD_StartDate between CONVERT(varchar(100),GETDATE()+29,23) and CONVERT(varchar(100),GETDATE()+29,23)+' 23:59'))
";
$query = $this->HT->query($sql);
return $query->result();
}
public function get_saletime($station){
$sql = 'select TST_saletime from TrainSaleTime where TST_station_cn = ?';
$query = $this->HT->query($sql,$station);
return $query->row();
}
//筛选符合发送邮件的订单
public function auto_sendmail(){
$sql = "SELECT
ts_cold_sn,
ts_ordernumber,
ts_status,
ts_isauto
FROM
trainsystem
left join
Tourmanager.dbo.BIZ_ConfirmLineDetail bcld
on
bcld.COLD_SN = ts_cold_sn
left join
Tourmanager.dbo.BIZ_ConfirmLineInfo bcli
on
bcld.COLD_COLI_SN = bcli.COLI_SN
WHERE
ts_sendmail is null
AND
ts_isauto = 1
AND
ts_status != '0'
AND
ts_status != 'e'
AND
ts_status != '2'
AND
bcli.COLI_WebCode in ('cht','WebMob-biz','WeChat-biz')
";
$query = $this->INFO->query($sql);
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();
}
//邮件使用
function get_user_info($jh_order){
$sql = "select
*
from
Tourmanager.dbo.BIZ_ConfirmLineDetail
where
COLD_SN = (
select
top 1 ts_cold_sn
from
trainsystem
where
ts_ordernumber = ?
)";
$query = $query = $this->INFO->query($sql, $jh_order);
if ($query->num_rows() > 0) {
return $query->row();
} else {
return false;
}
}
//用于自动出票,传入主订单翰特订单号 COLI_ID ,获取客人的姓名和邮箱
public function get_guest_info($COLI_ID){
$sql = "SELECT GUT_FirstName,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();
}
//获取paypal付款记录
function get_paypal($coli_id){
$sql = "select top 1 GAI_SQJE from BIZ_GroupAccountInfo where GAI_COLI_ID = ?";
$query = $query = $this->HT->query($sql, $coli_id);
if ($query->num_rows() > 0) {
return $query->row();
} else {
return false;
}
}
//通过 JOL_JuheOrder 获取 BIZ_JuheOrderList 获取聚合订单详情
public function get_biz_jol_info($cold_sn,$jol_jo){
$sql = "SELECT top 1
*
FROM trainsystem
WHERE ts_cold_sn = ? AND ts_ordernumber = ?
";
$query = $this->INFO->query($sql,array($cold_sn,$jol_jo));
return $query->row();
}
//获取跟踪号
public function getTrackingCode(){
include('c:/database_conn.php');
$connection = array(
'UID' => $db['HT']['username'],
'PWD' => $db['HT']['password'],
'Database' => 'tourmanager',
'ConnectionPooling' => 1,
'CharacterSet' => 'utf-8',
'ReturnDatesAsStrings' => 1
);
$conn = sqlsrv_connect($db['HT']['hostname'], $connection);
$stmt = sqlsrv_query($conn, "exec dbo.SP_getTrackingCode;");
if ($stmt === false) {
echo "Error in executing statement 3.\n";
die(print_r(sqlsrv_errors(), true));
}else{
//存储过程中每一个select都会产生一个结果集取某个结果集就需要从第一个移动到需要的那个结果集
//如果结果集为空就移到下一个
while (sqlsrv_has_rows($stmt) !== TRUE) {
sqlsrv_next_result($stmt);
}
$result_object = array();
while ($row = sqlsrv_fetch_object($stmt)) {
$result_object[] = $row;
}
sqlsrv_free_stmt($stmt);
sqlsrv_close($conn);
return($result_object[0]->TrackingCode);
}
}
//接收聚合订单号获取翰特订单号即BIZ_ConfirmLineInfo的COLI_ID
function jh_order_get_coli_id($ordernumber){
$sql="SELECT
COLI_ID,COLI_SN,COLI_OPI_ID
FROM
BIZ_ConfirmLineInfo bcli
WHERE
bcli.COLI_SN=
(SELECT COLD_COLI_SN FROM BIZ_ConfirmLineDetail bcld WHERE bcld.COLD_SN=
(SELECT ts_cold_sn FROM InfoManager.dbo.trainsystem WHERE ts_ordernumber = ? and ts_channel = 'juhe'))
";
$query = $this->HT->query($sql, $ordernumber);
return $query->result();
}
//跟踪号与订单关联
public function linkTrackingCode($coli_sn,$TrackCode){
include('c:/database_conn.php');
$connection = array(
'UID' => $db['HT']['username'],
'PWD' => $db['HT']['password'],
'Database' => 'tourmanager',
'ConnectionPooling' => 1,
'CharacterSet' => 'utf-8',
'ReturnDatesAsStrings' => 1
);
$conn = sqlsrv_connect($db['HT']['hostname'], $connection);
$stmt = sqlsrv_query($conn, "exec dbo.SP_recordTrackingCode '$coli_sn', '$TrackCode'");
if ($stmt === false) {
echo "Error in executing statement 3.\n";
die(print_r(sqlsrv_errors(), true));
}else{
//存储过程中每一个select都会产生一个结果集取某个结果集就需要从第一个移动到需要的那个结果集
//如果结果集为空就移到下一个
/*
while (sqlsrv_has_rows($stmt) !== TRUE) {
sqlsrv_next_result($stmt);
}
$result_object = array();
while ($row = sqlsrv_fetch_object($stmt)) {
$result_object[] = $row;
}
*/
sqlsrv_free_stmt($stmt);
sqlsrv_close($conn);
}
}
//通过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();
}
//修改
function update_biz_jol($where,$data){
return $this->INFO->where($where)->update("trainsystem", $data);
}
function delete_other(){
$sql = "delete from trainsystem where ts_id = '860'";
$query = $this->INFO->query($sql);
}
}

@ -0,0 +1,157 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Sendmail_model extends CI_Model {
function __construct()
{
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
}
function SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body)
{
$time = date('Y-m-d H:i:s',time());
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,
"M_AddTime" => $time
);
$this->HT->insert('Email_AutomaticSend',$data);
$m_sn = $this->HT->insert_id('Email_AutomaticSend');
return $m_sn;
}else{
return FALSE;
}
}
function SendMailToTabletest($fromName,$fromEmail,$toName,$toEmail,$subject,$body)
{
$time = date('Y-m-d H:i:s',time());
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,
"M_AddTime" => $time,
);
$this->HT->insert('Email_AutomaticSend',$data);
$m_sn = $this->HT->insert_id('Email_AutomaticSend');
return $m_sn;
}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);
$domain = str_replace(' ','',$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;
}
public function validEmailtest($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);
$domain = str_replace(' ','',$domain);
print_r(preg_match('/^[A-Za-z0-9\\-\\.]+$/', $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;
}
}

@ -0,0 +1,267 @@
<?php
class train_system_model extends CI_Model {
private $order="";//订单号
function __construct() {
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
$this->INFO = $this->load->database('INFO', TRUE);
}
public function get_order($pagesize=2,$page=0,$where="1=1"){
$data=new StdClass();
//获取总条数
$sql="SELECT COUNT(*) AS count FROM InfoManager.dbo.trainsystem
LEFT 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
{$where}
";
$query = $this->HT->query($sql);
$count=$query->result();
$data->count=$count[0]->count;
$sql="SELECT TOP {$pagesize} InfoManager.dbo.trainsystem.ts_subtime,
InfoManager.dbo.trainsystem.ts_cold_sn,
InfoManager.dbo.trainsystem.ts_ordernumber,
InfoManager.dbo.trainsystem.ts_status,
InfoManager.dbo.trainsystem.ts_errormsg,
InfoManager.dbo.trainsystem.ts_fromstationame,
InfoManager.dbo.trainsystem.ts_tostationame,
InfoManager.dbo.trainsystem.ts_checi,
InfoManager.dbo.trainsystem.ts_orderamount,
InfoManager.dbo.trainsystem.ts_isauto,
InfoManager.dbo.trainsystem.ts_sendmail,
InfoManager.dbo.trainsystem.ts_m_sn,
InfoManager.dbo.trainsystem.ts_channel,
BIZ_ConfirmLineInfo.COLI_ID,
BIZ_ConfirmLineInfo.COLI_WebCode
FROM
InfoManager.dbo.trainsystem
LEFT 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
InfoManager.dbo.trainsystem.ts_id NOT IN(
SELECT
TOP {$page} ts_id
FROM
InfoManager.dbo.trainsystem
LEFT 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 {$where}
ORDER BY ts_subtime DESC)
AND
{$where}
ORDER BY InfoManager.dbo.trainsystem.ts_subtime DESC";
$query = $this->HT->query($sql);
$data->list=$query->result();
return $data;
}
//获取指定订单信息
public function get_passager_details($ordernumber){
$sql = "select * from trainsystem_tickets where tst_ordernumber = '{$ordernumber}'";
$query = $this->INFO->query($sql);
return $query->result();
}
//获取火车信息
public function get_train_infos($ordernumber){
$sql = "select * from trainsystem where ts_ordernumber = '{$ordernumber}'";
$query = $this->INFO->query($sql);
return $query->row();
}
public function update_passpager_status($status,$passagerid){
$sql = "update trainsystem_tickets set tst_status = '{$status}' where tst_id = '{$passagerid}'";
$query = $this->INFO->query($sql);
}
//添加订单
function add_orders($data){
$sql="
INSERT INTO trainsystem(
ts_cold_sn,
ts_ordernumber,
ts_subtime,
ts_returncode,
ts_status,
ts_errormsg,
ts_fromstationame,
ts_fromstationcode,
ts_tostationame,
ts_tostationcode,
ts_startdate,
ts_startime,
ts_endtime,
ts_runtime,
ts_checi,
ts_channel,
ts_isauto
)
VALUES(
'{$data->cold_sn}',
'{$data->ordernumber}',
getdate(),
'{$data->returncode}',
'{$data->status}',
'{$data->errormsg}',
'{$data->fromstationame}',
'{$data->fromstationcode}',
'{$data->tostationame}',
'{$data->tostationcode}',
'{$data->startdate}',
'{$data->startime}',
'{$data->endtime}',
'{$data->runtime}',
'{$data->checi}',
'{$data->channel}',
'{$data->isauto}'
)
";
//echo $sql;
$query = $this->INFO->query($sql);
}
public function ticketfrom($ts_ordernumber){
$sql = "select ts_channel,ts_cold_sn,ts_ordernumber from trainsystem where ts_ordernumber = ?";
$query = $this->INFO->query($sql,array($ts_ordernumber));
return $query->row();
}
public function get_passenger_info($ordernumber,$passportname,$passportno){
$sql = "select * from trainsystem_tickets left join trainsystem on tst_ordernumber = ts_ordernumber where tst_realname = ? and tst_numberid = ? and tst_ordernumber = ?";
$query = $this->INFO->query($sql,array($passportname,$passportno,$ordernumber));
return $query->row();
}
function add_passagers($data){
$sql = "IF EXISTS (select * from trainsystem_tickets where tst_ordernumber = '{$data->ordernumber}' and tst_numberid = '{$data->numberid}')
update
trainsystem_tickets
set
tst_identitytype = '{$data->identitytype}',
tst_numberid = '{$data->numberid}',
tst_ticketype = '{$data->ticketype}',
tst_ticketprice = '{$data->ticketprice}',
tst_seatstype = '{$data->seatype}',
tst_seatdetail = '{$data->seatdetail}',
tst_status = '{$data->status}'
where
tst_ordernumber = '{$data->ordernumber}'
and
tst_numberid = '{$data->numberid}'
else
INSERT INTO trainsystem_tickets (
tst_ordernumber,
tst_status,
tst_realname,
tst_identitytype,
tst_numberid,
tst_ticketype,
tst_ticketprice,
tst_seatstype,
tst_seatdetail
)VALUES(
'{$data->ordernumber}',
'{$data->status}',
'{$data->realname}',
'{$data->identitytype}',
'{$data->numberid}',
'{$data->ticketype}',
'{$data->ticketprice}',
'{$data->seatype}',
'{$data->seatdetail}'
)
";
$query =$this->INFO->query($sql);
}
public function update_orders($data){
$where = '';
if(!empty($data->bookcallback)){
$where .= "
ts_seatsinfo = '{$data->seatsinfo}',
ts_checkdoor = '{$data->TicketCheck}',
ts_elecnumber = '{$data->ElectronicOrderNumber}',
ts_orderamount = '{$data->OrderTotleFee}',
ts_bookcallback = '{$data->bookcallback}',";
}else if(!empty($data->confirmcallback)){
$where .= "ts_confirmcallback = '{$data->confirmcallback}',";
}else if(!empty($data->returncallback)){
$where .= "ts_returncallback = '{$data->returncallback}',";
}else if(!empty($data->reschedulecallback)){
$where .= "ts_reschedulecallback = '{$data->reschedulecallback}',";
}
$sql ="
update trainsystem
set
ts_status = '{$data->OrderStatus}',
ts_errormsg = '{$data->ErrorMsg}',
".substr($where,0,strlen($where)-1)."
where
ts_ordernumber = '{$data->ordernumber}'
";
//echo $sql;die();
$query = $this->INFO->query($sql);
}
//更新乘客表信息
public function update_passpager_info($data){
$sql = "update
trainsystem_tickets
set
tst_status = '{$data->status}',
tst_returncallback = '{$data->returncallback}',
tst_lasteditdate = getdate()
where
tst_ordernumber = '{$data->ordernumber}'
and
tst_realname = '{$data->realname}'
and
tst_numberid = '{$data->numberid}'
";
$query = $this->INFO->query($sql);
}
public function get_tickets_info($cold_sn){
$sql = "select ts_cold_sn,ts_ordernumber,tst_realname,tst_numberid,tst_status from trainsystem left join trainsystem_tickets on ts_ordernumber = tst_ordernumber where ts_cold_sn = ? and ts_status = '4'";
$query = $this->INFO->query($sql,array($cold_sn));
//$sql = "select * from BIZ_JuheOrderList where JOL_COLD_SN = ? and jol_status = '4'";
//$query = $this->HT->query($sql,array($cold_sn));
return $query->result();
}
public function getallorders(){
$sql = "select * from Tourmanager.dbo.BIZ_JuheOrderList where JOL_SubTime > '2019-03-01' and (JOL_Status = '4' or JOL_Status = '7')";
$query = $this->HT->query($sql);
return $query->result();
}
public function update_juheorder($ordernumber,$subtime,$price){
$sql = "update trainsystem set ts_subtime = ? , ts_orderamount = ? where ts_ordernumber = ?";
$query = $this->INFO->query($sql,array($subtime,$price,$ordernumber));
}
//根据cold_sn 获取出票情况
public function get_ticketinfos($cold_sn){
$sql = "select * from trainsystem where ts_cold_sn = ? and ts_status = '4'";
$query = $this->INFO->query($sql,array($cold_sn));
return $query->row();
}
public function test(){
$sql = "delete from trainsystem where ts_cold_sn = '488121613_1552637689'";
$query = $this->INFO->query($sql);
}
}

@ -0,0 +1,43 @@
<?php // 代码各服务器已经同步 2016.06.01 ycc ?>
<div class="container-fluid footer">
<div class="row">
<div class="col-xs-5"></div>
<div class="col-xs-17">
<legend></legend>
<p class="muted pull-right"><strong>{elapsed_time}</strong> seconds , <strong>{memory_usage}</strong> memory ,技术支持:YCC 08987705</p>
</div>
<div class="col-xs-2"></div>
</div>
</div>
<!-- 静态化更新窗口 -->
<div class="modal fade" id="cache_refresh_modal" tabindex="-1" role="dialog" data-backdrop="false">
<div class="modal-dialog" role="document">
<div class="modal-content" >
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 style="margin:0;">静态化更新-系列站专用</h3>
</div>
<div class="modal-body">
<label>需要更新的页面</label>
<input type="text" class="form-control" name="static_html_url" id="static_html_url" placeholder="如http://www.voyageschine.com/shanghai-voyage/" />
<input type="hidden" name="updatecdn_byhand" id="updatecdn_byhand" value="">
<p class="text-danger" id="cache_refresh_modal_msg" name="cache_refresh_modal_msg"></p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal">关闭</button>
<a class="btn btn-primary" href="javascript:void(0);" onclick="$('#updatecdn_byhand').val('1');
updateCache($('#static_html_url').val(), 'cache_refresh_modal_msg');" >更新</a>
</div>
</div>
</div>
</div>
<!-- 静态化更新窗口 -->
</body>
</html>

@ -0,0 +1,131 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>出票系统</title>
<link rel="stylesheet" href="/css/information-system3.css?v=201508112" type="text/css" />
<script type="text/javascript" src="/min/?f=/js/information-system3.min.js,/js/common.js"></script>
<link rel="shortcut icon" href="/bootstrap/img/glyphicons_290_skull.png">
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-9" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/"><span class="glyphicon glyphicon-home text-white"></span></a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-9">
<ul class="nav navbar-nav">
<li><a href="<?php echo site_url(''); ?>">信息管理</a></li>
<li><a href="<?php echo site_url('product') ?>">产品管理</a></li>
<li><a href="<?php echo site_url('author'); ?>">作者平台</a></li>
<li><a href="<?php echo site_url('keyworlds') ?>">关键词</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
更多<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="<?php echo site_url('seo') ?>">SEO管理</a></li>
<li> <a href="<?php echo site_url('thirdparty/public/infopayauthor') ?>">打赏统计</a></li>
<li> <a href="<?php echo site_url('thirdparty/form') ?>">表单管理</a></li>
<li><a href="<?php echo site_url('thirdparty/advertise') ?>">广告管理</a></li>
<li><a href="<?php echo site_url('setting') ?>">系统设置</a></li>
</ul>
</li>
</ul>
<form id="form_information_search" name="form_information_search" method="post" action="<?php echo $this->router->class == 'infoshare' ? site_url('infoshare/search/') : site_url('welcome/search/'); ?>" class="navbar-form navbar-left" >
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" title="全文搜索" name="all_text_search" id="all_text_search" value="true" >
</span>
<input type="text" class="form-control input-sm" name="keywords" id="keywords" value="<?php echo isset($keywords) ? $keywords : false; ?>" style="min-width:450px;">
<span class="input-group-btn">
<button class="btn btn-default btn-sm" type="submit">搜索</button>
<a href="#" onclick="openKCFinder_fast();" class="btn btn-default btn-sm" title="快速上传图片" ><span class="glyphicon glyphicon-picture"></span></a>
<a href="#" title="静态化更新" class="btn btn-default btn-sm" data-toggle="modal" data-target="#cache_refresh_modal" ><span class="glyphicon glyphicon-repeat"></span></a>
</span>
</div>
</form>
<ul class="nav navbar-nav navbar-right">
<?php
$all_unread_sms = get_all_unread_sms();
$info_unread_sms = get_all_unread_sms('info');
if (isset($information->ic_id))
$current_msg = $information->ic_id;
if (isset($task->t_id))
$current_msg = $task->t_id;
$total_count = $all_unread_sms['sms_count'] + $info_unread_sms['sms_count']; //计算未读消息总数
$unread_sms_ic_id = 0; //用于设置所有收录消息为已读
if ($total_count != 0) {
?>
<!-- 如果当前页面存在未读消息,则消息数减一 -->
<?php
if (isset($current_msg) && isset($all_unread_sms['sms'][$current_msg])) {
$total_count = $total_count - count($all_unread_sms['sms'][$current_msg]);
unset($all_unread_sms['sms'][$current_msg]);
}
?>
<?php
if (isset($current_msg) && isset($info_unread_sms['sms'][$current_msg])) {
$total_count = $total_count - count($info_unread_sms['sms'][$current_msg]);
unset($info_unread_sms['sms'][$current_msg]);
}
?>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="icon-envelope icon-white pull-left" style="margin-top:3px;"></i> <span class="badge badge-important pull-right"><?php echo $total_count; ?></span>
</a>
<ul class="dropdown-menu">
<!-- 信息平台的消息 -->
<?php if (isset($info_unread_sms['sms']) && !empty($info_unread_sms['sms'])) { ?>
<a style="padding-left:20px;" href="javascript:void(0);" onclick="set_allmsg_to_read($('#unreadinfomsg').val());">标记全部收录信息为已读</a>
<li class="divider"></li>
<?php foreach ($info_unread_sms['sms'] as $m) { ?>
<li><a href="<?php echo site_url('information/edit/' . $m[0]->is_id); ?>"><?php
$t_title = get_text_short($m[0]->t_title, 15);
echo '[' . $m[0]->ic_sitecode . '] ' . $t_title['content'] . ' (' . $m[0]->m_content . ')';
?></a></li>
<?php $unread_sms_ic_id.=',' . $m[0]->m_object_id; ?>
<?php } ?>
<li class="divider"></li>
<input type="hidden" name="unreadinfomsg" id="unreadinfomsg" value="<?php echo $unread_sms_ic_id; ?>">
<?php } ?>
<!--作者平台的消息-->
<?php foreach ($all_unread_sms['sms'] as $am) { ?>
<li><a href="<?php echo site_url('author/edit_task/' . $am[0]->m_object_id); ?>"><?php
$t_title = get_text_short($am[0]->t_title, 15);
echo $t_title['content'] . ' (' . count($am) . ')';
?></a></li>
<?php } ?>
</ul>
</li>
<?php } ?>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<?php
echo $this->config->item('site_code');
echo ' -';
$admin_info = $this->session->userdata('session_admin');
echo $admin_info['OPI_Name'];
?>
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<?php foreach ($this->config->item('site') as $site_item) { ?>
<li> <a href="<?php echo site_url('login/change_site/' . $site_item['site_code']); ?>" ><?php echo $site_item['site_code'] ?></a></li>
<?php } ?>
<li><a href="<?php echo site_url('login/out'); ?>" >退出</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>

@ -0,0 +1,33 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>China train ticket(s) confirmed, Booking Number <?php echo $coli_id;?></title><style>*{ font-family:Verdana, Geneva, sans-serif; color:#545454;}</style></head><body style="font-family:Verdana, Geneva, sans-serif; border-left:1px solid #d1d1d1; border-right:1px solid #d1d1d1;"><h1 style="font-size:20px; text-align:center;">China Highlights Booking Confirmation</h1><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Dear <?php echo $toname?>,</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Thank you for your payment of US$<?php echo $price->GAI_SQJE?> . The train tickets have already been issued. </p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> You can collect the paper ticket(s) from now on at any train station in mainland China.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"><strong>Please note:</strong></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">1.Please present the <strong>original passport(s) of all the passenger(s)</strong> and the ticket pick-up number(s) <span style="color:#33F"><?php echo $ordernumber;?></span> at ticket collection counters. The counter will then issue your paper train ticket(s). </p>
<p>See the <a style="color:#33F" href="https://www.chinahighlights.com/travelguide/transportation/how-to-board-train.htm">video</a> about how to collect the ticket(s) in China.
</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">2.Please double check the train(s) information and passport information. Let us know AT ONCE if you see any mistakes below. We can try to cancel tickets to minimize your loss. A 20% cancellation fee is charged by China Railway.</p><table border="0" cellpadding="0" cellspacing="0" style="width:100%; border-top:3px solid #a31022; border-left:1px solid #d1d1d1; margin-bottom:15px;"><tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;width: 293px;">Ticket collection sentences</th><td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;"><p>The bilingual note below might help you pick up tickets at the ticket collection counter more easily.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 1.Please show me which window for picking up the train ticket. 你好,请问哪个是取票窗?</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">2.Please issue the paper tickets for me. The following is the pick up numbers.请帮我出票,电子取票号如下.</p></td></tr></table>
<?php
$j = 0;
foreach($train_info as $item){
echo '<table border="0" cellpadding="0" cellspacing="0" style="width:100%; border-top:3px solid #a31022; border-left:1px solid #d1d1d1; margin-bottom:15px;">
<tr>
<th style="width: 293px;text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Pick up number</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;"><span style="color:#33F">'.$item->FOI_TrainNetOrderNo.'</span></td>';
echo '</tr><tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Train No.</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->FlightsNo.'</td></tr><tr>';
echo '<th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Departure</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->DepartureTime.' '.$item->DepartureCity.' Station(in Chinese '.$item->DepartAirport_cn.'火车站)</td></tr>';
echo '<tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Arrival</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->ArrivalTime.' '.$item->ArrivalCity.' Station(in Chinese '.$item->ArrivalAirport_cn.'火车站)</td></tr>';
echo '<tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Class</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->Cabin.' ('.$seatinfo.')</td></tr></table>';
}
?>
<table border="0" cellpadding="0" cellspacing="0" style="width:100%; border-top:3px solid #a31022; border-left:1px solid #d1d1d1; margin-bottom:15px;"><tr><th style="width: 293px;text-align:left; padding:10px; font-size:14px; background:#f1f1f1;">Passenger(s)</th><td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;"><p><?php
if($adult>0){echo $adult.' adult(s) ';}
if($chlid>0){echo $chlid.' chlid(s) ';}
if($baby>0){echo $baby.' baby(s) ';}
?></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> <?php
$i=0;
foreach($allpeople as $item){
echo ++$i.'.'.$item->BPE_FirstName.$item->BPE_MiddleName.$item->BPE_LastName.' , passport number '.$item->BPE_Passport.'<br>';
}
?></p></td></tr></table>
<p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 3.On your departure day, please time your arrival at the station wisely. If you are going to collect your train ticket(s) on the departure day, allow enough time waiting in the queue of the ticket collection counter, for the security x-ray check of your luggage, and for the ticket check before entering the passenger lounge. Tickets will stop being issued 30 minutes prior to departure. We suggest you be at the station at least 1.5 hours ahead of the stated departure time. Please leave at least 2.5 hours during public holidays.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 4.If youve already collected your ticket before the departure day, we recommend that you be at the station at least 40 minutes ahead of time. Please be at the station at least 1.5 hours during a public holiday. </p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 5.Please don't throw your ticket(s) away because you'll need it to exit the station.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">6.If you cancel the ticket(s) at a train station yourself, the money will be refunded to our account. Please cancel the tickets before the train departure. And email us then we will refund you accordingly.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">7.<a style="color:#33F" href="https://www.chinahighlights.com/china-trains/booking-policy.htm">China Highlights train ticket booking policy </a></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Should you have any questions about your train ticket bookings, please do not hesitate to contact me.</p>
<p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Best Regards!</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"><?php echo $operator[0]->Name?>, Travel Advisor</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Tel: <?php echo $operator[0]->tel;?> Mobile: <?php echo $operator[0]->Mobile;?> </p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Fax: 86-773-2827424, 86-773-2885308 </p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> E-mail: <a href="mailto:<?php echo $emailarr[0]?>"><?php echo $emailarr[0]?>;</a><a href="mailto:<?php echo $emailarr[1]?>"><?php echo $emailarr[1]?>;</a></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">WeChat: CH_train<p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"><a href="http://www.chinahighlights.com">www.chinahighlights.com</a></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Address: Building 6, Chuangyi Business Park, 70 Qilidian Road, Guilin, Guangxi, 541004, China</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> If you wish to share anything with my supervisor (Ms. ethel), please feel free to send your email to <a href="mailto:ethel@chinahighlights.net">ethel@chinahighlights.net</a>.</p></body></html>

@ -0,0 +1,48 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>China Highlights Booking Confirmation</title><style>*{ font-family:Verdana, Geneva, sans-serif; color:#545454;}</style></head><body style="font-family:Verdana, Geneva, sans-serif; border-left:1px solid #d1d1d1; border-right:1px solid #d1d1d1;"><h1 style="font-size:20px; text-align:center;">China Highlights Booking Confirmation</h1><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Dear <?php echo $toname?>,</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Thanks for payment US$<?php echo $price->GAI_SQJE?> . The train tickets have already been issued. </p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> You can collect the paper ticket(s) from now at any train station in mainland China.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 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.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Please collect your paper tickets from a ticket counter in the train station. Tickets will stop being printed 30 minutes prior to departure. On departure day, please time your arrival wisely. If you are going to collect your tickets on departure day, allow for time waiting in queue at the ticket-counter, for security checks and for ticket checks. We suggest you be at the station at least 1.5 hours ahead of the stated departure time.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">If youve already collected before the departure day, it is also wise to be at the station at least 40 minutes ahead. </p><table border="0" cellpadding="0" cellspacing="0" style="width:100%; border-top:3px solid #a31022; border-left:1px solid #d1d1d1; margin-bottom:15px;"><tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;">Passenger(s)</th><td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;"><p><?php
if($adult>0){echo $adult.' adult(s) ';}
if($chlid>0){echo $chlid.' chlid(s) ';}
if($baby>0){echo $baby.' baby(s) ';}
?></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> <?php
$i=0;
foreach($allpeople as $item){
echo ++$i.'.'.$item->BPE_FirstName.$item->BPE_MiddleName.$item->BPE_LastName.' , passport number '.$item->BPE_Passport.'<br>';
}
?></p></td></tr></table>
<?php
$j = 0;
foreach($train_info as $item){
echo '<p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Train'.++$j.':</p>';
echo '<table border="0" cellpadding="0" cellspacing="0" style="width:100%; border-top:3px solid #a31022; border-left:1px solid #d1d1d1; margin-bottom:15px;">
<tr>
<th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Ticket Pick Up No.</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;"><span style="color:#33F">'.$item->FOI_TrainNetOrderNo.'</span></td>';
echo '</tr><tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Train No.</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->FlightsNo.'</td></tr><tr>';
echo '<th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Departure</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->DepartureTime.' '.$item->DepartureCity.' Station(in Chinese '.$item->DepartAirport_cn.'火车站)</td></tr>';
echo '<tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Arrival</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->ArrivalTime.' '.$item->ArrivalCity.' Station(in Chinese '.$item->ArrivalAirport_cn.'火车站)</td></tr>';
echo '<tr><th style="text-align:left; padding:10px; font-size:14px; background:#f1f1f1;"><strong>Class</strong></th>';
echo '<td style="border-bottom:1px solid #d1d1d1; border-right:1px solid #d1d1d1; font-size:14px; line-height:22px; padding:10px;">'.$item->Cabin.'</td></tr></table>';
}
?>
<p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">Kindly note below:</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">1.Please present all passenger(s) original passport(s) and Ticket Pick Up No.<span style="color:#33F"><?php echo $item->FOI_TrainNetOrderNo?></span>at any ticket counters of any railway stations. They will then issue your paper train ticket(s). You can find more instruction of collecting tickets enclosure.
</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 2.You can show screenshot of the paper tickets to the railway station counter. It helps get paper tickets easily.</p>
<?php
foreach($train_info as $obj){
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
echo '<tr style="background:#f0f0f0; color:#545454; font-weight:100; font-size:20px; ">';
echo ' <th style="font-weight:100; font-size:18px; text-align:left;padding:8px 10px; border-top:3px solid #ad1818;">'.substr($obj->DepartureDate,0,10).'&nbsp;&nbsp;&nbsp;'.$obj->FlightsNo.'&nbsp;&nbsp;&nbsp;'.$obj->FOI_TrainNetOrderNo.'</th></tr><tr>';
echo '<td style=" padding:8px 10px; font-size:15px; color:#545454; border-bottom:1px solid #d1d1d1;"><p>'.$obj->DepartAirport_cn.'('.$obj->DepartureCity.')<span style=" font-size:12px;">'.$obj->DepartureTime.'</span> To '.$obj->ArrivalAirport_cn.'('.$obj->ArrivalCity.')<span style=" font-size:12px;">'.$obj->ArrivalTime.'</span></p></td></tr>';
foreach($juhe_info->passengers as $people){
echo '<tr><td style=" padding:8px 10px; font-size:15px; color:#545454; border-bottom:1px solid #d1d1d1;">';
echo '<p>'.$people->passengersename.'('.$people->piaotypename.') ';
echo $people->cxin.' 票价:¥'.$people->price.'</p>';
echo '</td></tr>';
}
echo '<tr><td style=" padding:8px 10px; font-size:15px; color:#545454; border-bottom:1px solid #d1d1d1;"><p>出票成功</p></td></tr></table>';
}
?>
<p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 3. 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 the ticket counter at other stations. Return tickets are treated separately. 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.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 4. Please keep your ticket(s) and don't throw your ticket(s) away once you've boarded your train, you'll need it to exit the station.</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> 5.Download railway station instructions, maps and tips at <a href="https://www.chinahighlights.com/china-trains/station-map.htm">https://www.chinahighlights.com/china-trains/station-map.htm</a></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;">6.Terms & Conditions. <a href="https://www.chinahighlights.com/china-trains/booking-policy.htm">https://www.chinahighlights.com/china-trains/booking-policy.htm</a></p><p>&nbsp;</p>
<p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Best Regards!</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"><?php echo $operator[0]->Name?>, Travel Advisor</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Tel: <?php echo $operator[0]->tel;?> Mobile: <?php echo $operator[0]->Mobile;?> </p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Fax: 86-773-2827424, 86-773-2885308 </p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> E-mail: <a href="mailto:<?php echo $emailarr[0]?>"><?php echo $emailarr[0]?>;</a><a href="mailto:<?php echo $emailarr[1]?>"><?php echo $emailarr[1]?>;</a></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"><a href="http://www.chinahighlights.com">www.chinahighlights.com</a></p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> Address: Building 6, Chuangyi Business Park, 70 Qilidian Road, Guilin, Guangxi, 541004, China</p><p style="font-size:14px; margin:0 0 18px 0; line-height:22px;"> If you wish to share anything with my supervisor (Ms. Alex Yang), please feel free to send your email to <a href="mailto:alex@chinahighlights.net">alex@chinahighlights.net</a>.</p></body></html>

@ -0,0 +1,26 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title></head><body><p style="font-family:Verdana, Geneva, sans-serif; font-size:14px; line-height:24px; margin-bottom:12px;">Dear <?php echo $toname?>,</p><p style="font-family:Verdana, Geneva, sans-serif; font-size:14px; line-height:24px; margin-bottom:12px;"> Thank you for your booking (order number <?php echo $coli_id?>), we have received your payment of USD<?php echo $price->GAI_SQJE?>.&nbsp;</p><p style="font-family:Verdana, Geneva, sans-serif; font-size:14px; line-height:24px; margin-bottom:12px;"> Due to the heavy traffic flow of data, the system failed to automatically issue your ticket(s).</p><p style="font-family:Verdana, Geneva, sans-serif; font-size:14px; line-height:24px; margin-bottom:12px;">Your travel advisor will purchase your train ticket(s) manually. &nbsp;You will receive an email within half a working day (Our time now:&nbsp;<strong><?php echo date('H:i').' '.date('a');?></strong>, <?php echo date('D');?>,<?php echo date('F').' '.date('d').','.date('Y');?> GMT+8).Should you have any questions or concerns with regards to your train booking, please do not hesitate to contact me at <a href="mailto:<?php echo $emailarr[0]?>"><?php echo $emailarr[0]?></a>;<a href="mailto:<?php echo $emailarr[1]?>"><?php echo $emailarr[1]?></a> or telephone <?php echo $operator[0]->tel;?>. </p>
<?php foreach($train_info as $item){
echo '<table border="0" cellspacing="0" cellpadding="0" width="60%">';
echo '<tr><th width="17%" style="font-family:Verdana, Geneva, sans-serif;font-size:14px; color:#a31022; background:#e6e6e6; text-align:left; padding:10px;">Train No. </th>';
echo '<td width="83%" style="font-family:Verdana, Geneva, sans-serif;font-size:14px; text-align:left; padding:10px; border-bottom:1px solid #d1d1d1;">'.$item->FlightsNo.'</td></tr>';
echo '<tr><th style="font-family:Verdana, Geneva, sans-serif; font-size:14px; color:#a31022; background:#e6e6e6; text-align:left; padding:10px;">Departure </th>';
echo '<td style="font-family:Verdana, Geneva, sans-serif; font-size:14px; text-align:left; padding:10px; border-bottom:1px solid #d1d1d1;">'.$item->DepartureTime.', '.$item->DepartureCity.' Station(in Chinese '.$item->DepartAirport_cn.'火车站)&nbsp;</td></tr>';
echo '<tr><th style="font-family:Verdana, Geneva, sans-serif; font-size:14px; color:#a31022; background:#e6e6e6; text-align:left; padding:10px;">Arrival </th><td style="font-family:Verdana, Geneva, sans-serif; font-size:14px; text-align:left; padding:10px; border-bottom:1px solid #d1d1d1;">'.$item->ArrivalTime.', '.$item->ArrivalCity.'(in Chinese'. $item->ArrivalAirport_cn.'火车站)&nbsp; </td></tr>';
echo '<tr><th style="font-family:Verdana, Geneva, sans-serif; font-size:14px; color:#a31022; background:#e6e6e6; text-align:left; padding:10px;">Class </th><td style="font-family:Verdana, Geneva, sans-serif; font-size:14px; text-align:left; padding:10px; border-bottom:1px solid #d1d1d1;">'.$item->Cabin.'</td></tr>';
echo '<tr><th style="font-family:Verdana, Geneva, sans-serif; font-size:14px; color:#a31022; background:#e6e6e6; text-align:left; padding:10px;">Passenger(s) </th>';
echo '<td style="font-family:Verdana, Geneva, sans-serif; font-size:14px; text-align:left; padding:10px; border-bottom:1px solid #d1d1d1;">';
if($adult>0){echo $adult.' adult(s)<br/> ';}
if($chlid>0){echo $chlid.' chlid(s)<br/> ';}
if($baby>0){echo $baby.' baby(s)<br/> ';}
$i=0;
foreach($allpeople as $item){
echo ++$i.'.'.$item->BPE_FirstName.$item->BPE_MiddleName.$item->BPE_LastName.' , passport number '.$item->BPE_Passport.'<br>';
}
echo '</tr></table>';
echo '<p style="font-family:Verdana, Geneva, sans-serif; font-size:14px; line-height:24px; margin-bottom:12px;">Regards <br />';
echo $operator[0]->Name.'<br/>Travel Advisor<br/>';
echo 'Telephone:&nbsp;(Office)'.$operator[0]->tel.', M: '.$operator[0]->Mobile.',';
echo 'Email: <a href="mailto:'.$emailarr[0].'">'.$emailarr[0].'</a>;<a href="mailto:'.$emailarr[1].'">'.$emailarr[1].'</a>;&nbsp</p>';
}?>
</body>
</html>

@ -0,0 +1,110 @@
<div style="width:90%;margin:30px auto;">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">交易记录导出&nbsp;<a style="margin-left:50px;" target='_blank' href="<?php echo site_url('apps/train/index/ht_order_list');?>">订单列表>></a> </h3>
</div>
<div class="panel-body">
<form style="width: 80%;" action="http://www.mycht.cn/info.php/apps/trainsystem/api/export_excel/" method="post">
<input type="text" name="from_date" class="date" value="<?php echo empty($from_date)?"":$from_date;?>" autocomplete="off">
<input type="text" name="to_date" class="date" value="<?php echo empty($to_date)?"":$to_date;?>" autocomplete="off">
审核状态:<input type="checkbox" <?php echo empty($examine)?"":"checked";?> name="examine" />&nbsp;&nbsp;&nbsp;
<button type="submit" id="sub" class="btn btn-warning btn-sm"><span class="glyphicon glyphicon-download-alt"></span> Download</button>
</form>
<p style="margin: 0 0 10px; width: 200px; float: left; line-height: 30px;">
<!-- <table class="table table-hover" >
<thead>
<tr><th>时间</th><th>信息</th><th>变化值</th><th>团名</th><th>外联</th></tr>
</thead>
<tbody>
<tr data-id="161130252" title="Popover title" data-container="body" data-toggle="popover" data-placement="top" data-content="顶部的 Popover 中的一些内容">
<td>2016-12-01 11:18:28</td>
<td> 票款(有充值)</td>
<td>-1106.00</td>
<td>R161228-BYW161130252</td>
<td>李毅文</td>
</tr>
</tbody>
</table> -->
<div class="row <?php echo empty($examine)?"hidden":"";?>" style="width:90%;margin:0 auto;">
<div class="">
<table class="table table-hover" id="list_table">
<thead>
<tr><th>时间</th><th>信息</th><th>变化值</th><th>团名</th><th>外联</th></tr>
</thead>
<tbody>
<?php foreach ($data as $key => $value) {?>
<tr data-id="<?php echo $value[8];?>" title="Popover title" data-container="body" data-toggle="popover" data-placement="top" data-content="顶部的 Popover 中的一些内容">
<td><?php echo $value[2];?></td><td><?php echo $value[3];?></td><td><?php echo $value[1];?></td><td><?php echo $value[6];?></td><td><?php echo $value[7];?></td>
</tr>
<?php }?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="popover fade top in" role="tooltip" id="popover" style="width:auto;max-width: 100% !important;top: 139.6px; left: 50%; display: none;">
<div class="arrow"></div>
<h3 class="popover-title">我的支付</h3>
<div class="popover-content">
<table class="table" id="my_pay_data">
<thead>
<tr>
<td>序号</td><td>车次</td><td>出发日期</td><td>价格</td><td>备注</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<script>
$(".date").datepicker({
'format': 'yyyy-m-d',
'autoclose': true
});
$("body").click(function(){
$("#popover").css("display","none");
});
$("#popover").click(function(e){
e.stopPropagation();//阻止事件冒泡防止点击这个div也被隐藏
});
var popover_top=0;
var tr="";
$("#list_table>tbody>tr").click(function(e){
e.stopPropagation();
popover_top=$(this).offset().top-$("#popover").height();
var this_id=$(this).attr("data-id");
var THIS=$(this);
url="<?php echo site_url('apps/train/index/get_ht_my_pay?').'id=';?>"+this_id;
$.ajax({
url:url,
beforeSend:function(data){
// $("#popover").css("top",popover_top);
// $("#popover").css("display","block");
},
success:function(data){
tr="";
if(data.status==1){
$.each(data.datas,function(n,value){
tr+="<tr><td>"+(n+1)+"</td><td>"+value["TOC_TrainNumber"]+"</td><td>"+value["TOC_DepartureDate"]+"</td><td>"+value["TOC_TicketCost"]+"</td><td>"+value["TOC_Memo"]+"</td></tr>";
});
}
$("#my_pay_data>tbody").html(tr);
popover_top=THIS.offset().top-$("#popover").height();
$("#popover").css("top",popover_top);
$("#popover").css("display","block");
},
dataType: "json",
});
});
</script>

@ -0,0 +1,43 @@
<?php // 代码各服务器已经同步 2016.06.01 ycc ?>
<div class="container-fluid footer">
<div class="row">
<div class="col-xs-5"></div>
<div class="col-xs-17">
<legend></legend>
<p class="muted pull-right"><strong>{elapsed_time}</strong> seconds , <strong>{memory_usage}</strong> memory ,技术支持:YCC 08987705</p>
</div>
<div class="col-xs-2"></div>
</div>
</div>
<!-- 静态化更新窗口 -->
<div class="modal fade" id="cache_refresh_modal" tabindex="-1" role="dialog" data-backdrop="false">
<div class="modal-dialog" role="document">
<div class="modal-content" >
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 style="margin:0;">静态化更新-系列站专用</h3>
</div>
<div class="modal-body">
<label>需要更新的页面</label>
<input type="text" class="form-control" name="static_html_url" id="static_html_url" placeholder="如http://www.voyageschine.com/shanghai-voyage/" />
<input type="hidden" name="updatecdn_byhand" id="updatecdn_byhand" value="">
<p class="text-danger" id="cache_refresh_modal_msg" name="cache_refresh_modal_msg"></p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal">关闭</button>
<a class="btn btn-primary" href="javascript:void(0);" onclick="$('#updatecdn_byhand').val('1');
updateCache($('#static_html_url').val(), 'cache_refresh_modal_msg');" >更新</a>
</div>
</div>
</div>
</div>
<!-- 静态化更新窗口 -->
</body>
</html>

@ -0,0 +1,156 @@
<?php // 代码各服务器已经同步 2016.06.01 ycc ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>信息平台</title>
<link rel="stylesheet" href="/css/information-system3.css?v=201508112" type="text/css" />
<script type="text/javascript" src="/min/?f=/js/information-system3.min.js,/js/common.js"></script>
<script type="text/javascript" src="/js/kindeditor/kindeditor.js?v=20160601"></script>
<link rel="shortcut icon" href="/bootstrap/img/glyphicons_290_skull.png">
<script language="javascript">
//快速图片上传
function openKCFinder_fast() {
window.CallBack = oopenKCFinder_fast_callback;
window.open('/media/popselectpicture.php?site_code=<?php echo $this->config->item('site_code'); ?>&site_lgc=<?php echo $this->config->item('site_lgc'); ?>', 'kcfinder_textbox', 'status=0, toolbar=0, location=0, menubar=0, directories=0,resizable=1, scrollbars=0, width=800, height=600');
}
function oopenKCFinder_fast_callback(result) {
var site_image_url = '<?php echo $this->config->item('site_image_url') ?>';
if (result != null && result.Pinfo[0]) {
$.modaldialog.success("图片地址:<br/>" + site_image_url + result.Pinfo[0].PUrl);
}
}
//标识所有信息未已读
function set_allmsg_to_read(ic_ids) {
var url = '<?php echo site_url("author/set_msg_to_read"); ?>';
$.post(url, {'msg_ids': ic_ids}, function(result) {
window.location.href = window.location.href;
});
}
</script>
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-9" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/"><span class="glyphicon glyphicon-home text-white"></span></a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-9">
<ul class="nav navbar-nav">
<li><a href="<?php echo site_url(''); ?>">信息管理</a></li>
<li><a href="<?php echo site_url('product') ?>">产品管理</a></li>
<li><a href="<?php echo site_url('author'); ?>">作者平台</a></li>
<li><a href="<?php echo site_url('keyworlds') ?>">关键词</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
更多<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="<?php echo site_url('seo') ?>">SEO管理</a></li>
<li> <a href="<?php echo site_url('thirdparty/public/infopayauthor') ?>">打赏统计</a></li>
<li> <a href="<?php echo site_url('thirdparty/form') ?>">表单管理</a></li>
<li><a href="<?php echo site_url('thirdparty/advertise') ?>">广告管理</a></li>
<li><a href="<?php echo site_url('setting') ?>">系统设置</a></li>
</ul>
</li>
</ul>
<form id="form_information_search" name="form_information_search" method="post" action="<?php echo $this->router->class == 'infoshare' ? site_url('infoshare/search/') : site_url('welcome/search/'); ?>" class="navbar-form navbar-left" >
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox" title="全文搜索" name="all_text_search" id="all_text_search" value="true" >
</span>
<input type="text" class="form-control input-sm" name="keywords" id="keywords" value="<?php echo isset($keywords) ? $keywords : false; ?>" style="min-width:450px;">
<span class="input-group-btn">
<button class="btn btn-default btn-sm" type="submit">搜索</button>
<a href="#" onclick="openKCFinder_fast();" class="btn btn-default btn-sm" title="快速上传图片" ><span class="glyphicon glyphicon-picture"></span></a>
<a href="#" title="静态化更新" class="btn btn-default btn-sm" data-toggle="modal" data-target="#cache_refresh_modal" ><span class="glyphicon glyphicon-repeat"></span></a>
</span>
</div>
</form>
<ul class="nav navbar-nav navbar-right">
<?php
$all_unread_sms = get_all_unread_sms();
$info_unread_sms = get_all_unread_sms('info');
if (isset($information->ic_id))
$current_msg = $information->ic_id;
if (isset($task->t_id))
$current_msg = $task->t_id;
$total_count = $all_unread_sms['sms_count'] + $info_unread_sms['sms_count']; //计算未读消息总数
$unread_sms_ic_id = 0; //用于设置所有收录消息为已读
if ($total_count != 0) {
?>
<!-- 如果当前页面存在未读消息,则消息数减一 -->
<?php
if (isset($current_msg) && isset($all_unread_sms['sms'][$current_msg])) {
$total_count = $total_count - count($all_unread_sms['sms'][$current_msg]);
unset($all_unread_sms['sms'][$current_msg]);
}
?>
<?php
if (isset($current_msg) && isset($info_unread_sms['sms'][$current_msg])) {
$total_count = $total_count - count($info_unread_sms['sms'][$current_msg]);
unset($info_unread_sms['sms'][$current_msg]);
}
?>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="icon-envelope icon-white pull-left" style="margin-top:3px;"></i> <span class="badge badge-important pull-right"><?php echo $total_count; ?></span>
</a>
<ul class="dropdown-menu">
<!-- 信息平台的消息 -->
<?php if (isset($info_unread_sms['sms']) && !empty($info_unread_sms['sms'])) { ?>
<a style="padding-left:20px;" href="javascript:void(0);" onclick="set_allmsg_to_read($('#unreadinfomsg').val());">标记全部收录信息为已读</a>
<li class="divider"></li>
<?php foreach ($info_unread_sms['sms'] as $m) { ?>
<li><a href="<?php echo site_url('information/edit/' . $m[0]->is_id); ?>"><?php
$t_title = get_text_short($m[0]->t_title, 15);
echo '[' . $m[0]->ic_sitecode . '] ' . $t_title['content'] . ' (' . $m[0]->m_content . ')';
?></a></li>
<?php $unread_sms_ic_id.=',' . $m[0]->m_object_id; ?>
<?php } ?>
<li class="divider"></li>
<input type="hidden" name="unreadinfomsg" id="unreadinfomsg" value="<?php echo $unread_sms_ic_id; ?>">
<?php } ?>
<!--作者平台的消息-->
<?php foreach ($all_unread_sms['sms'] as $am) { ?>
<li><a href="<?php echo site_url('author/edit_task/' . $am[0]->m_object_id); ?>"><?php
$t_title = get_text_short($am[0]->t_title, 15);
echo $t_title['content'] . ' (' . count($am) . ')';
?></a></li>
<?php } ?>
</ul>
</li>
<?php } ?>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<?php
echo $this->config->item('site_code');
echo ' -';
$admin_info = $this->session->userdata('session_admin');
echo $admin_info['OPI_Name'];
?>
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<?php foreach ($this->config->item('site') as $site_item) { ?>
<li> <a href="<?php echo site_url('login/change_site/' . $site_item['site_code']); ?>" ><?php echo $site_item['site_code'] ?></a></li>
<?php } ?>
<li><a href="<?php echo site_url('login/out'); ?>" >退出</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>

@ -0,0 +1,515 @@
<style>
.clear {clear: both;}
.train-summary{ font-size:12px; margin-bottom:10px;}
.train-summary span{ color:#9a0918;}
a:link.seat-a{background-image:url(/css/images/train/a-seat.jpg); background-repeat:no-repeat; width:131px; display:block; height:42px; float:left;}
a:hover.seat-a{background-image:url(/css/images/train/a-seath.jpg);}
.selected_seat-a{background-image:url(/css/images/train/a-seata.jpg)!important; background-repeat:no-repeat; width:55px; display:block; height:42px; float:left;}
a:link.seat-b{background-image:url(/css/images/train/b-seat.jpg); background-repeat:no-repeat; text-decoration:none; width:55px; display:block; height:42px; float:left;}
a:hover.seat-b{background-image:url(/css/images/train/b-seath.jpg);}
.selected_seat-b{background-image:url(/css/images/train/b-seata.jpg)!important; background-repeat:no-repeat; width:55px; display:block; height:42px; float:left;}
a:link.seat-c{background-image:url(/css/images/train/c-seat.jpg); background-repeat:no-repeat; width:131px; display:block; height:42px; float:left;}
a:hover.seat-c{background-image:url(/css/images/train/c-seath.jpg);}
.selected_seat-c{background-image:url(/css/images/train/c-seata.jpg)!important; background-repeat:no-repeat; width:55px; display:block; height:42px; float:left;}
a:link.seat-d{background-image:url(/css/images/train/d-seat.jpg); background-repeat:no-repeat; width:55px; display:block; height:42px; float:left;}
a:hover.seat-d{background-image:url(/css/images/train/d-seath.jpg);}
.selected_seat-d{background-image:url(/css/images/train/d-seata.jpg)!important; background-repeat:no-repeat; width:136px; display:block; height:42px; float:left;}
a:link.seat-f{background-image:url(/css/images/train/f-seat.jpg); background-repeat:no-repeat; width:136px; display:block; height:42px; float:left;}
a:hover.seat-f{background-image:url(/css/images/train/f-seath.jpg);}
.selected_seat-f{background-image:url(/css/images/train/f-seata.jpg)!important; background-repeat:no-repeat; width:136px; display:block; height:42px; float:left;}
a:link.sleep-a {background-image:url(/css/images/train/l-up.jpg); background-repeat:no-repeat; width:163px; display:block; height:38px; float:left; }
a:hover.sleep-a { background-image:url(/css/images/train/l-upa.jpg); }
.selected_sleep-a { background-image:url(/css/images/train/l-upa.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-b {background-image:url(/css/images/train/r-up.jpg); background-repeat:no-repeat; width:104px; display:block; height:38px; float:left; }
a:hover.sleep-b { background-image:url(/css/images/train/r-upa.jpg); }
.selected_sleep-b { background-image:url(/css/images/train/r-upa.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-c {background-image:url(/css/images/train/l-mid.jpg); background-repeat:no-repeat; width:163px; display:block; height:38px; float:left; }
a:hover.sleep-c { background-image:url(/css/images/train/l-mida.jpg); }
.selected_sleep-c { background-image:url(/css/images/train/l-mida.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-d {background-image:url(/css/images/train/r-mid.jpg); background-repeat:no-repeat; width:104px; display:block; height:38px; float:left; }
a:hover.sleep-d { background-image:url(/css/images/train/r-mida.jpg); }
.selected_sleep-d { background-image:url(/css/images/train/r-mida.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-e {background-image:url(/css/images/train/l-low.jpg); background-repeat:no-repeat; width:163px; display:block; height:38px; float:left; }
a:hover.sleep-e { background-image:url(/css/images/train/l-lowa.jpg); }
.selected_sleep-e { background-image:url(/css/images/train/l-lowa.jpg)!important; width:163px; display:block; height:38px; float:left; }
a:link.sleep-f {background-image:url(/css/images/train/r-low.jpg); background-repeat:no-repeat; width:104px; display:block; height:38px; float:left; }
a:hover.sleep-f { background-image:url(/css/images/train/r-lowa.jpg); }
.selected_sleep-f { background-image:url(/css/images/train/r-lowa.jpg)!important; width:104px; display:block; height:38px; float:left; }
</style>
<script>
$(function(){
//var selected = $('.selectticket').find('.selected').length;
//$('.selected_People').html(selected);
});
function selseat(seat){
var type = $(seat).attr('type');
var total = $(seat).parent().parent().find('.train-summary .seat_TotalPeople').html();
if(total>=5){
total = 5;
$('.seat_TotalPeople').html(total);
}
var count = $(seat).parent().parent().find('.selected').length;
console.log('执行之前的数量'+count);
//处理选座事件
if($(seat).hasClass('selected_'+type)){
$(seat).removeClass('selected');
$(seat).removeClass('selected_'+type);
count = $(seat).parent().parent().find('.selected').length;
$('.selected_People').html(count);
console.log('减掉之后'+count);
}else{
if(count >= total){
alert('You already chose seats for all the passengers.');
}else{
$(seat).addClass('selected_'+type);
$(seat).addClass('selected');
count = $(seat).parent().parent().find('.selected').length;
$('.selected_People').html(count);
console.log('增加之后'+count);
}
}
}
</script>
<div style="width:90%;margin:30px auto;">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">翰特订单号&nbsp;<a style="margin-left:50px;" target='_blank' href="<?php echo site_url('apps/trainsystem/pages/order_list');?>">订单列表>></a><a style="margin-left:50px;" target='_blank' href="<?php echo site_url('apps/trainsystem/pages/export');?>">导出交易记录>></a> <span style="margin-left:200px;">版本V2.0</span><span class="pull-right">聚合余额(RMB)<?php echo $balance;?></span></h3>
</div>
<div class="panel-body">
<form style="width: 300px;float: left;" action="/info.php/apps/trainsystem/pages/index/" method="post">
<input type="text" name="ht_order" value="<?php echo isset($cols_id)?$cols_id:""; ?>">
<button type="submit" id="sub" class="btn btn-warning btn-sm"><span class="glyphicon glyphicon-download-alt"></span> 获取信息</button>
</form>
<p style="margin: 0 0 10px; width: 200px; float: left; line-height: 30px;">外联:<span><?php if(!empty($wl)){echo $wl[0]->OPI_Name;}?></span></p>
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">火车订单信息</h3>
</div>
<div class="panel-body">
<?php if(!empty($info)):?>
<?php $num=1; foreach($info as $v):?>
<table class="table table-bordered table-hover" style="text-align:center;">
<thead>
<tr>
<th style="text-align:center;">序号</th>
<th style="text-align:center;">车次</th>
<th style="text-align:center;">座位</th>
<th style="text-align:center;">出发城市</th>
<th style="text-align:center;">抵达城市</th>
<th style="text-align:center;">发车日期</th>
<th style="text-align:center;">发车时间</th>
<th style="text-align:center;">抵达时间</th>
<th style="text-align:center;">票价</th>
<th style="text-align:center;">是否提交过</th>
<th style="text-align:center;">是否接受无座</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $num++;?></td>
<td><?php echo $v->train[0]->FlightsNo;?></td>
<td><?php echo $v->train[0]->Cabin;?></td>
<td><?php echo $v->train[0]->DepartureCity;?></td>
<td><?php echo $v->train[0]->ArrivalCity;?></td>
<td><?php echo $v->train[0]->DepartureDate;?></td>
<td><?php echo $v->train[0]->DepartureTime;?></td>
<td><?php echo $v->train[0]->ArrivalTime;?></td>
<td><?php echo $v->train[0]->adultcost;?></td>
<td><?php echo !empty($v->status)?"否":"<span style='color:green;'>是</span>";?></td>
<td><input type="checkbox" name="istanding"/></td>
</tr>
<tr>
<td colspan="11">
<table class="table table-condensed table-bordered">
<thead>
<tr>
<th style="text-align:center;"><input class="check_people" type="checkbox" /></th>
<th style="text-align:center;">序号</th>
<th style="text-align:center;">姓名</th>
<th style="text-align:center;">护照</th>
<th style="text-align:center;">年龄类型</th>
</tr>
</thead>
<tbody>
<?php foreach($v->people as $key=>$p): ?>
<tr>
<?php if ($key < 5){?>
<td><input name="" type="checkbox" checked="checked" value="<?php echo $p->BPE_SN;?>" num="<?php echo $key;?>"/></td>
<?php }else{ ?>
<td><input name="" type="checkbox" value="<?php echo $p->BPE_SN;?>" /></td>
<?php } ?>
<td><?php echo $key+1;?></td>
<td class="people_name"><?php echo $p->BPE_FirstName." ".$p->BPE_MiddleName." ".$p->BPE_LastName;?></td>
<td><?php echo $p->BPE_Passport;?></td>
<td><?php echo $p->BPE_GuestType==1?"成人":($p->BPE_GuestType==2?"儿童":"婴儿");?></td>
</tr>
<?php endforeach;?>
<tr style="text-align:;">
<td colspan="11" class="selectticket">
<?php
$traintype = substr($v->train[0]->FlightsNo,0,1);
$arr = array('C','D','G');
$sel_count = 0;
if(in_array($traintype,$arr)){
$selectseat = '';
$train_select = $v->train[0]->FOI_SelectedSeat;
$a1=$b1=$c1=$d1=$f1=$a2=$b2=$c2=$d2=$f2=false;
if($train_select){
$obj = explode(',',$train_select);
foreach($obj as $value){
switch($value){
case '1A':
$a1 = true;
$sel_count++;
break;
case '1B':
$b1 = true;
$sel_count++;
break;
case '1C':
$c1 = true;
$sel_count++;
break;
case '1D':
$d1 = true;
$sel_count++;
break;
case '1F':
$f1 = true;
$sel_count++;
break;
case '2A':
$a2 = true;
$sel_count++;
break;
case '2B':
$b2 = true;
$sel_count++;
break;
case '2C':
$c2 = true;
$sel_count++;
break;
case '2D':
$d2 = true;
$sel_count++;
break;
case '2F':
$f2 = true;
$sel_count++;
break;
}
}
}
$html = '';
$html .= '<div class="train-summary">'.$v->train[0]->Cabin.' for '.$v->train[0]->FlightsNo.' <span>(<span class="selected_People">'.$sel_count.'</span> of <span class="seat_TotalPeople">'.count($v->people).'</span> Seats)</span></div>';
$html .= '<div class="seatPick">';
if($a1){
$html .= '<a class="seat-a selected_seat-a selected" type="seat-a" href="javascript:void(0);" data="1A" onclick ="selseat(this)";></a>';
}else{
$html .= '<a class="seat-a" type="seat-a" href="javascript:void(0);" data="1A" onclick ="selseat(this)";></a>';
}
if($v->train[0]->Aircraft == 'O' || $v->train[0]->Aircraft == '8'){
if($b1){
$html .= '<a class="seat-b selected_seat-b selected" type="seat-b" href="javascript:void(0);" data="1B" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-b" type="seat-b" href="javascript:void(0);" data="1B" onclick ="selseat(this);"></a>';
}
}
if($c1){
$html .= '<a class="seat-c selected_seat-c selected" type="seat-c" href="javascript:void(0);" data="1C" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-c" type="seat-c" href="javascript:void(0);" data="1C" onclick ="selseat(this);"></a>';
}
if($v->train[0]->Aircraft != '9'){
if($d1){
$html .= '<a class="seat-d selected_seat-d selected" type="seat-d" href="javascript:void(0);" data="1D" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-d" type="seat-d" href="javascript:void(0);" data="1D" onclick ="selseat(this);"></a>';
}
}
if($f1){
$html .= '<a class="seat-f selected_seat-f selected" type="seat-f" href="javascript:void(0);" data="1F" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-f" type="seat-f" href="javascript:void(0);" data="1F" onclick ="selseat(this);"></a>';
}
$html .= '<div class="clear"></div></div>';
$html .= '<div class="seatPick">';
if($a2){
$html .= '<a class="seat-a selected_seat-a selected" type="seat-a" href="javascript:void(0);" data="2A" onclick ="selseat(this)";></a>';
}else{
$html .= '<a class="seat-a" type="seat-a" href="javascript:void(0);" data="2A" onclick ="selseat(this)";></a>';
}
if($v->train[0]->Aircraft == 'O' || $v->train[0]->Aircraft == '8'){
if($b2){
$html .= '<a class="seat-b selected_seat-b selected" type="seat-b" href="javascript:void(0);" data="2B" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-b" type="seat-b" href="javascript:void(0);" data="2B" onclick ="selseat(this);"></a>';
}
}
if($c2){
$html .= '<a class="seat-c selected_seat-c selected" type="seat-c" href="javascript:void(0);" data="2C" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-c" type="seat-c" href="javascript:void(0);" data="2C" onclick ="selseat(this);"></a>';
}
if($v->train[0]->Aircraft != '9'){
if($d2){
$html .= '<a class="seat-d selected_seat-d selected" type="seat-d" href="javascript:void(0);" data="2D" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-d" type="seat-d" href="javascript:void(0);" data="2D" onclick ="selseat(this);"></a>';
}
}
if($f2){
$html .= '<a class="seat-f selected_seat-f selected" type="seat-f" href="javascript:void(0);" data="2F" onclick ="selseat(this);"></a>';
}else{
$html .= '<a class="seat-f" type="seat-f" href="javascript:void(0);" data="2F" onclick ="selseat(this);"></a>';
}
$html .= '<div class="clear"></div></div>';
if($v->train[0]->Aircraft != 'F'){
echo $html;
}
}
?>
</td>
</tr>
<tr style="text-align:;">
<td>
<button type="button" class="btn btn-success checked_pay" data-order="<?php echo $v->train[0]->FOI_COLD_SN;?>">聚合订票</button>
</td>
<td colspan="4" class="biaoqian"><span class="back_mes" style="color:red;line-height: 30px;"></span>
</td>
</tr>
<tr style="text-align:;">
<td>
<button type="button" class="btn btn-success ctrip_pay" data-order="<?php echo $v->train[0]->FOI_COLD_SN;?>">携程订票</button>
</td>
<td colspan="4" class="biaoqian"><span class="ctrip_back_mes" style="color:red;line-height: 30px;"></span>
</td>
</tr>
<tr style="text-align:;">
<td>
<button type="button" class="btn btn-success grab_ticket" data-order="<?php echo $v->train[0]->FOI_COLD_SN;?>">抢票</button>
</td>
<td colspan="4">
<span class="grab_config"><a style="text-decoration:none;cursor:pointer;">点击打开配置清单</a></span>
<p class="grab_mes" style="color:red;line-height: 30px;"></p>
<table class="table table-condensed table-bordered grab_config_table hidden">
<tbody>
<tr>
<td colspan="2"><span style="float:left">截止时间 : <input type="text" name="deadline" class="date"/> 示例2018-03-22 17:00:00(必填)</span></td>
<td colspan="2"><span style="float:left">备选车次 : <input type="text" name="alternate_train"/> 示例:["k10","G10"]</span></td>
<td colspan="2"><span style="float:left">备选座位 : <input type="text" name="alternate_seat"/> 示例:["1","2"]</span></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr id="back_<?php echo $v->train[0]->FOI_COLD_SN;?>" style="display:none;">
<td colspan="5">
快捷订票处理结果:<span style="color:red;"></span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<?php endforeach;endif;?>
</div>
</div>
</div>
<script>
var url="<?php echo site_url('apps/train/index/submit_juhe_order?').'order=';?>";
var order_ul="<?php echo site_url('apps/train/index/order?').'order=';?>";//订单详情页面
$(".pay_api").click(function(){
// alert(url+$(this).attr("data-order"));
var THIS=$(this);
var order=$(this).attr("data-order");
var selectseat = '';
$(this).parent().parent().next().find('.selected').each(function(){
if($(this).hasClass('selected')){
selectseat += $(this).attr('data');
}
});
$.ajax({
url:url+$(this).attr("data-order")+'&selectseat='+selectseat,
beforeSend:function(data){
THIS.html("处理中...");
THIS.attr("disabled","disabled")
},
success:function(data){
THIS.removeAttr("disabled");
THIS.html("快捷订票");
if(data.status==1){
THIS.parent().html("<a href='"+order_ul+data.order+"' target='_blank'>订单详情</a>");
}
$("#back_"+order+" span").html(data.mes);
$("#back_"+order).show();
},
dataType: "json",
});
return false;
});
$(".check_people").click(function(){
if($(this).is(":checked")){
$(this).parent().parent().parent().parent().find("input[type=checkbox]").attr("checked","checked");
}else{
$(this).parent().parent().parent().parent().find("input[type=checkbox]").removeAttr("checked");
}
});
//聚合出票
$(".checked_pay").click(function(){
var url2="<?php echo site_url('apps/trainsystem/addorders/booktickets?').'order=';?>";
var checkbox=$(this).parent().parent().parent().find(":checked");
var people_sn="";
checkbox.each(function(i){
people_sn+=","+$(this).val();
});
var selectseat = '';
$(this).parent().parent().prev().find('.selected').each(function(){
if($(this).hasClass('selected')){
selectseat += $(this).attr('data');
}
});
people_sn=people_sn.substring(1);
var istanding = $('input[name="istanding"]').is(':checked');
url2+=$(this).attr("data-order")+"&people="+people_sn+"&selectseat="+selectseat+"&type=juhe&istanding="+istanding;
var THIS=$(this);
THIS.parent().parent().find(".back_mes").html(" ");//清空提示
$.ajax({
url:url2,
beforeSend:function(data){
THIS.html("处理中...");
THIS.attr("disabled","disabled");
},
success:function(data){
THIS.removeAttr("disabled");
THIS.html("聚合订票");
var str = "<a href='http://www.mycht.cn/info.php/apps/trainsystem/pages/order?order="+data.order+"' target='_blank'>"+data.mes+"</a>";
THIS.parent().parent().find(".back_mes").html(str);
},
dataType: "json",
});
return false;
});
//携程出票
$(".ctrip_pay").click(function(){
var ctrip_url="<?php echo site_url('apps/trainsystem/addorders/booktickets?').'order=';?>";
var checkbox=$(this).parent().parent().parent().find(":checked");
var people_sn="";
checkbox.each(function(i){
people_sn+=","+$(this).val();
});
var selectseat = '';
$(this).parent().parent().prev().prev().find('.selected').each(function(){
if($(this).hasClass('selected')){
selectseat += $(this).attr('data')+',';
}
});
selectseat=selectseat.substr(0,selectseat.length-1);
people_sn=people_sn.substring(1);
ctrip_url+=$(this).attr("data-order")+"&people="+people_sn+"&selectseat="+selectseat+"&type=ctrip";
var THIS=$(this);
THIS.parent().parent().find(".ctrip_back_mes").html(" ");//清空提示
$.ajax({
url:ctrip_url,
beforeSend:function(data){
THIS.html("处理中...");
THIS.attr("disabled","disabled")
},
success:function(data){
THIS.removeAttr("disabled");
THIS.html("携程订票");
var str = "<a href='http://www.mycht.cn/info.php/apps/trainsystem/pages/order?order="+data.order+"' target='_blank'>"+data.mes+"</a>";
THIS.parent().parent().find(".ctrip_back_mes").html(str);
},
dataType: "json",
});
return false;
});
//抢票清单
$('.grab_config').click(function(){
var table = $(this).next().next('.grab_config_table');
if(table.hasClass('hidden')){
table.removeClass('hidden');
}else{
table.addClass('hidden');
}
});
//开始抢票
$('.grab_ticket').click(function(){
var url2="<?php echo site_url('apps/train/tuniu_train/grabTicketBook?').'order=';?>";
var checkbox=$(this).parent().parent().parent().find(":checked");
var people_sn="";
checkbox.each(function(i){
people_sn+=","+$(this).val();
});
people_sn=people_sn.substring(1);
// var coli_id = $('input[name="ht_order"]').val();
var deadline = $(this).parent().next().find('.date').val();
var alternate_train = $('input[name="alternate_train"]').val();
var alternate_seat = $('input[name="alternate_seat"]').val();
url2+=$(this).attr("data-order")+"&people="+people_sn+"&deadline="+deadline+"&alternate_train="+alternate_train+"&alternate_seat="+alternate_seat;
var THIS=$(this);
THIS.parent().parent().find(".back_mes").html(" ");//清空提示
$.ajax({
url:url2,
beforeSend:function(data){
THIS.html("处理中...");
THIS.attr("disabled","disabled");
},
success:function(data){
THIS.removeAttr("disabled");
THIS.html("抢票");
THIS.parent().next().find(".grab_mes").html(data.mes);
},
dataType: "json",
});
return false;
});
</script>

@ -0,0 +1,64 @@
<script type="text/javascript" src="https://data.chinahighlights.com/js/train/StationInfo.js"></script>
<div style="width:90%;margin:30px auto;">
<div class="panel panel-primary" style="width:60%;margin:0 auto;">
<div class="panel-heading">
<h3 class="panel-title"><?php echo $train_date;?>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $checi;?>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo isset($elecnumber)?$elecnumber:"";?></h3>
</div>
<div class="panel-body">
<?php if((int)$status>1):?>
<p style="display:inline-block"><?php echo $from_station_name;?><span class="from_station_en"> </span><br><span class="start_time"></span></p><span class="glyphicon glyphicon-arrow-right"> </span><p style="display:inline-block"> <?php echo $to_station_name;?><span class="to_station_en"> </span><br><span class="arrive_time"></span></p>
<?php foreach ($passengers as $v):?>
<p style="border-top:1px dashed #000; height:1px;margin-top:10px;" ></p>
<p><?php echo @$v->tst_realname."({$v->tst_identitytype})&nbsp;&nbsp;&nbsp;&nbsp;{$v->tst_seatstype}&nbsp;&nbsp;{$v->tst_seatdetail}&nbsp;&nbsp;&nbsp;&nbsp;票价:¥{$v->tst_ticketprice}";?></p>
<?php endforeach;?>
<?php if((int)$status === 4):?>
<p style="border-top:1px dashed #000; height:1px;margin-top:10px;" ></p>
<p>出票成功</p>
<p style="border-top:1px dashed #000; height:1px;margin-top:10px;" ></p>
<p style="text-align:center;"><a href="refund?order=<?php echo $ordernumber?>" style="padding:5px 15px;" class="btn btn-warning btn-sm">前往退票 <span class="glyphicon glyphicon-forward"></span></a></p>
<?php endif;?>
<?php if((int)$status === 6):?>
<p style="border-top:1px dashed #000; height:1px;margin-top:10px;" ></p>
<p>正在处理退票</p>
<p style="text-align:center;"><a href="refund?order=<?php echo $ordernumber?>" style="padding:5px 15px;" class="btn btn-warning btn-sm">查看详情 <span class="glyphicon glyphicon-forward"></span></a></p>
<?php endif;?>
<?php if((int)$status === 7):?>
<p style="border-top:1px dashed #000; height:1px;margin-top:10px;" ></p>
<p><?php echo $msg;?></p>
<p style="text-align:center;"><a href="refund?order=<?php echo $ordernumber?>" style="padding:5px 15px;" class="btn btn-warning btn-sm">查看详情 <span class="glyphicon glyphicon-forward"></span></a></p>
<?php endif;?>
<?php else:?>
<p><?php echo $msg;?></p>
<?php endif;?>
</div>
</div>
</div>
<script>
var StationInfoArr = StationInfo.split("@");
var StationNameArr = new Array();
var code_name = new Array();
var station_cn_en = new Array();
var form_data = {};
for (var i = 0; i < StationInfoArr.length; ++i) {
StationNameArr.push(StationInfoArr[i].split("|"));
code_name[StationNameArr[i][1]] = [StationNameArr[i][2]];
station_cn_en[StationNameArr[i][3]] = StationNameArr[i][2];
}
console.log(station_cn_en);
$(function(){
var from_station_en = code_name['<?php echo $from_station_code?>'];
var to_station_en = code_name['<?php echo $to_station_code?>'];
var start_date = '<?php echo $train_date?>';
var start_time = '<?php echo $start_time?>';
var arrive_time = '<?php echo $arrive_time?>';
//console.log(code_name);
$('.from_station_en').html('('+from_station_en+') ');
$('.to_station_en').html('('+to_station_en+')');
$('.start_time').html('('+start_date+' '+start_time+')');
$('.arrive_time').html('('+start_date+' '+arrive_time+')');
});
</script>

@ -0,0 +1,101 @@
<div style="width:90%;margin:30px auto;">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">订单搜索</h3>
</div>
<div class="panel-body">
<div class="row">
<form style="" action="" method="get">
<div class="col-md-6">
<input class="form-control" type="text" placeholder="汉特订单号或聚合订单号" name="order" value="<?php echo !empty($order)?"$order":"";?>" autocomplete="off">
</div>
<div class="col-md-4">
<select class="form-control" name="web_code">
<option value ="分站点查询,默认商旅" disabled="disabled" selected>分站点查询,默认全站</option>
<option value ="CHT">商旅</option>
<option value ="jp">日本</option>
<option value="train_vac">西班牙</option>
<option value="train_it">意大利</option>
<option value="train_ru">俄罗斯</option>
<option value="train_vc">法国</option>
</select>
</div>
<!--<div class="col-md-5">
<input type="text" name="from_date" class="date" value="" class="">
<input type="text" name="to_date" class="date" value="">
</div>-->
<div class="col-md-5">
<button type="submit" id="sub" class="btn btn-success btn-sm"><span class="glyphicon glyphicon-search"></span> 搜索</button>
</div>
</form>
</div>
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">订单列表</h3>
</div>
<div class="panel-body">
<table class="table table-striped" style="text-align:center;">
<thead>
<tr>
<th style="text-align:center;">序号</th>
<th style="text-align:center;">汉特订单号(商家订单号)</th>
<th style="text-align:center;">聚合订单号</th>
<th style="text-align:center;">车次</th>
<th style="text-align:center;">出发</th>
<th style="text-align:center;">到达</th>
<th style="text-align:center;">状态</th>
<th style="text-align:center;">价格</th>
<th style="text-align:center;">提交时间</th>
<th style="text-align:center;">所属部门</th>
<th style="text-align:center;">渠道</th>
<th style="text-align:center;">出票方式</th>
<th style="text-align:center;">是否发送邮件</th>
<th style="text-align:center;">操作</th>
</tr>
</thead>
<tbody>
<?php $num=0; foreach($data as $v):?>
<tr>
<td><?php echo ++$num;?></td>
<td><?php echo $v->COLI_ID.'('.$v->ts_cold_sn.')';?></td>
<td><?php echo $v->ts_ordernumber;?></td>
<td><?php echo $v->ts_checi;?></td>
<td><?php echo $v->ts_fromstationame;?></td>
<td><?php echo $v->ts_tostationame;?></td>
<td><?php echo $v->info;?></td>
<td><?php echo $v->ts_orderamount;?></td>
<td><?php echo $v->ts_subtime;?></td>
<td><?php echo $v->COLI_WebCode;?></td>
<td><?php echo $v->ts_channel;?></td>
<?php
if($v->ts_isauto == 1){
echo '<td>自动</td>';
}elseif($v->ts_isauto == 0){
echo '<td>手动</td>';
}elseif($v->ts_isauto == 3){
echo '<td>抢票</td>';
}
?>
<?php
if($v->ts_sendmail == 1){
if($v->ts_m_sn){
echo '<td><a target="_blank" href="http://www.mycht.cn/info.php/apps/train/index/get_mailinfo/'.$v->ts_m_sn.'"></a></td>';
}else{
echo '<td></td>';
}
}else{
echo '<td></td>';
}
?>
<td><a target="_blank" href="order?order=<?php echo $v->ts_ordernumber;?>">详情</a></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<div style="text-align:right;"><ul class="pagination"><?php echo $page_link;?></ul></div>
</div>
</div>
</div>

@ -0,0 +1,48 @@
<div style="width:90%;margin:30px auto;">
<div class="panel panel-primary" style="width:60%;margin:0 auto;">
<div class="panel-heading">
<h3 class="panel-title"><?php echo $train_date;?>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $checi;?>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo isset($elecnumber)?$elecnumber:"";?></h3>
</div>
<div class="panel-body">
<?php
foreach ($passengers as $items){
echo '<p>'.$from_station_name.'<span class="glyphicon glyphicon-arrow-right"></span>'.$to_station_name.'</p>';
echo '<p style="border-top:1px dashed #000; height:1px;margin-top:10px;" ></p>';
echo '<p>'.$items->tst_realname.'('.$items->tst_ticketype.')&nbsp;&nbsp;&nbsp;&nbsp;'.$items->tst_seatstype.'&nbsp;&nbsp;'.$items->tst_seatdetail.'&nbsp;&nbsp;&nbsp;&nbsp;票价:¥'.$items->tst_ticketprice.'</p>';
if((int)$items->tst_status != 7){
echo '<p>';
echo '<a href="###" style="padding:5px 15px;" class="btn btn-warning btn-sm returnticket" name="'.$items->tst_realname.'" passid="'.$items->tst_numberid.'"><span class="glyphicon glyphicon-remove"></span>退票</a>';
echo '</p>';
}else{
$info = json_decode($items->tst_returncallback);
echo '<p><table class="table table-bordered table-hover" style="text-align:center;"><tr><th colspan="2" style="text-align:center;">退票处理</th></tr>';
echo '<tr><td>'.$items->tst_lasteditdate.'</td>';
echo '<tr><td>'.$msg.'</td></tr></table></p>';
}
}?>
</div>
</div>
</div>
<script>
$(function(){
$('.returnticket').click(function(){
var url = <?php echo "'http://www.mycht.cn/info.php/apps/trainsystem/returnorders/returntickets?ordernumber=$ordernumber'"?>;
var return_ticket = $(this);
name = $(this).attr('name');
passid = $(this).attr('passid');
url += '&passportname='+name+'&passportno='+passid+'&usercenter=no';
//console.log(url);return false;
$.ajax({
url:url,
success:function(json){
alert('请求成功,正在处理退票...');
return_ticket.html('退票成功');
},
error:function(json){
alert('请求失败,请重新请求...');
return_ticket.html('退票失败');
}
});
});
});
</script>

@ -0,0 +1,178 @@
<?xml version="1.0" encoding="utf-8"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>c21</Author>
<LastAuthor>c21</LastAuthor>
<Created>2016-12-23T01:21:46Z</Created>
<LastSaved>2016-12-23T01:38:10Z</LastSaved>
<Version>12.00</Version>
</DocumentProperties>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>9630</WindowHeight>
<WindowWidth>21555</WindowWidth>
<WindowTopX>0</WindowTopX>
<WindowTopY>90</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Center"/>
<Borders/>
<Font ss:FontName="宋体" x:CharSet="134" ss:Size="11" ss:Color="#000000"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="m58993952">
<Alignment ss:Horizontal="Right" ss:Vertical="Center" ss:WrapText="1"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
<Font ss:FontName="微软雅黑" x:CharSet="134" x:Family="Swiss" ss:Size="11"
ss:Color="#000000"/>
</Style>
<Style ss:ID="m58993972">
<Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
<Font ss:FontName="微软雅黑" x:CharSet="134" x:Family="Swiss" ss:Size="20"
ss:Color="#000000" ss:Bold="1"/>
</Style>
<Style ss:ID="m58993992">
<Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
<Font ss:FontName="微软雅黑" x:CharSet="134" x:Family="Swiss" ss:Size="11"
ss:Color="#000000"/>
</Style>
<Style ss:ID="s78">
<Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
<Font ss:FontName="微软雅黑" x:CharSet="134" x:Family="Swiss" ss:Color="#000000"/>
</Style>
<Style ss:ID="s79">
<Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
<Borders>
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
</Borders>
<Font ss:FontName="微软雅黑" x:CharSet="134" x:Family="Swiss" ss:Color="#000000"/>
<NumberFormat ss:Format="General Date"/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<?php $num=count($arr);?>
<Table ss:ExpandedColumnCount="6" ss:ExpandedRowCount="<?php echo $num+6;?>" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="13.5">
<Column ss:AutoFitWidth="0" ss:Width="115.5"/>
<Column ss:AutoFitWidth="0" ss:Width="111"/>
<Column ss:AutoFitWidth="0" ss:Width="111"/>
<Column ss:AutoFitWidth="0" ss:Width="100.5"/>
<Column ss:AutoFitWidth="0" ss:Width="62.25"/>
<Column ss:AutoFitWidth="0" ss:Width="203.25"/>
<Row ss:AutoFitHeight="0">
<Cell ss:MergeAcross="5" ss:MergeDown="1" ss:StyleID="m58993952"><Data
ss:Type="String">苏州新科兰德科技有限公司&#10;地址苏州市园区启月街288号紫金东方307室&#10;联系电话051262391880&#10;开户银行:浙商银行苏州分行&#10;公司名称:苏州新科兰德科技有限公司&#10;银行账号3050020010120100129207&#10;跟踪号:<?php echo $arr[0]['trackcode'];?></Data></Cell>
</Row>
<Row ss:AutoFitHeight="0" ss:Height="99.75"/>
<Row ss:AutoFitHeight="0" ss:Height="42">
<Cell ss:MergeAcross="5" ss:StyleID="m58993972"><Data ss:Type="String">桂林海纳国际旅行社有限公司火车票对账文件</Data></Cell>
</Row>
<Row ss:AutoFitHeight="0" ss:Height="16.5">
<Cell ss:StyleID="s78"><Data ss:Type="String">时间</Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String">信息</Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String">购票人</Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String">团名</Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String">变化值</Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String">最新余额</Data></Cell>
</Row>
<?php for($i=$num-1;$i>=0;$i--){?>
<Row ss:AutoFitHeight="0" ss:Height="16.5">
<Cell ss:StyleID="s79"><Data ss:Type="String"><?php echo $arr[$i][2];?></Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String"><?php echo $arr[$i][3];?></Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String"><?php echo $arr[$i][7];?></Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="String"><?php echo $arr[$i][6];?></Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="Number"><?php echo $arr[$i][1];?></Data></Cell>
<Cell ss:StyleID="s78"><Data ss:Type="Number"><?php echo $arr[$i][5];?></Data></Cell>
</Row>
<?php }?>
<Row ss:AutoFitHeight="0" ss:Height="36">
<Cell ss:MergeAcross="5" ss:StyleID="m58993992"><Data ss:Type="String">苏州新科兰德科技有限公司©版权所有 苏ICP备14006450号-3 增值电信业务经营许可证苏B2-20140496</Data></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Unsynced/>
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>4</ActiveRow>
<ActiveCol>4</ActiveCol>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name="Sheet2">
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="13.5">
<Row ss:AutoFitHeight="0"/>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Unsynced/>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
<Worksheet ss:Name="Sheet3">
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="13.5">
<Row ss:AutoFitHeight="0"/>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Unsynced/>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>

@ -17,7 +17,11 @@ $config['tripadvisor_website'] = array(
'Lijiang' => 'http://www.tripadvisor.com/Attraction_Review-g303783-d8464335-Reviews{PAGENUM}China_Highlights_Lijiang-Lijiang_Yunnan.html',
'Zhangjiajie' => 'http://www.tripadvisor.com/Attraction_Review-g494933-d8077695-Reviews{PAGENUM}China_Highlights_Zhangjiajie_Day_Tour-Zhangjiajie_Hunan.html',
'HongKong' => 'https://www.tripadvisor.com/Attraction_Review-g294217-d10243951-Reviews{PAGENUM}China_Highlights_Hong_Kong-Hong_Kong.html',
'Panda' => 'https://www.tripadvisor.com/Attraction_Review-g297463-d11489225-Reviews{PAGENUM}China_Highlights-Chengdu_Sichuan.html'
'Panda' => 'https://www.tripadvisor.com/Attraction_Review-g297463-d11489225-Reviews{PAGENUM}China_Highlights-Chengdu_Sichuan.html',
'tp_Beijing' => 'https://www.tripadvisor.com/Attraction_Review-g294212-d4006739-Reviews-The_Trippest_Mini_Group_Tours-Beijing.html',
'tp_Xian' => 'https://www.tripadvisor.com/Attraction_Review-g298557-d10999897-Reviews-Xi_an_Trippest_Mini_Group_Tours-Xi_an_Shaanxi.html',
'tp_Shanghai' => 'https://www.tripadvisor.com/Attraction_Review-g308272-d6222868-Reviews-Shanghai_Trippest_Mini_Group_Tours-Shanghai.html',
'tp_Guilin' => 'https://www.tripadvisor.com/Attraction_Review-g298556-d14121459-Reviews-Trippest_Mini_Group_Tours-Guilin_Guangxi.html'
);

File diff suppressed because it is too large Load Diff

@ -0,0 +1,81 @@
<?php
PHPExcel_Autoloader::register();
// As we always try to run the autoloader before anything else, we can use it to do a few
// simple checks and initialisations
//PHPExcel_Shared_ZipStreamWrapper::register();
// check mbstring.func_overload
if (ini_get('mbstring.func_overload') & 2) {
throw new PHPExcel_Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
}
PHPExcel_Shared_String::buildCharacterSets();
/**
* PHPExcel
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Autoloader
{
/**
* Register the Autoloader with SPL
*
*/
public static function register()
{
if (function_exists('__autoload')) {
// Register any existing autoloader function with SPL, so we don't get any clashes
spl_autoload_register('__autoload');
}
// Register ourselves with SPL
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
return spl_autoload_register(array('PHPExcel_Autoloader', 'load'), true, true);
} else {
return spl_autoload_register(array('PHPExcel_Autoloader', 'load'));
}
}
/**
* Autoload a class identified by name
*
* @param string $pClassName Name of the object to load
*/
public static function load($pClassName)
{
if ((class_exists($pClassName, false)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
// Either already loaded, or not a PHPExcel class request
return false;
}
$pClassFilePath = PHPEXCEL_ROOT .
str_replace('_', DIRECTORY_SEPARATOR, $pClassName) .
'.php';
if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
// Can't load
return false;
}
require($pClassFilePath);
}
}

@ -0,0 +1,290 @@
<?php
/**
* PHPExcel_CachedObjectStorage_APC
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Prefix used to uniquely identify cache data for this worksheet
*
* @access private
* @var string
*/
private $cachePrefix = null;
/**
* Cache timeout
*
* @access private
* @var integer
*/
private $cacheTime = 600;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @access private
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
if (!apc_store(
$this->cachePrefix . $this->currentObjectID . '.cache',
serialize($this->currentObject),
$this->cacheTime
)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell ' . $this->currentObjectID . ' in APC');
}
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
/**
* Add or Update a cell in cache identified by coordinate address
*
* @access public
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->cellCache[$pCoord] = true;
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
}
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @access public
* @param string $pCoord Coordinate address of the cell to check
* @throws PHPExcel_Exception
* @return boolean
*/
public function isDataSet($pCoord)
{
// Check if the requested entry is the current object, or exists in the cache
if (parent::isDataSet($pCoord)) {
if ($this->currentObjectID == $pCoord) {
return true;
}
// Check if the requested entry still exists in apc
$success = apc_fetch($this->cachePrefix.$pCoord.'.cache');
if ($success === false) {
// Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
}
return true;
}
return false;
}
/**
* Get cell at a specific coordinate
*
* @access public
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
// Check if the entry that has been requested actually exists
if (parent::isDataSet($pCoord)) {
$obj = apc_fetch($this->cachePrefix . $pCoord . '.cache');
if ($obj === false) {
// Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
}
} else {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
$this->currentObject = unserialize($obj);
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
return parent::getCellList();
}
/**
* Delete a cell in cache identified by coordinate address
*
* @access public
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord)
{
// Delete the entry from APC
apc_delete($this->cachePrefix.$pCoord.'.cache');
// Delete the entry from our cell address array
parent::deleteCacheData($pCoord);
}
/**
* Clone the cell collection
*
* @access public
* @param PHPExcel_Worksheet $parent The new worksheet
* @throws PHPExcel_Exception
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
parent::copyCellCollection($parent);
// Get a new id for the new file name
$baseUnique = $this->getUniqueID();
$newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
$cacheList = $this->getCellList();
foreach ($cacheList as $cellID) {
if ($cellID != $this->currentObjectID) {
$obj = apc_fetch($this->cachePrefix . $cellID . '.cache');
if ($obj === false) {
// Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($cellID);
throw new PHPExcel_Exception('Cell entry ' . $cellID . ' no longer exists in APC');
}
if (!apc_store($newCachePrefix . $cellID . '.cache', $obj, $this->cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell ' . $cellID . ' in APC');
}
}
}
$this->cachePrefix = $newCachePrefix;
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells()
{
if ($this->currentObject !== null) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
// Flush the APC cache
$this->__destruct();
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
}
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments
*/
public function __construct(PHPExcel_Worksheet $parent, $arguments)
{
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
if ($this->cachePrefix === null) {
$baseUnique = $this->getUniqueID();
$this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
$this->cacheTime = $cacheTime;
parent::__construct($parent);
}
}
/**
* Destroy this cell collection
*/
public function __destruct()
{
$cacheList = $this->getCellList();
foreach ($cacheList as $cellID) {
apc_delete($this->cachePrefix . $cellID . '.cache');
}
}
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable()
{
if (!function_exists('apc_store')) {
return false;
}
if (apc_sma_info() === false) {
return false;
}
return true;
}
}

@ -0,0 +1,368 @@
<?php
/**
* PHPExcel_CachedObjectStorage_CacheBase
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
abstract class PHPExcel_CachedObjectStorage_CacheBase
{
/**
* Parent worksheet
*
* @var PHPExcel_Worksheet
*/
protected $parent;
/**
* The currently active Cell
*
* @var PHPExcel_Cell
*/
protected $currentObject = null;
/**
* Coordinate address of the currently active Cell
*
* @var string
*/
protected $currentObjectID = null;
/**
* Flag indicating whether the currently active Cell requires saving
*
* @var boolean
*/
protected $currentCellIsDirty = true;
/**
* An array of cells or cell pointers for the worksheet cells held in this cache,
* and indexed by their coordinate address within the worksheet
*
* @var array of mixed
*/
protected $cellCache = array();
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
*/
public function __construct(PHPExcel_Worksheet $parent)
{
// Set our parent worksheet.
// This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
// they are woken from a serialized state
$this->parent = $parent;
}
/**
* Return the parent worksheet for this cell collection
*
* @return PHPExcel_Worksheet
*/
public function getParent()
{
return $this->parent;
}
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return true;
}
// Check if the requested entry exists in the cache
return isset($this->cellCache[$pCoord]);
}
/**
* Move a cell object from one address to another
*
* @param string $fromAddress Current address of the cell to move
* @param string $toAddress Destination address of the cell to move
* @return boolean
*/
public function moveCell($fromAddress, $toAddress)
{
if ($fromAddress === $this->currentObjectID) {
$this->currentObjectID = $toAddress;
}
$this->currentCellIsDirty = true;
if (isset($this->cellCache[$fromAddress])) {
$this->cellCache[$toAddress] = &$this->cellCache[$fromAddress];
unset($this->cellCache[$fromAddress]);
}
return true;
}
/**
* Add or Update a cell in cache
*
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function updateCacheData(PHPExcel_Cell $cell)
{
return $this->addCacheData($cell->getCoordinate(), $cell);
}
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID && !is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObjectID = $this->currentObject = null;
}
if (is_object($this->cellCache[$pCoord])) {
$this->cellCache[$pCoord]->detach();
unset($this->cellCache[$pCoord]);
}
$this->currentCellIsDirty = false;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
return array_keys($this->cellCache);
}
/**
* Sort the list of all cell addresses currently held in cache by row and column
*
* @return string[]
*/
public function getSortedCellList()
{
$sortKeys = array();
foreach ($this->getCellList() as $coord) {
sscanf($coord, '%[A-Z]%d', $column, $row);
$sortKeys[sprintf('%09d%3s', $row, $column)] = $coord;
}
ksort($sortKeys);
return array_values($sortKeys);
}
/**
* Get highest worksheet column and highest row that have cell records
*
* @return array Highest column name and highest row number
*/
public function getHighestRowAndColumn()
{
// Lookup highest column and highest row
$col = array('A' => '1A');
$row = array(1);
foreach ($this->getCellList() as $coord) {
sscanf($coord, '%[A-Z]%d', $c, $r);
$row[$r] = $r;
$col[$c] = strlen($c).$c;
}
if (!empty($row)) {
// Determine highest column and row
$highestRow = max($row);
$highestColumn = substr(max($col), 1);
}
return array(
'row' => $highestRow,
'column' => $highestColumn
);
}
/**
* Return the cell address of the currently active cell object
*
* @return string
*/
public function getCurrentAddress()
{
return $this->currentObjectID;
}
/**
* Return the column address of the currently active cell object
*
* @return string
*/
public function getCurrentColumn()
{
sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
return $column;
}
/**
* Return the row address of the currently active cell object
*
* @return integer
*/
public function getCurrentRow()
{
sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
return (integer) $row;
}
/**
* Get highest worksheet column
*
* @param string $row Return the highest column for the specified row,
* or the highest column of any row if no row number is passed
* @return string Highest column name
*/
public function getHighestColumn($row = null)
{
if ($row == null) {
$colRow = $this->getHighestRowAndColumn();
return $colRow['column'];
}
$columnList = array(1);
foreach ($this->getCellList() as $coord) {
sscanf($coord, '%[A-Z]%d', $c, $r);
if ($r != $row) {
continue;
}
$columnList[] = PHPExcel_Cell::columnIndexFromString($c);
}
return PHPExcel_Cell::stringFromColumnIndex(max($columnList) - 1);
}
/**
* Get highest worksheet row
*
* @param string $column Return the highest row for the specified column,
* or the highest row of any column if no column letter is passed
* @return int Highest row number
*/
public function getHighestRow($column = null)
{
if ($column == null) {
$colRow = $this->getHighestRowAndColumn();
return $colRow['row'];
}
$rowList = array(0);
foreach ($this->getCellList() as $coord) {
sscanf($coord, '%[A-Z]%d', $c, $r);
if ($c != $column) {
continue;
}
$rowList[] = $r;
}
return max($rowList);
}
/**
* Generate a unique ID for cache referencing
*
* @return string Unique Reference
*/
protected function getUniqueID()
{
if (function_exists('posix_getpid')) {
$baseUnique = posix_getpid();
} else {
$baseUnique = mt_rand();
}
return uniqid($baseUnique, true);
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
$this->currentCellIsDirty;
$this->storeData();
$this->parent = $parent;
if (($this->currentObject !== null) && (is_object($this->currentObject))) {
$this->currentObject->attach($this);
}
} // function copyCellCollection()
/**
* Remove a row, deleting all cells in that row
*
* @param string $row Row number to remove
* @return void
*/
public function removeRow($row)
{
foreach ($this->getCellList() as $coord) {
sscanf($coord, '%[A-Z]%d', $c, $r);
if ($r == $row) {
$this->deleteCacheData($coord);
}
}
}
/**
* Remove a column, deleting all cells in that column
*
* @param string $column Column ID to remove
* @return void
*/
public function removeColumn($column)
{
foreach ($this->getCellList() as $coord) {
sscanf($coord, '%[A-Z]%d', $c, $r);
if ($c == $column) {
$this->deleteCacheData($coord);
}
}
}
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable()
{
return true;
}
}

@ -0,0 +1,208 @@
<?php
/**
* PHPExcel_CachedObjectStorage_DiscISAM
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Name of the file for this cache
*
* @var string
*/
private $fileName = null;
/**
* File handle for this cache file
*
* @var resource
*/
private $fileHandle = null;
/**
* Directory/Folder where the cache file is located
*
* @var string
*/
private $cacheDirectory = null;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
fseek($this->fileHandle, 0, SEEK_END);
$this->cellCache[$this->currentObjectID] = array(
'ptr' => ftell($this->fileHandle),
'sz' => fwrite($this->fileHandle, serialize($this->currentObject))
);
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
fseek($this->fileHandle, $this->cellCache[$pCoord]['ptr']);
$this->currentObject = unserialize(fread($this->fileHandle, $this->cellCache[$pCoord]['sz']));
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
return parent::getCellList();
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
*/
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
parent::copyCellCollection($parent);
// Get a new id for the new file name
$baseUnique = $this->getUniqueID();
$newFileName = $this->cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
// Copy the existing cell cache file
copy($this->fileName, $newFileName);
$this->fileName = $newFileName;
// Open the copied cell cache file
$this->fileHandle = fopen($this->fileName, 'a+');
}
/**
* Clear the cell collection and disconnect from our parent
*
*/
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
// Close down the temporary cache file
$this->__destruct();
}
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments
*/
public function __construct(PHPExcel_Worksheet $parent, $arguments)
{
$this->cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== null))
? $arguments['dir']
: PHPExcel_Shared_File::sys_get_temp_dir();
parent::__construct($parent);
if (is_null($this->fileHandle)) {
$baseUnique = $this->getUniqueID();
$this->fileName = $this->cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
$this->fileHandle = fopen($this->fileName, 'a+');
}
}
/**
* Destroy this cell collection
*/
public function __destruct()
{
if (!is_null($this->fileHandle)) {
fclose($this->fileHandle);
unlink($this->fileName);
}
$this->fileHandle = null;
}
}

@ -0,0 +1,103 @@
<?php
/**
* PHPExcel_CachedObjectStorage_ICache
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
interface PHPExcel_CachedObjectStorage_ICache
{
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell);
/**
* Add or Update a cell in cache
*
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function updateCacheData(PHPExcel_Cell $cell);
/**
* Fetch a cell from cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to retrieve
* @return PHPExcel_Cell Cell that was found, or null if not found
* @throws PHPExcel_Exception
*/
public function getCacheData($pCoord);
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord);
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord);
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList();
/**
* Get the list of all cell addresses currently held in cache sorted by column and row
*
* @return string[]
*/
public function getSortedCellList();
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent);
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable();
}

@ -0,0 +1,149 @@
<?php
/**
* PHPExcel_CachedObjectStorage_Igbinary
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
$this->cellCache[$this->currentObjectID] = igbinary_serialize($this->currentObject);
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
$this->currentObject = igbinary_unserialize($this->cellCache[$pCoord]);
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
} // function getCacheData()
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
return parent::getCellList();
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
} // function unsetWorksheetCells()
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable()
{
if (!function_exists('igbinary_serialize')) {
return false;
}
return true;
}
}

@ -0,0 +1,308 @@
<?php
/**
* PHPExcel_CachedObjectStorage_Memcache
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Prefix used to uniquely identify cache data for this worksheet
*
* @var string
*/
private $cachePrefix = null;
/**
* Cache timeout
*
* @var integer
*/
private $cacheTime = 600;
/**
* Memcache interface
*
* @var resource
*/
private $memcache = null;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
$obj = serialize($this->currentObject);
if (!$this->memcache->replace($this->cachePrefix . $this->currentObjectID . '.cache', $obj, null, $this->cacheTime)) {
if (!$this->memcache->add($this->cachePrefix . $this->currentObjectID . '.cache', $obj, null, $this->cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception("Failed to store cell {$this->currentObjectID} in MemCache");
}
}
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->cellCache[$pCoord] = true;
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
} // function addCacheData()
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
* @return boolean
*/
public function isDataSet($pCoord)
{
// Check if the requested entry is the current object, or exists in the cache
if (parent::isDataSet($pCoord)) {
if ($this->currentObjectID == $pCoord) {
return true;
}
// Check if the requested entry still exists in Memcache
$success = $this->memcache->get($this->cachePrefix.$pCoord.'.cache');
if ($success === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
}
return true;
}
return false;
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
// Check if the entry that has been requested actually exists
if (parent::isDataSet($pCoord)) {
$obj = $this->memcache->get($this->cachePrefix . $pCoord . '.cache');
if ($obj === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception("Cell entry {$pCoord} no longer exists in MemCache");
}
} else {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
$this->currentObject = unserialize($obj);
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
return parent::getCellList();
}
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord)
{
// Delete the entry from Memcache
$this->memcache->delete($this->cachePrefix . $pCoord . '.cache');
// Delete the entry from our cell address array
parent::deleteCacheData($pCoord);
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
parent::copyCellCollection($parent);
// Get a new id for the new file name
$baseUnique = $this->getUniqueID();
$newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
$cacheList = $this->getCellList();
foreach ($cacheList as $cellID) {
if ($cellID != $this->currentObjectID) {
$obj = $this->memcache->get($this->cachePrefix.$cellID.'.cache');
if ($obj === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($cellID);
throw new PHPExcel_Exception("Cell entry {$cellID} no longer exists in MemCache");
}
if (!$this->memcache->add($newCachePrefix . $cellID . '.cache', $obj, null, $this->cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception("Failed to store cell {$cellID} in MemCache");
}
}
}
$this->cachePrefix = $newCachePrefix;
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
// Flush the Memcache cache
$this->__destruct();
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
}
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments
*/
public function __construct(PHPExcel_Worksheet $parent, $arguments)
{
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
if (is_null($this->cachePrefix)) {
$baseUnique = $this->getUniqueID();
$this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
// Set a new Memcache object and connect to the Memcache server
$this->memcache = new Memcache();
if (!$this->memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) {
throw new PHPExcel_Exception("Could not connect to MemCache server at {$memcacheServer}:{$memcachePort}");
}
$this->cacheTime = $cacheTime;
parent::__construct($parent);
}
}
/**
* Memcache error handler
*
* @param string $host Memcache server
* @param integer $port Memcache port
* @throws PHPExcel_Exception
*/
public function failureCallback($host, $port)
{
throw new PHPExcel_Exception("memcache {$host}:{$port} failed");
}
/**
* Destroy this cell collection
*/
public function __destruct()
{
$cacheList = $this->getCellList();
foreach ($cacheList as $cellID) {
$this->memcache->delete($this->cachePrefix.$cellID . '.cache');
}
}
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable()
{
if (!function_exists('memcache_add')) {
return false;
}
return true;
}
}

@ -0,0 +1,118 @@
<?php
/**
* PHPExcel_CachedObjectStorage_Memory
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Dummy method callable from CacheBase, but unused by Memory cache
*
* @return void
*/
protected function storeData()
{
}
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
$this->cellCache[$pCoord] = $cell;
// Set current entry to the new/updated entry
$this->currentObjectID = $pCoord;
return $cell;
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
// Check if the entry that has been requested actually exists
if (!isset($this->cellCache[$pCoord])) {
$this->currentObjectID = null;
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
// Return requested entry
return $this->cellCache[$pCoord];
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
*/
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
parent::copyCellCollection($parent);
$newCollection = array();
foreach ($this->cellCache as $k => &$cell) {
$newCollection[$k] = clone $cell;
$newCollection[$k]->attach($this);
}
$this->cellCache = $newCollection;
}
/**
* Clear the cell collection and disconnect from our parent
*
*/
public function unsetWorksheetCells()
{
// Because cells are all stored as intact objects in memory, we need to detach each one from the parent
foreach ($this->cellCache as $k => &$cell) {
$cell->detach();
$this->cellCache[$k] = null;
}
unset($cell);
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
}
}

@ -0,0 +1,133 @@
<?php
/**
* PHPExcel_CachedObjectStorage_MemoryGZip
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
$this->cellCache[$this->currentObjectID] = gzdeflate(serialize($this->currentObject));
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
$this->currentObject = unserialize(gzinflate($this->cellCache[$pCoord]));
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
return parent::getCellList();
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
}
}

@ -0,0 +1,129 @@
<?php
/**
* PHPExcel_CachedObjectStorage_MemorySerialized
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
$this->cellCache[$this->currentObjectID] = serialize($this->currentObject);
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
$this->currentObject = unserialize($this->cellCache[$pCoord]);
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
return parent::getCellList();
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
}
}

@ -0,0 +1,200 @@
<?php
/**
* PHPExcel_CachedObjectStorage_PHPTemp
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Name of the file for this cache
*
* @var string
*/
private $fileHandle = null;
/**
* Memory limit to use before reverting to file cache
*
* @var integer
*/
private $memoryCacheSize = null;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
fseek($this->fileHandle, 0, SEEK_END);
$this->cellCache[$this->currentObjectID] = array(
'ptr' => ftell($this->fileHandle),
'sz' => fwrite($this->fileHandle, serialize($this->currentObject))
);
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
fseek($this->fileHandle, $this->cellCache[$pCoord]['ptr']);
$this->currentObject = unserialize(fread($this->fileHandle, $this->cellCache[$pCoord]['sz']));
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
return parent::getCellList();
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
parent::copyCellCollection($parent);
// Open a new stream for the cell cache data
$newFileHandle = fopen('php://temp/maxmemory:' . $this->memoryCacheSize, 'a+');
// Copy the existing cell cache data to the new stream
fseek($this->fileHandle, 0);
while (!feof($this->fileHandle)) {
fwrite($newFileHandle, fread($this->fileHandle, 1024));
}
$this->fileHandle = $newFileHandle;
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
// Close down the php://temp file
$this->__destruct();
}
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments
*/
public function __construct(PHPExcel_Worksheet $parent, $arguments)
{
$this->memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB';
parent::__construct($parent);
if (is_null($this->fileHandle)) {
$this->fileHandle = fopen('php://temp/maxmemory:' . $this->memoryCacheSize, 'a+');
}
}
/**
* Destroy this cell collection
*/
public function __destruct()
{
if (!is_null($this->fileHandle)) {
fclose($this->fileHandle);
}
$this->fileHandle = null;
}
}

@ -0,0 +1,307 @@
<?php
/**
* PHPExcel_CachedObjectStorage_SQLite
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Database table name
*
* @var string
*/
private $TableName = null;
/**
* Database handle
*
* @var resource
*/
private $DBHandle = null;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
if (!$this->DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->TableName." VALUES('".$this->currentObjectID."','".sqlite_escape_string(serialize($this->currentObject))."')")) {
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
}
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
$query = "SELECT value FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
$cellResultSet = $this->DBHandle->query($query, SQLITE_ASSOC);
if ($cellResultSet === false) {
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
} elseif ($cellResultSet->numRows() == 0) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
$cellResult = $cellResultSet->fetchSingle();
$this->currentObject = unserialize($cellResult);
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
}
/**
* Is a value set for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return true;
}
// Check if the requested entry exists in the cache
$query = "SELECT id FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
$cellResultSet = $this->DBHandle->query($query, SQLITE_ASSOC);
if ($cellResultSet === false) {
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
} elseif ($cellResultSet->numRows() == 0) {
// Return null if requested entry doesn't exist in cache
return false;
}
return true;
}
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
$this->currentObject->detach();
$this->currentObjectID = $this->currentObject = null;
}
// Check if the requested entry exists in the cache
$query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
if (!$this->DBHandle->queryExec($query)) {
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
}
$this->currentCellIsDirty = false;
}
/**
* Move a cell object from one address to another
*
* @param string $fromAddress Current address of the cell to move
* @param string $toAddress Destination address of the cell to move
* @return boolean
*/
public function moveCell($fromAddress, $toAddress)
{
if ($fromAddress === $this->currentObjectID) {
$this->currentObjectID = $toAddress;
}
$query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$toAddress."'";
$result = $this->DBHandle->exec($query);
if ($result === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
$query = "UPDATE kvp_".$this->TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
$result = $this->DBHandle->exec($query);
if ($result === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
return true;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
$query = "SELECT id FROM kvp_".$this->TableName;
$cellIdsResult = $this->DBHandle->unbufferedQuery($query, SQLITE_ASSOC);
if ($cellIdsResult === false) {
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
}
$cellKeys = array();
foreach ($cellIdsResult as $row) {
$cellKeys[] = $row['id'];
}
return $cellKeys;
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
$this->currentCellIsDirty;
$this->storeData();
// Get a new id for the new table name
$tableName = str_replace('.', '_', $this->getUniqueID());
if (!$this->DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
AS SELECT * FROM kvp_'.$this->TableName)
) {
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
}
// Copy the existing cell cache file
$this->TableName = $tableName;
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
// Close down the temporary cache file
$this->__destruct();
}
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
*/
public function __construct(PHPExcel_Worksheet $parent)
{
parent::__construct($parent);
if (is_null($this->DBHandle)) {
$this->TableName = str_replace('.', '_', $this->getUniqueID());
$_DBName = ':memory:';
$this->DBHandle = new SQLiteDatabase($_DBName);
if ($this->DBHandle === false) {
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
}
if (!$this->DBHandle->queryExec('CREATE TABLE kvp_'.$this->TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) {
throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
}
}
}
/**
* Destroy this cell collection
*/
public function __destruct()
{
if (!is_null($this->DBHandle)) {
$this->DBHandle->queryExec('DROP TABLE kvp_'.$this->TableName);
}
$this->DBHandle = null;
}
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable()
{
if (!function_exists('sqlite_open')) {
return false;
}
return true;
}
}

@ -0,0 +1,346 @@
<?php
/**
* PHPExcel_CachedObjectStorage_SQLite3
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Database table name
*
* @var string
*/
private $TableName = null;
/**
* Database handle
*
* @var resource
*/
private $DBHandle = null;
/**
* Prepared statement for a SQLite3 select query
*
* @var SQLite3Stmt
*/
private $selectQuery;
/**
* Prepared statement for a SQLite3 insert query
*
* @var SQLite3Stmt
*/
private $insertQuery;
/**
* Prepared statement for a SQLite3 update query
*
* @var SQLite3Stmt
*/
private $updateQuery;
/**
* Prepared statement for a SQLite3 delete query
*
* @var SQLite3Stmt
*/
private $deleteQuery;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
$this->insertQuery->bindValue('id', $this->currentObjectID, SQLITE3_TEXT);
$this->insertQuery->bindValue('data', serialize($this->currentObject), SQLITE3_BLOB);
$result = $this->insertQuery->execute();
if ($result === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
$this->selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
$cellResult = $this->selectQuery->execute();
if ($cellResult === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
if ($cellData === false) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
$this->currentObject = unserialize($cellData['value']);
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
}
/**
* Is a value set for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return true;
}
// Check if the requested entry exists in the cache
$this->selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
$cellResult = $this->selectQuery->execute();
if ($cellResult === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
return ($cellData === false) ? false : true;
}
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
$this->currentObject->detach();
$this->currentObjectID = $this->currentObject = null;
}
// Check if the requested entry exists in the cache
$this->deleteQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
$result = $this->deleteQuery->execute();
if ($result === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
$this->currentCellIsDirty = false;
}
/**
* Move a cell object from one address to another
*
* @param string $fromAddress Current address of the cell to move
* @param string $toAddress Destination address of the cell to move
* @return boolean
*/
public function moveCell($fromAddress, $toAddress)
{
if ($fromAddress === $this->currentObjectID) {
$this->currentObjectID = $toAddress;
}
$this->deleteQuery->bindValue('id', $toAddress, SQLITE3_TEXT);
$result = $this->deleteQuery->execute();
if ($result === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
$this->updateQuery->bindValue('toid', $toAddress, SQLITE3_TEXT);
$this->updateQuery->bindValue('fromid', $fromAddress, SQLITE3_TEXT);
$result = $this->updateQuery->execute();
if ($result === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
return true;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
$query = "SELECT id FROM kvp_".$this->TableName;
$cellIdsResult = $this->DBHandle->query($query);
if ($cellIdsResult === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
$cellKeys = array();
while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
$cellKeys[] = $row['id'];
}
return $cellKeys;
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
$this->currentCellIsDirty;
$this->storeData();
// Get a new id for the new table name
$tableName = str_replace('.', '_', $this->getUniqueID());
if (!$this->DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
AS SELECT * FROM kvp_'.$this->TableName)
) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
// Copy the existing cell cache file
$this->TableName = $tableName;
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
// Close down the temporary cache file
$this->__destruct();
}
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
*/
public function __construct(PHPExcel_Worksheet $parent)
{
parent::__construct($parent);
if (is_null($this->DBHandle)) {
$this->TableName = str_replace('.', '_', $this->getUniqueID());
$_DBName = ':memory:';
$this->DBHandle = new SQLite3($_DBName);
if ($this->DBHandle === false) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
if (!$this->DBHandle->exec('CREATE TABLE kvp_'.$this->TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) {
throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
}
}
$this->selectQuery = $this->DBHandle->prepare("SELECT value FROM kvp_".$this->TableName." WHERE id = :id");
$this->insertQuery = $this->DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->TableName." VALUES(:id,:data)");
$this->updateQuery = $this->DBHandle->prepare("UPDATE kvp_".$this->TableName." SET id=:toId WHERE id=:fromId");
$this->deleteQuery = $this->DBHandle->prepare("DELETE FROM kvp_".$this->TableName." WHERE id = :id");
}
/**
* Destroy this cell collection
*/
public function __destruct()
{
if (!is_null($this->DBHandle)) {
$this->DBHandle->exec('DROP TABLE kvp_'.$this->TableName);
$this->DBHandle->close();
}
$this->DBHandle = null;
}
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable()
{
if (!class_exists('SQLite3', false)) {
return false;
}
return true;
}
}

@ -0,0 +1,289 @@
<?php
/**
* PHPExcel_CachedObjectStorage_Wincache
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
{
/**
* Prefix used to uniquely identify cache data for this worksheet
*
* @var string
*/
private $cachePrefix = null;
/**
* Cache timeout
*
* @var integer
*/
private $cacheTime = 600;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object
*
* @return void
* @throws PHPExcel_Exception
*/
protected function storeData()
{
if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
$this->currentObject->detach();
$obj = serialize($this->currentObject);
if (wincache_ucache_exists($this->cachePrefix.$this->currentObjectID.'.cache')) {
if (!wincache_ucache_set($this->cachePrefix.$this->currentObjectID.'.cache', $obj, $this->cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$this->currentObjectID.' in WinCache');
}
} else {
if (!wincache_ucache_add($this->cachePrefix.$this->currentObjectID.'.cache', $obj, $this->cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$this->currentObjectID.' in WinCache');
}
}
$this->currentCellIsDirty = false;
}
$this->currentObjectID = $this->currentObject = null;
}
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell)
{
if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
$this->storeData();
}
$this->cellCache[$pCoord] = true;
$this->currentObjectID = $pCoord;
$this->currentObject = $cell;
$this->currentCellIsDirty = true;
return $cell;
}
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return boolean
*/
public function isDataSet($pCoord)
{
// Check if the requested entry is the current object, or exists in the cache
if (parent::isDataSet($pCoord)) {
if ($this->currentObjectID == $pCoord) {
return true;
}
// Check if the requested entry still exists in cache
$success = wincache_ucache_exists($this->cachePrefix.$pCoord.'.cache');
if ($success === false) {
// Entry no longer exists in Wincache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
}
return true;
}
return false;
}
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord)
{
if ($pCoord === $this->currentObjectID) {
return $this->currentObject;
}
$this->storeData();
// Check if the entry that has been requested actually exists
$obj = null;
if (parent::isDataSet($pCoord)) {
$success = false;
$obj = wincache_ucache_get($this->cachePrefix.$pCoord.'.cache', $success);
if ($success === false) {
// Entry no longer exists in WinCache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
}
} else {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->currentObjectID = $pCoord;
$this->currentObject = unserialize($obj);
// Re-attach this as the cell's parent
$this->currentObject->attach($this);
// Return requested entry
return $this->currentObject;
}
/**
* Get a list of all cell addresses currently held in cache
*
* @return string[]
*/
public function getCellList()
{
if ($this->currentObjectID !== null) {
$this->storeData();
}
return parent::getCellList();
}
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord)
{
// Delete the entry from Wincache
wincache_ucache_delete($this->cachePrefix.$pCoord.'.cache');
// Delete the entry from our cell address array
parent::deleteCacheData($pCoord);
}
/**
* Clone the cell collection
*
* @param PHPExcel_Worksheet $parent The new worksheet
* @return void
*/
public function copyCellCollection(PHPExcel_Worksheet $parent)
{
parent::copyCellCollection($parent);
// Get a new id for the new file name
$baseUnique = $this->getUniqueID();
$newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
$cacheList = $this->getCellList();
foreach ($cacheList as $cellID) {
if ($cellID != $this->currentObjectID) {
$success = false;
$obj = wincache_ucache_get($this->cachePrefix.$cellID.'.cache', $success);
if ($success === false) {
// Entry no longer exists in WinCache, so clear it from the cache array
parent::deleteCacheData($cellID);
throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in Wincache');
}
if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->cacheTime)) {
$this->__destruct();
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in Wincache');
}
}
}
$this->cachePrefix = $newCachePrefix;
}
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
public function unsetWorksheetCells()
{
if (!is_null($this->currentObject)) {
$this->currentObject->detach();
$this->currentObject = $this->currentObjectID = null;
}
// Flush the WinCache cache
$this->__destruct();
$this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->parent = null;
}
/**
* Initialise this new cell collection
*
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments
*/
public function __construct(PHPExcel_Worksheet $parent, $arguments)
{
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
if (is_null($this->cachePrefix)) {
$baseUnique = $this->getUniqueID();
$this->cachePrefix = substr(md5($baseUnique), 0, 8).'.';
$this->cacheTime = $cacheTime;
parent::__construct($parent);
}
}
/**
* Destroy this cell collection
*/
public function __destruct()
{
$cacheList = $this->getCellList();
foreach ($cacheList as $cellID) {
wincache_ucache_delete($this->cachePrefix.$cellID.'.cache');
}
}
/**
* Identify whether the caching method is currently available
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build
*
* @return boolean
*/
public static function cacheMethodIsAvailable()
{
if (!function_exists('wincache_ucache_add')) {
return false;
}
return true;
}
}

@ -0,0 +1,231 @@
<?php
/**
* PHPExcel_CachedObjectStorageFactory
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CachedObjectStorageFactory
{
const cache_in_memory = 'Memory';
const cache_in_memory_gzip = 'MemoryGZip';
const cache_in_memory_serialized = 'MemorySerialized';
const cache_igbinary = 'Igbinary';
const cache_to_discISAM = 'DiscISAM';
const cache_to_apc = 'APC';
const cache_to_memcache = 'Memcache';
const cache_to_phpTemp = 'PHPTemp';
const cache_to_wincache = 'Wincache';
const cache_to_sqlite = 'SQLite';
const cache_to_sqlite3 = 'SQLite3';
/**
* Name of the method used for cell cacheing
*
* @var string
*/
private static $cacheStorageMethod = null;
/**
* Name of the class used for cell cacheing
*
* @var string
*/
private static $cacheStorageClass = null;
/**
* List of all possible cache storage methods
*
* @var string[]
*/
private static $storageMethods = array(
self::cache_in_memory,
self::cache_in_memory_gzip,
self::cache_in_memory_serialized,
self::cache_igbinary,
self::cache_to_phpTemp,
self::cache_to_discISAM,
self::cache_to_apc,
self::cache_to_memcache,
self::cache_to_wincache,
self::cache_to_sqlite,
self::cache_to_sqlite3,
);
/**
* Default arguments for each cache storage method
*
* @var array of mixed array
*/
private static $storageMethodDefaultParameters = array(
self::cache_in_memory => array(
),
self::cache_in_memory_gzip => array(
),
self::cache_in_memory_serialized => array(
),
self::cache_igbinary => array(
),
self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB'
),
self::cache_to_discISAM => array( 'dir' => null
),
self::cache_to_apc => array( 'cacheTime' => 600
),
self::cache_to_memcache => array( 'memcacheServer' => 'localhost',
'memcachePort' => 11211,
'cacheTime' => 600
),
self::cache_to_wincache => array( 'cacheTime' => 600
),
self::cache_to_sqlite => array(
),
self::cache_to_sqlite3 => array(
),
);
/**
* Arguments for the active cache storage method
*
* @var array of mixed array
*/
private static $storageMethodParameters = array();
/**
* Return the current cache storage method
*
* @return string|null
**/
public static function getCacheStorageMethod()
{
return self::$cacheStorageMethod;
}
/**
* Return the current cache storage class
*
* @return PHPExcel_CachedObjectStorage_ICache|null
**/
public static function getCacheStorageClass()
{
return self::$cacheStorageClass;
}
/**
* Return the list of all possible cache storage methods
*
* @return string[]
**/
public static function getAllCacheStorageMethods()
{
return self::$storageMethods;
}
/**
* Return the list of all available cache storage methods
*
* @return string[]
**/
public static function getCacheStorageMethods()
{
$activeMethods = array();
foreach (self::$storageMethods as $storageMethod) {
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $storageMethod;
if (call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) {
$activeMethods[] = $storageMethod;
}
}
return $activeMethods;
}
/**
* Identify the cache storage method to use
*
* @param string $method Name of the method to use for cell cacheing
* @param array of mixed $arguments Additional arguments to pass to the cell caching class
* when instantiating
* @return boolean
**/
public static function initialize($method = self::cache_in_memory, $arguments = array())
{
if (!in_array($method, self::$storageMethods)) {
return false;
}
$cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
if (!call_user_func(array( $cacheStorageClass,
'cacheMethodIsAvailable'))) {
return false;
}
self::$storageMethodParameters[$method] = self::$storageMethodDefaultParameters[$method];
foreach ($arguments as $k => $v) {
if (array_key_exists($k, self::$storageMethodParameters[$method])) {
self::$storageMethodParameters[$method][$k] = $v;
}
}
if (self::$cacheStorageMethod === null) {
self::$cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $method;
self::$cacheStorageMethod = $method;
}
return true;
}
/**
* Initialise the cache storage
*
* @param PHPExcel_Worksheet $parent Enable cell caching for this worksheet
* @return PHPExcel_CachedObjectStorage_ICache
**/
public static function getInstance(PHPExcel_Worksheet $parent)
{
$cacheMethodIsAvailable = true;
if (self::$cacheStorageMethod === null) {
$cacheMethodIsAvailable = self::initialize();
}
if ($cacheMethodIsAvailable) {
$instance = new self::$cacheStorageClass(
$parent,
self::$storageMethodParameters[self::$cacheStorageMethod]
);
if ($instance !== null) {
return $instance;
}
}
return false;
}
/**
* Clear the cache storage
*
**/
public static function finalize()
{
self::$cacheStorageMethod = null;
self::$cacheStorageClass = null;
self::$storageMethodParameters = array();
}
}

@ -0,0 +1,94 @@
<?php
/**
* PHPExcel_CalcEngine_CyclicReferenceStack
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CalcEngine_CyclicReferenceStack
{
/**
* The call stack for calculated cells
*
* @var mixed[]
*/
private $stack = array();
/**
* Return the number of entries on the stack
*
* @return integer
*/
public function count()
{
return count($this->stack);
}
/**
* Push a new entry onto the stack
*
* @param mixed $value
*/
public function push($value)
{
$this->stack[$value] = $value;
}
/**
* Pop the last entry from the stack
*
* @return mixed
*/
public function pop()
{
return array_pop($this->stack);
}
/**
* Test to see if a specified entry exists on the stack
*
* @param mixed $value The value to test
*/
public function onStack($value)
{
return isset($this->stack[$value]);
}
/**
* Clear the stack
*/
public function clear()
{
$this->stack = array();
}
/**
* Return an array of all entries on the stack
*
* @return mixed[]
*/
public function showStack()
{
return $this->stack;
}
}

@ -0,0 +1,151 @@
<?php
/**
* PHPExcel_CalcEngine_Logger
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_CalcEngine_Logger
{
/**
* Flag to determine whether a debug log should be generated by the calculation engine
* If true, then a debug log will be generated
* If false, then a debug log will not be generated
*
* @var boolean
*/
private $writeDebugLog = false;
/**
* Flag to determine whether a debug log should be echoed by the calculation engine
* If true, then a debug log will be echoed
* If false, then a debug log will not be echoed
* A debug log can only be echoed if it is generated
*
* @var boolean
*/
private $echoDebugLog = false;
/**
* The debug log generated by the calculation engine
*
* @var string[]
*/
private $debugLog = array();
/**
* The calculation engine cell reference stack
*
* @var PHPExcel_CalcEngine_CyclicReferenceStack
*/
private $cellStack;
/**
* Instantiate a Calculation engine logger
*
* @param PHPExcel_CalcEngine_CyclicReferenceStack $stack
*/
public function __construct(PHPExcel_CalcEngine_CyclicReferenceStack $stack)
{
$this->cellStack = $stack;
}
/**
* Enable/Disable Calculation engine logging
*
* @param boolean $pValue
*/
public function setWriteDebugLog($pValue = false)
{
$this->writeDebugLog = $pValue;
}
/**
* Return whether calculation engine logging is enabled or disabled
*
* @return boolean
*/
public function getWriteDebugLog()
{
return $this->writeDebugLog;
}
/**
* Enable/Disable echoing of debug log information
*
* @param boolean $pValue
*/
public function setEchoDebugLog($pValue = false)
{
$this->echoDebugLog = $pValue;
}
/**
* Return whether echoing of debug log information is enabled or disabled
*
* @return boolean
*/
public function getEchoDebugLog()
{
return $this->echoDebugLog;
}
/**
* Write an entry to the calculation engine debug log
*/
public function writeDebugLog()
{
// Only write the debug log if logging is enabled
if ($this->writeDebugLog) {
$message = implode(func_get_args());
$cellReference = implode(' -> ', $this->cellStack->showStack());
if ($this->echoDebugLog) {
echo $cellReference,
($this->cellStack->count() > 0 ? ' => ' : ''),
$message,
PHP_EOL;
}
$this->debugLog[] = $cellReference .
($this->cellStack->count() > 0 ? ' => ' : '') .
$message;
}
}
/**
* Clear the calculation engine debug log
*/
public function clearLog()
{
$this->debugLog = array();
}
/**
* Return the calculation engine debug log
*
* @return string[]
*/
public function getLog()
{
return $this->debugLog;
}
}

@ -0,0 +1,676 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Calculation_Database
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Calculation_Database
{
/**
* fieldExtract
*
* Extracts the column ID to use for the data field.
*
* @access private
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
* @param mixed $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
* the first column, 2 for the second column, and so on.
* @return string|NULL
*
*/
private static function fieldExtract($database, $field)
{
$field = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($field));
$fieldNames = array_map('strtoupper', array_shift($database));
if (is_numeric($field)) {
$keys = array_keys($fieldNames);
return $keys[$field-1];
}
$key = array_search($field, $fieldNames);
return ($key) ? $key : null;
}
/**
* filter
*
* Parses the selection criteria, extracts the database rows that match those criteria, and
* returns that subset of rows.
*
* @access private
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
* You can use any range for the criteria argument, as long as it
* includes at least one column label and at least one cell below
* the column label in which you specify a condition for the
* column.
* @return array of mixed
*
*/
private static function filter($database, $criteria)
{
$fieldNames = array_shift($database);
$criteriaNames = array_shift($criteria);
// Convert the criteria into a set of AND/OR conditions with [:placeholders]
$testConditions = $testValues = array();
$testConditionsCount = 0;
foreach ($criteriaNames as $key => $criteriaName) {
$testCondition = array();
$testConditionCount = 0;
foreach ($criteria as $row => $criterion) {
if ($criterion[$key] > '') {
$testCondition[] = '[:'.$criteriaName.']'.PHPExcel_Calculation_Functions::ifCondition($criterion[$key]);
$testConditionCount++;
}
}
if ($testConditionCount > 1) {
$testConditions[] = 'OR(' . implode(',', $testCondition) . ')';
$testConditionsCount++;
} elseif ($testConditionCount == 1) {
$testConditions[] = $testCondition[0];
$testConditionsCount++;
}
}
if ($testConditionsCount > 1) {
$testConditionSet = 'AND(' . implode(',', $testConditions) . ')';
} elseif ($testConditionsCount == 1) {
$testConditionSet = $testConditions[0];
}
// Loop through each row of the database
foreach ($database as $dataRow => $dataValues) {
// Substitute actual values from the database row for our [:placeholders]
$testConditionList = $testConditionSet;
foreach ($criteriaNames as $key => $criteriaName) {
$k = array_search($criteriaName, $fieldNames);
if (isset($dataValues[$k])) {
$dataValue = $dataValues[$k];
$dataValue = (is_string($dataValue)) ? PHPExcel_Calculation::wrapResult(strtoupper($dataValue)) : $dataValue;
$testConditionList = str_replace('[:' . $criteriaName . ']', $dataValue, $testConditionList);
}
}
// evaluate the criteria against the row data
$result = PHPExcel_Calculation::getInstance()->_calculateFormulaValue('='.$testConditionList);
// If the row failed to meet the criteria, remove it from the database
if (!$result) {
unset($database[$dataRow]);
}
}
return $database;
}
private static function getFilteredColumn($database, $field, $criteria)
{
// reduce the database to a set of rows that match all the criteria
$database = self::filter($database, $criteria);
// extract an array of values for the requested column
$colData = array();
foreach ($database as $row) {
$colData[] = $row[$field];
}
return $colData;
}
/**
* DAVERAGE
*
* Averages the values in a column of a list or database that match conditions you specify.
*
* Excel Function:
* DAVERAGE(database,field,criteria)
*
* @access public
* @category Database Functions
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
* @param string|integer $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
* the first column, 2 for the second column, and so on.
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
* You can use any range for the criteria argument, as long as it
* includes at least one column label and at least one cell below
* the column label in which you specify a condition for the
* column.
* @return float
*
*/
public static function DAVERAGE($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return null;
}
// Return
return PHPExcel_Calculation_Statistical::AVERAGE(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
* DCOUNT
*
* Counts the cells that contain numbers in a column of a list or database that match conditions
* that you specify.
*
* Excel Function:
* DCOUNT(database,[field],criteria)
*
* Excel Function:
* DAVERAGE(database,field,criteria)
*
* @access public
* @category Database Functions
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
* @param string|integer $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
* the first column, 2 for the second column, and so on.
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
* You can use any range for the criteria argument, as long as it
* includes at least one column label and at least one cell below
* the column label in which you specify a condition for the
* column.
* @return integer
*
* @TODO The field argument is optional. If field is omitted, DCOUNT counts all records in the
* database that match the criteria.
*
*/
public static function DCOUNT($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return null;
}
// Return
return PHPExcel_Calculation_Statistical::COUNT(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
* DCOUNTA
*
* Counts the nonblank cells in a column of a list or database that match conditions that you specify.
*
* Excel Function:
* DCOUNTA(database,[field],criteria)
*
* @access public
* @category Database Functions
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
* @param string|integer $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
* the first column, 2 for the second column, and so on.
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
* You can use any range for the criteria argument, as long as it
* includes at least one column label and at least one cell below
* the column label in which you specify a condition for the
* column.
* @return integer
*
* @TODO The field argument is optional. If field is omitted, DCOUNTA counts all records in the
* database that match the criteria.
*
*/
public static function DCOUNTA($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return null;
}
// reduce the database to a set of rows that match all the criteria
$database = self::filter($database, $criteria);
// extract an array of values for the requested column
$colData = array();
foreach ($database as $row) {
$colData[] = $row[$field];
}
// Return
return PHPExcel_Calculation_Statistical::COUNTA(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
* DGET
*
* Extracts a single value from a column of a list or database that matches conditions that you
* specify.
*
* Excel Function:
* DGET(database,field,criteria)
*
* @access public
* @category Database Functions
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
* @param string|integer $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
* the first column, 2 for the second column, and so on.
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
* You can use any range for the criteria argument, as long as it
* includes at least one column label and at least one cell below
* the column label in which you specify a condition for the
* column.
* @return mixed
*
*/
public static function DGET($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return null;
}
// Return
$colData = self::getFilteredColumn($database, $field, $criteria);
if (count($colData) > 1) {
return PHPExcel_Calculation_Functions::NaN();
}
return $colData[0];
}
/**
* DMAX
*
* Returns the largest number in a column of a list or database that matches conditions you that
* specify.
*
* Excel Function:
* DMAX(database,field,criteria)
*
* @access public
* @category Database Functions
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
* @param string|integer $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
* the first column, 2 for the second column, and so on.
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
* You can use any range for the criteria argument, as long as it
* includes at least one column label and at least one cell below
* the column label in which you specify a condition for the
* column.
* @return float
*
*/
public static function DMAX($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return null;
}
// Return
return PHPExcel_Calculation_Statistical::MAX(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
* DMIN
*
* Returns the smallest number in a column of a list or database that matches conditions you that
* specify.
*
* Excel Function:
* DMIN(database,field,criteria)
*
* @access public
* @category Database Functions
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
* @param string|integer $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
* the first column, 2 for the second column, and so on.
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
* You can use any range for the criteria argument, as long as it
* includes at least one column label and at least one cell below
* the column label in which you specify a condition for the
* column.
* @return float
*
*/
public static function DMIN($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return null;
}
// Return
return PHPExcel_Calculation_Statistical::MIN(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
* DPRODUCT
*
* Multiplies the values in a column of a list or database that match conditions that you specify.
*
* Excel Function:
* DPRODUCT(database,field,criteria)
*
* @access public
* @category Database Functions
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
* @param string|integer $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
* the first column, 2 for the second column, and so on.
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
* You can use any range for the criteria argument, as long as it
* includes at least one column label and at least one cell below
* the column label in which you specify a condition for the
* column.
* @return float
*
*/
public static function DPRODUCT($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return null;
}
// Return
return PHPExcel_Calculation_MathTrig::PRODUCT(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
* DSTDEV
*
* Estimates the standard deviation of a population based on a sample by using the numbers in a
* column of a list or database that match conditions that you specify.
*
* Excel Function:
* DSTDEV(database,field,criteria)
*
* @access public
* @category Database Functions
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
* @param string|integer $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
* the first column, 2 for the second column, and so on.
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
* You can use any range for the criteria argument, as long as it
* includes at least one column label and at least one cell below
* the column label in which you specify a condition for the
* column.
* @return float
*
*/
public static function DSTDEV($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return null;
}
// Return
return PHPExcel_Calculation_Statistical::STDEV(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
* DSTDEVP
*
* Calculates the standard deviation of a population based on the entire population by using the
* numbers in a column of a list or database that match conditions that you specify.
*
* Excel Function:
* DSTDEVP(database,field,criteria)
*
* @access public
* @category Database Functions
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
* @param string|integer $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
* the first column, 2 for the second column, and so on.
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
* You can use any range for the criteria argument, as long as it
* includes at least one column label and at least one cell below
* the column label in which you specify a condition for the
* column.
* @return float
*
*/
public static function DSTDEVP($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return null;
}
// Return
return PHPExcel_Calculation_Statistical::STDEVP(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
* DSUM
*
* Adds the numbers in a column of a list or database that match conditions that you specify.
*
* Excel Function:
* DSUM(database,field,criteria)
*
* @access public
* @category Database Functions
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
* @param string|integer $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
* the first column, 2 for the second column, and so on.
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
* You can use any range for the criteria argument, as long as it
* includes at least one column label and at least one cell below
* the column label in which you specify a condition for the
* column.
* @return float
*
*/
public static function DSUM($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return null;
}
// Return
return PHPExcel_Calculation_MathTrig::SUM(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
* DVAR
*
* Estimates the variance of a population based on a sample by using the numbers in a column
* of a list or database that match conditions that you specify.
*
* Excel Function:
* DVAR(database,field,criteria)
*
* @access public
* @category Database Functions
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
* @param string|integer $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
* the first column, 2 for the second column, and so on.
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
* You can use any range for the criteria argument, as long as it
* includes at least one column label and at least one cell below
* the column label in which you specify a condition for the
* column.
* @return float
*
*/
public static function DVAR($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return null;
}
// Return
return PHPExcel_Calculation_Statistical::VARFunc(
self::getFilteredColumn($database, $field, $criteria)
);
}
/**
* DVARP
*
* Calculates the variance of a population based on the entire population by using the numbers
* in a column of a list or database that match conditions that you specify.
*
* Excel Function:
* DVARP(database,field,criteria)
*
* @access public
* @category Database Functions
* @param mixed[] $database The range of cells that makes up the list or database.
* A database is a list of related data in which rows of related
* information are records, and columns of data are fields. The
* first row of the list contains labels for each column.
* @param string|integer $field Indicates which column is used in the function. Enter the
* column label enclosed between double quotation marks, such as
* "Age" or "Yield," or a number (without quotation marks) that
* represents the position of the column within the list: 1 for
* the first column, 2 for the second column, and so on.
* @param mixed[] $criteria The range of cells that contains the conditions you specify.
* You can use any range for the criteria argument, as long as it
* includes at least one column label and at least one cell below
* the column label in which you specify a condition for the
* column.
* @return float
*
*/
public static function DVARP($database, $field, $criteria)
{
$field = self::fieldExtract($database, $field);
if (is_null($field)) {
return null;
}
// Return
return PHPExcel_Calculation_Statistical::VARP(
self::getFilteredColumn($database, $field, $criteria)
);
}
}

@ -0,0 +1,46 @@
<?php
/**
* PHPExcel_Calculation_Exception
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Calculation_Exception extends PHPExcel_Exception
{
/**
* Error handler callback
*
* @param mixed $code
* @param mixed $string
* @param mixed $file
* @param mixed $line
* @param mixed $context
*/
public static function errorHandlerCallback($code, $string, $file, $line, $context)
{
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
throw $e;
}
}

@ -0,0 +1,45 @@
<?php
/**
* PHPExcel_Calculation_ExceptionHandler
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Calculation_ExceptionHandler
{
/**
* Register errorhandler
*/
public function __construct()
{
set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL);
}
/**
* Unregister errorhandler
*/
public function __destruct()
{
restore_error_handler();
}
}

@ -0,0 +1,622 @@
<?php
/*
PARTLY BASED ON:
Copyright (c) 2007 E. W. Bachtal, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
The software is provided "as is", without warranty of any kind, express or implied, including but not
limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In
no event shall the authors or copyright holders be liable for any claim, damages or other liability,
whether in an action of contract, tort or otherwise, arising from, out of or in connection with the
software or the use or other dealings in the software.
http://ewbi.blogs.com/develops/2007/03/excel_formula_p.html
http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
*/
/**
* PHPExcel_Calculation_FormulaParser
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Calculation_FormulaParser
{
/* Character constants */
const QUOTE_DOUBLE = '"';
const QUOTE_SINGLE = '\'';
const BRACKET_CLOSE = ']';
const BRACKET_OPEN = '[';
const BRACE_OPEN = '{';
const BRACE_CLOSE = '}';
const PAREN_OPEN = '(';
const PAREN_CLOSE = ')';
const SEMICOLON = ';';
const WHITESPACE = ' ';
const COMMA = ',';
const ERROR_START = '#';
const OPERATORS_SN = "+-";
const OPERATORS_INFIX = "+-*/^&=><";
const OPERATORS_POSTFIX = "%";
/**
* Formula
*
* @var string
*/
private $formula;
/**
* Tokens
*
* @var PHPExcel_Calculation_FormulaToken[]
*/
private $tokens = array();
/**
* Create a new PHPExcel_Calculation_FormulaParser
*
* @param string $pFormula Formula to parse
* @throws PHPExcel_Calculation_Exception
*/
public function __construct($pFormula = '')
{
// Check parameters
if (is_null($pFormula)) {
throw new PHPExcel_Calculation_Exception("Invalid parameter passed: formula");
}
// Initialise values
$this->formula = trim($pFormula);
// Parse!
$this->parseToTokens();
}
/**
* Get Formula
*
* @return string
*/
public function getFormula()
{
return $this->formula;
}
/**
* Get Token
*
* @param int $pId Token id
* @return string
* @throws PHPExcel_Calculation_Exception
*/
public function getToken($pId = 0)
{
if (isset($this->tokens[$pId])) {
return $this->tokens[$pId];
} else {
throw new PHPExcel_Calculation_Exception("Token with id $pId does not exist.");
}
}
/**
* Get Token count
*
* @return string
*/
public function getTokenCount()
{
return count($this->tokens);
}
/**
* Get Tokens
*
* @return PHPExcel_Calculation_FormulaToken[]
*/
public function getTokens()
{
return $this->tokens;
}
/**
* Parse to tokens
*/
private function parseToTokens()
{
// No attempt is made to verify formulas; assumes formulas are derived from Excel, where
// they can only exist if valid; stack overflows/underflows sunk as nulls without exceptions.
// Check if the formula has a valid starting =
$formulaLength = strlen($this->formula);
if ($formulaLength < 2 || $this->formula{0} != '=') {
return;
}
// Helper variables
$tokens1 = $tokens2 = $stack = array();
$inString = $inPath = $inRange = $inError = false;
$token = $previousToken = $nextToken = null;
$index = 1;
$value = '';
$ERRORS = array("#NULL!", "#DIV/0!", "#VALUE!", "#REF!", "#NAME?", "#NUM!", "#N/A");
$COMPARATORS_MULTI = array(">=", "<=", "<>");
while ($index < $formulaLength) {
// state-dependent character evaluation (order is important)
// double-quoted strings
// embeds are doubled
// end marks token
if ($inString) {
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
if ((($index + 2) <= $formulaLength) && ($this->formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE)) {
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE;
++$index;
} else {
$inString = false;
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_TEXT);
$value = "";
}
} else {
$value .= $this->formula{$index};
}
++$index;
continue;
}
// single-quoted strings (links)
// embeds are double
// end does not mark a token
if ($inPath) {
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
if ((($index + 2) <= $formulaLength) && ($this->formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE)) {
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE;
++$index;
} else {
$inPath = false;
}
} else {
$value .= $this->formula{$index};
}
++$index;
continue;
}
// bracked strings (R1C1 range index or linked workbook name)
// no embeds (changed to "()" by Excel)
// end does not mark a token
if ($inRange) {
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_CLOSE) {
$inRange = false;
}
$value .= $this->formula{$index};
++$index;
continue;
}
// error values
// end marks a token, determined from absolute list of values
if ($inError) {
$value .= $this->formula{$index};
++$index;
if (in_array($value, $ERRORS)) {
$inError = false;
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_ERROR);
$value = "";
}
continue;
}
// scientific notation check
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_SN, $this->formula{$index}) !== false) {
if (strlen($value) > 1) {
if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->formula{$index}) != 0) {
$value .= $this->formula{$index};
++$index;
continue;
}
}
}
// independent character evaluation (order not important)
// establish state-dependent character evaluations
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
if (strlen($value > 0)) {
// unexpected
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
$value = "";
}
$inString = true;
++$index;
continue;
}
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
if (strlen($value) > 0) {
// unexpected
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
$value = "";
}
$inPath = true;
++$index;
continue;
}
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_OPEN) {
$inRange = true;
$value .= PHPExcel_Calculation_FormulaParser::BRACKET_OPEN;
++$index;
continue;
}
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::ERROR_START) {
if (strlen($value) > 0) {
// unexpected
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
$value = "";
}
$inError = true;
$value .= PHPExcel_Calculation_FormulaParser::ERROR_START;
++$index;
continue;
}
// mark start and end of arrays and array rows
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_OPEN) {
if (strlen($value) > 0) {
// unexpected
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
$value = "";
}
$tmp = new PHPExcel_Calculation_FormulaToken("ARRAY", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
$tokens1[] = $tmp;
$stack[] = clone $tmp;
$tmp = new PHPExcel_Calculation_FormulaToken("ARRAYROW", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
$tokens1[] = $tmp;
$stack[] = clone $tmp;
++$index;
continue;
}
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::SEMICOLON) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tmp = array_pop($stack);
$tmp->setValue("");
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
$tokens1[] = $tmp;
$tmp = new PHPExcel_Calculation_FormulaToken(",", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_ARGUMENT);
$tokens1[] = $tmp;
$tmp = new PHPExcel_Calculation_FormulaToken("ARRAYROW", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
$tokens1[] = $tmp;
$stack[] = clone $tmp;
++$index;
continue;
}
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_CLOSE) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tmp = array_pop($stack);
$tmp->setValue("");
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
$tokens1[] = $tmp;
$tmp = array_pop($stack);
$tmp->setValue("");
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
$tokens1[] = $tmp;
++$index;
continue;
}
// trim white-space
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tokens1[] = new PHPExcel_Calculation_FormulaToken("", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_WHITESPACE);
++$index;
while (($this->formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) && ($index < $formulaLength)) {
++$index;
}
continue;
}
// multi-character comparators
if (($index + 2) <= $formulaLength) {
if (in_array(substr($this->formula, $index, 2), $COMPARATORS_MULTI)) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tokens1[] = new PHPExcel_Calculation_FormulaToken(substr($this->formula, $index, 2), PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
$index += 2;
continue;
}
}
// standard infix operators
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_INFIX, $this->formula{$index}) !== false) {
if (strlen($value) > 0) {
$tokens1[] =new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX);
++$index;
continue;
}
// standard postfix operators (only one)
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_POSTFIX, $this->formula{$index}) !== false) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX);
++$index;
continue;
}
// start subexpression or function
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_OPEN) {
if (strlen($value) > 0) {
$tmp = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
$tokens1[] = $tmp;
$stack[] = clone $tmp;
$value = "";
} else {
$tmp = new PHPExcel_Calculation_FormulaToken("", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
$tokens1[] = $tmp;
$stack[] = clone $tmp;
}
++$index;
continue;
}
// function, subexpression, or array parameters, or operand unions
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::COMMA) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tmp = array_pop($stack);
$tmp->setValue("");
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
$stack[] = $tmp;
if ($tmp->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken(",", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_UNION);
} else {
$tokens1[] = new PHPExcel_Calculation_FormulaToken(",", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_ARGUMENT);
}
++$index;
continue;
}
// stop subexpression
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_CLOSE) {
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
$value = "";
}
$tmp = array_pop($stack);
$tmp->setValue("");
$tmp->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP);
$tokens1[] = $tmp;
++$index;
continue;
}
// token accumulation
$value .= $this->formula{$index};
++$index;
}
// dump remaining accumulation
if (strlen($value) > 0) {
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
}
// move tokenList to new set, excluding unnecessary white-space tokens and converting necessary ones to intersections
$tokenCount = count($tokens1);
for ($i = 0; $i < $tokenCount; ++$i) {
$token = $tokens1[$i];
if (isset($tokens1[$i - 1])) {
$previousToken = $tokens1[$i - 1];
} else {
$previousToken = null;
}
if (isset($tokens1[$i + 1])) {
$nextToken = $tokens1[$i + 1];
} else {
$nextToken = null;
}
if (is_null($token)) {
continue;
}
if ($token->getTokenType() != PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_WHITESPACE) {
$tokens2[] = $token;
continue;
}
if (is_null($previousToken)) {
continue;
}
if (! (
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
) ) {
continue;
}
if (is_null($nextToken)) {
continue;
}
if (! (
(($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($nextToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START)) ||
(($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($nextToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START)) ||
($nextToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
) ) {
continue;
}
$tokens2[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_INTERSECTION);
}
// move tokens to final list, switching infix "-" operators to prefix when appropriate, switching infix "+" operators
// to noop when appropriate, identifying operand and infix-operator subtypes, and pulling "@" from function names
$this->tokens = array();
$tokenCount = count($tokens2);
for ($i = 0; $i < $tokenCount; ++$i) {
$token = $tokens2[$i];
if (isset($tokens2[$i - 1])) {
$previousToken = $tokens2[$i - 1];
} else {
$previousToken = null;
}
if (isset($tokens2[$i + 1])) {
$nextToken = $tokens2[$i + 1];
} else {
$nextToken = null;
}
if (is_null($token)) {
continue;
}
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "-") {
if ($i == 0) {
$token->setTokenType(PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
} elseif ((($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) &&
($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) &&
($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)) {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
} else {
$token->setTokenType(PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
}
$this->tokens[] = $token;
continue;
}
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "+") {
if ($i == 0) {
continue;
} elseif ((($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) &&
($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) &&
($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)) {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
} else {
continue;
}
$this->tokens[] = $token;
continue;
}
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX &&
$token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
if (strpos("<>=", substr($token->getValue(), 0, 1)) !== false) {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
} elseif ($token->getValue() == "&") {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_CONCATENATION);
} else {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
}
$this->tokens[] = $token;
continue;
}
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND &&
$token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
if (!is_numeric($token->getValue())) {
if (strtoupper($token->getValue()) == "TRUE" || strtoupper($token->getValue() == "FALSE")) {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
} else {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_RANGE);
}
} else {
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NUMBER);
}
$this->tokens[] = $token;
continue;
}
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) {
if (strlen($token->getValue() > 0)) {
if (substr($token->getValue(), 0, 1) == "@") {
$token->setValue(substr($token->getValue(), 1));
}
}
}
$this->tokens[] = $token;
}
}
}

@ -0,0 +1,176 @@
<?php
/*
PARTLY BASED ON:
Copyright (c) 2007 E. W. Bachtal, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
The software is provided "as is", without warranty of any kind, express or implied, including but not
limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In
no event shall the authors or copyright holders be liable for any claim, damages or other liability,
whether in an action of contract, tort or otherwise, arising from, out of or in connection with the
software or the use or other dealings in the software.
http://ewbi.blogs.com/develops/2007/03/excel_formula_p.html
http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
*/
/**
* PHPExcel_Calculation_FormulaToken
*
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Calculation_FormulaToken
{
/* Token types */
const TOKEN_TYPE_NOOP = 'Noop';
const TOKEN_TYPE_OPERAND = 'Operand';
const TOKEN_TYPE_FUNCTION = 'Function';
const TOKEN_TYPE_SUBEXPRESSION = 'Subexpression';
const TOKEN_TYPE_ARGUMENT = 'Argument';
const TOKEN_TYPE_OPERATORPREFIX = 'OperatorPrefix';
const TOKEN_TYPE_OPERATORINFIX = 'OperatorInfix';
const TOKEN_TYPE_OPERATORPOSTFIX = 'OperatorPostfix';
const TOKEN_TYPE_WHITESPACE = 'Whitespace';
const TOKEN_TYPE_UNKNOWN = 'Unknown';
/* Token subtypes */
const TOKEN_SUBTYPE_NOTHING = 'Nothing';
const TOKEN_SUBTYPE_START = 'Start';
const TOKEN_SUBTYPE_STOP = 'Stop';
const TOKEN_SUBTYPE_TEXT = 'Text';
const TOKEN_SUBTYPE_NUMBER = 'Number';
const TOKEN_SUBTYPE_LOGICAL = 'Logical';
const TOKEN_SUBTYPE_ERROR = 'Error';
const TOKEN_SUBTYPE_RANGE = 'Range';
const TOKEN_SUBTYPE_MATH = 'Math';
const TOKEN_SUBTYPE_CONCATENATION = 'Concatenation';
const TOKEN_SUBTYPE_INTERSECTION = 'Intersection';
const TOKEN_SUBTYPE_UNION = 'Union';
/**
* Value
*
* @var string
*/
private $value;
/**
* Token Type (represented by TOKEN_TYPE_*)
*
* @var string
*/
private $tokenType;
/**
* Token SubType (represented by TOKEN_SUBTYPE_*)
*
* @var string
*/
private $tokenSubType;
/**
* Create a new PHPExcel_Calculation_FormulaToken
*
* @param string $pValue
* @param string $pTokenType Token type (represented by TOKEN_TYPE_*)
* @param string $pTokenSubType Token Subtype (represented by TOKEN_SUBTYPE_*)
*/
public function __construct($pValue, $pTokenType = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN, $pTokenSubType = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
{
// Initialise values
$this->value = $pValue;
$this->tokenType = $pTokenType;
$this->tokenSubType = $pTokenSubType;
}
/**
* Get Value
*
* @return string
*/
public function getValue()
{
return $this->value;
}
/**
* Set Value
*
* @param string $value
*/
public function setValue($value)
{
$this->value = $value;
}
/**
* Get Token Type (represented by TOKEN_TYPE_*)
*
* @return string
*/
public function getTokenType()
{
return $this->tokenType;
}
/**
* Set Token Type
*
* @param string $value
*/
public function setTokenType($value = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN)
{
$this->tokenType = $value;
}
/**
* Get Token SubType (represented by TOKEN_SUBTYPE_*)
*
* @return string
*/
public function getTokenSubType()
{
return $this->tokenSubType;
}
/**
* Set Token SubType
*
* @param string $value
*/
public function setTokenSubType($value = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
{
$this->tokenSubType = $value;
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save