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.
 
 
 
 
 

521 lines
28 KiB

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