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.
 
 
 
 
 

457 lines
24 KiB

  1. <?php
  2. /*
  3. * wechat 2.0
  4. * Copyright (c) 2016 yixi wei http://zhizhuchuxing.com/
  5. * Date: 2016.7.12
  6. * Something is to pay QQ1062140302
  7. */
  8. if (ALLOW_ORIGIN)
  9. header("Access-Control-Allow-Origin:*");
  10. date_default_timezone_set('PRC');
  11. $userid =0;//
  12. $member_id = isset($_COOKIE['user_id'])?$_COOKIE['user_id']:'0';
  13. if (!$member_id && 0) {
  14. echo json_encode(array("code" => 1,"iflogin"=>1, "info" => "未登录"));
  15. exit ;
  16. }
  17. //$userid=1;
  18. $myprod = isset($_POST['prod']) ? $_POST['prod'] : "{m152603p1|r202375}";//{m152603p1|r202375}
  19. $prod_id =substr($myprod,strpos($myprod, 'm')+1, strpos($myprod, 'p')-2);
  20. $tic_num =substr($myprod,strpos($myprod, 'p')+1, strpos($myprod, '|')-strpos($myprod, 'p')-1);
  21. if($tic_num==0){
  22. echo json_encode(array("code" => '1', "info" => "订票数量不可为0"));
  23. exit ;
  24. }
  25. $run_id = substr(substr($myprod,strpos($myprod, 'r')+1),0,-1);
  26. $sql_time = "select run_date,run_time,prod_id from run_main where run_id =".$run_id;
  27. $result_time= $pdo->query($sql_time);
  28. $row_t = $result_time->fetchAll(PDO::FETCH_ASSOC);
  29. $run_date = $row_t[0]['run_date'];
  30. $run_time = $row_t[0]['run_time'];
  31. $prod_wu=array(448568,448569,448778,448779,448780,448781);
  32. if(strtotime($run_date.' '.$run_time)- time()<1800){
  33. echo json_encode(array('code'=>1,'info'=>'预定时间已过'));exit();
  34. }
  35. if(in_array($row_t[0]['prod_id'],$prod_wu)){
  36. if(date('Y-m-d', time())>=$run_date){
  37. echo json_encode(array('code'=>1,'info'=>'预定时间已过'));exit();
  38. }elseif(date('Y-m-d', time()+24*60*60)==$run_date && date('H:i', time())>'10:01'){
  39. echo json_encode(array('code'=>1,'info'=>'预定时间已过'));exit();
  40. }
  41. }
  42. $mycustomer = isset($_POST['customer']) ? $_POST['customer'] : "nono";
  43. $order_from_org_id =0;
  44. $top_org_id = 0;
  45. $outside_order_id = isset($_POST['outside_order_id']) ? $_POST['outside_order_id'] : '0';
  46. $sql_price = "select cus_price from opera_product_price where prod_id =".$prod_id;
  47. $result_price = $pdo->query($sql_price);
  48. $row_p = $result_price->fetchAll(PDO::FETCH_ASSOC);
  49. $price_list = $prod_id.','.$row_p[0]['cus_price'];//'.$row_p['0']['cus_price'].'
  50. //$u_prod_list=isset($_POST['u_prod_list'])?$_POST['u_prod_list']:"";
  51. //$f_u_prod_list=isset($_POST['f_u_prod_list'])?$_POST['f_u_prod_list']:"";
  52. ///st-xm/Api/add_new_order.php?prod={m152603p1|r202375}&customer={,fuhc_ceshi,1,15821387785,150,511621199502032173,,0,,,}
  53. //&order_from_org_id=5&outside_order_id=9999999999999&tt=20160719195230&price={60.00}&doorPrice=10&hotelPrice=20&ifcheck=1&back_pro_id={m152248p1|r203865}
  54. //.返程 1=true 0=false
  55. $ifcheck = isset($_POST['ifback']) ? $_POST['ifback'] : "";
  56. if($ifcheck){
  57. $back_prod = isset($_POST['back_prod']) ? $_POST['back_prod'] : "";
  58. $prod_id_f =substr($back_prod,strpos($back_prod, 'm')+1, strpos($back_prod, 'p')-2);
  59. $sql_price_f = "select cus_price from opera_product_price where prod_id =".$prod_id_f;
  60. $result_price_f = $pdo->query($sql_price_f);
  61. $row_f = $result_price_f->fetchAll(PDO::FETCH_ASSOC);
  62. $price_list_f =$prod_id_f.','.$row_f['0']['cus_price'];
  63. }
  64. //获取渠道号
  65. $top_org_id = 0;
  66. //echo 111;die;
  67. $sql = "call sp_make_order(" . $userid . ",'" . $myprod . "','" . $mycustomer . "',1,'" . $outside_order_id . "')";
  68. if ($ifcheck == 0) {//不是含有返程的
  69. writeLog("sp_make_order---san: " . $sql);
  70. $rowset = create_order($sql,$price_list);
  71. // if (is_array($rowset) && $rowset[0]['errcode'] == 0 && SEND_MESSAGE == true) { //单程票订票成功
  72. // send_msg($rowset[0]['order_id']);
  73. // }
  74. if(!isset($rowset[0]['order_id'])){
  75. echo json_encode(array('code'=>1,'info'=>'error'));die;
  76. }
  77. $order_id = $rowset[0]['order_id'];
  78. //更改支付方式为 授信支付
  79. //根据订单号查找订单详情
  80. $sql = "select a.order_id,a.create_time,a.order_price,a.order_pay_main_id,a.customer_name,a.customer_mobile,count(b.order_id) as num,b.run_date,b.run_time,b.PROD_START_STATION_AREA_NAME AS start_area,b.PROD_END_STATION_AREA_NAME AS end_area,b.PROD_START_STATION_RES_NAME AS start_res,b.PROD_END_STATION_RES_NAME AS end_res from order_main a,order_main b where a.order_id = b.PARENT_ORDER_ID and a.order_id = " . $order_id . " group by a.order_id";
  81. $result = $pdo->query($sql);
  82. $order_info = $result->fetchAll(PDO::FETCH_ASSOC);
  83. $sql_pay = "update order_pay_detail set pay_type_id_1 =278 where pay_main_id = ".$order_info[0]['order_pay_main_id'];
  84. $sql_order_status = "update order_main set order_status =145 where order_id= ".$order_id." or parent_order_id=".$order_id;
  85. $sql_cancel = "update order_main set ORDER_BOOK_STATUS =1,member_id = ".$member_id." where order_id= ".$order_id." or parent_order_id=".$order_id;
  86. $result=$pdo->exec($sql_cancel);
  87. $result=$pdo->exec($sql_order_status);
  88. $result=$pdo->exec($sql_pay);
  89. $data['ifback'] =0;
  90. $data['ifdisney'] =0;
  91. $data['code'] = $rowset[0]['errcode'];
  92. $data['info'] = $rowset[0]['errinfo'];
  93. $data['order_id'] = $rowset[0]['order_id'];
  94. $data['go_list'] = $order_info[0];
  95. $data['go_list']['site_type'] = "普通票";
  96. $data['shengyu_time'] = strtotime($order_info[0]['create_time'])+600-time();
  97. if(!$data['code'])
  98. echo json_encode(array('code'=>'0','info'=>'http://xmwx.zhizhuchuxing.cn/wechat/WxPay/realpay/onlinePay.php?orderid='.$rowset[0]['order_id'].'&fx=11&code2=wxsc'));
  99. else
  100. echo json_encode($data);
  101. } else {
  102. $rowset = create_order($sql,$price_list);
  103. if(!$rowset){
  104. echo json_encode(array('code'=>1,'info'=>'error'));die;
  105. }
  106. if (is_array($rowset) && $rowset[0]['errcode'] == 0 && SEND_MESSAGE == true) {//返程---单程票订票成功
  107. $order_id_go = $rowset[0]['order_id'];
  108. //根据订单号查找订单详情
  109. $sql = "select a.order_id,a.create_time,a.order_price,a.order_pay_main_id,a.customer_name,a.customer_mobile,count(b.order_id) as num,b.run_date,b.run_time,b.PROD_START_STATION_AREA_NAME AS start_area,b.PROD_END_STATION_AREA_NAME AS end_area,b.PROD_START_STATION_RES_NAME AS start_res,b.PROD_END_STATION_RES_NAME AS end_res from order_main a,order_main b where a.order_id = b.PARENT_ORDER_ID and a.order_id = " . $order_id_go . " group by a.order_id";
  110. $result = $pdo->query($sql);
  111. $order_info_go = $result->fetchAll(PDO::FETCH_ASSOC);
  112. $sql_pay = "update order_pay_detail set pay_type_id_1 =278 where pay_main_id = ".$order_info_go[0]['order_pay_main_id'];
  113. $sql_order_status = "update order_main set order_status =145 where order_id= ".$order_id_go." or parent_order_id=".$order_id_go;
  114. $sql_cancel = "update order_main set ORDER_BOOK_STATUS =1,member_id = ".$member_id." where order_id= ".$order_id_go." or parent_order_id=".$order_id_go;
  115. $result=$pdo->exec($sql_cancel);
  116. $pdo->exec($sql_pay);
  117. $pdo->exec($sql_order_status);
  118. //当前时间减10分钟
  119. $data['shengyu_time'] = strtotime($order_info_go[0]['create_time'])+600-time();
  120. // $data['code'] = $rowset[0]['errcode'];
  121. // $data['info'] = $rowset[0]['errinfo'];
  122. $data['order_id'] = $rowset[0]['order_id'];
  123. $data['go_list'] = $order_info_go[0];
  124. $data['go_list']['site_type'] = "普通票";
  125. // $data['code_f'] = "";
  126. // $data['info_f'] = "";
  127. // $data['order_id_f'] = "";
  128. $sql_f = "call sp_make_order(" . $userid . ",'" . $back_prod . "','" . $mycustomer . "',1,'" . $outside_order_id . "')";
  129. writeLog('fan_dan_success sql_f========'.$sql_f);
  130. $rowset_f = create_order($sql_f,$price_list_f);
  131. //..判断返程票是否成功,若不成功,则去程订单
  132. if (is_array($rowset_f) && $rowset_f[0]['errcode'] == 0 && SEND_MESSAGE == true) {//返程--返程票订票成功
  133. $order_id_back = $rowset_f[0]['order_id'];
  134. //根据订单号查找订单详情
  135. $sql = "select a.order_id,a.create_time,a.order_price,a.order_pay_main_id,a.customer_name,a.customer_mobile,count(b.order_id) as num,b.run_date,b.run_time,b.PROD_START_STATION_AREA_NAME AS start_area,b.PROD_END_STATION_AREA_NAME AS end_area,b.PROD_START_STATION_RES_NAME AS start_res,b.PROD_END_STATION_RES_NAME AS end_res from order_main a,order_main b where a.order_id = b.PARENT_ORDER_ID and a.order_id = " . $order_id_back . " group by a.order_id";
  136. $result = $pdo->query($sql);
  137. $order_info_back = $result->fetchAll(PDO::FETCH_ASSOC);
  138. $sql_pay = "update order_pay_detail set pay_type_id_1 =278 where pay_main_id = ".$order_info_back[0]['order_pay_main_id'];
  139. $sql_order_status = "update order_main set order_status =145 where order_id= ".$order_id_back." or parent_order_id=".$order_id_back;
  140. $sql_cancel = "update order_main set ORDER_BOOK_STATUS =1,member_id = ".$member_id." where order_id= ".$order_id_back." or parent_order_id=".$order_id_back;
  141. $result=$pdo->exec($sql_cancel);
  142. $pdo->exec($sql_pay);
  143. $pdo->exec($sql_order_status);
  144. $data['ifback'] = 1;
  145. $data['ifdisney'] =0;
  146. $data['code'] = $rowset_f[0]['errcode'];
  147. $data['info'] = $rowset_f[0]['errinfo'];
  148. $data['order_id_f'] = $rowset_f[0]['order_id'] ;
  149. $data['back_list'] = $order_info_back[0];
  150. $data['back_list']['site_type'] = "普通票";
  151. writeLog('fan_fan_success');
  152. //发两条短信
  153. // send_msg($rowset[0]['order_id']);
  154. // send_msg($rowset_f[0]['order_id']);
  155. //订票成功写入 往返订单关系表
  156. $to_id = $rowset[0]['order_id'];
  157. $back_id = $rowset_f[0]['order_id'];
  158. $sql_conn = "insert into to_from values(NULL,".$to_id.",".$back_id.",'". date('Y-m-d h:i:s', time())."')";
  159. $pdo= conn();
  160. $pdo->exec($sql_conn);
  161. if(!$data['code'])
  162. echo json_encode(array('code'=>'0','info'=>'http://xmwx.zhizhuchuxing.cn/wechat/WxPay/realpay/onlinePay.php?orderid='.$rowset[0]['order_id'].'&fx=11&code2=wxsc'));
  163. else
  164. echo json_encode($data);
  165. exit();
  166. } else {//如果返程票订票不成功,则取消单程票
  167. $sql_cancel = "CALL SP_CANCEL_ORDER(" . $userid . "," . $rowset[0]['order_id'] . ")";
  168. writeLog('fan_dan_faile_sql_cancel======'.$sql_cancel);
  169. $pdo_cancel = conn();
  170. $result_cancel = $pdo_cancel -> query($sql_cancel);
  171. $rowset_cancel = $result_cancel -> fetchAll(PDO::FETCH_ASSOC);
  172. $result_cancel -> closeCursor();
  173. //取消单程不发短信,但要写入取消订单原因
  174. $res_content = get_msg_info($rowset[0]['order_id']);
  175. // $tel = isset($res_content[1])?$res_content[1]:"";
  176. $content = $rowset_f[0]['errinfo'] . "-订单已取消";
  177. $comment_type = 0;
  178. $comment_text = "";
  179. $sql1 = "CALL HT_ADD_MSG_COMMENT(2,'addmsg'," . $rowset[0]['order_id'] . "," . $comment_type . ",'" . $comment_text . "','" . $tel . "','" . $content . "','" . date("Y-m-d H:i:s") . "',0)";
  180. $result1 = $pdo_cancel -> query($sql1);
  181. $rowset1 = $result1 -> fetchAll(PDO::FETCH_ASSOC);
  182. $result1 -> closeCursor();
  183. writeLog("order_list.php HT_ADD_MSG_COMMENT()::" . $sql1);
  184. $data['code_f'] = $rowset_f[0]['errcode'];
  185. $data['info_f'] = $rowset_f[0]['errinfo'];
  186. $data['order_id_f'] = isset($rowset_f[0]['order_id']) ? $rowset_f[0]['order_id'] : "";
  187. echo json_encode($data);exit();
  188. }
  189. }
  190. }
  191. function create_order($sql,$price_list) {
  192. $pdo = conn();
  193. if (is_object($pdo)) {
  194. $result = $pdo -> query($sql);
  195. if(!$result){
  196. echo json_encode(array('code'=>1,'info'=>'可售资源不足'));die;
  197. }
  198. // echo json_encode(array('aa'=>$sql));die;
  199. $rowset_create = $result -> fetchAll(PDO::FETCH_ASSOC);
  200. $result -> closeCursor();
  201. writeLog('下订单成功');
  202. writeLog(json_encode($rowset_create));
  203. if (is_array($rowset_create) && $rowset_create[0]['errcode'] == 0 && SEND_MESSAGE == true) {
  204. //下订单成功再修改价格
  205. writeLog('change_price.php' . json_encode($_POST));
  206. $sql_up_price = "call SP_CHANGE_PRICE(" . $rowset_create[0]['order_id'] . ",'" . $price_list . "')";
  207. //$sql="update order_main set order_price ='".$price_arr[$k]."' where PROD_ID=".$v." and PARENT_ORDER_ID=".$ordid." and RUN_ID>0";
  208. $result_up_price = $pdo -> query($sql_up_price);
  209. $rowset_up_price = $result_up_price -> fetchAll(PDO::FETCH_ASSOC);
  210. writeLog("change_price.php sql:: " . $sql_up_price . "::rowset ::" . json_encode($rowset_up_price));
  211. $result_up_price -> closeCursor();
  212. }
  213. }
  214. return $rowset_create;
  215. }
  216. //发短信
  217. function send_msg($ORDER_ID) {
  218. $send_pdo=conn();
  219. $order_id = $ORDER_ID;
  220. $res_content = get_msg_info($order_id);
  221. $name = $res_content[0];
  222. $tel = $res_content[1];
  223. $content = $res_content[2];
  224. writeLog("短信模板内容:【" . $content . "】");
  225. //..发短信先取消
  226. $response = sendTelMessage($tel, $name, $content, $order_id);
  227. writeLog(json_encode($response));
  228. $comment_type = 0;
  229. $comment_text = "";
  230. $send_success = (int)$response;
  231. $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})";
  232. $result1 = $send_pdo -> query($sql1);
  233. $rowset1 = $result1 -> fetchAll(PDO::FETCH_ASSOC);
  234. $result1 -> closeCursor();
  235. writeLog("hotel_order_status.php HT_ADD_MSG_COMMENT()::" . $sql1);
  236. //insert order extra
  237. $hotelPrice = isset($_GET['hotelPrice']) ? $_GET['hotelPrice'] : "";
  238. $doorPrice = isset($_GET["doorPrice"]) ? $_GET["doorPrice"] : "";
  239. if ($hotelPrice != "" || $doorPrice != "") {
  240. $sqlInsert = " INSERT INTO order_extra_info (order_id,hotel_price,gate_price) VALUE(" . $ORDER_ID . ",'" . $hotelPrice . "','" . $doorPrice . "') ";
  241. writeLog("insert extra info: " . $sqlInsert);
  242. $result = $send_pdo -> exec($sqlInsert);
  243. }
  244. }
  245. //..短信模板-改为17:30后OK,当天下单也OK
  246. function get_msg_info($ORDER_ID) {
  247. $msg_pdo = conn();
  248. $msg_sql = "CALL SP_GET_MESSAGE_TEMPLATE('" . $ORDER_ID . "')";
  249. $content = '';
  250. if (is_object($msg_pdo)) {
  251. $msg_result = $msg_pdo -> query($msg_sql);
  252. $i = 1;
  253. $data = array();
  254. if ($msg_result) {
  255. $data['code'] = "0";
  256. $data['info'] = "";
  257. do {
  258. $row = $msg_result -> fetchAll(PDO::FETCH_ASSOC);
  259. if ($i == 1) {
  260. $data['seat'] = isset($row) ? $row : array();
  261. } else if ($i == 2) {
  262. $data['run_info'] = isset($row) ? $row : array();
  263. } else if ($i == 3) {
  264. $data['driver'] = isset($row) ? $row : array();
  265. } else if($i==4){
  266. $data['dsn_prod']=isset($row) ? $row : array();
  267. }else if($i==5){
  268. $data['zhou_su_prod']=isset($row) ? $row : array();
  269. }
  270. $i++;
  271. } while($msg_result->nextRowset());
  272. }
  273. $json_obj = json_decode(json_encode($data), TRUE);
  274. $seat = isset($json_obj['seat'][0]) ? $json_obj['seat'][0] : array();
  275. $run_info = isset($json_obj['run_info'][0]) ? $json_obj['run_info'][0] : array();
  276. $driver = isset($json_obj['driver'][0]) ? $json_obj['driver'][0] : array();
  277. $dsn_prod = isset($json_obj['dsn_prod'])?$json_obj['dsn_prod']:array();
  278. $zhou_su_prod=isset($json_obj['zhou_su_prod'])?$json_obj['zhou_su_prod']:array();
  279. $bus_res_id = isset($json_obj['driver'][0]) ? $json_obj['driver'][0]["bus_res_id"] : 0;
  280. $short_url = false;
  281. $ticket_url = TICKET_QR_URL.$ORDER_ID;
  282. $short_url = sinaShortenUrl($ticket_url);
  283. $extra_message = "";
  284. if( $short_url != false ) {
  285. $extra_message = "或点击以下链接获取您的电子票扫码上车:{$short_url}";
  286. }
  287. //出票成功
  288. // $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已购票成功。乘车订单号为{订单号},请凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车,车牌号{车牌号},司机电话{司机姓司机电话}。";
  289. // 得到明天的时间
  290. date_default_timezone_set('PRC');
  291. //解决时区问题
  292. $tomorrow = date("Y-m-d", strtotime("+1 day"));
  293. $now_time = date('H:i:s', time());
  294. //判断当前时间是否在17:30:00之后
  295. $cur_date = date('Y-m-d', time());
  296. //迪士尼特殊情况parent_prod_id
  297. // $dsn_arr_prod = array(152752, 152759, 152763, 152770, 152777, 152784, 152791, 152801, 152808, 152815, 152822, 152832, 152842, 152852, 152859, 152866, 152873, 152877, 152884, 152891, 152898, 152905, 152915, 152922, 152929, 152936, 152946, 152956, 152966, 152973, 152980, 152990, 153003, 153016, 153023, 153033, 153034, 153044, 153057, 153070, 153083, 153090, 153100, 153110);
  298. $dsn_arr_prod = array(); //用来保存迪士尼产品的prod_id
  299. foreach($dsn_prod as $temp){
  300. $dsn_arr_prod[]=$temp['prod_id'];
  301. }
  302. $zhou_su_arr_prod = array();
  303. foreach($zhou_su_prod as $temp){
  304. $zhou_su_arr_prod[]=$temp['prod_id'];
  305. }
  306. $new_message_array = array(448569,448568);
  307. if( in_array( $run_info['parent_prod_id'], $new_message_array ) ) {
  308. $content = "您预订的{出发日期}{出发地}-{目的地}{票种名}{张数}张,已成功出票,请在{出发时间}前十五分钟到达{上车站点}。出行前一天下午的18:00左右将会有导游和您联系,预祝您旅途愉快。";
  309. } else if (($now_time > "18:30:00" && $run_info['start_date'] == $tomorrow) || $cur_date == $run_info['start_date']) {//17:30之后的订单或者下单时间为今天出行为今天下午 发送短信模板
  310. // if("18:30:00">"17:30:00" && $run_info['start_date']==$tomorrow){ //17:30之后的订单 发送短信模板
  311. //$content = "您预订的{出发日期}{出发地}-{目的地}{票种名}{张数}张,已成功出票,请在{出发时间}前三十分钟到达{上车站点}。您的乘车订单号为{订单号},车牌号{车牌号},司机电话{司机姓司机电话},请凭短信订单号乘车{$extra_message},预祝您旅途愉快。";
  312. $content = "您的车票订单{订单号}:您预订的{出发日期}{出发地}-{目的地}{票种名}{张数}已成功出票,车牌号{车牌号},司机电话{司机姓司机电话}。请于{出发日期}{出发时间}前10分钟到达{上车站点},请凭短信订单号乘车{$extra_message},预祝您旅途愉快。";
  313. if (in_array($run_info['parent_prod_id'], $dsn_arr_prod)) {
  314. $ticket_url = TICKET_QR_URL.$ORDER_ID;
  315. $short_url = sinaShortenUrl($ticket_url);
  316. $content = "您的车票订单{订单号}:您预订的{出发日期}{出发地}-{目的地}{票种名}{张数}已成功出票,车牌号{车牌号},司机电话{司机姓司机电话}。请于{出发日期}{出发时间}前10分钟到达{上车站点}:{上车站点详细地址},并提前点开电子车票准备乘车{$short_url}。请关注微信公众号【蜘蛛出行】,查看车辆及站点照片。";
  317. $start_station_address = $run_info['start_station_address'];
  318. $content = str_replace("{上车站点详细地址}", $start_station_address, $content);
  319. $content = str_replace("{上车站点}", $run_info['res_name'], $content);
  320. $content = str_replace("{下车站点}", $run_info['end_res_name'], $content);
  321. $content = str_replace("{订单号}", $ORDER_ID, $content);
  322. }
  323. } else {
  324. //$content = "您预订的{出发日期}{出发地}-{目的地}{票种名}{张数}张,已成功出票,请在{出发时间}前三十分钟到达{上车站点}。您的乘车订单号为{订单号},请凭短信订单号乘车。出行前一天下午的18:30会将车牌号与司机电话发送给您,预祝您旅途愉快。";
  325. $content = "您的车票订单{订单号}:您预订的{出发日期}{出发地}-{目的地}{票种名}{张数}已成功出票。出发前一天18点30分前会通过短信通知您车牌号及司机电话。请关注微信公众号【蜘蛛出行】,提前获取车辆信息。";
  326. if (in_array($run_info['parent_prod_id'], $dsn_arr_prod)) {
  327. $ticket_url = TICKET_QR_URL.$ORDER_ID;
  328. $short_url = sinaShortenUrl($ticket_url);
  329. $extra_content = "";
  330. if( $short_url != false ) {
  331. $extra_content = "或点击以下链接获取乘车二维码扫码上车(".$short_url.")";
  332. }
  333. $content = "您的车票订单{订单号}:您预订的{出发日期}{出发地}-{目的地}{票种名}{张数}已成功出票。请于{出发日期}{出发时间}前10分钟到达{上车站点}:{上车站点详细地址},并提前点开电子车票准备乘车{$short_url}。请关注微信公众号【蜘蛛出行】,查看车辆及站点照片。";
  334. $start_station_address = $run_info['start_station_address'];
  335. $content = str_replace("{上车站点详细地址}", $start_station_address, $content);
  336. $content = str_replace("{上车站点}", $run_info['res_name'], $content);
  337. $content = str_replace("{下车站点}", $run_info['end_res_name'], $content);
  338. $content = str_replace("{订单号}", $ORDER_ID, $content);
  339. }
  340. }
  341. // $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已购票成功。乘车订单号为{订单号},请凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车。";
  342. if ($seat) {
  343. $seat_x = isset($seat['seat_x']) ? $seat['seat_x'] : "";
  344. $seat_y = isset($seat['seat_y']) ? $seat['seat_y'] : "";
  345. $seat_name = isset($seat['seat_name']) ? $seat['seat_name'] : "";
  346. $order_main_id = isset($seat['order_main_id']) ? $seat['order_main_id'] : "";
  347. } else {
  348. }
  349. if ($run_info) {
  350. $order_count = $run_info['order_count'];
  351. $start_date = $run_info['start_date'];
  352. $start_time = $run_info['start_time'];
  353. $parent_order_id = $run_info['parent_order_id'];
  354. $end_date = $run_info['end_date'];
  355. $start_area = $run_info['start_area'];
  356. $end_area = $run_info['end_area'];
  357. $res_name = $run_info['res_name'];
  358. $parent_prod_id = $run_info['parent_prod_id'];
  359. $prod_name = $run_info['prod_name'];
  360. $prod_name = "标准票";
  361. $customer_name = $run_info['customer_name'];
  362. $customer_mobile = $run_info['customer_mobile'];
  363. $start_end_date = $start_date . "," . $start_time;
  364. $content = str_replace("{出发日期}", $start_date, $content);
  365. $content = str_replace("{出发时间}", $start_time, $content);
  366. $content = str_replace("{上车站点}", $res_name, $content);
  367. $content = str_replace("{出发地}", $start_area, $content);
  368. $content = str_replace("{目的地}", $end_area, $content);
  369. $content = str_replace("{票种名}", $prod_name, $content);
  370. $content = str_replace("{张数}", $order_count, $content);
  371. $content = str_replace("{订单号}", $ORDER_ID, $content);
  372. } else {
  373. $content = str_replace("{出发日期}", "", $content);
  374. $content = str_replace("{出发时间}", "", $content);
  375. $content = str_replace("{出发地}", "", $content);
  376. $content = str_replace("{目的地}", "", $content);
  377. $content = str_replace("{票种名}", "", $content);
  378. $content = str_replace("{张数}", "", $content);
  379. $content = str_replace("{订单号}", "", $content);
  380. }
  381. if ($driver) {
  382. $bus_no = isset($driver['bus_no']) ? $driver['bus_no'] : "";
  383. $driver_name = isset($driver['driver_name']) ? $driver['driver_name'] : "";
  384. $driver_mobile = isset($driver['driver_mobile']) ? $driver['driver_mobile'] : "";
  385. if ($bus_no == "") {
  386. $content = str_replace(",车牌号{车牌号}", "", $content);
  387. } else {
  388. $content = str_replace("{车牌号}", $bus_no, $content);
  389. }
  390. if ($driver_name == "") {
  391. $content = str_replace(",司机电话{司机姓司机电话},", "。", $content);
  392. } else {
  393. $driver_xing = mb_substr($driver_name, 0, 1, 'utf-8');
  394. $driver_name_mobile = $driver_xing . $driver_mobile;
  395. $content = str_replace("{司机姓司机电话}", $driver_name_mobile, $content);
  396. }
  397. } else {
  398. $content = str_replace("车牌号{车牌号},", "", $content);
  399. $content = str_replace("司机电话{司机姓司机电话},", "", $content);
  400. }
  401. /*
  402. if( $now_time < "18:30:00" ) {
  403. //判断是不是苏州或周庄
  404. // 判断如果不是迪士尼的票就不发短信
  405. if (!in_array($run_info['parent_prod_id'], $dsn_arr_prod) && !in_array($run_info['parent_prod_id'], $zhou_su_arr_prod)) {
  406. return array("", "-1", "不是迪士尼、苏州、周庄的票,目前不发送短信");
  407. }
  408. }*/
  409. return array(isset($customer_name) ? $customer_name : "", isset($customer_mobile) ? $customer_mobile : "", isset($content) ? $content : "短信错误,联系客服!!!");
  410. }
  411. }