|
|
<?php
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
|
}
|
|
|
|
|
|
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 = $price->PKP_AdultSpecialPrice;
|
|
|
$PKP_AdultPrice = $price->PKP_AdultPrice;
|
|
|
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($this->currency->convert_moneny_by_char($price,"USD"));
|
|
|
}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
|
|
|
}
|
|
|
|
|
|
|
|
|
//图片
|
|
|
$imageCdn = "//images.chinatravel.com";//有些HT绑定图片需要加cdn
|
|
|
if (!empty($row->pic1)){
|
|
|
if (strpos($row->pic1,"chinatravel.com")!== false){
|
|
|
$picurl=$row->pic1;
|
|
|
}else{
|
|
|
$picurl = $imageCdn.$row->pic1;
|
|
|
}
|
|
|
|
|
|
}else if(!empty($row->pic2)){
|
|
|
if (strpos($row->pic2,"chinatravel.com")!== false){
|
|
|
$picurl=$row->pic2;
|
|
|
}else{
|
|
|
$picurl = $imageCdn.$row->pic2;
|
|
|
}
|
|
|
}else{
|
|
|
$picurl="//data.chinatravel.com/images/loading2.gif";
|
|
|
}
|
|
|
|
|
|
$row->price = $addPrice; //新增价格属性
|
|
|
$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/loading2.gif";
|
|
|
}
|
|
|
|
|
|
$row->pic = $picurl; //显示图片地址
|
|
|
}
|
|
|
|
|
|
echo json_encode($list);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/* End of file Api.php */
|