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 27 KiB

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