|
|
<?php
|
|
|
if (!defined('BASEPATH'))
|
|
|
exit('No direct script access allowed');
|
|
|
|
|
|
class api extends CI_Controller
|
|
|
{
|
|
|
public function __construct()
|
|
|
{
|
|
|
parent::__construct();
|
|
|
$this->load->helper('tuniu');
|
|
|
$this->load->model('flight_model');
|
|
|
}
|
|
|
|
|
|
public function index()
|
|
|
{
|
|
|
exit('前方高能!!');
|
|
|
}
|
|
|
|
|
|
//帐号绑定
|
|
|
public function bindAccount()
|
|
|
{
|
|
|
$timestamp = time();
|
|
|
$data = '{"account":"phoebe@hainatravel.com","defaultPay":0}';
|
|
|
$sign = md5(TUNIU_FLIGHT_KEY . $data . $timestamp);
|
|
|
$accountJson = '{
|
|
|
"purchaseId": ' . TUNIU_FLIGHT_ID . ',
|
|
|
"sign": "' . $sign . '",
|
|
|
"function": "paymentSign",
|
|
|
"timestamp": ' . $timestamp . ',
|
|
|
"data":' . $data . '
|
|
|
}';
|
|
|
$returnJson = post_tuniu(TUNIU_FLIGHT_API, $accountJson, 'POST');
|
|
|
//print_r($returnData);
|
|
|
echo $returnJson;
|
|
|
}
|
|
|
|
|
|
//查询钱包接口
|
|
|
public function checkWallet()
|
|
|
{
|
|
|
$timestamp = time();
|
|
|
$data = '{}';
|
|
|
$sign = md5(TUNIU_FLIGHT_KEY . $data . $timestamp);
|
|
|
$walletJson = '{
|
|
|
"purchaseId": ' . TUNIU_FLIGHT_ID . ',
|
|
|
"sign": "' . $sign . '",
|
|
|
"function": "tuNiuWalletInfo",
|
|
|
"timestamp": ' . $timestamp . ',
|
|
|
"data":' . $data . '
|
|
|
}';
|
|
|
$returnJson = post_tuniu(TUNIU_FLIGHT_API, $walletJson, 'POST');
|
|
|
//print_r($returnData);
|
|
|
echo $returnJson;
|
|
|
}
|
|
|
|
|
|
//保险查询
|
|
|
public function getinsurance()
|
|
|
{
|
|
|
$timestamp = time();
|
|
|
$data = '{}';
|
|
|
$sign = md5(TUNIU_FLIGHT_KEY . $data . $timestamp);
|
|
|
$insuranceJson = '{
|
|
|
"purchaseId": ' . TUNIU_FLIGHT_ID . ',
|
|
|
"sign": "' . $sign . '",
|
|
|
"function": "insurance",
|
|
|
"timestamp": ' . $timestamp . ',
|
|
|
"data":' . $data . '
|
|
|
}';
|
|
|
$returnJson = post_tuniu(TUNIU_FLIGHT_API, $insuranceJson, 'POST');
|
|
|
//print_r($returnData);
|
|
|
echo $returnJson;
|
|
|
}
|
|
|
|
|
|
//查询接口
|
|
|
public function searchForHt()
|
|
|
{
|
|
|
$departDate = $this->input->get_post('departDate');
|
|
|
$departCode = $this->input->get_post('departCode');
|
|
|
$arriveCode = $this->input->get_post('arriveCode');
|
|
|
|
|
|
if (empty($departDate) || empty($departCode) || empty($arriveCode)) {
|
|
|
exit('请传入正确的参数,如有疑问请联系CYC!!!');
|
|
|
}
|
|
|
|
|
|
$url = 'https://www.trainspread.com/guide.php/flight/search/?departDate=' . $departDate . '&departCode=' . $departCode . '&arriveCode=' . $arriveCode;
|
|
|
$json = post_tuniu($url);
|
|
|
$data['data'] = json_decode($json);
|
|
|
|
|
|
$this->load->view('searchForHt', $data);
|
|
|
}
|
|
|
|
|
|
//下单接口
|
|
|
public function addorders()
|
|
|
{
|
|
|
//接收参数
|
|
|
$departime = $this->input->get_post('departime');
|
|
|
$fromcode = $this->input->get_post('fromcode');
|
|
|
$tocode = $this->input->get_post('tocode');
|
|
|
$flightnumber = $this->input->get_post('flightnumber');
|
|
|
|
|
|
//测试数据
|
|
|
$deparTime = '2019-11-15';
|
|
|
$fromCode = 'BJS';
|
|
|
$toCode = 'SHA';
|
|
|
$flightNumber = 'KN5955';
|
|
|
|
|
|
//查询到sessionid
|
|
|
$searchJson = get_serach_json($deparTime, $fromCode, $toCode, $flightNumber);
|
|
|
$returnJson = post_tuniu(TUNIU_FLIGHT_API, $searchJson, 'POST');
|
|
|
$returnData = json_decode($returnJson);
|
|
|
$sessionId = $returnData->data->queryResultList['0']->resourceList['0']->sessionId;
|
|
|
//$sessionId = 'eyJuYW1lIjoiZGlzdE5ldyIsImZrIjoiTkFZI1NIQSNLTjU5NTUjMjAxOS0wOC0xNSIsInNpIjo4LCJjYSI6IlkiLCJjbyI6IkgiLCJhcCI6IjUxOCIsImNwIjoiNzcyIn0';
|
|
|
echo $sessionId;
|
|
|
|
|
|
//获取航班信息,订单信息
|
|
|
|
|
|
|
|
|
//拼接下单报文
|
|
|
$data = '{"contactTel":"18877381547","flight":{"adtPrice":1111,"arriveCityCode":"' . $toCode . '","cabinClass":"Y","cabinCode":"H","departureCityCode":"' . $fromCode . '","departureDate":"' . $deparTime . '","flightNum":"' . $flightNumber . '"},"remark":"haina123456","sessionId":"' . $sessionId . '","touristList":[{"birthday":"1992-08-13","firstName":"chen","lastName":"yuchao","name":"陈宇超","personType":"ADT","psptId":"450302199208131039","psptType":1,"tel":"18877381547"}]}';
|
|
|
$timestamp = time();
|
|
|
$sign = md5(TUNIU_FLIGHT_KEY . $data . $timestamp);
|
|
|
$bookJson = '{
|
|
|
"purchaseId": ' . TUNIU_FLIGHT_ID . ',
|
|
|
"sign": "' . $sign . '",
|
|
|
"timestamp": ' . $timestamp . ',
|
|
|
"function": "createOrder",
|
|
|
"data":' . $data . '
|
|
|
}';
|
|
|
//echo $bookJson;die();
|
|
|
$returnJson = post_tuniu(TUNIU_FLIGHT_API, $bookJson, 'POST');
|
|
|
//print_r($returnData);
|
|
|
echo $returnJson;
|
|
|
//生成报文
|
|
|
}
|
|
|
|
|
|
//请求支付接口
|
|
|
public function payorders()
|
|
|
{
|
|
|
$order = $this->input->get_post('order');
|
|
|
$order = '1226443588';
|
|
|
|
|
|
if (empty($order)) {
|
|
|
exit('订单号为空');
|
|
|
} else {
|
|
|
//拼接支付报文
|
|
|
$timestamp = time();
|
|
|
$data = '{"account":"phoebe@hainatravel.com","orderId":"' . $order . '","payType":1}';
|
|
|
$sign = md5(TUNIU_FLIGHT_KEY . $data . $timestamp);
|
|
|
$payjson = '{
|
|
|
"purchaseId": ' . TUNIU_FLIGHT_ID . ',
|
|
|
"sign": "' . $sign . '",
|
|
|
"timestamp": ' . $timestamp . ',
|
|
|
"function": "paymentOrder",
|
|
|
"data":' . $data . '
|
|
|
}';
|
|
|
$returnJson = post_tuniu(TUNIU_FLIGHT_API, $payjson, 'POST');
|
|
|
echo $returnJson;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//单个订单详情查询接口
|
|
|
public function getorderinfos()
|
|
|
{
|
|
|
$order = $this->input->get_post('order');
|
|
|
|
|
|
if (empty($order)) {
|
|
|
exit('订单号为空');
|
|
|
} else {
|
|
|
//拼接支付报文
|
|
|
$timestamp = time();
|
|
|
$data = '{"orderId":"' . $order . '"}';
|
|
|
$sign = md5(TUNIU_FLIGHT_KEY . $data . $timestamp);
|
|
|
$orderinfojson = '{
|
|
|
"purchaseId": ' . TUNIU_FLIGHT_ID . ',
|
|
|
"sign": "' . $sign . '",
|
|
|
"timestamp": ' . $timestamp . ',
|
|
|
"function": "orderDetail",
|
|
|
"data":' . $data . '
|
|
|
}';
|
|
|
$returnJson = post_tuniu(TUNIU_FLIGHT_API, $orderinfojson, 'POST');
|
|
|
echo $returnJson;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//机票退票费查询接口
|
|
|
public function refundfee()
|
|
|
{
|
|
|
$order = $this->input->get_post('order');
|
|
|
$ticketcode = $this->input->get_post('ticketcode');
|
|
|
$order = '1226443588';
|
|
|
$ticketcode = '822-2386171483';
|
|
|
|
|
|
if (empty($order)) {
|
|
|
exit('订单号为空');
|
|
|
} else {
|
|
|
//拼接支付报文
|
|
|
$timestamp = time();
|
|
|
$data = '{"orderId":' . $order . ',"ticketCodeList":["' . $ticketcode . '"]}';
|
|
|
$sign = md5(TUNIU_FLIGHT_KEY . $data . $timestamp);
|
|
|
$refundfeejson = '{
|
|
|
"purchaseId": ' . TUNIU_FLIGHT_ID . ',
|
|
|
"sign": "' . $sign . '",
|
|
|
"timestamp":' . $timestamp . ',
|
|
|
"function":"refundFee",
|
|
|
"data":' . $data . '
|
|
|
}';
|
|
|
//echo $refundfeejson;die();
|
|
|
$returnJson = post_tuniu(TUNIU_FLIGHT_API, $refundfeejson, 'POST');
|
|
|
echo $returnJson;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//机票退票接口
|
|
|
public function refundapply()
|
|
|
{
|
|
|
$order = $this->input->get_post('order');
|
|
|
$ticketcode = $this->input->get_post('ticketcode');
|
|
|
$order = '1226443588';
|
|
|
$ticketcode = '822-2386171483';
|
|
|
|
|
|
if (empty($order)) {
|
|
|
exit('订单号为空');
|
|
|
} else {
|
|
|
//拼接支付报文
|
|
|
$timestamp = time();
|
|
|
$data = '{"attachmentList":[],"orderId":"' . $order . '","refundReason":"行程调整","refundType":1,"ticketCodeList":["' . $ticketcode . '"]}';
|
|
|
$sign = md5(TUNIU_FLIGHT_KEY . $data . $timestamp);
|
|
|
$returnorderjson = '{
|
|
|
"purchaseId": ' . TUNIU_FLIGHT_ID . ',
|
|
|
"sign": "' . $sign . '",
|
|
|
"timestamp": ' . $timestamp . ',
|
|
|
"function": "refundApply",
|
|
|
"data":' . $data . '
|
|
|
}';
|
|
|
echo $returnorderjson;
|
|
|
die();
|
|
|
$returnJson = post_tuniu(TUNIU_FLIGHT_API, $returnorderjson, 'POST');
|
|
|
echo $returnJson;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//返回三字码接口
|
|
|
public function ajaxGetCodeAndName($flag = false)
|
|
|
{
|
|
|
//http://202.103.68.104:61/info.php/apps/flightsystem/api/ajaxGetCodeAndName/ //测试地址
|
|
|
$returnData = new stdClass();
|
|
|
$allCityNameAndCode = $this->flight_model->getAllCityCodeAndName();
|
|
|
$returnJson = json_encode($allCityNameAndCode);
|
|
|
|
|
|
//return $returnJson;
|
|
|
if ($flag) {
|
|
|
return $returnJson;
|
|
|
} else {
|
|
|
echo $returnJson;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//获取所有机场信息
|
|
|
public function ajaxGetAirPort()
|
|
|
{
|
|
|
|
|
|
$returnData = new stdClass();
|
|
|
$airPortCodeAndName = $this->flight_model->getAllAirPort();
|
|
|
$returnData = array();
|
|
|
foreach ($airPortCodeAndName as $items) {
|
|
|
$returnData[$items->air_threeChar] = $items->air_english_name;
|
|
|
}
|
|
|
$returnJson = json_encode($returnData);
|
|
|
|
|
|
print_r($returnJson);
|
|
|
}
|
|
|
|
|
|
//查询接口
|
|
|
public function search()
|
|
|
{
|
|
|
//http://202.103.68.104:61/info.php/apps/flightsystem/api/search/?departDate=2021-09-04&departCode=BJS&arriveCode=KWL //测试地址
|
|
|
$departDate = $this->input->get_post('departDate');
|
|
|
$departCode = $this->input->get_post('departCode');
|
|
|
$arriveCode = $this->input->get_post('arriveCode');
|
|
|
$flightnumber = $this->input->get_post('flightnumber');
|
|
|
|
|
|
if (empty($departDate) || empty($departCode) || empty($arriveCode)) {
|
|
|
exit('error');
|
|
|
}
|
|
|
|
|
|
$postJson = get_serach_json($departDate, $departCode, $arriveCode, $flightnumber);
|
|
|
//echo $postJson;die();
|
|
|
$returnJson = post_tuniu(TUNIU_FLIGHT_API, $postJson, 'POST');
|
|
|
$returnData = json_decode($returnJson);
|
|
|
//print_r($returnJson);die();
|
|
|
$cacheData = new stdClass();
|
|
|
if (!empty($returnData)) {
|
|
|
$cacheData->success = $returnData->success;
|
|
|
$cacheData->msg = $returnData->msg;
|
|
|
$cacheData->errorCode = $returnData->errorCode;
|
|
|
$cacheData->queryResultList = array();
|
|
|
$i = 0;
|
|
|
//$airPortCodeAndName = json_decode($redis->get('airPortCodeAndName'));
|
|
|
$airPortCodeAndName = $this->ajaxGetCodeAndName(true);
|
|
|
//print_r($airPortCodeAndName);die();
|
|
|
foreach ($returnData->data->queryResultList as $items) {
|
|
|
$cacheData->queryResultList[$i] = new stdClass();
|
|
|
$cacheData->queryResultList[$i]->flight = new stdClass();
|
|
|
|
|
|
//航班信息
|
|
|
$cacheData->queryResultList[$i]->flight->flightNo = $items->flight->flightNo;
|
|
|
$cacheData->queryResultList[$i]->flight->craftType = $items->flight->craftType;
|
|
|
$cacheData->queryResultList[$i]->flight->airlineCompany = $items->flight->airlineCompany;
|
|
|
$cacheData->queryResultList[$i]->flight->airlineIataCode = $items->flight->airlineIataCode;
|
|
|
$cacheData->queryResultList[$i]->flight->arriveAirportCode = $items->flight->arriveAirportCode;
|
|
|
$cacheData->queryResultList[$i]->flight->arriveAirportName = $items->flight->arriveAirportName;
|
|
|
$arriveAirportCode = $items->flight->arriveAirportCode;
|
|
|
$cacheData->queryResultList[$i]->flight->arriveAirportNameEn = $this->flight_model->getAirPortNameEn($items->flight->arriveAirportCode); //$airPortCodeAndName->$arriveAirportCode;
|
|
|
$cacheData->queryResultList[$i]->flight->arriveAirportTerminal = $items->flight->arriveAirportTerminal;
|
|
|
$cacheData->queryResultList[$i]->flight->arriveCityIataCode = $items->flight->arriveCityIataCode;
|
|
|
$cacheData->queryResultList[$i]->flight->arriveCityName = $items->flight->arriveCityName;
|
|
|
$cacheData->queryResultList[$i]->flight->arriveDate = $items->flight->arriveDate;
|
|
|
$cacheData->queryResultList[$i]->flight->arriveTime = $items->flight->arriveTime;
|
|
|
$cacheData->queryResultList[$i]->flight->departAirportCode = $items->flight->departAirportCode;
|
|
|
$cacheData->queryResultList[$i]->flight->departAirportName = $items->flight->departAirportName;
|
|
|
$departAirportCode = $items->flight->departAirportCode;
|
|
|
$cacheData->queryResultList[$i]->flight->departAirportNameEn = $this->flight_model->getAirPortNameEn($items->flight->departAirportCode); //$airPortCodeAndName->$departAirportCode;
|
|
|
$cacheData->queryResultList[$i]->flight->departAirportTerminal = $items->flight->departAirportTerminal;
|
|
|
$cacheData->queryResultList[$i]->flight->departCityIataCode = $items->flight->departCityIataCode;
|
|
|
$cacheData->queryResultList[$i]->flight->departCityName = $items->flight->departCityName;
|
|
|
$cacheData->queryResultList[$i]->flight->departDate = $items->flight->departDate;
|
|
|
$cacheData->queryResultList[$i]->flight->departTime = $items->flight->departTime;
|
|
|
$cacheData->queryResultList[$i]->flight->duration = $items->flight->duration;
|
|
|
$cacheData->queryResultList[$i]->flight->meal = $items->flight->meal;
|
|
|
$cacheData->queryResultList[$i]->flight->stopInformation = $items->flight->stopInformation;
|
|
|
$cacheData->queryResultList[$i]->flight->stopNum = $items->flight->stopNum;
|
|
|
$cacheData->queryResultList[$i]->flight->stopPointList = $items->flight->stopPointList;
|
|
|
|
|
|
//航班对应可用的资源列表
|
|
|
$cacheData->queryResultList[$i]->resourceList = array();
|
|
|
$j = 0;
|
|
|
foreach ($items->resourceList as $resourceItems) {
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j] = new stdClass();
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price = new stdClass();
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price->adultPrice = $resourceItems->price->adultPrice;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price->childPrice = $resourceItems->price->childPrice;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price->adultFacePrice = $resourceItems->price->adultFacePrice;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price->childFacePrice = $resourceItems->price->childFacePrice;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price->cabinClassFullPrice = $resourceItems->price->cabinClassFullPrice;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price->adultTax = $resourceItems->price->adultTax;
|
|
|
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList = array();
|
|
|
$k = 0;
|
|
|
foreach ($resourceItems->cabinList as $cabinListItems) {
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k] = new stdClass();
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->cabinClass = $cabinListItems->cabinClass;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->cabinClassName = $cabinListItems->cabinClassName;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->freeLuggage = $cabinListItems->freeLuggage;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->freeLuggageUnit = $cabinListItems->freeLuggageUnit;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->billType = $cabinListItems->billType;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->seatStatus = $cabinListItems->seatStatus;
|
|
|
|
|
|
$k++;
|
|
|
}
|
|
|
$j++;
|
|
|
}
|
|
|
$i++;
|
|
|
}
|
|
|
|
|
|
print_r(json_encode($cacheData));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//查询接口,单一Y仓全价
|
|
|
public function search_simple()
|
|
|
{
|
|
|
//http://202.103.68.104:61/info.php/apps/flightsystem/api/search/?departDate=2021-09-04&departCode=BJS&arriveCode=KWL //测试地址
|
|
|
$departDate = $this->input->get_post('departDate');
|
|
|
$departCode = $this->input->get_post('departCode');
|
|
|
$arriveCode = $this->input->get_post('arriveCode');
|
|
|
$flightnumber = $this->input->get_post('flightnumber');
|
|
|
|
|
|
if (empty($departDate) || empty($departCode) || empty($arriveCode)) {
|
|
|
exit('error');
|
|
|
}
|
|
|
|
|
|
$postJson = get_serach_json($departDate, $departCode, $arriveCode, $flightnumber);
|
|
|
//echo $postJson;die();
|
|
|
$returnJson = post_tuniu(TUNIU_FLIGHT_API, $postJson, 'POST');
|
|
|
$returnData = json_decode($returnJson);
|
|
|
//print_r($returnJson);die();
|
|
|
$cacheData = new stdClass();
|
|
|
if (!empty($returnData)) {
|
|
|
if ($returnData->success==false){
|
|
|
exit('error');
|
|
|
}
|
|
|
$cacheData->success = $returnData->success;
|
|
|
$cacheData->msg = $returnData->msg;
|
|
|
$cacheData->errorCode = $returnData->errorCode;
|
|
|
$cacheData->queryResultList = array();
|
|
|
$i = 0;
|
|
|
//$airPortCodeAndName = json_decode($redis->get('airPortCodeAndName'));
|
|
|
$airPortCodeAndName = $this->ajaxGetCodeAndName(true);
|
|
|
//print_r($airPortCodeAndName);die();
|
|
|
foreach ($returnData->data->queryResultList as $items) {
|
|
|
$cacheData->queryResultList[$i] = new stdClass();
|
|
|
$cacheData->queryResultList[$i]->flight = new stdClass();
|
|
|
|
|
|
//航班信息
|
|
|
$cacheData->queryResultList[$i]->flight->flightNo = $items->flight->flightNo;
|
|
|
$cacheData->queryResultList[$i]->flight->craftType = $items->flight->craftType;
|
|
|
$cacheData->queryResultList[$i]->flight->airlineCompany = $items->flight->airlineCompany;
|
|
|
$cacheData->queryResultList[$i]->flight->airlineIataCode = $items->flight->airlineIataCode;
|
|
|
$cacheData->queryResultList[$i]->flight->arriveAirportCode = $items->flight->arriveAirportCode;
|
|
|
$cacheData->queryResultList[$i]->flight->arriveAirportName = $items->flight->arriveAirportName;
|
|
|
$arriveAirportCode = $items->flight->arriveAirportCode;
|
|
|
$cacheData->queryResultList[$i]->flight->arriveAirportNameEn = $this->flight_model->getAirPortNameEn($items->flight->arriveAirportCode); //$airPortCodeAndName->$arriveAirportCode;
|
|
|
$cacheData->queryResultList[$i]->flight->arriveAirportTerminal = $items->flight->arriveAirportTerminal;
|
|
|
$cacheData->queryResultList[$i]->flight->arriveCityIataCode = $items->flight->arriveCityIataCode;
|
|
|
$cacheData->queryResultList[$i]->flight->arriveCityName = $items->flight->arriveCityName;
|
|
|
$cacheData->queryResultList[$i]->flight->arriveDate = $items->flight->arriveDate;
|
|
|
$cacheData->queryResultList[$i]->flight->arriveTime = $items->flight->arriveTime;
|
|
|
$cacheData->queryResultList[$i]->flight->departAirportCode = $items->flight->departAirportCode;
|
|
|
$cacheData->queryResultList[$i]->flight->departAirportName = $items->flight->departAirportName;
|
|
|
$departAirportCode = $items->flight->departAirportCode;
|
|
|
$cacheData->queryResultList[$i]->flight->departAirportNameEn = $this->flight_model->getAirPortNameEn($items->flight->departAirportCode); //$airPortCodeAndName->$departAirportCode;
|
|
|
$cacheData->queryResultList[$i]->flight->departAirportTerminal = $items->flight->departAirportTerminal;
|
|
|
$cacheData->queryResultList[$i]->flight->departCityIataCode = $items->flight->departCityIataCode;
|
|
|
$cacheData->queryResultList[$i]->flight->departCityName = $items->flight->departCityName;
|
|
|
$cacheData->queryResultList[$i]->flight->departDate = $items->flight->departDate;
|
|
|
$cacheData->queryResultList[$i]->flight->departTime = $items->flight->departTime;
|
|
|
$cacheData->queryResultList[$i]->flight->duration = $items->flight->duration;
|
|
|
$cacheData->queryResultList[$i]->flight->meal = $items->flight->meal;
|
|
|
$cacheData->queryResultList[$i]->flight->stopInformation = $items->flight->stopInformation;
|
|
|
$cacheData->queryResultList[$i]->flight->stopNum = $items->flight->stopNum;
|
|
|
$cacheData->queryResultList[$i]->flight->stopPointList = $items->flight->stopPointList;
|
|
|
|
|
|
//航班对应可用的资源列表
|
|
|
$cacheData->queryResultList[$i]->resourceList = array();
|
|
|
$j = 0;
|
|
|
$Y = 0; //Y仓单独计数
|
|
|
$otherCabin = "";//其它舱位也只读取第一个
|
|
|
foreach ($items->resourceList as $resourceItems) {
|
|
|
|
|
|
//根据舱位分别处理,Y仓只要一个。
|
|
|
$arrCabinListItems = $resourceItems->cabinList;
|
|
|
$cabinListItems = $arrCabinListItems[0];
|
|
|
if ($cabinListItems->cabinClass == "Y" && $Y==0){
|
|
|
//只处理第一次的Y仓
|
|
|
if (count($items->resourceList)>0){
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j] = new stdClass();
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price = new stdClass();
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price->adultPrice = $resourceItems->price->cabinClassFullPrice;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price->childPrice = $resourceItems->price->childPrice;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price->adultFacePrice = $resourceItems->price->cabinClassFullPrice;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price->childFacePrice = $resourceItems->price->childFacePrice;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price->cabinClassFullPrice = $resourceItems->price->cabinClassFullPrice;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price->adultTax = $resourceItems->price->adultTax;
|
|
|
$k = 0;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k] = new stdClass();
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->cabinClass = $cabinListItems->cabinClass;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->cabinClassName = $cabinListItems->cabinClassName;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->freeLuggage = $cabinListItems->freeLuggage;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->freeLuggageUnit = $cabinListItems->freeLuggageUnit;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->billType = $cabinListItems->billType;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->seatStatus = $cabinListItems->seatStatus;
|
|
|
|
|
|
$Y++;
|
|
|
$j++;
|
|
|
}
|
|
|
|
|
|
}else if ($cabinListItems->cabinClass != "Y"){
|
|
|
|
|
|
$checkExitCabin = false;
|
|
|
foreach ($cacheData->queryResultList[$i]->resourceList as $cCabin) {
|
|
|
if ($cabinListItems->cabinClass == $cCabin->cabinList[0]->cabinClass){
|
|
|
$checkExitCabin = true; //判断是否已经添加了该类型的仓。
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if ($cabinListItems->cabinClass != $otherCabin && $checkExitCabin==false){
|
|
|
//其它仓
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j] = new stdClass();
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price = new stdClass();
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price->adultPrice = $resourceItems->price->cabinClassFullPrice;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price->childPrice = $resourceItems->price->childPrice;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price->adultFacePrice = $resourceItems->price->adultFacePrice;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price->childFacePrice = $resourceItems->price->childFacePrice;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price->cabinClassFullPrice = $resourceItems->price->cabinClassFullPrice;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->price->adultTax = $resourceItems->price->adultTax;
|
|
|
|
|
|
$k = 0;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k] = new stdClass();
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->cabinClass = $cabinListItems->cabinClass;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->cabinClassName = $cabinListItems->cabinClassName;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->freeLuggage = $cabinListItems->freeLuggage;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->freeLuggageUnit = $cabinListItems->freeLuggageUnit;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->billType = $cabinListItems->billType;
|
|
|
$cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->seatStatus = $cabinListItems->seatStatus;
|
|
|
|
|
|
$otherCabin = $cabinListItems->cabinClass;
|
|
|
$j++;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
// //只读取全价,Y仓
|
|
|
// if ($resourceItems->price->adultFacePrice == $resourceItems->price->cabinClassFullPrice && $resourceItems->price->adultPrice == $resourceItems->price->cabinClassFullPrice){
|
|
|
// //只显示经济舱
|
|
|
// $isY = false;
|
|
|
// foreach ($resourceItems->cabinList as $cabinListItems) {
|
|
|
// if ($cabinListItems->cabinClass == "Y"){
|
|
|
// $isY = true;
|
|
|
// break;
|
|
|
// }
|
|
|
// }
|
|
|
// if ($isY){
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j] = new stdClass();
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price = new stdClass();
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price->adultPrice = $resourceItems->price->adultPrice;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price->childPrice = $resourceItems->price->childPrice;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price->adultFacePrice = $resourceItems->price->adultFacePrice;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price->childFacePrice = $resourceItems->price->childFacePrice;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price->cabinClassFullPrice = $resourceItems->price->cabinClassFullPrice;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price->adultTax = $resourceItems->price->adultTax;
|
|
|
|
|
|
// $k = 0;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k] = new stdClass();
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->cabinClass = $cabinListItems->cabinClass;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->cabinClassName = $cabinListItems->cabinClassName;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->freeLuggage = $cabinListItems->freeLuggage;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->freeLuggageUnit = $cabinListItems->freeLuggageUnit;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->billType = $cabinListItems->billType;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->seatStatus = $cabinListItems->seatStatus;
|
|
|
|
|
|
// $j++;
|
|
|
// $Y++;
|
|
|
// }
|
|
|
// }else{
|
|
|
// //非全价的只显示其它舱位
|
|
|
// $arrCabinListItems = $resourceItems->cabinList;
|
|
|
// $cabinListItems = $arrCabinListItems[0];
|
|
|
// if ($cabinListItems->cabinClass != "Y"){
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j] = new stdClass();
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price = new stdClass();
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price->adultPrice = $resourceItems->price->adultPrice;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price->childPrice = $resourceItems->price->childPrice;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price->adultFacePrice = $resourceItems->price->adultFacePrice;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price->childFacePrice = $resourceItems->price->childFacePrice;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price->cabinClassFullPrice = $resourceItems->price->cabinClassFullPrice;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price->adultTax = $resourceItems->price->adultTax;
|
|
|
|
|
|
// $k = 0;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k] = new stdClass();
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->cabinClass = $cabinListItems->cabinClass;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->cabinClassName = $cabinListItems->cabinClassName;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->freeLuggage = $cabinListItems->freeLuggage;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->freeLuggageUnit = $cabinListItems->freeLuggageUnit;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->billType = $cabinListItems->billType;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->seatStatus = $cabinListItems->seatStatus;
|
|
|
|
|
|
// $j++;
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
// //Y仓没有全价的处理,默认加上一个全价
|
|
|
// if ($Y===0){
|
|
|
// if (count($items->resourceList)>0){
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j] = new stdClass();
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price = new stdClass();
|
|
|
|
|
|
// $resourceList = $items->resourceList;
|
|
|
// $resourceItems = $resourceList[0];
|
|
|
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price->adultPrice = $resourceItems->price->cabinClassFullPrice;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price->childPrice = $resourceItems->price->childPrice;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price->adultFacePrice = $resourceItems->price->cabinClassFullPrice;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price->childFacePrice = $resourceItems->price->childFacePrice;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price->cabinClassFullPrice = $resourceItems->price->cabinClassFullPrice;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->price->adultTax = $resourceItems->price->adultTax;
|
|
|
// $k = 0;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k] = new stdClass();
|
|
|
|
|
|
// $cabinList = $resourceItems->cabinList;
|
|
|
// $cabinListItems = $cabinList[0];
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->cabinClass = $cabinListItems->cabinClass;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->cabinClassName = $cabinListItems->cabinClassName;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->freeLuggage = $cabinListItems->freeLuggage;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->freeLuggageUnit = $cabinListItems->freeLuggageUnit;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->billType = $cabinListItems->billType;
|
|
|
// $cacheData->queryResultList[$i]->resourceList[$j]->cabinList[$k]->seatStatus = $cabinListItems->seatStatus;
|
|
|
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
$i++;
|
|
|
}
|
|
|
|
|
|
print_r(json_encode($cacheData));
|
|
|
}
|
|
|
}
|
|
|
}
|