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.
 
 
 
 

269 lines
12 KiB

  1. <?php
  2. /*
  3. Author:fuhc
  4. Compeny:Spiders Travel
  5. */
  6. require_once '../Common/Mysql.php';
  7. if (ALLOW_ORIGIN)
  8. header("Access-Control-Allow-Origin:*");
  9. $method = isset($_GET['method']) ? $_GET['method'] : "";
  10. $user_id = getUserId();
  11. //if ($user_id == false) {
  12. // echo json_encode(array("code" => "1", "info" => "用户未登录"));
  13. // exit ;
  14. //}
  15. $user_id=1;
  16. //取消订单原因
  17. if(isset($_GET['reason'])){
  18. $reason=$_GET['reason'];
  19. $order_id=$_GET['order_id'];
  20. $clock=$_GET['clock'];
  21. // $return_data = array();
  22. // $return_data["code"] = 1;
  23. // $return_data["info"] = $reason;
  24. $pdo_insert = conn1();
  25. $sql = "insert into order_comment(ORDER_ID,COMMENT_TXT,CREATE_TIME) VALUES ({$order_id},'{$reason}','{$clock}')";
  26. $result = $pdo_insert->exec($sql);
  27. }
  28. if ($method == "cancelOrder") {
  29. $order_id = isset($_GET['order_id']) ? $_GET['order_id'] : "";
  30. $pdo = conn1();
  31. $sql = "CALL SP_CANCEL_ORDER(" . $user_id . "," . $order_id . ")";
  32. writeLog('cancelOrder= sql='.$sql);
  33. $result = $pdo -> query($sql);
  34. if($result){
  35. $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
  36. $data['code']=isset($rowset[0]['errorcode'])?$rowset[0]['errorcode']:"499";
  37. $data['info']=isset($rowset[0]['errorinfo'])?$rowset[0]['errorinfo']:"未从数据库中获得返回值";
  38. // echo json_encode($data);exit();
  39. }else{
  40. $data['code']="500";
  41. $data['info']="数据库错误";
  42. echo json_encode($data);exit();
  43. }
  44. $result -> closeCursor();
  45. if (is_array($rowset) && $rowset['code'] == 0 && SEND_MESSAGE == true) {
  46. $res_content = get_msg_info($order_id);
  47. $name = isset($res_content[0])?$res_content[0]:"";
  48. $tel = isset($res_content[1])?$res_content[1]:"";
  49. $content = isset($res_content[2])?$res_content[2]:"";
  50. // $content = "单号:" . $order_id . ',订单状态变更为' . $order_status . "随机数" . rand(1, 10000);
  51. writeLog("巴士取消短信模板内容:【" . $content . "】");
  52. //..取消发短信
  53. $response=null;
  54. $send_success="-100";
  55. // $response = sendTelMessage($tel, $name, $content, $order_id);
  56. // writeLog(json_encode($response));
  57. // $send_success = (int)$response;
  58. $comment_type=0;
  59. $comment_text="";
  60. $sql1 = "CALL HT_ADD_MSG_COMMENT(".$user_id.",'addmsg'," . $order_id . "," . $comment_type . ",'" . $comment_text . "','" . $tel . "','" . $content . "','" . date("Y-m-d H:i:s") . "',{$send_success})";
  61. $result1 = $pdo -> query($sql1);
  62. $rowset1 = $result1 -> fetchAll(PDO::FETCH_ASSOC);
  63. $result1 -> closeCursor();
  64. writeLog("order_list.php HT_ADD_MSG_COMMENT()::" . $sql1);
  65. }
  66. echo json_encode($data);
  67. }else if($method=="getOrderORG"){
  68. $pdo=conn1();
  69. $sql="SELECT ORG_ID AS org_id ,ORG_NAME as soure FROM base_organization where cancel_flag=0;";
  70. $result=$pdo->query($sql);
  71. $rowset=array("code"=>"0","info"=>"");
  72. $rowset['order_ORG_List']=$result->fetchAll(PDO::FETCH_ASSOC);
  73. $result->closeCursor();
  74. echo json_encode($rowset);exit();
  75. }
  76. else {
  77. $timelimit = isset($_GET['timelimit']) ? $_GET['timelimit'] : '';
  78. $starttime = isset($_GET['starttime']) ? $_GET['starttime'] : '';
  79. $endtime = isset($_GET['endtime']) ? $_GET['endtime'] : '';
  80. $ordersource = isset($_GET['ordersource']) ? (empty($_GET['ordersource']) ? 0 : $_GET['ordersource']) : 0;
  81. $orderstatus = isset($_GET['orderstatus']) ? (empty($_GET['orderstatus']) ? 0 : $_GET['orderstatus']) : 0;
  82. $paystatus = isset($_GET['paystatus']) ? (empty($_GET['paystatus']) ? -1 : $_GET['paystatus']) : -1;
  83. $billingstatus = isset($_GET['billingstatus']) ? $_GET['billingstatus'] : '';
  84. $mealbounce = isset($_GET['mealbounce']) ? $_GET['mealbounce'] : '';
  85. $refund = isset($_GET['refund']) ? $_GET['refund'] : '';
  86. $moresearch = isset($_GET['moresearch']) ? trim($_GET['moresearch']) : '';
  87. $export = isset($_GET['export']) ? $_GET['export'] : '';
  88. //2016-07-15新增
  89. $start_area=isset($_GET['start_area']) ? $_GET['start_area'] : '';
  90. $end_area=isset($_GET['end_area']) ? $_GET['end_area'] : '';
  91. $line=isset($_GET['line']) ? $_GET['line'] : '';
  92. //..暂未加入存储过程
  93. $currpage = isset($_GET['currpage']) ? (empty($_GET['currpage']) ? 1 : $_GET['currpage']) : 1;
  94. $pagesize = isset($_GET['pagesize']) ? (empty($_GET['pagesize']) ? 10 : $_GET['pagesize']) : 10;
  95. $pdo = conn1();
  96. $sql = "CALL XM_ORDER_GET_LIST_nj(".$user_id.",'" . $timelimit . "','" . $starttime . "','" . $endtime . "'," . $ordersource . "," . $orderstatus . "," . $paystatus . ",'" . $billingstatus . "','" . $mealbounce . "','" . $refund . "','" . $moresearch . "','" . $export . "'," . $currpage . "," . $pagesize . ",'".$line."','".$start_area."','".$end_area."')";
  97. // writeLog('order_list.php -- sql== '.$sql);
  98. $result = $pdo -> query($sql);
  99. $data = array();
  100. do {
  101. $rowset = $result -> fetchAll(PDO::FETCH_ASSOC);
  102. if ($rowset) {
  103. $data[] = $rowset;
  104. }
  105. } while ($result->nextRowset());
  106. $count = count($data);
  107. // print_r(json_encode($data[3]));exit();
  108. if ($count == 1 && isset($data[0][0]['code']) && $data[0][0]['code'] != 0) {
  109. echo json_encode($data[0][0]);
  110. } else if ($count == 4) {
  111. // } else if ($count > 0) {
  112. $data1 = array();
  113. $data2 = array();
  114. $data3 = array();
  115. $order_id_array = array();
  116. $data1=isset($data[1])?$data[1]:array();
  117. foreach($data[1] as $k => $v){
  118. $order_id_array[]=$v['parent_orderNo'];
  119. }
  120. $pdo2 = conn1();
  121. $search_extra_sql = " SELECT * FROM order_extra_info WHERE order_id IN (".implode(",",$order_id_array).") ";
  122. $result2 = $pdo2->query($search_extra_sql);
  123. $order_extra_array = $result2->fetchAll();
  124. if( $order_extra_array != false && count($order_extra_array) > 0 ) {
  125. $order_extra_array2 = array();
  126. foreach ( $order_extra_array as $order_extra_info ) {
  127. $order_extra_array2[$order_extra_info["order_id"]] = $order_extra_info;
  128. }
  129. $order_extra_array = $order_extra_array2;
  130. }
  131. $data1_temp = array();
  132. foreach( $data1 as $k=>$data1_info ) {
  133. if( isset($order_extra_array[$data1_info["M_ID"]]) ) {
  134. $data1_info["hotel_price"] = $order_extra_array[$data1_info["M_ID"]]["hotel_price"];
  135. $data1_info["gate_price"] = $order_extra_array[$data1_info["M_ID"]]["gate_price"];
  136. $extra_info_array = array();
  137. if( isset($data1_info["hotel_price"]) && mb_strlen($data1_info["hotel_price"]) > 0 ) {
  138. $extra_info_array[] ="酒店:".$data1_info["hotel_price"];
  139. }
  140. if( isset($data1_info["gate_price"]) && mb_strlen($data1_info["gate_price"]) > 0 ) {
  141. $extra_info_array[] ="门票:".$data1_info["gate_price"];
  142. }
  143. $data1_info["seat"] .= "[br /]".implode(" ", $extra_info_array);
  144. }
  145. $data1_temp[] = $data1_info;
  146. }
  147. $data1 = $data1_temp;
  148. // echo json_encode($data[1]);exit();
  149. $json = array("code" => "0", "info" => "");
  150. $json['totalTickets'] = $data[2][0]['num'];
  151. $json['totalPages'] = $data[2][0]['pagecount'];
  152. $json['currentpage'] = isset($data[2][0]['CURRENTPAGE']) ? $data[2][0]['CURRENTPAGE'] : "1";
  153. $json['pagesize'] = $data[2][0]['PAGESIZE'];
  154. $json['orderSource'] = $data[0];
  155. $json['orderList'] = array_values($data1);
  156. $or_st = array();
  157. $or_st['status_all'] = $data[2][0]['num'];
  158. foreach ($data[3] as $da) {
  159. $or_st[$da['order_status']] = $da['order_cnt'];
  160. }
  161. $json['orderStatus'][] = $or_st;
  162. // $json['orderStatus'][$data[3]['order_status']]=
  163. // $row_count_array = array();
  164. // foreach ($data[1] as $k => $v) {
  165. // if (!isset($row_count_array[$v["order_status"]])) {
  166. // $row_count_array[$v["order_status"]] = 0;
  167. // }
  168. // $row_count_array[$v["order_status"]]++;
  169. // }
  170. // $sum = (string)count($data[1]);
  171. // if ($sum == "0") {
  172. // $sum = "";
  173. // }
  174. // $row_count_array['status_all'] = $data[2][0]['num'];
  175. // if (count($row_count_array) > 0) {
  176. // $json['orderStatus'][] = $row_count_array;
  177. // } else {
  178. // $json['orderStatus'][] = array();
  179. // }
  180. //echo json_encode($data1);
  181. echo json_encode($json);
  182. } else {
  183. echo json_encode(array("code" => "0", "info" => "", "searchInfo" => array()));
  184. }
  185. }
  186. function get_msg_info($ORDER_ID) {
  187. $msg_pdo = conn1();
  188. $msg_sql = "CALL SP_GET_MESSAGE_TEMPLATE('" . $ORDER_ID . "')";
  189. $content = '';
  190. if (is_object($msg_pdo)) {
  191. $msg_result = $msg_pdo -> query($msg_sql);
  192. $i = 1;
  193. $data = array();
  194. if ($msg_result) {
  195. $data['code'] = "0";
  196. $data['info'] = "";
  197. do {
  198. $row = $msg_result -> fetchAll(PDO::FETCH_ASSOC);
  199. if ($i == 1) {
  200. $data['seat'] = isset($row) ? $row : array();
  201. } else if ($i == 2) {
  202. $data['run_info'] = isset($row) ? $row : array();
  203. } else if ($i == 3) {
  204. $data['driver'] = isset($row) ? $row : array();
  205. } else {
  206. }
  207. $i++;
  208. } while($msg_result->nextRowset());
  209. }
  210. $json_obj = json_decode(json_encode($data), TRUE);
  211. $seat = isset($json_obj['seat'][0])?$json_obj['seat'][0]:array();
  212. $run_info = isset($json_obj['run_info'][0])?$json_obj['run_info'][0]:array();
  213. $driver = isset($json_obj['driver'][0])?$json_obj['driver'][0]:array();
  214. //取消
  215. $content = "您预订的{出发日期 出发时间}{出发地}-{目的地}{票种名}{张数}张,已成功退票,期待下次再为您服务!";
  216. if ($seat) {
  217. $seat_x = $seat['seat_x'];
  218. $seat_y = $seat['seat_y'];
  219. $seat_name = $seat['seat_name'];
  220. $order_main_id = $seat['order_main_id'];
  221. }
  222. if ($run_info) {
  223. $order_count = $run_info['order_count'];
  224. $start_date = $run_info['start_date'];
  225. $start_time = $run_info['start_time'];
  226. $parent_order_id = $run_info['parent_order_id'];
  227. $end_date = $run_info['end_date'];
  228. $start_area = $run_info['start_area'];
  229. $end_area = $run_info['end_area'];
  230. $res_name = $run_info['res_name'];
  231. $prod_name=$run_info['prod_name'];
  232. $prod_name="标准票";
  233. $customer_name = $run_info['customer_name'];
  234. $customer_mobile = $run_info['customer_mobile'];
  235. $start_end_date = $start_date . "," . $start_time;
  236. $content = str_replace("{出发地}", $start_area, $content);
  237. $content = str_replace("{目的地}", $end_area, $content);
  238. $content = str_replace("{出发日期 出发时间}", $start_end_date, $content);
  239. $content = str_replace("{票种名}", $prod_name, $content);
  240. $content = str_replace("{张数}", $order_count, $content);
  241. }
  242. if ($driver) {
  243. $bus_no = $driver['bus_no'];
  244. $driver_name = $driver['driver_name'];
  245. $driver_mobile = $driver['driver_mobile'];
  246. }
  247. return array(isset($customer_name)?$customer_name:"", isset($customer_mobile)?$customer_mobile:"", isset($content)?$content:"短信错误!!!");
  248. }
  249. }
  250. exit();