You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

236 line
9.2 KiB

  1. <?php
  2. define( "API_USER", "zzcx01");
  3. define( "API_PASSWORD", "12345678");
  4. define( "API_SIGN", "03EF41375E5149EFB5CCD6AE236555C7");
  5. define( "DISNEY_CODE1", "SHDSN" );//单日票
  6. define( "DISNEY_CODE2", "SHDSN2" );//两日票
  7. define( "DISNEY_CODE3", "DSNSZW" );//演出票
  8. //define( "API_USER", "zzcx02");
  9. //define( "API_PASSWORD", "12345678");
  10. //define( "API_SIGN", "4E84E1EEBAF00B352DEF2B8F3336B63C");
  11. //define( "DISNEY_CODE1", "shz101" );//单日票
  12. //define( "DISNEY_CODE2", "shz101" );//两日票
  13. //define( "DISNEY_CODE3", "shz101" );//演出票
  14. define( "LOGIN_URL", "http://partner.zizaitrip.net/login" );
  15. define( "OPERATE_URL", "http://partner.zizaitrip.net/interface" );
  16. $_ary_goods_zizai_index = array(
  17. "3" => "成人票",
  18. "4" => "老人票",
  19. "5" => "儿童票",
  20. "6" => "成人票",
  21. "7" => "老人票",
  22. "8" => "儿童票",
  23. "9" => "AA区",
  24. "10" => "AB区",
  25. "11" => "BA区",
  26. "12" => "BB区",
  27. "13" => "CA区",
  28. "14" => "CB区"
  29. );
  30. //向自在发送post参数(链接,参数数组)
  31. function send_post($url, $post_data) {
  32. $postdata = http_build_query($post_data);
  33. $options = array(
  34. 'http' => array(
  35. 'method' => 'POST',
  36. 'header' => 'Content-type:application/x-www-form-urlencoded',
  37. 'content' => $postdata,
  38. 'timeout' => 15 * 60 // 超时时间(单位:s)
  39. )
  40. );
  41. $context = stream_context_create($options);
  42. $result = file_get_contents($url, false, $context);
  43. return $result;
  44. }
  45. //向自在发送get参数(链接,参数数组)
  46. function send_get($url, $get_data) {
  47. $url_param = http_build_query($get_data);
  48. $result = file_get_contents($url."?{$url_param}");
  49. return $result;
  50. }
  51. //将xml转换为数组
  52. function xml_to_array($xml)
  53. {
  54. $ob = simplexml_load_string($xml);
  55. $json = json_encode($ob);
  56. $array = json_decode($json, true);
  57. return $array;
  58. }
  59. //获取数据(链接,参数数组)
  60. function base_api( $url, $get_data ) {
  61. $get_data["tt"] = rand(100000,999999);
  62. $return_result = send_get($url, $get_data);
  63. $return_result = xml_to_array($return_result);
  64. return $return_result;
  65. }
  66. //登录接口(用户名,密码)
  67. function login_api( $user, $pass ) {
  68. $get_data = array("user" => $user,"pass" => $pass);
  69. return base_api( LOGIN_URL, $get_data);
  70. }
  71. //票务系统线路列表查询(用户名,密码,操作参数)
  72. function run_list( $user, $pass){
  73. $sign = API_SIGN;
  74. $get_data = array("user" => $user,"sign" => $sign,"op" => "list");
  75. return base_api( OPERATE_URL, $get_data);
  76. }
  77. //获取线路运营日期数据(用户名,密码,操作参数,线路代码)
  78. function godate( $user, $pass, $projcode){
  79. $sign = API_SIGN;
  80. $get_data = array("user" => $user,"sign" => $sign,"op" => "godate","projcode" => $projcode);
  81. return base_api( OPERATE_URL, $get_data);
  82. }
  83. //获取线路运营班次数据(用户名,密码,操作参数,线路代码,运营日期)
  84. function gorun( $user, $pass, $projcode ,$godate){
  85. $sign = API_SIGN;
  86. $get_data = array("user" => $user,"sign" => $sign,"op" => "gorun","projcode" => $projcode,"godate" => $godate);
  87. return base_api( OPERATE_URL, $get_data);
  88. }
  89. //获取某个线路代码某一天的票种信息
  90. function get_ticket_array( $user, $pass, $projcode , $godate, $gotime = "" ) {
  91. $return_result = gorun($user, $pass, $projcode ,$godate);
  92. if( $return_result["code"] == 0 ) {
  93. $run_array = $return_result["go_run_list"]["run"];
  94. if( isset($return_result["go_run_list"]["run"]["runid"]) ) {
  95. $run_id = $return_result["go_run_list"]["run"]["runid"];
  96. } else {
  97. foreach ($run_array as $run_info) {
  98. if ( $gotime == "" || $run_info["runtime"] == $gotime) {
  99. $run_id = $run_info["runid"];
  100. break;
  101. }
  102. }
  103. }
  104. } else {
  105. return false;
  106. }
  107. $return_result = ticket( $user, $pass, $projcode, $run_id);
  108. if( $return_result["code"] == 0 ) {
  109. $ticket_array = $return_result["ticket_list"]["ticket"];
  110. } else {
  111. $ticket_array = false;
  112. }
  113. return $ticket_array;
  114. }
  115. //获取迪士尼单日票信息
  116. function get_disney_info( $godate, $gotime = "" ) {
  117. $ticket_array = get_ticket_array( API_USER,API_PASSWORD, DISNEY_CODE1, $godate, $gotime );
  118. if( $ticket_array == false ) { return false; }
  119. $ticket_array2 = array();
  120. foreach( $ticket_array as $ticket_info ) {
  121. if( mb_strpos("成人",$ticket_info["ticketname"]) !== false ) {
  122. $index_name = "成人票";
  123. } else if( mb_strpos("儿童",$ticket_info["ticketname"]) !== false ) {
  124. $index_name = "儿童票";
  125. } else if( mb_strpos("老人",$ticket_info["ticketname"]) !== false ) {
  126. $index_name = "老人票";
  127. } else {
  128. $name_length = mb_strlen($ticket_info["ticketname"]);
  129. $index_name = mb_substr($ticket_info["ticketname"], $name_length - 3, 3);
  130. }
  131. $ticket_array2[$index_name] = $ticket_info;
  132. }
  133. return $ticket_array2;
  134. }
  135. //获取迪士尼两日票信息
  136. function get_disney_info2( $godate, $gotime = "" ) {
  137. $ticket_array = get_ticket_array( API_USER,API_PASSWORD, DISNEY_CODE2, $godate, $gotime );
  138. if( $ticket_array == false ) { return false; }
  139. $ticket_array2 = array();
  140. foreach( $ticket_array as $ticket_info ) {
  141. // $name_length = mb_strlen($ticket_info["ticketname"]);
  142. if( mb_strpos("成人",$ticket_info["ticketname"]) !== false ) {
  143. $index_name = "成人票";
  144. } else if( mb_strpos("儿童",$ticket_info["ticketname"]) !== false ) {
  145. $index_name = "儿童票";
  146. } else if( mb_strpos("老人",$ticket_info["ticketname"]) !== false ) {
  147. $index_name = "老人票";
  148. } else {
  149. $index_name = mb_substr($ticket_info["ticketname"], 2, 3);
  150. }
  151. $ticket_array2[$index_name] = $ticket_info;
  152. }
  153. return $ticket_array2;
  154. }
  155. //获取迪士尼演出信息
  156. function get_disney_info3( $godate, $gotime = "" ) {
  157. $ticket_array = get_ticket_array( API_USER,API_PASSWORD, DISNEY_CODE3, $godate, $gotime );
  158. if( $ticket_array == false ) { return false; }
  159. $ticket_array2 = array();
  160. foreach( $ticket_array as $ticket_info ) {
  161. $index_name = mb_substr($ticket_info["ticketname"],2,3);
  162. $ticket_array2[$index_name] = $ticket_info;
  163. }
  164. return $ticket_array2;
  165. }
  166. //获取线路运营班次返程日期数据(用户名,密码,操作参数,线路代码,去程班次id)
  167. function backdate( $user, $pass, $projcode ,$runid){
  168. $sign = API_SIGN;
  169. $get_data = array("user" => $user,"sign" => $sign,"op" => "backdate","projcode" => $projcode,"runid" => $runid);
  170. return base_api( OPERATE_URL, $get_data);
  171. }
  172. //获取线路特定班次返程班次数据(用户名,密码,操作参数,线路代码,去程班次id,回程日期)
  173. function backrun( $user, $pass, $projcode ,$runid ,$backdate){
  174. $sign = API_SIGN;
  175. $get_data = array("user" => $user,"sign" => $sign,"op" => "backrun","projcode" => $projcode,"runid" => $runid,"backdate" => $backdate);
  176. return base_api( OPERATE_URL, $get_data);
  177. }
  178. //获取班次票种数据(用户名,密码,操作参数,线路代码,去程班次id)
  179. function ticket( $user, $pass, $projcode ,$runid){
  180. $sign = API_SIGN;
  181. $get_data = array("user" => $user,"sign" => $sign,"op" => "ticket","projcode" => $projcode,"runid" => $runid);
  182. return base_api( OPERATE_URL, $get_data);
  183. }
  184. //票务系统锁位(用户名,密码,操作参数,锁位时间,票种id及张数中间用‘P’隔开,订单客人信息,会员ID,优惠码,会员积分)
  185. function lock( $user, $pass, $lock = 15 ,$ticket ,$customer = "",$memid = "",$barcode = "",$score= ""){
  186. $sign = API_SIGN;
  187. $get_data = array("user" => $user,"sign" => $sign,"op" => "lock","lock" => $lock,"ticket" => $ticket,"customer" => $customer,"memid" => $memid,"barcode" => $barcode,"score" => $score);
  188. return base_api( OPERATE_URL, $get_data);
  189. }
  190. //票务系统订单确认(用户名,密码,操作参数,票务系统订单号)
  191. function eticket( $user, $pass, $tradeno){
  192. $sign = API_SIGN;
  193. $get_data = array("user" => $user,"sign" => $sign,"op" => "eticket","tradeno" => $tradeno);
  194. return base_api( OPERATE_URL, $get_data);
  195. }
  196. //票务系统更新补充客户数据(用户名,密码,操作参数,票务系统订单号,客户信息)
  197. function customer( $user, $pass, $tradeno ,$customerlist){
  198. $sign = API_SIGN;
  199. $get_data = array("user" => $user,"sign" => $sign,"op" => "customer","tradeno" => $tradeno,"customerlist" => $customerlist);
  200. return base_api( OPERATE_URL, $get_data);
  201. }
  202. //票务系统订单状态查询(用户名,密码,操作参数,票务系统订单号)
  203. function status( $user, $pass, $tn){
  204. $sign = API_SIGN;
  205. $get_data = array("user" => $user,"sign" => $sign,"op" => "status","tn" => $tn);
  206. return base_api( OPERATE_URL, $get_data);
  207. }
  208. //获取线路产品介绍信息(用户名,密码,操作参数,产品代码)
  209. function circuitry( $user, $pass, $op, $ccode){
  210. $sign = API_SIGN;
  211. $get_data = array("user" => $user,"sign" => $sign,"op" => "circuitry","ccode" => $ccode);
  212. return base_api( OPERATE_URL, $get_data);
  213. }