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.
 
 
 
 
 

553 lines
28 KiB

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