|
|
<?php
|
|
|
|
|
|
use function GuzzleHttp\json_decode;
|
|
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
|
class Api extends CI_Controller {
|
|
|
public function __construct()
|
|
|
{
|
|
|
parent::__construct();
|
|
|
$this->load->model('api_model');
|
|
|
$this->load->library('Currency');
|
|
|
|
|
|
//获取调用网站数据
|
|
|
$this->getWebData();
|
|
|
}
|
|
|
|
|
|
var $imageCdn = "//images.chinatravel.com";//有些HT绑定图片需要加cdn
|
|
|
|
|
|
public function index()
|
|
|
{
|
|
|
echo("<1>api</h1>");
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @description: 返回一日游价格
|
|
|
* @param {*} $returntype
|
|
|
* @return {*}
|
|
|
* @Date Changed:
|
|
|
*/
|
|
|
public function getDaytripsPrice(){
|
|
|
if (isset($_GET["param"])){
|
|
|
$param = $_GET["param"];
|
|
|
if (strpos($param,",")!== false){
|
|
|
$pagecode = explode(",",$param)[0];
|
|
|
$personnum=explode(",",$param)[1];
|
|
|
}else{
|
|
|
$pagecode = $param;
|
|
|
$personnum=2;
|
|
|
}
|
|
|
if (isset($_GET["personnum"])){
|
|
|
$personnum=$_GET["personnum"];
|
|
|
}else{
|
|
|
$personnum=2;
|
|
|
}
|
|
|
$result["status"]="ok";
|
|
|
$price = $this->api_model->getDaytripsPrice($pagecode,$personnum);
|
|
|
$PKP_AdultSpecialPrice = isset($price->PKP_AdultSpecialPrice)?$price->PKP_AdultSpecialPrice:0;
|
|
|
$PKP_AdultPrice = isset($price->PKP_AdultPrice)?$price->PKP_AdultPrice:0;
|
|
|
if ($PKP_AdultPrice!=$PKP_AdultSpecialPrice && $PKP_AdultSpecialPrice>0){
|
|
|
$result["price"] = $this->currency->convert_moneny_by_char($PKP_AdultSpecialPrice,"USD");
|
|
|
}else{
|
|
|
$result["price"] = $this->currency->convert_moneny_by_char($PKP_AdultPrice,"USD");
|
|
|
}
|
|
|
|
|
|
echo json_encode($result);
|
|
|
}else {
|
|
|
$result["status"]="no param";
|
|
|
echo json_encode($result);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @description: 获取精华线路价格(2人等)
|
|
|
* @param {*}
|
|
|
* @return {*}
|
|
|
* @Date Changed:
|
|
|
*/
|
|
|
public function getTourPrice(){
|
|
|
if (isset($_GET["param"])){
|
|
|
$param = $_GET["param"];
|
|
|
$result["status"]="ok";
|
|
|
$price = $this->api_model->getTourPrice($param);
|
|
|
$result["pricecn"]=$price;
|
|
|
if (is_numeric($price)){
|
|
|
$price = $this->currency->calc_show_price($price);
|
|
|
}else{
|
|
|
$price = "0";
|
|
|
}
|
|
|
|
|
|
$result["price"] = $price;
|
|
|
echo json_encode($result);
|
|
|
}else{
|
|
|
$result["status"]="no param";
|
|
|
echo json_encode($result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @description: 获取HT及信息平台的一日游列表数据
|
|
|
* @param {*}
|
|
|
* @return {*}
|
|
|
* @Date Changed:
|
|
|
*/
|
|
|
public function getDaytripList(){
|
|
|
//先处理传递过来的参数(逗号隔开两个参数的格式:城市名称,父ID)
|
|
|
$whereHT="";
|
|
|
$whereInfo="";
|
|
|
if (isset($_GET["param"])){
|
|
|
$param = str_replace("'","''",$_GET["param"]);
|
|
|
if (strpos($param,",")!== false){
|
|
|
$city = explode(",",$param)[0];
|
|
|
$whereHT = " and (CII2_Name ='".$city."') ";
|
|
|
$parentid = explode(",",$param)[1];
|
|
|
$whereInfo = " and is_parent_id = '".$parentid."'";
|
|
|
}else{
|
|
|
$whereHT = " and (CII2_Name ='".$param."') ";
|
|
|
$whereInfo = " and is_parent_id = -1 ";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
$list = $this->api_model->getDaytripList($whereHT,$whereInfo);
|
|
|
|
|
|
foreach ($list as $row) {
|
|
|
//获取价格
|
|
|
$price = $this->api_model->getDaytripsPrice($row->code,2);
|
|
|
if ($price!=null){
|
|
|
$PKP_AdultSpecialPrice = $price->PKP_AdultSpecialPrice;
|
|
|
$PKP_AdultPrice = $price->PKP_AdultPrice;
|
|
|
if ($PKP_AdultPrice!=$PKP_AdultSpecialPrice && $PKP_AdultSpecialPrice>0){
|
|
|
$addPrice = $this->currency->convert_moneny_by_char($PKP_AdultSpecialPrice,"USD");
|
|
|
}else{
|
|
|
$addPrice= $this->currency->convert_moneny_by_char($PKP_AdultPrice,"USD");
|
|
|
}
|
|
|
}else{
|
|
|
$addPrice=0;
|
|
|
}
|
|
|
|
|
|
//URL
|
|
|
if (empty($row->url)){
|
|
|
$str_Url = "/china-day-trips/".strtolower($row->code).".htm";
|
|
|
$row->url = $str_Url; //更新url
|
|
|
}
|
|
|
|
|
|
|
|
|
//图片
|
|
|
|
|
|
if (!empty($row->pic1)){
|
|
|
$picurl = $row->pic1;
|
|
|
}else if(!empty($row->pic2)){
|
|
|
$picurl = $row->pic2;
|
|
|
}else{
|
|
|
$picurl="//data.chinatravel.com/images/loading2.gif";
|
|
|
}
|
|
|
|
|
|
$row->price = $addPrice; //新增价格属性
|
|
|
$picurl = $this->api_model->getPicCdn($picurl).$picurl;
|
|
|
$row->pic =$picurl; //图片地址
|
|
|
|
|
|
}
|
|
|
|
|
|
echo json_encode($list);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @description: 获取新旧网站的子类列表
|
|
|
* @param {*} $old_pid
|
|
|
* @param {*} $new_pid
|
|
|
* @return {*}
|
|
|
* @Date Changed:
|
|
|
*/
|
|
|
public function getGuideList($old_pid = null,$new_pid=null)
|
|
|
{
|
|
|
//处理参数
|
|
|
if (isset($_GET["param"])){
|
|
|
$param = str_replace("'","''",$_GET["param"]);
|
|
|
if (strpos($param,",")!== false){
|
|
|
$new_pid = explode(",",$param)[0];
|
|
|
$old_pid = explode(",",$param)[1];
|
|
|
}else{
|
|
|
$old_pid = -1;
|
|
|
$new_pid = $param;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (empty($old_pid) || !is_numeric($old_pid)){
|
|
|
$old_pid = -1 ;
|
|
|
}
|
|
|
|
|
|
if (empty($new_pid)|| !is_numeric($new_pid)){
|
|
|
$new_pid = -1;
|
|
|
}
|
|
|
|
|
|
$list = $this->api_model->getGuideList($old_pid,$new_pid);
|
|
|
foreach ($list as $row) {
|
|
|
//图片
|
|
|
if (!empty($row->ic_photo)){
|
|
|
$picurl = $row->ic_photo;
|
|
|
}else if (!empty($row->pic1)){
|
|
|
$picurl = $row->pic1;
|
|
|
}else{
|
|
|
$picurl="//data.chinatravel.com/images/no-photos.jpg";
|
|
|
}
|
|
|
// if (strpos($picurl,"chinatravel.com")!== false){
|
|
|
// }else{
|
|
|
// $picurl = $this->imageCdn.$picurl;
|
|
|
// }
|
|
|
$picurl = $this->api_model->getPicCdn($picurl).$picurl;
|
|
|
$row->pic = $picurl; //显示图片地址
|
|
|
}
|
|
|
|
|
|
echo json_encode($list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @description: 获取线路sn
|
|
|
* @param {*} $clino
|
|
|
* @return {*}
|
|
|
* @Date Changed:
|
|
|
*/
|
|
|
public function getCliSn(){
|
|
|
//处理参数
|
|
|
if (isset($_GET["param"])){
|
|
|
$param = $_GET["param"];
|
|
|
$result["status"]="ok";
|
|
|
$tour = $this->api_model->getCliSn($param);
|
|
|
$CLI_SN = isset($tour->CLI_SN)?$tour->CLI_SN:0;
|
|
|
if (!empty($CLI_SN)){
|
|
|
$result["clisn"]=$CLI_SN;
|
|
|
}else {
|
|
|
$result["clisn"]=0;
|
|
|
}
|
|
|
}else{
|
|
|
$result["status"]="no param";
|
|
|
$result["clisn"]=0;
|
|
|
|
|
|
}
|
|
|
echo json_encode($result);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @description: 一日游价格表
|
|
|
* @param {*}
|
|
|
* @return {*}
|
|
|
* @Date Changed:
|
|
|
*/
|
|
|
public function getDaytripPriceList(){
|
|
|
if (isset($_GET["param"])){
|
|
|
$param = str_replace("'","''",$_GET["param"]);
|
|
|
$list = $this->api_model->getDaytripPriceList($param);
|
|
|
if (!empty($list)){
|
|
|
if (count($list)==1){
|
|
|
//echo "1";
|
|
|
foreach ($list as $row) {
|
|
|
$PKP_AdultPrice = $row->PKP_AdultPrice;
|
|
|
$PKP_AdultSpecialPrice = $row->PKP_AdultSpecialPrice;
|
|
|
if ($PKP_AdultPrice!=$PKP_AdultSpecialPrice && $PKP_AdultSpecialPrice>0){
|
|
|
$PKP_AdultPrice=$PKP_AdultSpecialPrice;
|
|
|
}
|
|
|
$PKP_AdultPrice = $this->currency->convert_moneny_by_char($PKP_AdultPrice,"USD");
|
|
|
echo '<table border="0" align="center" cellpadding="10" cellspacing="1" class="pricetable"><tr><th>>1 Person</th></tr><tr><td><strong class="orange"> $'.$PKP_AdultPrice.'</strong></td></tr></table>';
|
|
|
}
|
|
|
}else{
|
|
|
//echo "2";
|
|
|
$str_th="";
|
|
|
$str_td="";
|
|
|
foreach ($list as $row) {
|
|
|
$PKP_AdultPrice = $row->PKP_AdultPrice;
|
|
|
$PKP_AdultSpecialPrice = $row->PKP_AdultSpecialPrice;
|
|
|
if ($PKP_AdultPrice!=$PKP_AdultSpecialPrice && $PKP_AdultSpecialPrice>0){
|
|
|
$PKP_AdultPrice=$PKP_AdultSpecialPrice;
|
|
|
}
|
|
|
$PKP_AdultPrice = $this->currency->convert_moneny_by_char($PKP_AdultPrice,"USD");
|
|
|
$PKP_PersonStart = $row->PKP_PersonStart;
|
|
|
$PKP_PersonStop = $row->PKP_PersonStop;
|
|
|
//'根据数据生成显示内容
|
|
|
if ($PKP_PersonStart == $PKP_PersonStop){
|
|
|
$str_th .= "<th> ".$PKP_PersonStart." Person</th>";
|
|
|
}
|
|
|
else if ($PKP_PersonStop=="1000") {
|
|
|
$str_th .= "<th> >".$PKP_PersonStart." Person</th>";
|
|
|
}
|
|
|
else{
|
|
|
$str_th .= "<th> ".$PKP_PersonStart." - ".$PKP_PersonStop." Person</th>";
|
|
|
}
|
|
|
|
|
|
$str_td .="<td><strong class='orange'> $ ".$PKP_AdultPrice."</strong></td>";
|
|
|
}
|
|
|
|
|
|
echo '<table border="0" align="center" cellpadding="10" cellspacing="1" class="pricetable"><tr>'.$str_th.'</tr><tr>'.$str_td.'</tr></table>';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
echo "";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @description: 拷贝旧内容
|
|
|
* @param {*} 新信息ic_id ,旧URL
|
|
|
* @return {*}
|
|
|
* @Date Changed:
|
|
|
*/
|
|
|
public function copyOldUrl(){
|
|
|
//参数
|
|
|
$id = $this->input->post("id");
|
|
|
$oldUrl = $this->input->post("oldurl");
|
|
|
|
|
|
//调用拷贝
|
|
|
$update = $this->api_model->copyOldUrl($id,$oldUrl);
|
|
|
|
|
|
if ($update){
|
|
|
$result["status"]="ok";
|
|
|
}else{
|
|
|
$result["status"]="error";
|
|
|
}
|
|
|
$result["id"]=$id;
|
|
|
$result["oldUrl"]=$oldUrl;
|
|
|
echo json_encode($result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取是哪个站点调用
|
|
|
*/
|
|
|
public function getWebData(){
|
|
|
|
|
|
$chinatravel = [
|
|
|
'dei_sn' => '17',
|
|
|
'LGC' =>'104',
|
|
|
'WebCode'=>'chinatravel',
|
|
|
'WebUrl'=>'www.chinatravel.com',
|
|
|
'WebCdn'=>'data.chinatravel.com',
|
|
|
'imagesUrl'=>'images.chinatravel.com',
|
|
|
];
|
|
|
|
|
|
$shanghai = [
|
|
|
'dei_sn' => '25',
|
|
|
'LGC' =>'107',
|
|
|
'WebCode'=>'shanghai',
|
|
|
'WebUrl'=>'www.shanghaihighlights.com',
|
|
|
'WebCdn'=>'data.shanghaihighlights.com',
|
|
|
'imagesUrl'=>'images.shanghaihighlights.com',
|
|
|
];
|
|
|
|
|
|
$beijing = [
|
|
|
'dei_sn' => '26',
|
|
|
'LGC' =>'106',
|
|
|
'WebCode'=>'beijing',
|
|
|
'WebUrl'=>'www.mybeijingchina.com',
|
|
|
'WebCdn'=>'data.mybeijingchina.com',
|
|
|
'imagesUrl'=>'images.mybeijingchina.com',
|
|
|
];
|
|
|
|
|
|
$trainspread = [
|
|
|
'dei_sn' => '14',
|
|
|
'LGC' =>'1',
|
|
|
'WebCode'=>'trainspread',
|
|
|
'WebUrl'=>'www.trainspread.com',
|
|
|
'WebCdn'=>'data.trainspread.com',
|
|
|
'imagesUrl'=>'images.trainspread.com',
|
|
|
];
|
|
|
|
|
|
$guilin = [
|
|
|
'dei_sn' => '24',
|
|
|
'LGC' =>'103',
|
|
|
'WebCode'=>'guilin',
|
|
|
'WebUrl'=>'www.guilinchina.net',
|
|
|
'WebCdn'=>'data.guilinchina.net',
|
|
|
'imagesUrl'=>'images.guilinchina.net',
|
|
|
];
|
|
|
|
|
|
$hly = [
|
|
|
'dei_sn' => '31',
|
|
|
'LGC' =>'2',
|
|
|
'WebCode'=>'hly',
|
|
|
'WebUrl'=>'www.hualiyingtravel.com',
|
|
|
'WebCdn'=>'www.hualiyingtravel.com',
|
|
|
'imagesUrl'=>'www.hualiyingtravel.com',
|
|
|
];
|
|
|
|
|
|
|
|
|
$localeMap = [
|
|
|
'chinatravel' => $chinatravel,
|
|
|
'shanghai' => $shanghai,
|
|
|
'beijing' => $beijing,
|
|
|
'trainspread' => $trainspread,
|
|
|
'guilin' =>$guilin,
|
|
|
'hly' =>$hly,
|
|
|
];
|
|
|
|
|
|
if (isset($_GET["webcode"])){
|
|
|
$WebCode = $_GET["webcode"];
|
|
|
}else{
|
|
|
$WebCode = "chinatravel"; //默认读取ct站的数据
|
|
|
}
|
|
|
|
|
|
if (!isset($localeMap[$WebCode])){
|
|
|
$WebCode = "chinatravel" ; //如果传递的站点编码找不到对应数据,也默认为ct站
|
|
|
}
|
|
|
|
|
|
|
|
|
//根据各站点信息赋值model
|
|
|
$this->api_model->dei_sn = $localeMap[$WebCode]["dei_sn"];
|
|
|
$this->api_model->CTLGC = $localeMap[$WebCode]["LGC"];
|
|
|
$this->api_model->WebCode = $localeMap[$WebCode]["WebCode"];
|
|
|
$this->api_model->WebUrl = $localeMap[$WebCode]["WebUrl"];
|
|
|
$this->api_model->WebCdn = $localeMap[$WebCode]["WebCdn"];
|
|
|
$this->api_model->imagesUrl = $localeMap[$WebCode]["imagesUrl"];
|
|
|
|
|
|
//print_r($localeMap[$WebCode]);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取对应产品的汉特详细信息
|
|
|
*/
|
|
|
public function getDaytripDetail(){
|
|
|
if (isset($_GET["param"])){
|
|
|
$param = $_GET["param"];
|
|
|
$list = new stdClass();
|
|
|
if (strpos($param,",")!== false){
|
|
|
$arrCode = explode(",",$param);
|
|
|
$pagecode = $arrCode[0];
|
|
|
|
|
|
}else{
|
|
|
$arrCode = array($param);
|
|
|
$pagecode = $param;
|
|
|
}
|
|
|
//基础信息,如果有关联,读取第一条产品
|
|
|
$list = $this->api_model->get_pagdetail($pagecode);
|
|
|
$i = 0 ;
|
|
|
$ProductList = array();
|
|
|
foreach ($arrCode as $value) {
|
|
|
$value = trim($value);
|
|
|
//循环读取每条产品的价格列表
|
|
|
$ProductList[$i] = new stdClass();
|
|
|
$ProductList[$i] ->productdetail = $this->api_model->get_pagdetail($value);
|
|
|
$priceData = $this->api_model->getDaytripPriceData($value);
|
|
|
$j = 0;
|
|
|
foreach($priceData as $row){
|
|
|
$PKP_AdultPrice = $row->PKP_AdultPrice;
|
|
|
$PKP_AdultPrice = $this->currency->convert_moneny_by_char($PKP_AdultPrice,"USD");
|
|
|
$PKP_ChildPrice = $row->PKP_ChildPrice;
|
|
|
$PKP_ChildPrice = $this->currency->convert_moneny_by_char($PKP_ChildPrice,"USD");
|
|
|
$priceData[$j]->PKP_AdultPrice = $PKP_AdultPrice;
|
|
|
$priceData[$j]->PKP_ChildPrice = $PKP_ChildPrice;
|
|
|
$j++;
|
|
|
}
|
|
|
$ProductList[$i] ->pricelist = $priceData;
|
|
|
$i++;
|
|
|
}
|
|
|
$list->productlist = $ProductList;
|
|
|
|
|
|
echo json_encode($list,JSON_NUMERIC_CHECK);
|
|
|
|
|
|
|
|
|
}else{
|
|
|
echo null;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取线路类型列表
|
|
|
*/
|
|
|
public function getLineTypeList(){
|
|
|
$list = $this->api_model->getLineTypeList();
|
|
|
echo json_encode($list,JSON_NUMERIC_CHECK);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取所有录入线路的列表
|
|
|
*/
|
|
|
public function getTourList(){
|
|
|
$list = $this->api_model->getTourList();
|
|
|
echo json_encode($list,JSON_UNESCAPED_UNICODE);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取发布的一日游详细页的所有产品对应的类型列表,扩展类型列表。(用于搜索页)
|
|
|
*/
|
|
|
public function getPagTypeList(){
|
|
|
$list = $this->api_model->getPagTypeList();
|
|
|
echo json_encode($list,JSON_UNESCAPED_UNICODE);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取所有录入一日游的列表(搜索页)
|
|
|
*/
|
|
|
function getSearchDaytripList(){
|
|
|
$list = $this->api_model->getSearchDaytripList();
|
|
|
echo json_encode($list,JSON_UNESCAPED_UNICODE);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/* End of file Api.php */
|