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.
 
 
 
 

500 lines
23 KiB

  1. <?php
  2. require_once '../st-xm/Common/Mysql.php';
  3. require_once '../st-xm/Common/sinaAPI.php';
  4. header("Access-Control-Allow-Origin:*");
  5. $limit_sell_prod = array( 152248, 152251, 448568, 448569);
  6. //test
  7. //$_POST['auth_code'] = "abcdefg";
  8. //$_POST['run_code'] = "210554_152698_210929_152714";
  9. //$_POST['ticket_num'] = 2;
  10. //$_POST['per_price'] = 50;
  11. //$_POST['all_price'] = 100;
  12. //$_POST['customer_name'] = "测试员001";
  13. //$_POST['customer_mobile'] = "13816608252";
  14. //$_POST['customer_id_no'] = "12345678901245678";
  15. //$_POST['ctrip_order_no'] = "zxcvbbn123";
  16. //end of test
  17. $current_time = time();
  18. $current_hour = date("H:i:s",$current_time);
  19. $tomorrow_day = date("Y-m-d",strtotime("+1 days"));
  20. $today = date("Y-m-d");
  21. $limit_time = date("H:i", strtotime("+30 minutes"));
  22. $limit_sell_prod = array( 152248, 152251, 448568, 448569);
  23. $auth_code=isset($_POST['auth_code'])? $_POST['auth_code']:false;
  24. $run_code=isset($_POST['run_code'])? $_POST['run_code']:false;
  25. $ticket_num=isset($_POST['ticket_num'])? $_POST['ticket_num']:false;
  26. $per_price=isset($_POST['per_price'])? $_POST['per_price']:false;
  27. $all_price=isset($_POST['all_price'])? $_POST['all_price']:false;
  28. $customer_name=isset($_POST['customer_name'])? $_POST['customer_name']:false;
  29. $customer_mobile=isset($_POST['customer_mobile'])? $_POST['customer_mobile']:false;
  30. $customer_id_no=isset($_POST['customer_id_no'])? $_POST['customer_id_no']:false;
  31. $ctrip_order_no=isset($_POST['ctrip_order_no'])? $_POST['ctrip_order_no']:false;
  32. $passenger_array = isset($_POST['passengers'])? json_decode($_POST['passengers'],true):false;
  33. $passenger_txt = "";
  34. $passenger_txt_ary = array();
  35. if( $passenger_array != false ) {
  36. foreach ($passenger_array as $passenger_info) {
  37. $passenger_txt_ary[] = $passenger_info["name"] . "*" . $passenger_info["id_no"];
  38. }
  39. if (count($passenger_txt_ary) <= 0) {
  40. $passenger_txt = "";
  41. } else {
  42. $passenger_txt = implode("/", $passenger_txt_ary);
  43. }
  44. }
  45. $pdo=conn1();
  46. $sql=" SELECT user_name,user_psd,user_auth_code FROM api_auth_code WHERE user_auth_code='".$auth_code."' ";
  47. $result=$pdo->query($sql);
  48. $rowset=$result->fetchAll();
  49. $result->closeCursor();
  50. if( false == $rowset ) {
  51. $return_data['code']='400';
  52. echo json_encode($return_data);
  53. exit();
  54. }
  55. $sql = " SELECT * FROM order_main WHERE OUTSIDE_ORDER_NO='{$ctrip_order_no}' AND PARENT_ORDER_ID = 0 ";
  56. $result=$pdo->query($sql);
  57. $rowset=$result->fetchAll();
  58. $result->closeCursor();
  59. if( false != $rowset ) {
  60. //$order_id = $rowset[0]["ORDER_ID"];
  61. $return_data['code']='701';
  62. echo json_encode($return_data);
  63. exit();
  64. }
  65. $current_time = date("Y-m-d H:i:s");
  66. $pdo_insert = conn1();
  67. $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(" .
  68. "17,'{$ctrip_order_no}','{$run_code }',{$ticket_num},{$per_price},{$all_price},'{$customer_name}','{$customer_mobile}','{$customer_id_no}',0,'{$current_time}','{$passenger_txt}') ";
  69. $pdo_insert->exec($sql_insert);
  70. $return_data = array();
  71. $return_data['code']='201';
  72. if( $auth_code == false || $run_code == false || $ticket_num == false || $per_price == false || $all_price == false || $customer_name == false || $customer_id_no == false || $ctrip_order_no == false ) {
  73. $return_data['code']='401';
  74. echo json_encode($return_data);
  75. exit();
  76. }
  77. $param_run_code = $run_code;
  78. $run_code_array = explode("_",$run_code);
  79. //for 第三方
  80. if( !isset($run_code_array[1]) ) {
  81. require_once '../st-xm/Common/zizai_orderAPI.php';
  82. //zizai
  83. $prod_id = $run_code_array[0];
  84. $sql = " SELECT * FROM outside_run WHERE prod_code='".$prod_id."' AND cancel_flag = 0 ";
  85. $result=$pdo->query($sql);
  86. $rowset=$result->fetchAll();
  87. $result->closeCursor();
  88. $return_data = array();
  89. if( $result == false ) {
  90. $return_data['code']='501';
  91. $return_data['msg']='该班次为无效班次';
  92. echo json_encode($return_data);
  93. exit();
  94. }
  95. $run_info = $rowset[0];
  96. if( $run_info["prod_name"] == "儿童票" ) {
  97. $return_data['code']='501';
  98. $return_data['msg']='该班次为无效班次';
  99. echo json_encode($return_data);
  100. exit();
  101. }
  102. $remain_count = $run_info["remain_count"] > 3 ? $run_info["remain_count"] - 3 : 0;
  103. if( $remain_count < $ticket_num ) {
  104. $return_data['code'] = '500';
  105. $return_data['msg'] = '该班次剩余库存不足';
  106. echo json_encode($return_data);exit();
  107. }
  108. $run_code = $run_info["run_code"];
  109. //自在下票
  110. //$setOrder = new orderService();
  111. //票务系统锁定
  112. //$zizai_cus = "{|".$customer_name."|".$customer_mobile."|".$customer_id_no."||}";
  113. //$lock_order = $setOrder->createOrder(zizaiArgs::$USER, $prod_id."P".$ticket_num."|", $customer_name,$customer_mobile,$customer_id_no,'', 0);
  114. //$lock_order = $setOrder->lock(zizaiArgs::$USER, 30, $prod_id."P".$ticket_num."|", $zizai_cus );
  115. //if ($lock_order['code']!=0) {
  116. // $return_data['code'] = '500';
  117. // $return_data['msg'] = '该班次剩余库存不足';
  118. // echo json_encode($return_data);exit();
  119. //}
  120. //$tradeno = $lock_order['tradeno'];
  121. //$customerlist = "";
  122. //foreach( $passenger_array as $passenger_info ) {
  123. // $customerlist .= '{'.$prod_id.'|'.$passenger_info["passengerName"].'||'.descryption_by_shif($passenger_info["passengerId"]).'}';
  124. //}
  125. //$return_info = $setOrder->customer(zizaiArgs::$USER, $tradeno, $customerlist);
  126. /*
  127. //确认订单
  128. $res_order = $setOrder->eticket(zizaiArgs::$USER, $tradeno);
  129. if ($res_order['code']!=0) {
  130. $return_data['code'] = '500';
  131. $return_data['msg'] = '该班次剩余库存不足';
  132. echo json_encode($return_data);exit();
  133. }*/
  134. //出发地和目的地的area_id
  135. $sql = " SELECT ID,AREA_NAME FROM base_area WHERE AREA_NAME like \"".$run_info["start_area"]."%%\" AND cancel_flag = 0 ";
  136. $result=$pdo->query($sql);
  137. $rowset=$result->fetchAll();
  138. $result->closeCursor();
  139. if( $rowset == false ) {
  140. $start_area_id = 791;
  141. } else {
  142. $start_area_id = $rowset[0]["ID"];
  143. }
  144. $sql = " SELECT ID,AREA_NAME FROM base_area WHERE AREA_NAME like \"".$run_info["end_area"]."%%\" AND cancel_flag = 0 ";
  145. $result=$pdo->query($sql);
  146. $rowset=$result->fetchAll();
  147. $result->closeCursor();
  148. if( $rowset == false ) {
  149. $end_area_id = 791;
  150. } else {
  151. $end_area_id = $rowset[0]["ID"];
  152. }
  153. $userid = 1;
  154. $prod_id = 380001;
  155. $run_code = 0;
  156. $myprod = '{m'.$prod_id.'p'.$ticket_num.'|r'.$run_code.'}';
  157. $mycustomer = "{,".$customer_name.",,".$customer_mobile.",150,".$customer_id_no.",,,,".$passenger_txt."}";
  158. $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."}";
  159. $sql_insert="call sp_make_order_for_zizai(".$userid.",'".$myprod."','".$mycustomer."', 17, '".$ctrip_order_no."',".$run_info["cus_price"].", '".$run_info_txt."')";
  160. writeLog($sql_insert);
  161. $result=$pdo->query($sql_insert);
  162. if( $result == false ) {
  163. $rowset = array();
  164. $rowset[] = array("errcode" => -1);
  165. } else {
  166. $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
  167. }
  168. $result->closeCursor();
  169. if (is_array($rowset) && $rowset[0]['errcode'] == 0 ) {
  170. $order_id=$rowset[0]['order_id'];
  171. //update submit order
  172. $pdo_update = conn1();
  173. $sql_update = " UPDATE order_main set PROD_SUPPLY_ORG_NAME='自在旅行' WHERE ORDER_ID=".$order_id." OR PARENT_ORDER_ID=".$order_id;
  174. $pdo_update->exec($sql_update);
  175. $pdo_update2 = conn1();
  176. $sql_update = " UPDATE outside_submit_order set submit_status=1,supply_order_id='-1' WHERE outside_order_no='{$ctrip_order_no}'";
  177. $pdo_update2->exec($sql_update);
  178. $return_data["code"] = "201";
  179. $return_data["order_no"] = $order_id;
  180. $return_data["msg"] = "";
  181. $return_data["send_message_num"] = 1;
  182. $return_data["send_message_array"] = array("您已成功订购了{$run_info["line_name"]}[{$run_info["prod_name"]}]{$ticket_num}张。出发时间:{$run_info["start_date"]} {$run_info["start_time"]}。上车地点:{$run_info["start_res"]}。请于发车前到上车站点的服务台领票。咨询电话4008872626");
  183. echo json_encode($return_data);
  184. exit();
  185. } else {
  186. $pdo_update2 = conn1();
  187. $sql_update = " UPDATE outside_submit_order set supply_order_id='-2',submit_status={$rowset[0]['errcode']} WHERE outside_order_no='{$ctrip_order_no}'";
  188. $pdo_update2->exec($sql_update);
  189. $return_data['code'] = '500';
  190. $return_data['msg'] = '该班次剩余库存不足';
  191. echo json_encode($return_data);
  192. exit();
  193. }
  194. }
  195. $run_code = $run_code_array[0];
  196. $prod_id = $run_code_array[1];
  197. $sql2 = " SELECT * FROM run_main WHERE RUN_ID = {$run_code} ";
  198. $result=$pdo->query($sql2);
  199. $rowset=$result->fetchAll();
  200. $result->closeCursor();
  201. $return_data['code']='201';
  202. if( $rowset == false ) {
  203. $return_data['code']='501';
  204. $return_data['msg']='该班次为无效班次';
  205. echo json_encode($return_data);
  206. exit();
  207. }
  208. $run_main_info = $rowset[0];
  209. $sql3 = " SELECT * FROM run_bus WHERE RUN_ID = {$run_code} AND RUN_BUS_STATUS = 138 ";
  210. $result=$pdo->query($sql3);
  211. $result_array=$result->fetchAll();
  212. $result->closeCursor();
  213. if( $result == false ) {
  214. $return_data['code'] = '402';
  215. $return_data['msg'] = '发送参数不符合定义';
  216. echo json_encode($return_data);exit();
  217. }
  218. $run_bus_array = array();
  219. foreach( $result_array as $run_bus_info ) {
  220. if( !isset($run_bus_array[$run_bus_info["RUN_ID"]]) ) {
  221. $run_bus_array[$run_bus_info["RUN_ID"]] = array();
  222. }
  223. $run_bus_array[$run_bus_info["RUN_ID"]][] = $run_bus_info;
  224. }
  225. $data_array = array();
  226. if( !$run_bus_array[$run_main_info["RUN_ID"]] || ( $run_main_info["RUN_DATE"] == $today && $limit_time >= $run_main_info["RUN_TIME"] ) || ( in_array( $run_main_info["PROD_ID"], $limit_sell_prod ) && $run_main_info["RUN_DATE"] <= $tomorrow_day && $current_hour > "10:00" ) ) {
  227. $total_count = 0;
  228. $saled_count = 0;
  229. $remain_count = 0;
  230. } else {
  231. $total_count = 0;
  232. $saled_count = 0;
  233. $remain_count = 0;
  234. foreach( $run_bus_array[$run_main_info["RUN_ID"]] as $run_bus_info ) {
  235. $total_count += $run_bus_info["SEAT_COUNT"];
  236. $saled_count += $run_bus_info["SALED_COUNT"];
  237. }
  238. $remain_count = $total_count - $saled_count;
  239. $remain_count = $remain_count <= 3 ? 0 : $remain_count;
  240. }
  241. if( $remain_count < $ticket_num ) {
  242. $return_data['code'] = '500';
  243. $return_data['msg'] = '该班次剩余库存不足';
  244. echo json_encode($return_data);exit();
  245. }
  246. $sql4 = " SELECT opera_product.PROD_ID FROM opera_product WHERE PARENT_ID={$run_main_info["PROD_ID"]} AND PROD_TYPE=82";
  247. $result=$pdo->query($sql4);
  248. $result_array=$result->fetchAll();
  249. $result->closeCursor();
  250. if( $result_array == false ) {
  251. $return_data['code'] = '500';
  252. $return_data['msg'] = '该班次剩余库存不足';
  253. echo json_encode($return_data);exit();
  254. }
  255. $match_prod_flag = 0;
  256. foreach( $result_array as $ticket_info ) {
  257. if( $ticket_info["PROD_ID"] == $prod_id ) {
  258. $match_prod_flag = 1;
  259. break;
  260. }
  261. }
  262. if( $match_prod_flag == 0 ) {
  263. $return_data['code'] = '402';
  264. $return_data['msg'] = '发送参数不符合定义';
  265. echo json_encode($return_data);exit();
  266. }
  267. $userid = 1;
  268. $myprod = '{m'.$prod_id.'p'.$ticket_num.'|r'.$run_code.'}';
  269. $mycustomer = "{,".$customer_name.",,".$customer_mobile.",150,".$customer_id_no.",,,,".$passenger_txt."}";
  270. $sql_insert="call sp_make_order(".$userid.",'".$myprod."','".$mycustomer."', 17, '".$ctrip_order_no."')";
  271. $result=$pdo->query($sql_insert);
  272. $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
  273. $result->closeCursor();
  274. $send_message_num = 0;
  275. $send_message_mobile = array();
  276. $back_order_id = false;
  277. if (is_array($rowset) && $rowset[0]['errcode'] == 0 ) {
  278. $order_id=$rowset[0]['order_id'];
  279. //come back ticket
  280. if( count($run_code_array) > 2 ) {
  281. $back_run_code = $run_code_array[2];
  282. $back_prod_id = $run_code_array[3];
  283. $back_myprod = '{m'.$back_prod_id.'p'.$ticket_num.'|r'.$back_run_code.'}';
  284. $sql_insert2="call sp_make_order(".$userid.",'".$back_myprod."','".$mycustomer."', 17, '".$ctrip_order_no."')";
  285. $result=$pdo->query($sql_insert2);
  286. $rowset_back=$result->fetchAll(PDO::FETCH_ASSOC);
  287. $result->closeCursor();
  288. if (is_array($rowset_back) && $rowset_back[0]['errcode'] == 0 ) {
  289. $back_order_id=$rowset_back[0]['order_id'];
  290. } else {
  291. $sql = "CALL SP_CANCEL_ORDER(" . $user_id . "," . $order_id . ")";
  292. $result = $pdo->query($sql);
  293. $result->closeCursor();
  294. $return_data["code"] = $rowset_back[0]['errcode'];
  295. $return_data["msg"] = $rowset_back[0]['errinfo'];
  296. echo json_encode($return_data);
  297. exit();
  298. }
  299. }
  300. $res_content=get_msg_info($order_id);
  301. $name=$res_content[0];
  302. $tel=$res_content[1];
  303. $content=$res_content[2];
  304. //$response = sendTelMessage($tel, $name, $content, $order_id);
  305. $send_message_mobile[] = $content;
  306. $comment_type=0;
  307. $comment_text="";
  308. $send_success = 0;
  309. $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})";
  310. $result1 = $pdo -> query($sql1);
  311. $rowset1 = $result1 -> fetchAll(PDO::FETCH_ASSOC);
  312. $result1 -> closeCursor();
  313. if( $back_order_id != false ) {
  314. $res_content=get_msg_info($back_order_id);
  315. $name=$res_content[0];
  316. $tel=$res_content[1];
  317. $content=$res_content[2];
  318. //$response = sendTelMessage($tel, $name, $content, $back_order_id);
  319. $send_message_mobile[] = $content;
  320. $comment_type=0;
  321. $comment_text="";
  322. $send_success = 0;
  323. $sql1 = "CALL HT_ADD_MSG_COMMENT(2,'addmsg'," . $back_order_id . "," . $comment_type . ",'" . $comment_text . "','" . $tel . "','" . $content . "','" . date("Y-m-d H:i:s") . "',{$send_success})";
  324. $result1 = $pdo -> query($sql1);
  325. $rowset1 = $result1 -> fetchAll(PDO::FETCH_ASSOC);
  326. $result1 -> closeCursor();
  327. }
  328. } else {
  329. $return_data["code"] = $rowset[0]['errcode'];
  330. $return_data["msg"] = $rowset[0]['errinfo'];
  331. echo json_encode($return_data);
  332. exit();
  333. }
  334. $pdo_update = conn1();
  335. $sql_update = " UPDATE outside_submit_order set submit_status=1 WHERE outside_order_no='{$ctrip_order_no}'";
  336. $pdo_update->exec($sql_update);
  337. $return_data["code"] = "201";
  338. $return_data["order_no"] = $rowset[0]['order_id'];
  339. $return_data["msg"] = "";
  340. $return_data["send_message_num"] = count($send_message_mobile);
  341. $return_data["send_message_array"] = $send_message_mobile;
  342. echo json_encode($return_data);
  343. exit();
  344. function get_msg_info($ORDER_ID) {
  345. $msg_pdo = conn1();
  346. $msg_sql = "CALL SP_GET_MESSAGE_TEMPLATE('" . $ORDER_ID . "')";
  347. $content = '';
  348. if (is_object($msg_pdo)) {
  349. $msg_result = $msg_pdo -> query($msg_sql);
  350. $i = 1;
  351. $data = array();
  352. if ($msg_result) {
  353. $data['code'] = "0";
  354. $data['info'] = "";
  355. do {
  356. $row = $msg_result -> fetchAll(PDO::FETCH_ASSOC);
  357. if ($i == 1) {
  358. $data['seat'] = isset($row) ? $row : array();
  359. } else if ($i == 2) {
  360. $data['run_info'] = isset($row) ? $row : array();
  361. } else if ($i == 3) {
  362. $data['driver'] = isset($row) ? $row : array();
  363. } else {
  364. }
  365. $i++;
  366. } while($msg_result->nextRowset());
  367. }
  368. $json_obj = json_decode(json_encode($data), TRUE);
  369. $seat = isset($json_obj['seat'][0]) ? $json_obj['seat'][0] : array();
  370. $run_info = isset($json_obj['run_info'][0]) ? $json_obj['run_info'][0] : array();
  371. $driver = isset($json_obj['driver'][0]) ? $json_obj['driver'][0] : array();
  372. $bus_res_id = isset($json_obj['driver'][0]) ? $json_obj['driver'][0]["bus_res_id"] : 0;
  373. $short_url = false;
  374. if( $bus_res_id != 0 ) {
  375. $ary_sell_ary = array(916,917);
  376. if( in_array( $bus_res_id, $ary_sell_ary ) ) {
  377. $ticket_url = TICKET_QR_URL.$ORDER_ID;
  378. $short_url = sinaShortenUrl($ticket_url);
  379. }
  380. }
  381. $extra_message = "";
  382. if( $short_url != false ) {
  383. $extra_message = "或点击以下链接获取您的电子票扫码上车:{$short_url}";
  384. }
  385. //出票成功
  386. // $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已购票成功。乘车订单号为{订单号},请凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车,车牌号{车牌号},司机电话{司机姓司机电话}。";
  387. // 得到明天的时间
  388. date_default_timezone_set('PRC');
  389. //解决时区问题
  390. $tomorrow = date("Y-m-d", strtotime("+1 day"));
  391. $now_time = date('H:i:s', time());
  392. //判断当前时间是否在17:30:00之后
  393. $cur_date = date('Y-m-d', time());
  394. if (($now_time > "17:30:00" && $run_info['start_date'] == $tomorrow) || $cur_date == $run_info['start_date']) {//17:30之后的订单或者下单时间为今天出行为今天下午 发送短信模板
  395. // if("18:30:00">"17:30:00" && $run_info['start_date']==$tomorrow){ //17:30之后的订单 发送短信模板
  396. // $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已购票成功。乘车订单号为{订单号},请凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车,车牌号{车牌号},司机电话{司机姓司机电话}。";
  397. $content = "您预订的{出发日期}{出发地}-{目的地}{票种名}{张数}张,已成功出票,请在{出发时间}前三十分钟到达{上车站点}。您的乘车订单号为{订单号},车牌号{车牌号},司机电话{司机姓司机电话},请凭短信订单号乘车".$extra_message.",预祝您旅途愉快。";
  398. } else {
  399. // $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已购票成功。乘车订单号为{订单号},请凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车。";
  400. $content = "您预订的{出发日期}{出发地}-{目的地}{票种名}{张数}张,已成功出票,请在{出发时间}前三十分钟到达{上车站点}。您的乘车订单号为{订单号},请凭短信订单号乘车".$extra_message."。出行前一天下午的18:30会将车牌号与司机电话发送给您,预祝您旅途愉快。";
  401. }
  402. // $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已购票成功。乘车订单号为{订单号},请凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车。";
  403. if ($seat) {
  404. $seat_x = isset($seat['seat_x']) ? $seat['seat_x'] : "";
  405. $seat_y = isset($seat['seat_y']) ? $seat['seat_y'] : "";
  406. $seat_name = isset($seat['seat_name']) ? $seat['seat_name'] : "";
  407. $order_main_id = isset($seat['order_main_id']) ? $seat['order_main_id'] : "";
  408. } else {
  409. }
  410. if ($run_info) {
  411. $order_count = $run_info['order_count'];
  412. $start_date = $run_info['start_date'];
  413. $start_time = $run_info['start_time'];
  414. $parent_order_id = $run_info['parent_order_id'];
  415. $end_date = $run_info['end_date'];
  416. $start_area = $run_info['start_area'];
  417. $end_area = $run_info['end_area'];
  418. $res_name = $run_info['res_name'];
  419. $prod_name = $run_info['prod_name'];
  420. $prod_name = "标准票";
  421. $customer_name = $run_info['customer_name'];
  422. $customer_mobile = $run_info['customer_mobile'];
  423. $start_end_date = $start_date . "," . $start_time;
  424. $content = str_replace("{出发日期}", $start_date, $content);
  425. $content = str_replace("{出发时间}", $start_time, $content);
  426. $content = str_replace("{上车站点}", $res_name, $content);
  427. $content = str_replace("{出发地}", $start_area, $content);
  428. $content = str_replace("{目的地}", $end_area, $content);
  429. $content = str_replace("{票种名}", $prod_name, $content);
  430. $content = str_replace("{张数}", $order_count, $content);
  431. $content = str_replace("{订单号}", $ORDER_ID, $content);
  432. } else {
  433. $content = str_replace("{出发日期}", "", $content);
  434. $content = str_replace("{出发时间}", "", $content);
  435. $content = str_replace("{出发地}", "", $content);
  436. $content = str_replace("{目的地}", "", $content);
  437. $content = str_replace("{票种名}", "", $content);
  438. $content = str_replace("{张数}", "", $content);
  439. $content = str_replace("{订单号}", "", $content);
  440. }
  441. if ($driver) {
  442. $bus_no = isset($driver['bus_no']) ? $driver['bus_no'] : "";
  443. $driver_name = isset($driver['driver_name']) ? $driver['driver_name'] : "";
  444. $driver_mobile = isset($driver['driver_mobile']) ? $driver['driver_mobile'] : "";
  445. if ($bus_no == "") {
  446. $content = str_replace(",车牌号{车牌号}", "", $content);
  447. } else {
  448. $content = str_replace("{车牌号}", $bus_no, $content);
  449. }
  450. if ($driver_name == "") {
  451. $content = str_replace(",司机电话{司机姓司机电话},", "。", $content);
  452. } else {
  453. $driver_xing = mb_substr($driver_name, 0, 1, 'utf-8');
  454. $driver_name_mobile = $driver_xing . $driver_mobile;
  455. $content = str_replace("{司机姓司机电话}", $driver_name_mobile, $content);
  456. }
  457. } else {
  458. $content = str_replace("车牌号{车牌号},", "", $content);
  459. $content = str_replace("司机电话{司机姓司机电话},", "", $content);
  460. }
  461. $content.="【重要提示】:因G20峰会影响,7月1号开始实名登记安检,出行时请所有游客携带有效证件(身份证或户口本),凭有效证件上车,如被查出无有效证件,导致无法出行,责任自行承担,谢谢配合!";
  462. return array(isset($customer_name) ? $customer_name : "", isset($customer_mobile) ? $customer_mobile : "", isset($content) ? $content : "短信错误,联系客服!!!");
  463. }
  464. }