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.
 
 
 
 

563 lines
30 KiB

  1. <?php
  2. require_once __DIR__.'/../st-xm/Common/Mysql.php';
  3. require_once __DIR__.'/../st-xm/Common/config_api.inc';
  4. require_once '/usr/share/nginx/ZZCS/coding/st-xm/Common/sinaAPI.php';
  5. require_once '/usr/share/nginx/ZZCS/coding/st-xm/Common/zizai_orderAPI.php';
  6. header("Access-Control-Allow-Origin:*");
  7. $current_time = time();
  8. $current_hour = date("H:i:s",$current_time);
  9. $tomorrow_day = date("Y-m-d",strtotime("+1 days"));
  10. $today = date("Y-m-d");
  11. $limit_time = date("H:i", strtotime("+30 minutes"));
  12. //拼接数组
  13. $post_data = array();
  14. $post_data["agentId"] = QUNAR_AGENT_ID;
  15. $post_data["time"] = $current_time;
  16. $post_data["auth"] = get_qunar_auth($post_data);
  17. $return_data = send_post( QUNAR_CHECK_ORDER_URL, $post_data);
  18. $return_array = json_decode($return_data,true);
  19. if( !isset($return_array["orderNum"]) || $return_array["orderNum"] <= 0 ) {
  20. print_r($return_array);
  21. return;
  22. }
  23. //print_r($return_array);exit();//test
  24. $no_sell_array = array(152739,152740,152741,152691,152697,152715,152709,152715,153133,153135,153137,152569,152570,152571,152572,152573,152575,152577,152579,152581,152582,152695,152696,152706,152707,448587,449825,449827,449829,449831,449832,449843,449847,449825,449827,449829,449831);
  25. $limit_sell_prod = array( 448568, 448569,448778,448779,448780,448781);
  26. $userid = 1;
  27. $current_time = date("Y-m-d H:i:s");
  28. $pdo=conn1();
  29. $order_array = $return_array["data"];
  30. foreach( $order_array as $order_info ) {
  31. $run_code = $order_info["coachNo"];
  32. $run_code_array = explode("_",$run_code);
  33. if( isset($run_code_array[1]) ) {
  34. $run_code = $run_code_array[0];
  35. $prod_id = $run_code_array[1];
  36. } else {
  37. //zizai
  38. $run_code = $run_code_array[1];
  39. }
  40. $ticket_num = $order_info["ticketNum"];
  41. $customer_name = $order_info["contactName"];
  42. $customer_mobile = descryption_by_shif($order_info["contactPhone"]);
  43. $customer_id_no = descryption_by_shif($order_info["contactId"]);
  44. $out_order_no = $order_info["orderNo"];
  45. $passengers = $order_info["passengers"];
  46. $passengers_array = array();
  47. foreach( $passengers as $passenger_info ) {
  48. $passengers_array[] = $passenger_info["passengerName"]."*".descryption_by_shif($passenger_info["passengerId"]);
  49. }
  50. $passengers_list = implode("/",$passengers_array);
  51. $sql = " SELECT * FROM order_main WHERE OUTSIDE_ORDER_NO='{$out_order_no}' AND PARENT_ORDER_ID = 0 ";
  52. $result = $pdo->query($sql);
  53. $rowset = $result->fetchAll();
  54. $result->closeCursor();
  55. if ($rowset != false) {
  56. continue;
  57. }
  58. if( isset($run_code_array[1]) ) {
  59. $sql = " SELECT * FROM run_main WHERE RUN_ID={$run_code} ";
  60. $result = $pdo->query($sql);
  61. $rowset = $result->fetchAll();
  62. $result->closeCursor();
  63. $run_main_info = $rowset[0];
  64. if( $run_main_info["RUN_DATE"] != $order_info["date"] ) {
  65. $sql = " SELECT * FROM run_main WHERE PROD_ID={$run_main_info["PROD_ID"]} AND RUN_DATE='{$order_info["date"]}' ";
  66. $result = $pdo->query($sql);
  67. $rowset = $result->fetchAll();
  68. $result->closeCursor();
  69. $run_main_info = $rowset[0];
  70. $run_code = $run_main_info["RUN_ID"];
  71. }
  72. $sql = " SELECT * FROM opera_product_price WHERE PROD_ID={$prod_id} ";
  73. $result = $pdo->query($sql);
  74. $rowset = $result->fetchAll();
  75. $result->closeCursor();
  76. $per_price = $rowset[0]["CUS_PRICE"];
  77. $all_price = $per_price * $ticket_num;
  78. } else {
  79. //zizai
  80. $prod_id = $run_code_array[0];
  81. $sql = " SELECT * FROM outside_run WHERE prod_code='".$prod_id."' AND cancel_flag = 0 ";
  82. $result=$pdo->query($sql);
  83. $rowset=$result->fetchAll();
  84. $result->closeCursor();
  85. if( false == $rowset ) {
  86. $post_data = array();
  87. $post_data["agentId"] = QUNAR_AGENT_ID;
  88. $post_data["time"] = $current_time;
  89. $post_data["comment"] = "出票失败:该线路已停售";
  90. $post_data["ticketInfo"] = json_encode(array( "ret" => false, "data" => array("orderNo" => $out_order_no, "ticketStatu" => 1)) );
  91. $post_data["auth"] = get_qunar_auth($post_data);
  92. $complete_result = send_post( QUNAR_COMPLETE_ORDER_URL, $post_data );
  93. continue;
  94. }
  95. $run_info = $rowset[0];
  96. if( $run_info["start_date"] != $order_info["date"] ) {
  97. $sql = " SELECT * FROM outside_run WHERE line_code='{$run_info["line_code"]}' AND start_date='{$order_info["date"]}' AND start_time='{$order_info["startTime"]}' AND prod_name='{$run_info["prod_name"]}'";
  98. $result = $pdo->query($sql);
  99. $rowset = $result == false ? false : $result->fetchAll();
  100. $result->closeCursor();
  101. if( false == $rowset ) {
  102. $post_data = array();
  103. $post_data["agentId"] = QUNAR_AGENT_ID;
  104. $post_data["time"] = $current_time;
  105. $post_data["comment"] = "出票失败:该线路已停售";
  106. $post_data["ticketInfo"] = json_encode(array( "ret" => false, "data" => array("orderNo" => $out_order_no, "ticketStatu" => 1)) );
  107. $post_data["auth"] = get_qunar_auth($post_data);
  108. $complete_result = send_post( QUNAR_COMPLETE_ORDER_URL, $post_data );
  109. continue;
  110. }
  111. $run_info = $rowset[0];
  112. $prod_id = $run_info["prod_code"];
  113. }
  114. $per_price = $run_info["cus_price"];
  115. $all_price = $per_price * $ticket_num;
  116. }
  117. $pdo_insert = conn1();
  118. $sql_insert = " INSERT INTO outside_submit_order (from_org_id,outside_order_no,prod_id,ticket_num,per_price,all_price,customer_name,customer_mobile,customer_id_no,submit_status,opera_time,passenger) VALUE(" .
  119. "28,'{$out_order_no}','{$order_info["coachNo"]}',{$ticket_num},{$per_price},{$all_price},'{$customer_name}','{$customer_mobile}','{$customer_id_no}',0,'{$current_time}','{$passengers_list}') ";
  120. $pdo_insert->exec($sql_insert);
  121. if( !isset($run_code_array[1]) ) {
  122. $remain_count = $run_info["remain_count"] > 3 ? $run_info["remain_count"] - 3 : 0;
  123. $update_date = substr($run_info["update_time"],0,10);
  124. if( $update_date < $today ) {
  125. $remain_count = 0;
  126. }
  127. if( $remain_count < $ticket_num ) {
  128. $post_data = array();
  129. $post_data["agentId"] = QUNAR_AGENT_ID;
  130. $post_data["time"] = $current_time;
  131. $post_data["comment"] = "出票失败:该线路已停售";
  132. $post_data["ticketInfo"] = json_encode(array( "ret" => false, "data" => array("orderNo" => $out_order_no, "ticketStatu" => 1)) );
  133. $post_data["auth"] = get_qunar_auth($post_data);
  134. $complete_result = send_post( QUNAR_COMPLETE_ORDER_URL, $post_data );
  135. continue;
  136. }
  137. $run_code = $run_info["run_code"];
  138. //自在下票
  139. $setOrder = new orderService();
  140. //票务系统锁定
  141. $zizai_cus = "{|".$customer_name."|".$customer_mobile."|".$customer_id_no."||}";
  142. $lock_order = $setOrder->createOrder(zizaiArgs::$USER, $prod_id."P".$ticket_num."|", $customer_name,$customer_mobile,$customer_id_no,'', 0);
  143. //$lock_order = $setOrder->lock(zizaiArgs::$USER, 30, $prod_id."P".$ticket_num."|", $zizai_cus );
  144. if ($lock_order['code']!=0) {
  145. $post_data = array();
  146. $post_data["agentId"] = QUNAR_AGENT_ID;
  147. $post_data["time"] = $current_time;
  148. $post_data["comment"] = "出票失败:该线路已停售";
  149. $post_data["ticketInfo"] = json_encode(array( "ret" => false, "data" => array("orderNo" => $out_order_no, "ticketStatu" => 1)) );
  150. $post_data["auth"] = get_qunar_auth($post_data);
  151. $complete_result = send_post( QUNAR_COMPLETE_ORDER_URL, $post_data );
  152. continue;
  153. }
  154. $tradeno = $lock_order['tradeno'];
  155. $customerlist = "";
  156. foreach( $passengers as $passenger_info ) {
  157. $customerlist .= '{'.$prod_id.'|'.$passenger_info["passengerName"].'||'.descryption_by_shif($passenger_info["passengerId"]).'}';
  158. }
  159. $return_info = $setOrder->customer(zizaiArgs::$USER, $tradeno, $customerlist);
  160. $pdo_update3 = conn1();
  161. $sql_update = " UPDATE outside_submit_order set supply_order_id='{$tradeno}' WHERE outside_order_no='{$out_order_no}'";
  162. $pdo_update3->exec($sql_update);
  163. $post_data = array();
  164. $post_data["agentId"] = QUNAR_AGENT_ID;
  165. $post_data["time"] = $current_time;
  166. $line_name = str_replace("舟山","普陀山",$run_info["line_name"]);
  167. $post_data["comment"] = "出票成功:您已成功订购了{$line_name}[{$run_info["prod_name"]}]{$ticket_num}张。订单号为:".$tradeno."。出发时间:{$run_info["start_date"]} {$run_info["start_time"]}。上车地点:{$run_info["start_res"]}。请于发车前到上车站点的服务台领票。咨询电话4008872626";
  168. $ticketCode = sprintf("%d",$tradeno);
  169. for( $ticket_index = 1; $ticket_index < $ticket_num; $ticket_index++ ) {
  170. $ticketCode .= "|".sprintf("%d",$tradeno);
  171. }
  172. $post_data["ticketInfo"] = json_encode(array( "ret" => true, "data" => array("orderNo" => $out_order_no, "ticketStatu" => 0, "ticketNum" => sprintf("%d",$ticket_num), "ticketPassword" => $ticketCode, "ticketCode" => $ticketCode )) );
  173. $post_data["auth"] = get_qunar_auth($post_data);
  174. $complete_result = send_post( QUNAR_COMPLETE_ORDER_URL, $post_data );
  175. /*
  176. $res_order = $setOrder->eticket(zizaiArgs::$USER, $tradeno);
  177. if ($res_order['code']!=0) {
  178. $post_data = array();
  179. $post_data["agentId"] = QUNAR_AGENT_ID;
  180. $post_data["time"] = $current_time;
  181. $post_data["comment"] = "出票失败:该线路已停售";
  182. $post_data["ticketInfo"] = json_encode(array( "ret" => false, "data" => array("orderNo" => $out_order_no, "ticketStatu" => 1)) );
  183. $post_data["auth"] = get_qunar_auth($post_data);
  184. $complete_result = send_post( QUNAR_COMPLETE_ORDER_URL, $post_data );
  185. continue;
  186. }*/
  187. //出发地和目的地的area_id
  188. $sql = " SELECT ID,AREA_NAME FROM base_area WHERE AREA_NAME like \"".$run_info["start_area"]."%%\" AND cancel_flag = 0 ";
  189. $result=$pdo->query($sql);
  190. $rowset=$result->fetchAll();
  191. $result->closeCursor();
  192. if( $rowset == false ) {
  193. $start_area_id = 791;
  194. } else {
  195. $start_area_id = $rowset[0]["ID"];
  196. }
  197. $sql = " SELECT ID,AREA_NAME FROM base_area WHERE AREA_NAME like \"".$run_info["end_area"]."%%\" AND cancel_flag = 0 ";
  198. $result=$pdo->query($sql);
  199. $rowset=$result->fetchAll();
  200. $result->closeCursor();
  201. if( $rowset == false ) {
  202. $end_area_id = 791;
  203. } else {
  204. $end_area_id = $rowset[0]["ID"];
  205. }
  206. $userid = 1;
  207. $prod_id = 380001;
  208. $run_code = 0;
  209. $myprod = '{m'.$prod_id.'p'.$ticket_num.'|r'.$run_code.'}';
  210. $mycustomer = "{,".$customer_name.",,".$customer_mobile.",150,".$customer_id_no.",,,,".$passenger_txt."}";
  211. $run_info_txt = "{0,普通座票,".$run_info["line_name"].",".$run_info["start_date"].",".$run_info["start_time"].",".$run_info["start_res"].",".$run_info["start_date"].",".$run_info["start_time"].",".$run_info["start_area"].",".$run_info["end_res"].",,,".$run_info["end_area"].",".$start_area_id.",".$end_area_id."}";
  212. $sql_insert="call sp_make_order_for_zizai(".$userid.",'".$myprod."','".$mycustomer."', 28, '".$out_order_no."',".$run_info["cus_price"].", '".$run_info_txt."')";
  213. writeLog($sql_insert);
  214. $result=$pdo->query($sql_insert);
  215. $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
  216. $result->closeCursor();
  217. if (is_array($rowset) && $rowset[0]['errcode'] == 0 ) {
  218. $order_id=$rowset[0]['order_id'];
  219. //update submit order
  220. $pdo_update = conn1();
  221. $sql_update = " UPDATE order_main set order_status =146,PROD_SUPPLY_ORG_NAME='自在旅行' WHERE ORDER_ID=".$order_id." OR PARENT_ORDER_ID=".$order_id;
  222. $pdo_update->exec($sql_update);
  223. $pdo_update2 = conn1();
  224. $sql_update = " UPDATE outside_submit_order set submit_status=1 WHERE outside_order_no='{$out_order_no}'";
  225. $pdo_update2->exec($sql_update);
  226. continue;
  227. } else {
  228. /*
  229. $post_data = array();
  230. $post_data["agentId"] = QUNAR_AGENT_ID;
  231. $post_data["time"] = $current_time;
  232. $post_data["comment"] = "出票失败:该线路已停售";
  233. $post_data["ticketInfo"] = json_encode(array( "ret" => false, "data" => array("orderNo" => $out_order_no, "ticketStatu" => 1)) );
  234. $post_data["auth"] = get_qunar_auth($post_data);
  235. $complete_result = send_post( QUNAR_COMPLETE_ORDER_URL, $post_data );
  236. */
  237. continue;
  238. }
  239. continue;
  240. }
  241. if( in_array($run_main_info["PROD_ID"], $limit_sell_prod) && (($current_hour >= "15:00" && $run_main_info["RUN_DATE"] <= $tomorrow_day) || $run_main_info["RUN_DATE"] < $tomorrow_day )) {
  242. $post_data = array();
  243. $post_data["agentId"] = QUNAR_AGENT_ID;
  244. $post_data["time"] = $current_time;
  245. $post_data["comment"] = "出票失败:该线路已停售";
  246. $post_data["ticketInfo"] = json_encode(array( "ret" => false, "data" => array("orderNo" => $out_order_no, "ticketStatu" => 1)) );
  247. $post_data["auth"] = get_qunar_auth($post_data);
  248. $complete_result = send_post( QUNAR_COMPLETE_ORDER_URL, $post_data );
  249. continue;
  250. } else if( $run_main_info["RUN_DATE"] == $today && $limit_time >= $run_main_info["RUN_TIME"] ) {
  251. $post_data = array();
  252. $post_data["agentId"] = QUNAR_AGENT_ID;
  253. $post_data["time"] = $current_time;
  254. $post_data["comment"] = "出票失败:该线路已停售";
  255. $post_data["ticketInfo"] = json_encode(array( "ret" => false, "data" => array("orderNo" => $out_order_no, "ticketStatu" => 1)) );
  256. $post_data["auth"] = get_qunar_auth($post_data);
  257. $complete_result = send_post( QUNAR_COMPLETE_ORDER_URL, $post_data );
  258. continue;
  259. }
  260. if( in_array($prod_id,$no_sell_array) ) {
  261. $post_data = array();
  262. $post_data["agentId"] = QUNAR_AGENT_ID;
  263. $post_data["time"] = $current_time;
  264. $post_data["comment"] = "出票失败:该线路已停售";
  265. $post_data["ticketInfo"] = json_encode(array( "ret" => false, "data" => array("orderNo" => $out_order_no, "ticketStatu" => 1)) );
  266. $post_data["auth"] = get_qunar_auth($post_data);
  267. $complete_result = send_post( QUNAR_COMPLETE_ORDER_URL, $post_data );
  268. continue;
  269. }
  270. $myprod = '{m'.$prod_id.'p'.$ticket_num.'|r'.$run_code.'}';
  271. $mycustomer = '{,'.$customer_name.',,'.$customer_mobile.',150,'.$customer_id_no.',,,,'.$passengers_list.'}';
  272. if($prod_id== "449862" || $prod_id == "449867" ){
  273. if($prod_id== "449862") {
  274. $result = post2('http://wx.zhizhuchuxing.com/ZZDZ/application/custom_made/control.php', array(
  275. 'type' => 'order_submitforout',
  276. 'prod_list' => $myprod,
  277. 'customer_info' => $mycustomer,
  278. 'start_name' => '南京五塘广场',
  279. 'end_name' => '南通政务中心',
  280. 'startx_y' => '32.116682,118.784105',
  281. 'endx_y' => '32.011714,120.894448',
  282. 'line_id' => '449860',
  283. 'start_time' => '07:37',
  284. 'end_time' => '10:30'
  285. ));
  286. } else {
  287. $result = post2('http://wx.zhizhuchuxing.com/ZZDZ/application/custom_made/control.php',array(
  288. 'type' =>'order_submitforout',
  289. 'prod_list'=>$myprod,
  290. 'customer_info'=>$mycustomer,
  291. 'start_name'=>'南通政务中心',
  292. 'end_name'=>'南京五塘广场',
  293. 'endx_y'=>'32.116682,118.784105',
  294. 'startx_y'=>'32.011714,120.894448',
  295. 'line_id'=>'449865',
  296. 'start_time'=>'07:37',
  297. 'end_time'=>'10:30'
  298. ));
  299. }
  300. $result_array = json_decode($result,true);
  301. writeLog($result);
  302. if( $result_array["code"] == 0 ) {
  303. $order_id = $result_array['order_id'];
  304. $sql_order_status = "update order_main set order_status =146,OUTSIDE_SALE_ORG_ID=28,OUTSIDE_ORDER_NO='".$out_order_no."' where order_id= " . $order_id . " or parent_order_id = " . $order_id;
  305. $pdo_update2 = conn1();
  306. $pdo_update2->exec($sql_order_status);
  307. $res_content = get_msg_info($order_id);
  308. $name = $res_content[0];
  309. $tel = $res_content[1];
  310. $content = $res_content[2];
  311. $post_data["comment"] = $content;
  312. $comment_type = 0;
  313. $comment_text = "";
  314. $send_success = 0;
  315. $sql1 = "CALL HT_ADD_MSG_COMMENT(2,'addmsg'," . $order_id . "," . $comment_type . ",'" . $comment_text . "','" . $tel . "','" . $content . "','" . date("Y-m-d H:i:s") . "',{$send_success})";
  316. $result1 = $pdo->query($sql1);
  317. $rowset1 = $result1->fetchAll(PDO::FETCH_ASSOC);
  318. $result1->closeCursor();
  319. $pdo_update = conn1();
  320. $sql_update = " UPDATE outside_submit_order set submit_status=1 WHERE outside_order_no='{$out_order_no}'";
  321. $pdo_update->exec($sql_update);
  322. $ticketCode = sprintf("%d", $order_id);
  323. for ($ticket_index = 1; $ticket_index < $ticket_num; $ticket_index++) {
  324. $ticketCode .= "|" . sprintf("%d", $order_id);
  325. }
  326. $post_data["ticketInfo"] = json_encode(array("ret" => true, "data" => array("orderNo" => $out_order_no, "ticketStatu" => 0, "ticketNum" => sprintf("%d", $ticket_num), "ticketPassword" => $ticketCode, "ticketCode" => $ticketCode)));
  327. $post_data["auth"] = get_qunar_auth($post_data);
  328. $complete_result = send_post(QUNAR_COMPLETE_ORDER_URL, $post_data);
  329. $complete_result_array = json_decode($complete_result, true);
  330. continue;
  331. } else if( $result_array["code"] == 101 ) {
  332. $post_data = array();
  333. $post_data["agentId"] = QUNAR_AGENT_ID;
  334. $post_data["time"] = $current_time;
  335. $post_data["comment"] = "出票失败:该线路已停售";
  336. $post_data["ticketInfo"] = json_encode(array( "ret" => false, "data" => array("orderNo" => $out_order_no, "ticketStatu" => 1)) );
  337. $post_data["auth"] = get_qunar_auth($post_data);
  338. $complete_result = send_post( QUNAR_COMPLETE_ORDER_URL, $post_data );
  339. continue;
  340. } else {
  341. $post_data = array();
  342. $post_data["agentId"] = QUNAR_AGENT_ID;
  343. $post_data["time"] = $current_time;
  344. $post_data["comment"] = "出票失败:该线路已停售";
  345. $post_data["ticketInfo"] = json_encode(array( "ret" => false, "data" => array("orderNo" => $out_order_no, "ticketStatu" => 1)) );
  346. $post_data["auth"] = get_qunar_auth($post_data);
  347. $complete_result = send_post( QUNAR_COMPLETE_ORDER_URL, $post_data );
  348. continue;
  349. }
  350. } else {
  351. $sql_insert = "call sp_make_order(" . $userid . ",'" . $myprod . "','" . $mycustomer . "', 28, '" . $out_order_no . "')";
  352. $result = $pdo->query($sql_insert);
  353. $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
  354. $result->closeCursor();
  355. $post_data = array();
  356. $post_data["agentId"] = QUNAR_AGENT_ID;
  357. $post_data["time"] = $current_time;
  358. if (is_array($rowset) && $rowset[0]['errcode'] == 0) {
  359. $order_id = $rowset[0]['order_id'];
  360. $res_content = get_msg_info($order_id);
  361. $name = $res_content[0];
  362. $tel = $res_content[1];
  363. $content = $res_content[2];
  364. $post_data["comment"] = $content;
  365. $ticketCode = sprintf("%d", $order_id);
  366. for ($ticket_index = 1; $ticket_index < $ticket_num; $ticket_index++) {
  367. $ticketCode .= "|" . sprintf("%d", $order_id);
  368. }
  369. $post_data["ticketInfo"] = json_encode(array("ret" => true, "data" => array("orderNo" => $out_order_no, "ticketStatu" => 0, "ticketNum" => sprintf("%d", $ticket_num), "ticketPassword" => $ticketCode, "ticketCode" => $ticketCode)));
  370. } else {
  371. $post_data["comment"] = "出票失败:" . $rowset_back[0]['errinfo'];
  372. $post_data["ticketInfo"] = json_encode(array("ret" => false, "data" => array("orderNo" => $out_order_no, "ticketStatu" => 1)));
  373. }
  374. $post_data["auth"] = get_qunar_auth($post_data);
  375. $complete_result = send_post(QUNAR_COMPLETE_ORDER_URL, $post_data);
  376. $complete_result_array = json_decode($complete_result, true);
  377. if (is_array($rowset) && $rowset[0]['errcode'] == 0) {
  378. $comment_type = 0;
  379. $comment_text = "";
  380. $send_success = 0;
  381. $sql1 = "CALL HT_ADD_MSG_COMMENT(2,'addmsg'," . $order_id . "," . $comment_type . ",'" . $comment_text . "','" . $tel . "','" . $content . "','" . date("Y-m-d H:i:s") . "',{$send_success})";
  382. $result1 = $pdo->query($sql1);
  383. $rowset1 = $result1->fetchAll(PDO::FETCH_ASSOC);
  384. $result1->closeCursor();
  385. $pdo_update = conn1();
  386. $sql_update = " UPDATE outside_submit_order set submit_status=1 WHERE outside_order_no='{$out_order_no}'";
  387. $pdo_update->exec($sql_update);
  388. $sql_order_status = "update order_main set order_status =146 where order_id= " . $order_id . " or parent_order_id = " . $order_id;
  389. $pdo_update2 = conn1();
  390. $pdo_update2->exec($sql_order_status);
  391. }
  392. }
  393. }
  394. echo "success";
  395. exit();
  396. function get_msg_info($ORDER_ID) {
  397. $msg_pdo = conn1();
  398. $msg_sql = "CALL SP_GET_MESSAGE_TEMPLATE('" . $ORDER_ID . "')";
  399. $content = '';
  400. if (is_object($msg_pdo)) {
  401. $msg_result = $msg_pdo -> query($msg_sql);
  402. $i = 1;
  403. $data = array();
  404. if ($msg_result) {
  405. $data['code'] = "0";
  406. $data['info'] = "";
  407. do {
  408. $row = $msg_result -> fetchAll(PDO::FETCH_ASSOC);
  409. if ($i == 1) {
  410. $data['seat'] = isset($row) ? $row : array();
  411. } else if ($i == 2) {
  412. $data['run_info'] = isset($row) ? $row : array();
  413. } else if ($i == 3) {
  414. $data['driver'] = isset($row) ? $row : array();
  415. } else {
  416. }
  417. $i++;
  418. } while($msg_result->nextRowset());
  419. }
  420. $json_obj = json_decode(json_encode($data), TRUE);
  421. $seat = isset($json_obj['seat'][0]) ? $json_obj['seat'][0] : array();
  422. $run_info = isset($json_obj['run_info'][0]) ? $json_obj['run_info'][0] : array();
  423. $driver = isset($json_obj['driver'][0]) ? $json_obj['driver'][0] : array();
  424. $bus_res_id = isset($json_obj['driver'][0]) ? $json_obj['driver'][0]["bus_res_id"] : 0;
  425. $short_url = false;
  426. if( $bus_res_id != 0 ) {
  427. $ary_sell_ary = array(916,917);
  428. if( in_array( $bus_res_id, $ary_sell_ary ) ) {
  429. $ticket_url = TICKET_QR_URL.$ORDER_ID;
  430. $short_url = sinaShortenUrl($ticket_url);
  431. }
  432. }
  433. $extra_message = "";
  434. if( $short_url != false ) {
  435. $extra_message = "点击以下链接获取您的电子票扫码上车:{$short_url}";
  436. }
  437. //出票成功
  438. // $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已购票成功。乘车订单号为{订单号},请凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车,车牌号{车牌号},司机电话{司机姓司机电话}。";
  439. // 得到明天的时间
  440. date_default_timezone_set('prc');
  441. //解决时区问题
  442. $tomorrow = date("Y-m-d", strtotime("+1 day"));
  443. $now_time = date('H:i:s', time());
  444. //判断当前时间是否在17:30:00之后
  445. $cur_date = date('Y-m-d', time());
  446. $new_message_array = array(448569,448568);
  447. $new_message_array2 = array(449860,449865);
  448. if( in_array( $run_info['parent_prod_id'], $new_message_array ) ) {
  449. $content = "您预订的{出发日期}{出发地}-{目的地}{票种名}{张数}张,已成功出票,请在{出发时间}前十五分钟到达{上车站点}。出行前一天下午的18:00左右将会有导游和您联系,预祝您旅途愉快。";
  450. } else if( in_array( $run_info['parent_prod_id'], $new_message_array2 ) ) {
  451. $content = "您已成功预订{出发地}-{目的地}城际商务车{张数}张车票,车型为奔驰7座,发车时间为{出发日期} {出发时间},请提前10分钟到达{上车站点}。车辆和司机联系方式会在出行前一天18:30发送给您。";
  452. } else if (($now_time > "17:30:00" && $run_info['start_date'] == $tomorrow) || $cur_date == $run_info['start_date']) {//17:30之后的订单或者下单时间为今天出行为今天下午 发送短信模板
  453. // if("18:30:00">"17:30:00" && $run_info['start_date']==$tomorrow){ //17:30之后的订单 发送短信模板
  454. // $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已购票成功。乘车订单号为{订单号},请凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车,车牌号{车牌号},司机电话{司机姓司机电话}。";
  455. $content = "您预订的{出发日期}{出发地}-{目的地}{票种名}{张数}张,已成功出票,请在{出发时间}前三十分钟到达{上车站点}。您的乘车订单号为{订单号},车牌号{车牌号},司机电话{司机姓司机电话},请凭短信订单号乘车".$extra_message.",预祝您旅途愉快。";
  456. } else {
  457. // $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已购票成功。乘车订单号为{订单号},请凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车。";
  458. $content = "您预订的{出发日期}{出发地}-{目的地}{票种名}{张数}张,已成功出票,请在{出发时间}前三十分钟到达{上车站点}。您的乘车订单号为{订单号},请凭短信订单号乘车".$extra_message."。出行前一天下午的18:30会将车牌号与司机电话发送给您,预祝您旅途愉快。";
  459. }
  460. // $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已购票成功。乘车订单号为{订单号},请凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车。";
  461. if ($seat) {
  462. $seat_x = isset($seat['seat_x']) ? $seat['seat_x'] : "";
  463. $seat_y = isset($seat['seat_y']) ? $seat['seat_y'] : "";
  464. $seat_name = isset($seat['seat_name']) ? $seat['seat_name'] : "";
  465. $order_main_id = isset($seat['order_main_id']) ? $seat['order_main_id'] : "";
  466. } else {
  467. }
  468. if ($run_info) {
  469. $order_count = $run_info['order_count'];
  470. $start_date = $run_info['start_date'];
  471. $start_time = $run_info['start_time'];
  472. $parent_order_id = $run_info['parent_order_id'];
  473. $end_date = $run_info['end_date'];
  474. $start_area = $run_info['start_area'];
  475. $end_area = $run_info['end_area'];
  476. $res_name = $run_info['res_name'];
  477. $prod_name = $run_info['prod_name'];
  478. $prod_name = "标准票";
  479. $customer_name = $run_info['customer_name'];
  480. $customer_mobile = $run_info['customer_mobile'];
  481. $start_end_date = $start_date . "," . $start_time;
  482. $content = str_replace("{出发日期}", $start_date, $content);
  483. $content = str_replace("{出发时间}", $start_time, $content);
  484. $content = str_replace("{上车站点}", $res_name, $content);
  485. $content = str_replace("{出发地}", $start_area, $content);
  486. $content = str_replace("{目的地}", $end_area, $content);
  487. $content = str_replace("{票种名}", $prod_name, $content);
  488. $content = str_replace("{张数}", $order_count, $content);
  489. $content = str_replace("{订单号}", $ORDER_ID, $content);
  490. } else {
  491. $content = str_replace("{出发日期}", "", $content);
  492. $content = str_replace("{出发时间}", "", $content);
  493. $content = str_replace("{出发地}", "", $content);
  494. $content = str_replace("{目的地}", "", $content);
  495. $content = str_replace("{票种名}", "", $content);
  496. $content = str_replace("{张数}", "", $content);
  497. $content = str_replace("{订单号}", "", $content);
  498. }
  499. if ($driver) {
  500. $bus_no = isset($driver['bus_no']) ? $driver['bus_no'] : "";
  501. $driver_name = isset($driver['driver_name']) ? $driver['driver_name'] : "";
  502. $driver_mobile = isset($driver['driver_mobile']) ? $driver['driver_mobile'] : "";
  503. if ($bus_no == "") {
  504. $content = str_replace(",车牌号{车牌号}", "", $content);
  505. } else {
  506. $content = str_replace("{车牌号}", $bus_no, $content);
  507. }
  508. if ($driver_name == "") {
  509. $content = str_replace(",司机电话{司机姓司机电话},", "。", $content);
  510. } else {
  511. $driver_xing = mb_substr($driver_name, 0, 1, 'utf-8');
  512. $driver_name_mobile = $driver_xing . $driver_mobile;
  513. $content = str_replace("{司机姓司机电话}", $driver_name_mobile, $content);
  514. }
  515. } else {
  516. $content = str_replace("车牌号{车牌号},", "", $content);
  517. $content = str_replace("司机电话{司机姓司机电话},", "", $content);
  518. }
  519. return array(isset($customer_name) ? $customer_name : "", isset($customer_mobile) ? $customer_mobile : "", isset($content) ? $content : "短信错误,联系客服!!!");
  520. }
  521. <<<<<<< .mine
  522. }
  523. =======
  524. }
  525. function post2($url, $data){//file_get_content
  526. $postdata = http_build_query(
  527. $data
  528. );
  529. $opts = array('http' =>
  530. array(
  531. 'method' => 'POST',
  532. 'header' => 'Content-type: application/x-www-form-urlencoded',
  533. 'content' => $postdata
  534. )
  535. );
  536. $context = stream_context_create($opts);
  537. $result = file_get_contents($url, false, $context);
  538. return $result;
  539. }>>>>>>> .r1099