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.
 
 
 
 

576 lines
26 KiB

  1. <?php
  2. /*
  3. Author:XM
  4. Update:fuhc
  5. Compeny:Spiders Travel
  6. Descript:添加录入订单时的备注
  7. */
  8. define( "BASE_TICKET_URL", "http://api.zhizhuchuxing.com/api1.0/ticket.php?orderid=" );
  9. //exit();
  10. require_once '../Common/Mysql.php';
  11. require_once '../Common/sinaAPI.php';
  12. if (ALLOW_ORIGIN)
  13. header("Access-Control-Allow-Origin:*");
  14. //$res_content = get_msg_info(222226);
  15. //print_r($res_content);
  16. //exit();
  17. $userid = getUserId();
  18. if ($userid === false) {
  19. echo json_encode(array("code" => 1, "info" => "未登录"));
  20. $userid = 1;
  21. exit ;
  22. }
  23. $pdo=conn();
  24. $myprod = isset($_GET['prod']) ? $_GET['prod'] : "";
  25. $mycustomer = isset($_GET['customer']) ? $_GET['customer'] : "";
  26. $order_from_org_id = isset($_GET['order_from_org_id']) ? $_GET['order_from_org_id'] : '-2';
  27. $outside_order_id = isset($_GET['outside_order_id']) ? $_GET['outside_order_id'] : '';
  28. $u_prod_list = isset($_GET['u_prod_list']) ? $_GET['u_prod_list'] : "";
  29. $f_u_prod_list = isset($_GET['f_u_prod_list']) ? $_GET['f_u_prod_list'] : "";
  30. $per_go_price = sprintf( "%1$.2f", substr($u_prod_list, (strpos($u_prod_list,",") + 1) ));
  31. $per_back_price = 0;
  32. if( $f_u_prod_list != "") {
  33. $per_back_price = sprintf( "%1\$.2f", substr($f_u_prod_list, (strpos($f_u_prod_list,",") + 1) ));
  34. }
  35. ///st-xm/Api/add_new_order.php?prod={m152603p1|r202375}&customer={,fuhc_ceshi,1,15821387785,150,511621199502032173,,0,,,}&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}
  36. //.返程 1=true 0=false
  37. $ifcheck = isset($_GET['ifcheck']) ? $_GET['ifcheck'] : "0";
  38. $back_prod = isset($_GET['back_prod']) ? $_GET['back_prod'] : "";
  39. //将用户信息中的半角替换成全角
  40. $mycustomer=str_replace(',',',',$mycustomer);
  41. //再将^替换成半角,
  42. $mycustomer=str_replace('^',',',$mycustomer);
  43. $mycustomer_array = explode(",", substr($mycustomer,1,strlen($mycustomer)-2) );
  44. $current_time = date("Y-m-d H:i:s");
  45. /**
  46. *
  47. $prod_list = isset($_POST['prod_list'])?$_POST['prod_list']:'';//购票信息
  48. $customer_info = isset($_POST['customer_info'])?$_POST['customer_info']:'';//乘客信息
  49. $start_name = isset($_POST['start_name'])?$_POST['start_name']:'';//起点地名
  50. $end_name = isset($_POST['end_name'])?$_POST['end_name']:'';//终点地名
  51. $startx_y = isset($_POST['startx_y'])?$_POST['startx_y']:'';//起点纬经度
  52. $endx_y = isset($_POST['endx_y'])?$_POST['endx_y']:'';//终点纬经度
  53. $line_id = isset($_POST['line_id'])?$_POST['line_id']:'';;//线路ID
  54. $start_time = isset($_POST['start_time'])?$_POST['start_time']:'';//开始时间
  55. $end_time = isset($_POST['end_time'])?$_POST['end_time']:'';//结束时间
  56. *
  57. *
  58. */
  59. $ticket_id = substr($myprod, strpos($myprod, 'm') + 1, strpos($myprod, 'p') - 2);
  60. if($ticket_id== 449862 ||$ticket_id == 449867 || $ticket_id== 450036 ||$ticket_id == 450037){
  61. if($ticket_id== 449862){
  62. $result = post2('http://wx.zhizhuchuxing.com/ZZDZ/application/custom_made/control.php',array(
  63. 'type' =>'order_submitforout',
  64. 'prod_list'=>$myprod,
  65. 'customer_info'=>$mycustomer,
  66. 'start_name'=>'南京五塘广场',
  67. 'end_name'=>'南通政务中心',
  68. 'startx_y'=>'32.116682,118.784105',
  69. 'endx_y'=>'32.011714,120.894448',
  70. 'line_id'=>'449860',
  71. 'start_time'=>'07:37',
  72. 'end_time'=>'10:30'
  73. ));
  74. echo $result;die;
  75. }
  76. if($ticket_id== 449867){
  77. $result = post2('http://wx.zhizhuchuxing.com/ZZDZ/application/custom_made/control.php',array(
  78. 'type' =>'order_submitforout',
  79. 'prod_list'=>$myprod,
  80. 'customer_info'=>$mycustomer,
  81. 'start_name'=>'南通政务中心',
  82. 'end_name'=>'南京五塘广场',
  83. 'endx_y'=>'32.116682,118.784105',
  84. 'startx_y'=>'32.011714,120.894448',
  85. 'line_id'=>'449865',
  86. 'start_time'=>'07:37',
  87. 'end_time'=>'10:30'
  88. ));
  89. echo $result;die;
  90. }
  91. }
  92. $from_org_name = "";
  93. $sql = " SELECT SUPPLIER_NAME FROM base_supplier WHERE ID={$order_from_org_id} ";
  94. $sql = " SELECT ORG_NAME as SUPPLIER_NAME FROM base_organization WHERE ORG_ID={$order_from_org_id} ";//
  95. $result=$pdo->query($sql);
  96. if( $result != false ) {
  97. $rowset = $result->fetchAll();
  98. $result->closeCursor();
  99. if( $rowset != false && count($rowset) > 0 ) {
  100. $from_org_name = $rowset[0]["SUPPLIER_NAME"];
  101. }
  102. }
  103. $sql = "call sp_make_order(" . $userid . ",'" . $myprod . "','" . $mycustomer . "'," . $order_from_org_id . ",'" . $outside_order_id . "')";
  104. if ($ifcheck == "0") {//不是含有返程的
  105. writeLog("sp_make_order---dan: " . $sql);
  106. $rowset = create_order($sql, $u_prod_list);
  107. if (is_array($rowset) && $rowset[0]['errcode'] == 0 && SEND_MESSAGE == true) {//单程票订票成功
  108. $res_content = send_msg($rowset[0]['order_id']);
  109. $sql_order_status = "update order_main set order_status =146 where order_id= ".$rowset[0]['order_id']." or parent_order_id = ".$rowset[0]['order_id'];
  110. $pdo->exec($sql_order_status);
  111. $order_id = $rowset[0]['order_id'];
  112. $order_run_info = $res_content[3];
  113. $pdo_insert2 = conn();
  114. if( $order_run_info != false ) {
  115. $order_all_price = $per_go_price*$order_run_info['order_count'];
  116. $opera_detail = "创建订单,出发日期{$order_run_info["start_date"]},订单渠道{$from_org_name},单价{$per_go_price},总额{$order_all_price},联系人信息:{$mycustomer_array[1]},{$mycustomer_array[3]},{$mycustomer_array[5]},备注信息:{$mycustomer_array[9]}";
  117. } else {
  118. $opera_detail = "创建订单";
  119. }
  120. $sql = "insert into order_opera_log(order_id,opera_user_id,opera_type,opera_time,opera_detail,opera_platform) VALUES ({$order_id},$userid,1,'{$current_time}','{$opera_detail}','CS系统')";
  121. $result = $pdo_insert2->exec($sql);
  122. $post_data['order_id'] = $order_id;
  123. $post_data['order_status'] = "451,452,453";
  124. post2("http://". CS_DOMAIN. "/st-xm/Api/add_order_status_log.php",$post_data);
  125. }
  126. echo json_encode($rowset[0]);
  127. } else {
  128. writeLog("sp_make_order---fan_dan: " . $sql);
  129. $rowset = create_order($sql, $u_prod_list);
  130. if (is_array($rowset) && $rowset[0]['errcode'] == 0 && SEND_MESSAGE == true) {//返程---单程票订票成功
  131. $data['errcode'] = $rowset[0]['errcode'];
  132. $data['errinfo'] = $rowset[0]['errinfo'];
  133. $data['order_id'] = $rowset[0]['order_id'];
  134. $data['errcode_f'] = "";
  135. $data['errinfo_f'] = "";
  136. $data['order_id_f'] = "";
  137. $sql_f = "call sp_make_order(" . $userid . ",'" . $back_prod . "','" . $mycustomer . "'," . $order_from_org_id . ",'" . $outside_order_id . "')";
  138. writeLog('fan_success sql_f========' . $sql_f);
  139. $rowset_f = create_order($sql_f, $f_u_prod_list);
  140. //..判断返程票是否成功,若不成功,则去程订单
  141. if (is_array($rowset_f) && $rowset_f[0]['errcode'] == 0 && SEND_MESSAGE == true) {//返程--返程票订票成功
  142. $data['errcode_f'] = $rowset_f[0]['errcode'];
  143. $data['errinfo_f'] = $rowset_f[0]['errinfo'];
  144. $data['order_id_f'] = isset($rowset_f[0]['order_id']) ? $rowset_f[0]['order_id'] : "";
  145. writeLog('fan_fan_success');
  146. //发两条短信
  147. $res_content = send_msg($rowset[0]['order_id']);
  148. $res_content_f = send_msg($rowset_f[0]['order_id']);
  149. $sql_order_status = "update order_main set order_status =146 where order_id= ".$rowset[0]['order_id']." or parent_order_id = ".$rowset[0]['order_id']
  150. .";update order_main set order_status =146 where order_id= ".$rowset_f[0]['order_id']." or parent_order_id = ".$rowset_f[0]['order_id'];
  151. $pdo->exec($sql_order_status);
  152. $order_id = $rowset[0]['order_id'];
  153. $order_run_info = $res_content[3];
  154. $pdo_insert2 = conn();
  155. $current_time = date("Y-m-d H:i:s");
  156. if( $order_run_info != false ) {
  157. $order_all_price = $per_go_price*$order_run_info['order_count'];
  158. $opera_detail = "创建订单,出发日期{$order_run_info["start_date"]},订单渠道{$from_org_name},单价{$per_go_price},总额{$order_all_price},联系人信息:{$mycustomer_array[1]},{$mycustomer_array[3]},{$mycustomer_array[5]},备注信息:{$mycustomer_array[9]}";
  159. } else {
  160. $opera_detail = "创建订单";
  161. }
  162. $sql = "insert into order_opera_log(order_id,opera_user_id,opera_type,opera_time,opera_detail,opera_platform) VALUES ({$order_id},$userid,1,'{$current_time}','{$opera_detail}','CS系统')";
  163. $result = $pdo_insert2->exec($sql);
  164. $back_order_id = $rowset_f[0]['order_id'];
  165. $order_run_info = $res_content_f[3];
  166. $pdo_insert2 = conn();
  167. if( $order_run_info != false ) {
  168. $order_all_price = $per_back_price*$order_run_info['order_count'];
  169. $opera_detail = "创建订单,出发日期{$order_run_info["start_date"]},订单渠道{$from_org_name},单价{$per_back_price},总额{$order_all_price},联系人信息:{$mycustomer_array[1]},{$mycustomer_array[3]},{$mycustomer_array[5]},备注信息:{$mycustomer_array[9]}";
  170. } else {
  171. $opera_detail = "创建订单";
  172. }
  173. $sql = "insert into order_opera_log(order_id,opera_user_id,opera_type,opera_time,opera_detail,opera_platform) VALUES ({$back_order_id},$userid,1,'{$current_time}','{$opera_detail}','CS系统')";
  174. $result = $pdo_insert2->exec($sql);
  175. //往返订单需要插入关联表
  176. $sql = "insert into to_from(to_orderid,back_orderid) VALUES ({$order_id},{$back_order_id})";
  177. $result = $pdo_insert2->exec($sql);
  178. $post_data['order_id'] = "{$order_id},{$back_order_id}";
  179. $post_data['order_status'] = "451,452,453";
  180. post2("http://". CS_DOMAIN. "/st-xm/Api/add_order_status_log.php",$post_data);
  181. echo json_encode($data);
  182. exit();
  183. } else {//如果返程票订票不成功,则取消单程票
  184. $sql_cancel = "CALL SP_CANCEL_ORDER(" . $userid . "," . $rowset[0]['order_id'] . ")";
  185. writeLog('fan_faile_sql_cancel_dan======' . $sql_cancel);
  186. $pdo_cancel = conn();
  187. $result_cancel = $pdo_cancel -> query($sql_cancel);
  188. $rowset_cancel = $result_cancel -> fetchAll(PDO::FETCH_ASSOC);
  189. $result_cancel -> closeCursor();
  190. //取消单程不发短信,但要写入取消订单原因
  191. $res_content = get_msg_info($rowset[0]['order_id']);
  192. // $tel = isset($res_content[1])?$res_content[1]:"";
  193. $content = $rowset_f[0]['errinfo'] . "-订单已取消";
  194. $comment_type = 0;
  195. $comment_text = "";
  196. //$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)";
  197. //$result1 = $pdo_cancel -> query($sql1);
  198. //$rowset1 = $result1 -> fetchAll(PDO::FETCH_ASSOC);
  199. //$result1 -> closeCursor();
  200. $sql1 = "insert into order_send_message(ORDER_ID,SEND_MOBILE,SEND_MESSAGE,SEND_TIME,SEND_ERROR,CREATE_USER_ID,CREATE_TIME,UPDATE_USER_ID,UPDATE_TIME) VALUES ({$rowset[0]['order_id']},' ', '{$content}','{$current_time}', 0, {$userid},'{$current_time}', {$userid},'{$current_time}' )";
  201. $pdo_cancel->exec( $sql1 );
  202. writeLog("order_list.php HT_ADD_MSG_COMMENT()::" . $sql1);
  203. $data['errcode_f'] = $rowset_f[0]['errcode'];
  204. $data['errinfo_f'] = $rowset_f[0]['errinfo'];
  205. $data['order_id_f'] = isset($rowset_f[0]['order_id']) ? $rowset_f[0]['order_id'] : "";
  206. echo json_encode($data);
  207. exit();
  208. }
  209. }else{
  210. $data['errcode'] = $rowset[0]['errcode'];
  211. $data['errinfo'] = "单程".$rowset[0]['errinfo'];
  212. $data['order_id'] = isset($rowset[0]['order_id'])?$rowset[0]['order_id']:"";
  213. $data['errcode_f'] = "";
  214. $data['errinfo_f'] = "";
  215. $data['order_id_f'] = "";
  216. echo json_encode($data);
  217. exit();
  218. }
  219. }
  220. function create_order($sql, $price_list) {
  221. $pdo = conn();
  222. if (is_object($pdo)) {
  223. $result = $pdo -> query($sql);
  224. if(!$result){
  225. writeLog('存储过程出错'.$sql);
  226. echo json_encode(array("code"=>"-1","info"=>"system error存储过程出错"));
  227. exit();
  228. }else{
  229. $rowset_create = $result -> fetchAll(PDO::FETCH_ASSOC);
  230. $result -> closeCursor();
  231. writeLog('下订单成功');
  232. writeLog(json_encode($rowset_create));
  233. if (is_array($rowset_create) && $rowset_create[0]['errcode'] == 0 && SEND_MESSAGE == true) {
  234. //下订单成功再修改价格
  235. writeLog('change_price.php' . json_encode($_POST));
  236. $sql_up_price = "call SP_CHANGE_PRICE(" . $rowset_create[0]['order_id'] . ",'" . $price_list . "')";
  237. //$sql="update order_main set order_price ='".$price_arr[$k]."' where PROD_ID=".$v." and PARENT_ORDER_ID=".$ordid." and RUN_ID>0";
  238. $result_up_price = $pdo -> query($sql_up_price);
  239. $rowset_up_price = $result_up_price -> fetchAll(PDO::FETCH_ASSOC);
  240. writeLog("change_price.php sql:: " . $sql_up_price . "::rowset ::" . json_encode($rowset_up_price));
  241. $result_up_price -> closeCursor();
  242. }
  243. }
  244. }else{
  245. writeLog('$pdo conn error');
  246. }
  247. return $rowset_create;
  248. }
  249. //发短信
  250. function send_msg($ORDER_ID) {
  251. $send_pdo = conn();
  252. $order_id = $ORDER_ID;
  253. $res_content = get_msg_info($order_id);
  254. if( false == $res_content ) {
  255. return false;
  256. }
  257. //$url = BASE_TICKET_URL.$order_id;
  258. //$short_url = sinaShortenUrl(filterUrl($url)); //根据传入的长网址生产短网址
  259. $name = $res_content[0];
  260. $tel = $res_content[1];
  261. $content = $res_content[2];
  262. //$content .= "或者点击以下链接生成二维码:".$short_url;
  263. $response=null;
  264. $send_success="-100"; // 默认-100
  265. writeLog("短信模板内容:".$name."tel".$tel."【" . $content . "】");
  266. if($tel!="-1"){
  267. //..发短信
  268. $send_success="-90"; // 说明手机号不是-1
  269. $response = sendTelMessage($tel, $name, $content, $order_id);
  270. writeLog(json_encode($response));
  271. }else{
  272. $send_success="-1"; // 说明手机号为-1
  273. writeLog('send_msg==tel==='.$tel.":内容:==》".$content);
  274. }
  275. $comment_type = 0;
  276. $comment_text = "";
  277. if($response!=null){
  278. $send_success=(int)$response;
  279. }
  280. $current_time = date("Y-m-d H:i:s");
  281. $user_id = getUserId();
  282. // writeLog("发送短信返回code=".$req['error']);
  283. //$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})";
  284. //$result1 = $send_pdo -> query($sql1);
  285. //$rowset1 = $result1 -> fetchAll(PDO::FETCH_ASSOC);
  286. //$result1 -> closeCursor();
  287. $sql1 = "insert into order_send_message(ORDER_ID,SEND_MOBILE,SEND_MESSAGE,SEND_TIME,SEND_ERROR,CREATE_USER_ID,CREATE_TIME,UPDATE_USER_ID,UPDATE_TIME) VALUES ({$order_id},'{$tel}', '{$content}','{$current_time}', {$send_success}, {$user_id},'{$current_time}', {$user_id},'{$current_time}' )";
  288. $send_pdo->exec( $sql1 );
  289. writeLog("hotel_order_status.php HT_ADD_MSG_COMMENT()::" . $sql1);
  290. //insert order extra
  291. $hotelPrice = isset($_GET['hotelPrice']) ? $_GET['hotelPrice'] : "";
  292. $doorPrice = isset($_GET["doorPrice"]) ? $_GET["doorPrice"] : "";
  293. if ($hotelPrice != "" || $doorPrice != "") {
  294. $sqlInsert = " INSERT INTO order_extra_info (order_id,hotel_price,gate_price) VALUE(" . $ORDER_ID . ",'" . $hotelPrice . "','" . $doorPrice . "') ";
  295. writeLog("insert extra info: " . $sqlInsert);
  296. $result = $send_pdo -> exec($sqlInsert);
  297. }
  298. return $res_content;
  299. }
  300. //..短信模板-改为17:30后OK,当天下单也OK
  301. function get_msg_info($ORDER_ID) {
  302. $not_send_prod = array(451023,451024,451025,451026,451027,451028);
  303. $msg_pdo = conn();
  304. $msg_sql = "CALL SP_GET_MESSAGE_TEMPLATE('" . $ORDER_ID . "')";
  305. $content = '';
  306. if (is_object($msg_pdo)) {
  307. $msg_result = $msg_pdo -> query($msg_sql);
  308. $i = 1;
  309. $data = array();
  310. if ($msg_result) {
  311. $data['code'] = "0";
  312. $data['info'] = "";
  313. do {
  314. $row = $msg_result -> fetchAll(PDO::FETCH_ASSOC);
  315. if ($i == 1) {
  316. $data['seat'] = isset($row) ? $row : array();
  317. } else if ($i == 2) {
  318. $data['run_info'] = isset($row) ? $row : array();
  319. } else if ($i == 3) {
  320. $data['driver'] = isset($row) ? $row : array();
  321. } else if($i==4){
  322. $data['dsn_prod']=isset($row) ? $row : array();
  323. }else if($i==5){
  324. $data['zhou_su_prod']=isset($row) ? $row : array();
  325. }
  326. $i++;
  327. } while($msg_result->nextRowset());
  328. }
  329. $json_obj = json_decode(json_encode($data), TRUE);
  330. $seat = isset($json_obj['seat'][0]) ? $json_obj['seat'][0] : array();
  331. $run_info = isset($json_obj['run_info'][0]) ? $json_obj['run_info'][0] : array();
  332. $driver = isset($json_obj['driver'][0]) ? $json_obj['driver'][0] : array();
  333. $dsn_prod = isset($json_obj['dsn_prod'])?$json_obj['dsn_prod']:array();
  334. $zhou_su_prod=isset($json_obj['zhou_su_prod'])?$json_obj['zhou_su_prod']:array();
  335. $bus_res_id = isset($json_obj['driver'][0]) ? $json_obj['driver'][0]["bus_res_id"] : 0;
  336. if (in_array($run_info['parent_prod_id'], $not_send_prod)) {
  337. return false;
  338. }
  339. //出票成功
  340. // $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已购票成功。乘车订单号为{订单号},请凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车,车牌号{车牌号},司机电话{司机姓司机电话}。";
  341. // 得到明天的时间
  342. date_default_timezone_set('PRC');
  343. //解决时区问题
  344. $tomorrow = date("Y-m-d", strtotime("+1 day"));
  345. $now_time = date('H:i:s', time());
  346. //判断当前时间是否在17:30:00之后
  347. $cur_date = date('Y-m-d', time());
  348. //迪士尼特殊情况parent_prod_id
  349. // $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);
  350. $dsn_arr_prod = array(); //用来保存迪士尼产品的prod_id
  351. foreach($dsn_prod as $temp){
  352. $dsn_arr_prod[]=$temp['prod_id'];
  353. }
  354. $zhou_su_arr_prod = array();
  355. foreach($zhou_su_prod as $temp){
  356. $zhou_su_arr_prod[]=$temp['prod_id'];
  357. }
  358. $short_url = false;
  359. $ticket_url = TICKET_QR_URL.$ORDER_ID;
  360. $short_url = sinaShortenUrl($ticket_url);
  361. $extra_message = "";
  362. if( $short_url != false ) {
  363. $extra_message = "您的电子车票链接{$short_url},请在上车前点开,扫码乘车。";
  364. }
  365. if (($now_time > "18:30:00" && $run_info['start_date'] == $tomorrow) || $cur_date == $run_info['start_date']) {//17:30之后的订单或者下单时间为今天出行为今天下午 发送短信模板
  366. // if("18:30:00">"17:30:00" && $run_info['start_date']==$tomorrow){ //17:30之后的订单 发送短信模板
  367. // $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已购票成功。乘车订单号为{订单号},请凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车,车牌号{车牌号},司机电话{司机姓司机电话}。";
  368. $content = "订单号{订单号},{出发地}—{目的地}标准票{张数}张将于{出发日期} {出发时间}准点发车。车牌号{车牌号},司机电话{司机姓司机电话},请提前10分钟抵达上车地点:{上车站点详细地址}并点开电子车票{$short_url}进行验票。如有疑问请拨打客服电话021-33280519。";
  369. } else {
  370. $content = "订单号{订单号},{出发日期} {出发时间}{出发地}—{目的地}标准票{张数}张预定成功。发车前一天19点会短信通知您车牌号及司机电话,如未收到短信请拨打客服电话021-33280519。";
  371. }
  372. $new_message_array3 = array(450517,450522);
  373. if( in_array( $run_info['parent_prod_id'], $new_message_array3 ) ) {
  374. if( $run_info['parent_prod_id'] == 450517 ) {
  375. $address_txt = "上车地点:吴山广场西侧河坊巷8号(吴山广场旅游集散中心候车室); 上车方式:请至吴山广场旅游集散中心候车室服务台,凭预定姓名和手机号码上车。";
  376. } else {
  377. $address_txt = "上车地点:普陀城北长途客运中心;取票方式:请提前到达(学运路18号)普陀城北长途客运中心候车大厅服务台报预订名字和电话取票。";
  378. }
  379. $content = "您已成功预定{出发日期} {出发时间} {出发地}-{目的地}汽车票{张数}张(请最晚提前10分钟到达)。{$address_txt}紧急电话:15888866564。";
  380. }
  381. $new_message_array4 = array(450588,450589);
  382. if( in_array( $run_info['parent_prod_id'], $new_message_array4 ) ) {
  383. $content .= "紧急联系电话:18100158199。";
  384. }
  385. $content .= "提前一天19点之前,如未收到司机电话,请速与021-52218088联系。";
  386. $new_message_array5 = array(451437,451438);
  387. if( in_array( $run_info['parent_prod_id'], $new_message_array5 ) ) {
  388. $content = "订单号{订单号},{出发地}—{目的地}标准票{张数}张将于{出发日期} {出发时间}准点发车。车牌号{车牌号},司机电话{司机姓司机电话},请提前10分钟抵达上车地点:{上车站点详细地址}并点开电子车票{$short_url}进行验票。请关注微信公众号[蜘蛛出行],提前获取车辆信息。司机会提前与您联系,如有疑问,请联系021-33280578 。";
  389. }
  390. // $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已购票成功。乘车订单号为{订单号},请凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车。";
  391. if ($seat) {
  392. $seat_x = isset($seat['seat_x']) ? $seat['seat_x'] : "";
  393. $seat_y = isset($seat['seat_y']) ? $seat['seat_y'] : "";
  394. $seat_name = isset($seat['seat_name']) ? $seat['seat_name'] : "";
  395. $order_main_id = isset($seat['order_main_id']) ? $seat['order_main_id'] : "";
  396. } else {
  397. }
  398. if ($run_info) {
  399. $order_count = $run_info['order_count'];
  400. $start_date = $run_info['start_date'];
  401. $start_time = $run_info['start_time'];
  402. $parent_order_id = $run_info['parent_order_id'];
  403. $end_date = $run_info['end_date'];
  404. $start_area = $run_info['start_area'];
  405. $end_area = $run_info['end_area'];
  406. $res_name = $run_info['res_name'];
  407. $parent_prod_id = $run_info['parent_prod_id'];
  408. $prod_name = $run_info['prod_name'];
  409. $prod_name = "标准票";
  410. $customer_name = $run_info['customer_name'];
  411. $customer_mobile = $run_info['customer_mobile'];
  412. $start_station_address = $run_info['start_station_address'];
  413. $start_end_date = $start_date . "," . $start_time;
  414. $content = str_replace("{下车站点}", $run_info['end_res_name'], $content);
  415. $content = str_replace("{出发日期}", $start_date, $content);
  416. $content = str_replace("{出发时间}", $start_time, $content);
  417. $content = str_replace("{上车站点}", $res_name, $content);
  418. $content = str_replace("{出发地}", $start_area, $content);
  419. $content = str_replace("{目的地}", $end_area, $content);
  420. $content = str_replace("{票种名}", $prod_name, $content);
  421. $content = str_replace("{张数}", $order_count, $content);
  422. $content = str_replace("{上车站点详细地址}", $start_station_address, $content);
  423. $content = str_replace("{订单号}", $ORDER_ID, $content);
  424. } else {
  425. $content = str_replace("{下车站点}", "", $content);
  426. $content = str_replace("{出发日期}", "", $content);
  427. $content = str_replace("{出发时间}", "", $content);
  428. $content = str_replace("{出发地}", "", $content);
  429. $content = str_replace("{目的地}", "", $content);
  430. $content = str_replace("{票种名}", "", $content);
  431. $content = str_replace("{张数}", "", $content);
  432. $content = str_replace("{订单号}", "", $content);
  433. $content = str_replace("{上车站点详细地址}", "", $content);
  434. }
  435. if ($driver) {
  436. $bus_no = isset($driver['bus_no']) ? $driver['bus_no'] : "";
  437. $driver_name = isset($driver['driver_name']) ? $driver['driver_name'] : "";
  438. $driver_mobile = isset($driver['driver_mobile']) ? $driver['driver_mobile'] : "";
  439. if ($bus_no == "") {
  440. $content = str_replace(",车牌号{车牌号}", "", $content);
  441. } else {
  442. $content = str_replace("{车牌号}", $bus_no, $content);
  443. }
  444. if ($driver_name == "") {
  445. $content = str_replace(",司机电话{司机姓司机电话},", "。", $content);
  446. } else {
  447. $driver_xing = mb_substr($driver_name, 0, 1, 'utf-8');
  448. $driver_name_mobile = $driver_xing . $driver_mobile;
  449. $content = str_replace("{司机姓司机电话}", $driver_name_mobile, $content);
  450. }
  451. } else {
  452. $content = str_replace("车牌号{车牌号},", "", $content);
  453. $content = str_replace("司机电话{司机姓司机电话},", "", $content);
  454. }
  455. /*
  456. if( $now_time < "18:30:00" ) {
  457. //判断是不是苏州或周庄
  458. // 判断如果不是迪士尼的票就不发短信
  459. if (!in_array($run_info['parent_prod_id'], $dsn_arr_prod) && !in_array($run_info['parent_prod_id'], $zhou_su_arr_prod)) {
  460. return array("", "-1", "不是迪士尼、苏州、周庄的票,目前不发送短信");
  461. }
  462. }*/
  463. return array(isset($customer_name) ? $customer_name : "", isset($customer_mobile) ? $customer_mobile : "", isset($content) ? $content : "短信错误,联系客服!!!", $run_info );
  464. }
  465. }
  466. function post2($url, $data){//file_get_content
  467. $postdata = http_build_query(
  468. $data
  469. );
  470. $opts = array('http' =>
  471. array(
  472. 'method' => 'POST',
  473. 'header' => 'Content-type: application/x-www-form-urlencoded',
  474. 'content' => $postdata
  475. )
  476. );
  477. $context = stream_context_create($opts);
  478. $result = file_get_contents($url, false, $context);
  479. return $result;
  480. }
  481. /*
  482. // 解析 XML
  483. function xml_to_array($xml_string){
  484. $xml_string=trimall($xml_string);
  485. $xml=simplexml_load_string($xml_string);
  486. $json=json_encode($xml);
  487. // 加上TRUE 返回数组格式。
  488. $arr=json_decode($json,TRUE);
  489. return $arr;
  490. }
  491. function trimall($str)
  492. {
  493. $qian=array(" "," ","\t","\n","\r");
  494. $hou=array("","","","","");
  495. return str_replace($qian,$hou,$str);
  496. }
  497. /*
  498. */