|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- <?php
- define( "API_USER", "zzcx01");
- define( "API_PASSWORD", "12345678");
- define( "API_SIGN", "03EF41375E5149EFB5CCD6AE236555C7");
- define( "DISNEY_CODE1", "SHDSN" );//单日票
- define( "DISNEY_CODE2", "SHDSN2" );//两日票
- define( "DISNEY_CODE3", "DSNSZW" );//演出票
-
- //define( "API_USER", "zzcx02");
- //define( "API_PASSWORD", "12345678");
- //define( "API_SIGN", "4E84E1EEBAF00B352DEF2B8F3336B63C");
- //define( "DISNEY_CODE1", "shz101" );//单日票
- //define( "DISNEY_CODE2", "shz101" );//两日票
- //define( "DISNEY_CODE3", "shz101" );//演出票
-
- define( "LOGIN_URL", "http://partner.zizaitrip.net/login" );
- define( "OPERATE_URL", "http://partner.zizaitrip.net/interface" );
-
- $_ary_goods_zizai_index = array(
- "3" => "成人票",
- "4" => "老人票",
- "5" => "儿童票",
- "6" => "成人票",
- "7" => "老人票",
- "8" => "儿童票",
- "9" => "AA区",
- "10" => "AB区",
- "11" => "BA区",
- "12" => "BB区",
- "13" => "CA区",
- "14" => "CB区"
- );
-
- //向自在发送post参数(链接,参数数组)
- function send_post($url, $post_data) {
- $postdata = http_build_query($post_data);
- $options = array(
- 'http' => array(
- 'method' => 'POST',
- 'header' => 'Content-type:application/x-www-form-urlencoded',
- 'content' => $postdata,
- 'timeout' => 15 * 60 // 超时时间(单位:s)
- )
- );
- $context = stream_context_create($options);
- $result = file_get_contents($url, false, $context);
- return $result;
- }
-
- //向自在发送get参数(链接,参数数组)
- function send_get($url, $get_data) {
- $url_param = http_build_query($get_data);
- $result = file_get_contents($url."?{$url_param}");
- return $result;
- }
-
- //将xml转换为数组
- function xml_to_array($xml)
- {
- $ob = simplexml_load_string($xml);
- $json = json_encode($ob);
- $array = json_decode($json, true);
- return $array;
- }
-
- //获取数据(链接,参数数组)
- function base_api( $url, $get_data ) {
- $get_data["tt"] = rand(100000,999999);
- $return_result = send_get($url, $get_data);
- $return_result = xml_to_array($return_result);
- return $return_result;
- }
-
- //登录接口(用户名,密码)
- function login_api( $user, $pass ) {
- $get_data = array("user" => $user,"pass" => $pass);
- return base_api( LOGIN_URL, $get_data);
- }
-
- //票务系统线路列表查询(用户名,密码,操作参数)
- function run_list( $user, $pass){
- $sign = API_SIGN;
- $get_data = array("user" => $user,"sign" => $sign,"op" => "list");
- return base_api( OPERATE_URL, $get_data);
- }
-
- //获取线路运营日期数据(用户名,密码,操作参数,线路代码)
- function godate( $user, $pass, $projcode){
- $sign = API_SIGN;
- $get_data = array("user" => $user,"sign" => $sign,"op" => "godate","projcode" => $projcode);
- return base_api( OPERATE_URL, $get_data);
- }
-
- //获取线路运营班次数据(用户名,密码,操作参数,线路代码,运营日期)
- function gorun( $user, $pass, $projcode ,$godate){
- $sign = API_SIGN;
- $get_data = array("user" => $user,"sign" => $sign,"op" => "gorun","projcode" => $projcode,"godate" => $godate);
- return base_api( OPERATE_URL, $get_data);
- }
-
- //获取某个线路代码某一天的票种信息
- function get_ticket_array( $user, $pass, $projcode , $godate, $gotime = "" ) {
- $return_result = gorun($user, $pass, $projcode ,$godate);
- if( $return_result["code"] == 0 ) {
- $run_array = $return_result["go_run_list"]["run"];
- if( isset($return_result["go_run_list"]["run"]["runid"]) ) {
- $run_id = $return_result["go_run_list"]["run"]["runid"];
- } else {
- foreach ($run_array as $run_info) {
- if ( $gotime == "" || $run_info["runtime"] == $gotime) {
- $run_id = $run_info["runid"];
- break;
- }
- }
- }
- } else {
- return false;
- }
- $return_result = ticket( $user, $pass, $projcode, $run_id);
- if( $return_result["code"] == 0 ) {
- $ticket_array = $return_result["ticket_list"]["ticket"];
- } else {
- $ticket_array = false;
- }
- return $ticket_array;
- }
-
- //获取迪士尼单日票信息
- function get_disney_info( $godate, $gotime = "" ) {
- $ticket_array = get_ticket_array( API_USER,API_PASSWORD, DISNEY_CODE1, $godate, $gotime );
- if( $ticket_array == false ) { return false; }
- $ticket_array2 = array();
- foreach( $ticket_array as $ticket_info ) {
- if( mb_strpos("成人",$ticket_info["ticketname"]) !== false ) {
- $index_name = "成人票";
- } else if( mb_strpos("儿童",$ticket_info["ticketname"]) !== false ) {
- $index_name = "儿童票";
- } else if( mb_strpos("老人",$ticket_info["ticketname"]) !== false ) {
- $index_name = "老人票";
- } else {
- $name_length = mb_strlen($ticket_info["ticketname"]);
- $index_name = mb_substr($ticket_info["ticketname"], $name_length - 3, 3);
- }
- $ticket_array2[$index_name] = $ticket_info;
- }
- return $ticket_array2;
- }
-
- //获取迪士尼两日票信息
- function get_disney_info2( $godate, $gotime = "" ) {
- $ticket_array = get_ticket_array( API_USER,API_PASSWORD, DISNEY_CODE2, $godate, $gotime );
- if( $ticket_array == false ) { return false; }
- $ticket_array2 = array();
- foreach( $ticket_array as $ticket_info ) {
- // $name_length = mb_strlen($ticket_info["ticketname"]);
- if( mb_strpos("成人",$ticket_info["ticketname"]) !== false ) {
- $index_name = "成人票";
- } else if( mb_strpos("儿童",$ticket_info["ticketname"]) !== false ) {
- $index_name = "儿童票";
- } else if( mb_strpos("老人",$ticket_info["ticketname"]) !== false ) {
- $index_name = "老人票";
- } else {
- $index_name = mb_substr($ticket_info["ticketname"], 2, 3);
- }
- $ticket_array2[$index_name] = $ticket_info;
- }
- return $ticket_array2;
- }
-
- //获取迪士尼演出信息
- function get_disney_info3( $godate, $gotime = "" ) {
- $ticket_array = get_ticket_array( API_USER,API_PASSWORD, DISNEY_CODE3, $godate, $gotime );
- if( $ticket_array == false ) { return false; }
- $ticket_array2 = array();
- foreach( $ticket_array as $ticket_info ) {
- $index_name = mb_substr($ticket_info["ticketname"],2,3);
- $ticket_array2[$index_name] = $ticket_info;
- }
- return $ticket_array2;
- }
-
- //获取线路运营班次返程日期数据(用户名,密码,操作参数,线路代码,去程班次id)
- function backdate( $user, $pass, $projcode ,$runid){
- $sign = API_SIGN;
- $get_data = array("user" => $user,"sign" => $sign,"op" => "backdate","projcode" => $projcode,"runid" => $runid);
- return base_api( OPERATE_URL, $get_data);
- }
-
- //获取线路特定班次返程班次数据(用户名,密码,操作参数,线路代码,去程班次id,回程日期)
- function backrun( $user, $pass, $projcode ,$runid ,$backdate){
- $sign = API_SIGN;
- $get_data = array("user" => $user,"sign" => $sign,"op" => "backrun","projcode" => $projcode,"runid" => $runid,"backdate" => $backdate);
- return base_api( OPERATE_URL, $get_data);
- }
-
- //获取班次票种数据(用户名,密码,操作参数,线路代码,去程班次id)
- function ticket( $user, $pass, $projcode ,$runid){
- $sign = API_SIGN;
- $get_data = array("user" => $user,"sign" => $sign,"op" => "ticket","projcode" => $projcode,"runid" => $runid);
- return base_api( OPERATE_URL, $get_data);
- }
-
- //票务系统锁位(用户名,密码,操作参数,锁位时间,票种id及张数中间用‘P’隔开,订单客人信息,会员ID,优惠码,会员积分)
- function lock( $user, $pass, $lock = 15 ,$ticket ,$customer = "",$memid = "",$barcode = "",$score= ""){
- $sign = API_SIGN;
- $get_data = array("user" => $user,"sign" => $sign,"op" => "lock","lock" => $lock,"ticket" => $ticket,"customer" => $customer,"memid" => $memid,"barcode" => $barcode,"score" => $score);
- return base_api( OPERATE_URL, $get_data);
- }
-
- //票务系统订单确认(用户名,密码,操作参数,票务系统订单号)
- function eticket( $user, $pass, $tradeno){
- $sign = API_SIGN;
- $get_data = array("user" => $user,"sign" => $sign,"op" => "eticket","tradeno" => $tradeno);
- return base_api( OPERATE_URL, $get_data);
- }
-
- //票务系统更新补充客户数据(用户名,密码,操作参数,票务系统订单号,客户信息)
- function customer( $user, $pass, $tradeno ,$customerlist){
- $sign = API_SIGN;
- $get_data = array("user" => $user,"sign" => $sign,"op" => "customer","tradeno" => $tradeno,"customerlist" => $customerlist);
- return base_api( OPERATE_URL, $get_data);
- }
-
- //票务系统订单状态查询(用户名,密码,操作参数,票务系统订单号)
- function status( $user, $pass, $tn){
- $sign = API_SIGN;
- $get_data = array("user" => $user,"sign" => $sign,"op" => "status","tn" => $tn);
- return base_api( OPERATE_URL, $get_data);
- }
-
- //获取线路产品介绍信息(用户名,密码,操作参数,产品代码)
- function circuitry( $user, $pass, $op, $ccode){
- $sign = API_SIGN;
- $get_data = array("user" => $user,"sign" => $sign,"op" => "circuitry","ccode" => $ccode);
- return base_api( OPERATE_URL, $get_data);
- }
|