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.

submit.php 29 KiB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. <?php
  2. /*
  3. * wechat 2.0
  4. * Copyright (c) 2016 zhangs http://zhizhuchuxing.com/
  5. * Date: 2016.9.21
  6. * Something is to pay QQ1062140302
  7. */
  8. date_default_timezone_set('PRC');
  9. require_once __DIR__ . '/../../api/common.php';
  10. require_once __DIR__ . '/../../api/create_order.php';
  11. //require_once __DIR__ . '/../../api/cancel_order.php';
  12. require_once __DIR__ . '/../../api/submitOrder.php';
  13. require_once __DIR__ . '/../dictionary.php';
  14. require_once __DIR__ . '/../../api/cancelOrder.php';
  15. $array_line_info = $array_line_info;
  16. class submit extends virtifyUsers
  17. {
  18. //提交订单流程
  19. public function execSubmit($prod_list, $customer_info, $start_id, $end_id, $line_id, $start_time, $end_time, $pdo, $array_line_info)
  20. {
  21. //获取要提交的详细信息
  22. $prod_info = $this->get_prod_info($prod_list, $pdo);
  23. $ticket_id = $prod_info['ticket_id'];//票种ID
  24. $tic_num = $prod_info['tic_num'];//订票数量
  25. $run_id = $prod_info['run_id'];//班次ID
  26. $userid = $prod_info['userid'];//用户ID
  27. $member_id = $prod_info['member_id'];//会员号
  28. $run_date = $prod_info['run_date'];//发车日期
  29. $run_time = $prod_info['run_time'];//发车时间
  30. $run_date_time = $prod_info['run_date_time'];//检验订单所需时间
  31. //判断会员号
  32. if (!$member_id) {
  33. echo json_encode(array("code" => '1', "iflogin" => 1, "info" => "请关注公众号:蜘蛛出行"));
  34. exit;
  35. }
  36. //判断购票数量
  37. if ($tic_num == 0) {
  38. echo json_encode(array("code" => '1', "info" => "订票数量不可为0"));
  39. exit;
  40. }
  41. //获取站点详情
  42. $start_name = $array_line_info[$line_id]['start'][$start_id]['name'];
  43. $end_name = $array_line_info[$line_id]['end'][$end_id]['name'];
  44. //派车
  45. $order_result = $this->send_car($line_id, $run_id, $run_date_time, $tic_num, $start_id, $end_id, $pdo);
  46. writeLog("send_car:" . json_encode($order_result));
  47. // echo json_encode(array("code" => '1', "info" =>$order_result));
  48. // exit();
  49. //派车失败
  50. if ($order_result['code'] != 0) {
  51. echo json_encode(array("code" => '1', "info" => "失败"));
  52. exit();
  53. }
  54. //派车成功
  55. $order_result = $order_result['result'];
  56. $order_id = $order_result['order_id'];//订单ID
  57. $bus_no = $order_result['bus_no'];//车号
  58. $order_from_org_id = 0;//订单渠道ID
  59. $top_org_id = 0;//顶级订单渠道ID
  60. $outside_order_id = isset($_POST['outside_order_id']) ? $_POST['outside_order_id'] : '1';//外部订单渠道ID
  61. //获取票种价格
  62. $sql_price = "select cus_price from opera_product_price where prod_id =" . $ticket_id;
  63. $result_price = $pdo->query($sql_price);
  64. $row_p = $result_price->fetchAll(PDO::FETCH_ASSOC);
  65. $price_list = $ticket_id . ',' . $row_p[0]['cus_price'];//票种价格完整信息
  66. if (isset($_COOKIE['out_part'])) { //该订单为南通热线微信号推广的订单 ,从该渠道进来的订单会带参数out_part=137 这个cookie会在dzbz_login中存入
  67. $sql = "CALL sp_make_order_for_business('" . $userid . "','" . $prod_list . "','" . $customer_info . "','137','0','" . $start_name . "','" . $end_name . "','" . $start_time . "','" . $end_time . "','" . $bus_no . "','" . $member_id . "','" . $order_id . "')";
  68. writeLog("sp_make_order_for_business---san: " . $sql);
  69. } else {
  70. $sql = "CALL sp_make_order_for_business('" . $userid . "','" . $prod_list . "','" . $customer_info . "','1','0','" . $start_name . "','" . $end_name . "','" . $start_time . "','" . $end_time . "','" . $bus_no . "','" . $member_id . "','" . $order_id . "')";
  71. writeLog("sp_make_order_for_business---san:" . $sql);
  72. }
  73. //提交order_main表
  74. $rowset = $this->create_order($sql, $price_list, $pdo);
  75. // echo json_encode(array('code' => '1', 'info' =>$rowset));
  76. // exit();
  77. //order_main提交失败
  78. if (!$rowset || $rowset[0]['errcode']) {
  79. $co = new cancelOrder();
  80. $res = $co->cancel_order($run_id, $bus_no, $start_id, $end_id, $order_id, $tic_num);
  81. if ($res['code'] != 0) {
  82. echo json_encode(array('code' => '1', 'info' => '服务器异常,请稍后重试!', 'info1' => '向数据库提交订单和退票算法都挂掉了!'));
  83. exit();
  84. }
  85. echo json_encode(array('code' => '1', 'info' => '服务器异常,请稍后重试!'));
  86. exit();
  87. }
  88. //获取订单详情
  89. $order_info = $this->get_order_info($order_id, $pdo);
  90. $pay_main_id = $order_info[0]['order_pay_main_id'];//支付方式
  91. $pay_price = $order_info[0]['order_price'];
  92. if (($line_id == 450544 && $end_id == 7) || ($line_id == 450539 && $start_id == 0)) {
  93. $price_change = 150;
  94. }
  95. if (isset($price_change) && $price_change) {
  96. $price_huaian = ($pay_price / 110) * 150;
  97. $sql_price_huaian = "UPDATE order_main
  98. SET ORDER_BOOK_STATUS = 1,
  99. order_price = " . $price_huaian . "
  100. WHERE
  101. order_id = " . $order_id;
  102. $result = $pdo->exec($sql_price_huaian);
  103. }
  104. //修改订单
  105. if (isset($price_change) && $price_change) {
  106. $this->update_order_info($order_id, $run_id, $bus_no, $member_id, $pay_main_id, $pdo, $price_change);
  107. } else {
  108. $this->update_order_info($order_id, $run_id, $bus_no, $member_id, $pay_main_id, $pdo);
  109. }
  110. echo json_encode(array('code' => '0', 'info' => 'http://xmwx.zhizhuchuxing.cn/wechat/WxPay/realpay/onlinePay.php?orderid=' . $order_id . '&fx=11&code2=dzbs'));
  111. exit();
  112. }
  113. //获取要提交订单的详细信息
  114. public function get_prod_info($prod_list, $pdo)
  115. {
  116. $ticket_id = substr($prod_list, strpos($prod_list, 'm') + 1, strpos($prod_list, 'p') - 2);//票种ID
  117. $tic_num = substr($prod_list, strpos($prod_list, 'p') + 1, strpos($prod_list, '|') - strpos($prod_list, 'p') - 1);//乘客数量
  118. $run_id = substr(substr($prod_list, strpos($prod_list, 'r') + 1), 0, -1);//班次ID
  119. //$beginX_Y = isset($_POST['startx_y']) ? $_POST['startx_y'] : false;
  120. $userid = 0;//用户ID
  121. $member_id = isset($_COOKIE['user_id']) ? $_COOKIE['user_id'] : '0';//会员号ID
  122. $sql_time = "select run_date,run_time from run_main where run_id =" . $run_id;
  123. $result_time = $pdo->query($sql_time);
  124. $row_t = $result_time->fetchAll(PDO::FETCH_ASSOC);
  125. $run_date = $row_t[0]['run_date'];//出发日期
  126. $run_time = $row_t[0]['run_time'];//出发时间
  127. $run_date_time = $run_date . " " . $run_time;
  128. $prod_info['ticket_id'] = $ticket_id;
  129. $prod_info['tic_num'] = $tic_num;
  130. $prod_info['run_id'] = $run_id;
  131. $prod_info['userid'] = $userid;
  132. $prod_info['member_id'] = $member_id;
  133. $prod_info['run_date'] = $run_date;
  134. $prod_info['run_time'] = $run_time;
  135. $prod_info['run_date_time'] = $run_date_time;
  136. return $prod_info;
  137. }
  138. //解析乘客信息
  139. public function explode_cust_info($cust_info)
  140. {
  141. $cust_info_temp = explode(',', $cust_info);
  142. $temp['name'] = $cust_info_temp['1'];
  143. $temp['phone'] = $cust_info_temp['3'];
  144. return $temp;
  145. }
  146. //派车
  147. public function send_car($line_id, $run_id, $run_date, $num, $station_start, $station_end, $pdo)
  148. {
  149. $submit_order = new submitOrder();
  150. $order_id = $this->getUniqeId($pdo);
  151. $submit_set = $submit_order->setOrder($line_id, $run_id, $order_id, $run_date, $num, $station_start, $station_end);
  152. return $submit_set;
  153. }
  154. function getUniqeId($pdo)
  155. {
  156. $result = $pdo->query("select FUNC_GET_UNIQUE_ID('1','1') id");
  157. $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
  158. return $rowset[0]['id'];
  159. }
  160. //检验订单
  161. public function check_order($startx_y, $endx_y, $line_id, $run_id, $tic_num, $start_name, $end_name, $run_date_time)
  162. {
  163. $co = new createOrder();
  164. $time = commonUtils::baiduShortTime($startx_y, $endx_y);
  165. if (!$startx_y || !$endx_y) {
  166. $result['status'] = 111; //状态码:111为经纬度不能为空)
  167. $result['info'] = "经纬度不能为空";
  168. echo json_encode($result);
  169. exit();
  170. }
  171. if ($time > 360) //总时长不能超过360分钟
  172. {
  173. $result['status'] = 101; //状态码:101为总时长不符合要求(超过360分钟)
  174. $result['info'] = "总时长不能超过360分钟";
  175. echo json_encode($result);
  176. exit();
  177. }
  178. if ($tic_num > 6) {
  179. $result['status'] = 108; //状态码:人数不能超过6人
  180. $result['info'] = "每个订单人数不能超过6人";
  181. echo json_encode($result);
  182. exit();
  183. }
  184. //先判断是否属于规定的市区
  185. $start_area = commonUtils::GeocodingAPI($startx_y);
  186. $end_area = commonUtils::GeocodingAPI($endx_y);
  187. if (($line_id == "449860" && $start_area == "南京市" && $end_area == "南通市") || ($line_id == "449865" && $start_area == "南通市" && $end_area == "南京市")) {
  188. if ($line_id && $run_id && $tic_num && $startx_y && $endx_y && $run_date_time) {
  189. $orderID = commonUtils::produceOrderId($tic_num); //获取订单号
  190. $res = $co->calShortTime($line_id, $run_id, $orderID, $tic_num, $startx_y, $start_name, $endx_y, $end_name, $run_date_time);
  191. return $res;
  192. } else {
  193. $result['code'] = '1';
  194. $result['info'] = "订单提交信息不全";
  195. echo json_encode($result);
  196. exit();
  197. }
  198. } else {
  199. $result['code'] = '1';
  200. $result['info'] = "所选地点不在规划范围内";
  201. echo json_encode($result);
  202. exit();
  203. }
  204. }
  205. //..短信模板-改为17:30后OK,当天下单也OK
  206. public function get_msg_info($ORDER_ID)
  207. {
  208. $msg_pdo = conn();
  209. $msg_sql = "CALL SP_GET_MESSAGE_TEMPLATE('" . $ORDER_ID . "')";
  210. $content = '';
  211. if (is_object($msg_pdo)) {
  212. $msg_result = $msg_pdo->query($msg_sql);
  213. $i = 1;
  214. $data = array();
  215. if ($msg_result) {
  216. $data['code'] = "0";
  217. $data['info'] = "";
  218. do {
  219. $row = $msg_result->fetchAll(PDO::FETCH_ASSOC);
  220. if ($i == 1) {
  221. $data['seat'] = isset($row) ? $row : array();
  222. } else if ($i == 2) {
  223. $data['run_info'] = isset($row) ? $row : array();
  224. } else if ($i == 3) {
  225. $data['driver'] = isset($row) ? $row : array();
  226. } else if ($i == 4) {
  227. $data['dsn_prod'] = isset($row) ? $row : array();
  228. } else if ($i == 5) {
  229. $data['zhou_su_prod'] = isset($row) ? $row : array();
  230. }
  231. $i++;
  232. } while ($msg_result->nextRowset());
  233. }
  234. $json_obj = json_decode(json_encode($data), TRUE);
  235. $seat = isset($json_obj['seat'][0]) ? $json_obj['seat'][0] : array();
  236. $run_info = isset($json_obj['run_info'][0]) ? $json_obj['run_info'][0] : array();
  237. $driver = isset($json_obj['driver'][0]) ? $json_obj['driver'][0] : array();
  238. $dsn_prod = isset($json_obj['dsn_prod']) ? $json_obj['dsn_prod'] : array();
  239. $zhou_su_prod = isset($json_obj['zhou_su_prod']) ? $json_obj['zhou_su_prod'] : array();
  240. $bus_res_id = isset($json_obj['driver'][0]) ? $json_obj['driver'][0]["bus_res_id"] : 0;
  241. $short_url = false;
  242. if ($bus_res_id != 0) {
  243. $ary_sell_ary = array(916, 917);
  244. if (in_array($bus_res_id, $ary_sell_ary)) {
  245. $ticket_url = TICKET_QR_URL . $ORDER_ID;
  246. $short_url = sinaShortenUrl($ticket_url);
  247. }
  248. }
  249. $extra_message = "";
  250. if ($short_url != false) {
  251. $extra_message = "点击以下链接获取您的电子票扫码上车:{$short_url}";
  252. }
  253. //出票成功
  254. // $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已购票成功。乘车订单号为{订单号},请凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车,车牌号{车牌号},司机电话{司机姓司机电话}。";
  255. // 得到明天的时间
  256. date_default_timezone_set('PRC');
  257. //解决时区问题
  258. $tomorrow = date("Y-m-d", strtotime("+1 day"));
  259. $now_time = date('H:i:s', time());
  260. //判断当前时间是否在17:30:00之后
  261. $cur_date = date('Y-m-d', time());
  262. //迪士尼特殊情况parent_prod_id
  263. // $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);
  264. $dsn_arr_prod = array(); //用来保存迪士尼产品的prod_id
  265. foreach ($dsn_prod as $temp) {
  266. $dsn_arr_prod[] = $temp['prod_id'];
  267. }
  268. $zhou_su_arr_prod = array();
  269. foreach ($zhou_su_prod as $temp) {
  270. $zhou_su_arr_prod[] = $temp['prod_id'];
  271. }
  272. $new_message_array = array(448569, 448568);
  273. if (in_array($run_info['parent_prod_id'], $new_message_array)) {
  274. $content = "您预订的{出发日期}{出发地}-{目的地}{票种名}{张数}张,已成功出票,请在{出发时间}前十五分钟到达{上车站点}。出行前一天下午的18:00左右将会有导游和您联系,预祝您旅途愉快。";
  275. } elseif (($now_time > "18:30:00" && $run_info['start_date'] == $tomorrow) || $cur_date == $run_info['start_date']) {//17:30之后的订单或者下单时间为今天出行为今天下午 发送短信模板
  276. // if("18:30:00">"17:30:00" && $run_info['start_date']==$tomorrow){ //17:30之后的订单 发送短信模板
  277. // $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已购票成功。乘车订单号为{订单号},请凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车,车牌号{车牌号},司机电话{司机姓司机电话}。";
  278. $content = "您预订的{出发日期}{出发地}-{目的地}{票种名}{张数}张,已成功出票,请在{出发时间}前三十分钟到达{上车站点}。您的乘车订单号为{订单号},车牌号{车牌号},司机电话{司机姓司机电话},请凭短信订单号乘车{$extra_message},预祝您旅途愉快。";
  279. if (in_array($run_info['parent_prod_id'], $dsn_arr_prod)) {
  280. $content = "您预订的{出发日期}{上车站点}-{下车站点}{票种名}{张数}张,已成功出票,请在{出发时间}前三十分钟到达{上车站点}。您的乘车订单号为{订单号}。请凭短信订单号乘车{$extra_message},预祝您旅途愉快。(如需咨询请致电:021-33280578)【zhizhuchuxing】Congratulations! Your ticket from hotel to Disney has been approved. Your order number is {订单号}. Please keep it and arrive at the place before {出发时间}. Enjoy your trip and have a nice day! If you have any questions, please call: 021-33280578.";
  281. $content = str_replace("{上车站点}", $run_info['res_name'], $content);
  282. $content = str_replace("{下车站点}", $run_info['end_res_name'], $content);
  283. $content = str_replace("{订单号}", $ORDER_ID, $content);
  284. }
  285. } else {
  286. // $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已购票成功。乘车订单号为{订单号},请凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车。";
  287. $content = "您预订的{出发日期}{出发地}-{目的地}{票种名}{张数}张,已成功出票,请在{出发时间}前三十分钟到达{上车站点}。您的乘车订单号为{订单号},请凭短信订单号乘车。出行前一天下午的18:30会将车牌号与司机电话发送给您,预祝您旅途愉快。";
  288. if (in_array($run_info['parent_prod_id'], $dsn_arr_prod)) {
  289. $ticket_url = TICKET_QR_URL . $ORDER_ID;
  290. $short_url = sinaShortenUrl($ticket_url);
  291. $extra_content = "";
  292. if ($short_url != false) {
  293. $extra_content = "或点击以下链接获取乘车二维码扫码上车(" . $short_url . ")";
  294. }
  295. $content = "您预订的{出发日期}{上车站点}-{下车站点}{票种名}{张数}张,已成功出票,请在{出发时间}前三十分钟到达{上车站点}。您的乘车订单号为{订单号}。请凭短信订单号乘车{$extra_content},预祝您旅途愉快。(如需咨询请致电:021-33280578)【zhizhuchuxing】Congratulations! Your ticket from hotel to Disney has been approved. Your order number is {订单号}. Please keep it and arrive at the place before {出发时间}. Enjoy your trip and have a nice day! If you have any questions, please call: 021-33280578.";
  296. $content = str_replace("{上车站点}", $run_info['res_name'], $content);
  297. $content = str_replace("{下车站点}", $run_info['end_res_name'], $content);
  298. $content = str_replace("{订单号}", $ORDER_ID, $content);
  299. }
  300. }
  301. // $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已购票成功。乘车订单号为{订单号},请凭订单号或绑定微信(微信服务号“蜘蛛出行”)扫码上车。";
  302. if ($seat) {
  303. $seat_x = isset($seat['seat_x']) ? $seat['seat_x'] : "";
  304. $seat_y = isset($seat['seat_y']) ? $seat['seat_y'] : "";
  305. $seat_name = isset($seat['seat_name']) ? $seat['seat_name'] : "";
  306. $order_main_id = isset($seat['order_main_id']) ? $seat['order_main_id'] : "";
  307. } else {
  308. }
  309. if ($run_info) {
  310. $order_count = $run_info['order_count'];
  311. $start_date = $run_info['start_date'];
  312. $start_time = $run_info['start_time'];
  313. $parent_order_id = $run_info['parent_order_id'];
  314. $end_date = $run_info['end_date'];
  315. $start_area = $run_info['start_area'];
  316. $end_area = $run_info['end_area'];
  317. $res_name = $run_info['res_name'];
  318. $parent_prod_id = $run_info['parent_prod_id'];
  319. $prod_name = $run_info['prod_name'];
  320. $prod_name = "标准票";
  321. $customer_name = $run_info['customer_name'];
  322. $customer_mobile = $run_info['customer_mobile'];
  323. $start_end_date = $start_date . "," . $start_time;
  324. $content = str_replace("{出发日期}", $start_date, $content);
  325. $content = str_replace("{出发时间}", $start_time, $content);
  326. $content = str_replace("{上车站点}", $res_name, $content);
  327. $content = str_replace("{出发地}", $start_area, $content);
  328. $content = str_replace("{目的地}", $end_area, $content);
  329. $content = str_replace("{票种名}", $prod_name, $content);
  330. $content = str_replace("{张数}", $order_count, $content);
  331. $content = str_replace("{订单号}", $ORDER_ID, $content);
  332. } else {
  333. $content = str_replace("{出发日期}", "", $content);
  334. $content = str_replace("{出发时间}", "", $content);
  335. $content = str_replace("{出发地}", "", $content);
  336. $content = str_replace("{目的地}", "", $content);
  337. $content = str_replace("{票种名}", "", $content);
  338. $content = str_replace("{张数}", "", $content);
  339. $content = str_replace("{订单号}", "", $content);
  340. }
  341. if ($driver) {
  342. $bus_no = isset($driver['bus_no']) ? $driver['bus_no'] : "";
  343. $driver_name = isset($driver['driver_name']) ? $driver['driver_name'] : "";
  344. $driver_mobile = isset($driver['driver_mobile']) ? $driver['driver_mobile'] : "";
  345. if ($bus_no == "") {
  346. $content = str_replace(",车牌号{车牌号}", "", $content);
  347. } else {
  348. $content = str_replace("{车牌号}", $bus_no, $content);
  349. }
  350. if ($driver_name == "") {
  351. $content = str_replace(",司机电话{司机姓司机电话},", "。", $content);
  352. } else {
  353. $driver_xing = mb_substr($driver_name, 0, 1, 'utf-8');
  354. $driver_name_mobile = $driver_xing . $driver_mobile;
  355. $content = str_replace("{司机姓司机电话}", $driver_name_mobile, $content);
  356. }
  357. } else {
  358. $content = str_replace("车牌号{车牌号},", "", $content);
  359. $content = str_replace("司机电话{司机姓司机电话},", "", $content);
  360. }
  361. /*
  362. if( $now_time < "18:30:00" ) {
  363. //判断是不是苏州或周庄
  364. // 判断如果不是迪士尼的票就不发短信
  365. if (!in_array($run_info['parent_prod_id'], $dsn_arr_prod) && !in_array($run_info['parent_prod_id'], $zhou_su_arr_prod)) {
  366. return array("", "-1", "不是迪士尼、苏州、周庄的票,目前不发送短信");
  367. }
  368. }*/
  369. $content .= "【重要提示】:因G20峰会影响,7月1号开始实名登记安检,出行时请所有游客携带有效证件(身份证或户口本),凭有效证件上车,如被查出无有效证件,导致无法出行,责任自行承担,谢谢配合!";
  370. return array(isset($customer_name) ? $customer_name : "", isset($customer_mobile) ? $customer_mobile : "", isset($content) ? $content : "短信错误,联系客服!!!");
  371. }
  372. }
  373. //发短信
  374. public function send_msg($ORDER_ID)
  375. {
  376. $send_pdo = conn();
  377. $order_id = $ORDER_ID;
  378. $res_content = get_msg_info($order_id);
  379. $name = $res_content[0];
  380. $tel = $res_content[1];
  381. $content = $res_content[2];
  382. writeLog("短信模板内容:【" . $content . "】");
  383. //..发短信先取消
  384. $response = sendTelMessage($tel, $name, $content, $order_id);
  385. writeLog(json_encode($response));
  386. $comment_type = 0;
  387. $comment_text = "";
  388. $send_success = (int)$response;
  389. $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})";
  390. $result1 = $send_pdo->query($sql1);
  391. $rowset1 = $result1->fetchAll(PDO::FETCH_ASSOC);
  392. $result1->closeCursor();
  393. writeLog("hotel_order_status.php HT_ADD_MSG_COMMENT()::" . $sql1);
  394. //insert order extra
  395. $hotelPrice = isset($_GET['hotelPrice']) ? $_GET['hotelPrice'] : "";
  396. $doorPrice = isset($_GET["doorPrice"]) ? $_GET["doorPrice"] : "";
  397. if ($hotelPrice != "" || $doorPrice != "") {
  398. $sqlInsert = " INSERT INTO order_extra_info (order_id,hotel_price,gate_price) VALUE(" . $ORDER_ID . ",'" . $hotelPrice . "','" . $doorPrice . "') ";
  399. writeLog("insert extra info: " . $sqlInsert);
  400. $result = $send_pdo->exec($sqlInsert);
  401. }
  402. }
  403. //创建订单
  404. public function create_order($sql, $price_list, $pdo)
  405. {
  406. if (is_object($pdo)) {
  407. $result = $pdo->query($sql);
  408. if (!$result) {
  409. return false;
  410. }
  411. // echo json_encode(array('aa'=>$sql));die;
  412. $rowset_create = $result->fetchAll(PDO::FETCH_ASSOC);
  413. $result->closeCursor();
  414. writeLog('下订单成功');
  415. writeLog(json_encode($rowset_create));
  416. if (is_array($rowset_create) && $rowset_create[0]['errcode'] == 0 && SEND_MESSAGE == true) {
  417. //下订单成功再修改价格
  418. writeLog('change_price.php' . json_encode($_POST));
  419. $sql_up_price = "call SP_CHANGE_PRICE(" . $rowset_create[0]['order_id'] . ",'" . $price_list . "')";
  420. //$sql="update order_main set order_price ='".$price_arr[$k]."' where PROD_ID=".$v." and PARENT_ORDER_ID=".$ordid." and RUN_ID>0";
  421. $result_up_price = $pdo->query($sql_up_price);
  422. $rowset_up_price = $result_up_price->fetchAll(PDO::FETCH_ASSOC);
  423. writeLog("change_price.php sql:: " . $sql_up_price . "::rowset ::" . json_encode($rowset_up_price));
  424. $result_up_price->closeCursor();
  425. }
  426. }
  427. return $rowset_create;
  428. }
  429. //获取订单详情
  430. public function get_order_info($order_id, $pdo)
  431. {
  432. //根据订单号查找订单详情
  433. $sql = "SELECT
  434. a.order_id,
  435. a.create_time,
  436. a.order_price,
  437. a.order_pay_main_id,
  438. a.customer_name,
  439. a.customer_mobile,
  440. count(b.order_id) AS num,
  441. b.PROD_START_STATION_DATE AS run_date,
  442. b.PROD_START_STATION_TIME AS run_time,
  443. b.PROD_START_STATION_AREA_NAME AS start_area,
  444. b.PROD_END_STATION_AREA_NAME AS end_area,
  445. b.PROD_START_STATION_RES_NAME AS start_res,
  446. b.PROD_END_STATION_RES_NAME AS end_res
  447. FROM
  448. order_main a,
  449. order_main b
  450. WHERE
  451. a.order_id = b.PARENT_ORDER_ID
  452. AND a.order_id = " . $order_id . "
  453. GROUP BY
  454. a.order_id";
  455. $result = $pdo->query($sql);
  456. $order_info = $result->fetchAll(PDO::FETCH_ASSOC);
  457. return $order_info;
  458. }
  459. //修改订单详情
  460. public function update_order_info($order_id, $run_id, $bus_no, $member_id, $pay_main_id, $pdo, $price_change = NULL)
  461. {
  462. $sql_pay = "UPDATE order_pay_detail
  463. SET pay_type_id_1 = 278
  464. WHERE
  465. pay_main_id = " . $pay_main_id;
  466. $sql_cancel = "UPDATE order_main
  467. SET ORDER_BOOK_STATUS = 1,
  468. member_id = " . $member_id . "
  469. WHERE
  470. order_id = " . $order_id . "
  471. OR parent_order_id = " . $order_id;
  472. $sql_check = "INSERT into order_check_tickets(order_id,run_id,bus_no,check_status,check_time,check_station)
  473. VALUES(" . $order_id . "," . $run_id . "," . $bus_no . ",1,'" . date("Y-m-d H:i:s", time()) . "',0)";
  474. $result = $pdo->exec($sql_cancel);
  475. $result = $pdo->exec($sql_pay);
  476. $result = $pdo->exec($sql_check);
  477. }
  478. }
  479. $prod_list = isset($_POST['prod_list']) ? $_POST['prod_list'] : '';//购票信息
  480. $customer_info = isset($_POST['customer_info']) ? $_POST['customer_info'] : '';//乘客信息
  481. $start_id = isset($_POST['start_id']) ? $_POST['start_id'] : '';//起点站点id
  482. $end_id = isset($_POST['end_id']) ? $_POST['end_id'] : '';//终点站点id
  483. $line_id = isset($_POST['line_id']) ? $_POST['line_id'] : '';;//线路ID
  484. $start_time = isset($_POST['start_time']) ? $_POST['start_time'] : '';//开始时间
  485. $end_time = isset($_POST['end_time']) ? $_POST['end_time'] : '';//结束时间
  486. //判断是否有时间
  487. if (empty($start_time) || empty($end_time)) {
  488. echo json_encode(array('code' => '1', 'info' => '开始和结束时间均不能为空'));
  489. exit();
  490. }
  491. //if($start_time < date('Y-m-d H:i',time()+3600)){
  492. // echo json_encode(array('code' => '1', 'info' => '发车前停止售票'));
  493. // exit();
  494. //}
  495. $submit = new submit();
  496. $res = $submit->execSubmit($prod_list, $customer_info, $start_id, $end_id, $line_id, $start_time, $end_time, $pdo, $array_line_info);
  497. ?>