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.

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