Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

341 linhas
13 KiB

  1. <?php
  2. if (ALLOW_ORIGIN)
  3. header("Access-Control-Allow-Origin:*");
  4. date_default_timezone_set('PRC');
  5. //require_once '../../Common/Mysql.php';
  6. $user_id = isset($_COOKIE['user_id']) ? $_COOKIE['user_id'] : '';//getUserId();
  7. $order_from_org_id = isset($_COOKIE['org_id']) ? $_COOKIE['org_id'] : '';
  8. if (!$user_id) {
  9. echo json_encode(array("code" => 1, "iflogin" => 1, "info" => "用户未登录"));
  10. exit;
  11. }
  12. $currpage = isset($_POST['currpage']) ? $_POST['currpage'] : '1';
  13. $pagesize = isset($_POST['pagesize']) ? $_POST['pagesize'] : '10';
  14. $list_start = ($currpage - 1) * $pagesize;
  15. $condition = '';
  16. if ($_POST) {
  17. $condition = array(); //定义条件数组
  18. //接受条件数据
  19. $time_style = isset($_POST['time_style']) ? $_POST['time_style'] : ''; //timestyle=1 代表创建时间 =2 代表是出发时间
  20. if ($user_id >= 65 && $user_id <= 113 && $user_id != 106 && $user_id != 107) {
  21. $start_time = isset($_POST['start_time']) ? $_POST['start_time'] > '2016-09-01' ? $_POST['start_time'] : '2016-09-01' : '2016-09-01';
  22. } else {
  23. $start_time = isset($_POST['start_time']) ? $_POST['start_time'] : '';
  24. }
  25. $end_time = isset($_POST['end_time']) ? $_POST['end_time'] : '';
  26. $start_area = isset($_POST['start_area']) ? $_POST['start_area'] : '';
  27. $end_area = isset($_POST['end_area']) ? $_POST['end_area'] : '';
  28. $product_type = isset($_POST['product_type']) ? $_POST['product_type'] : ''; //票种类 0.256.255.257 0为空 256穿梭巴士,255直通巴士
  29. $order_id = isset($_POST['order_id']) ? $_POST['order_id'] : ''; //订单号 1,2,3, 1 为 订单号 2 为客户姓名 3 为客户手机号
  30. $order_condition = isset($_POST['condition']) ? $_POST['condition'] : '';
  31. if ($time_style == 1) {
  32. empty($start_time) ? null : $condition[] = ' and a.create_time >= "' . $start_time . ' 00:00:01"'; //创建时间条件筛选
  33. empty($end_time) ? null : $condition[] = ' and a.create_time <= "' . $end_time . ' 23:59:00"';
  34. } elseif ($time_style == 2) {
  35. empty($start_time) ? null : $condition[] = ' and a.run_date >= "' . $start_time . '"'; // 出发时间筛选
  36. empty($end_time) ? null : $condition[] = ' and a.run_date <= "' . $end_time . '"';
  37. }
  38. empty($start_area) ? null : $condition[] = ' and PROD_START_STATION_AREA_NAME like "%' . $start_area . '%" ';
  39. empty($end_area) ? null : $condition[] = ' and PROD_END_STATION_AREA_NAME like "%' . $end_area . '%" ';
  40. if ($product_type == 257) {
  41. $condition[] = ' and order_prod_type in (258,259) ';
  42. } else {
  43. empty($product_type) ? null : $condition[] = ' and bus_type=' . $product_type;
  44. }
  45. if ($order_id == 1 || $order_id == 2 || $order_id == 3) {
  46. if ($order_id == 1)
  47. $condition[] = ' and a.PARENT_ORDER_ID like "%' . $order_condition . '%"';
  48. if ($order_id == 2)
  49. $condition[] = ' and a.customer_name like "%' . $order_condition . '%"';
  50. if ($order_id == 3)
  51. $condition[] = ' and a.customer_mobile like "%' . $order_condition . '%"';
  52. }
  53. $condition2 = '';
  54. if (isset($_POST['order_status'])) {
  55. $_POST['order_status'] != 0 ? $condition2 = ' and order_status=' . $_POST['order_status'] : null;
  56. }
  57. $condition = implode('', $condition); //订单状态条件 148 已取消 146 已出票 147已出行
  58. }
  59. //echo $condition;die;
  60. //$order_status=isset($_POST['order_status'])?$condition[]=' and order_status='.$_POST['order_status']:null;
  61. //var_dump($condition);die;
  62. $pdo = conn();
  63. $sql = "select a.order_id "
  64. . "from order_main as a "
  65. . "where a.PARENT_ORDER_ID=0 and ORDER_BOOK_STATUS=1 and CANCEL_FLAG=0 and outside_sale_org_id =" . $order_from_org_id . " $condition2 ";
  66. $result = $pdo->query($sql);
  67. $json = array();
  68. do {
  69. $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
  70. if ($rowset) {
  71. $json = $rowset;
  72. }
  73. } while ($result->nextRowset());
  74. if (empty($json)) {
  75. $data = (array("code" => "0", "info" => "此条件下没有订单", "list_count" => 0, "searchInfo" => array()));
  76. echo json_encode($data);
  77. die;
  78. }
  79. foreach ($json as $v) {
  80. $json2[] = $v['order_id'];
  81. }
  82. $sql = "select DISTINCT PARENT_ORDER_ID,line_type as bus_type"
  83. . " from order_main a left join opera_line b on a.parent_prod_id = b. line_id "//and main_create_user_id =".$user_id."
  84. . "where PARENT_ORDER_ID in(" . implode(",", $json2) . ") " . $condition . " order by a.create_time desc";//and PARENT_ORDER_ID = 203839
  85. //echo $sql;
  86. //die;
  87. $result_id = $pdo->query($sql);
  88. $json_id = array();
  89. $json = array();
  90. $bus_type = array();
  91. do {
  92. $rowset = $result_id->fetchAll(PDO::FETCH_ASSOC);
  93. if ($rowset) {
  94. $json = $rowset;
  95. }
  96. } while ($result_id->nextRowset());
  97. //var_dump($json);die;
  98. if (empty($json)) {
  99. $data = (array("code" => "0", "info" => "此条件下没有订单", "list_count" => 0, "searchInfo" => array()));
  100. echo json_encode($data);
  101. die;
  102. }
  103. foreach ($json as $v) {
  104. if (isset($v['PARENT_ORDER_ID'])) ;
  105. $json_id[] = $v['PARENT_ORDER_ID'];
  106. $bus_type[$v['PARENT_ORDER_ID']] = $v['bus_type'];
  107. }
  108. //条件筛选后的订单编号
  109. //echo $sql;
  110. //var_dump($json_id);die;
  111. $sql = "select a.prod_name,a.order_prod_type,a.order_description,a.ORDER_PAY_MAIN_ID,a.order_id,a.customer_name,a.customer_mobile,a.customer_id_type,a.customer_id_no,a.order_price,a.order_status,a.create_time,a.prod_id "
  112. . "from order_main as a "
  113. . "where a.PARENT_ORDER_ID=0 and a.ORDER_ID in (" . implode(",", $json_id) . ")";//on a.order_id=b.order_id
  114. $result = $pdo->query($sql);
  115. $data = array();
  116. do {
  117. $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
  118. if ($rowset) {
  119. $data[] = $rowset; //
  120. }
  121. } while ($result->nextRowset());
  122. $order_info = array();
  123. foreach ($data[0] as $v) {
  124. $order_info[$v['order_id']] = $v; //价格手机 姓名 run_time pay_time
  125. }
  126. $array_order_desc = array();
  127. foreach ($data[0] as $v) {
  128. $arr_temp = explode('|', $v['order_description']);
  129. $arr = array();
  130. foreach ($arr_temp as $k => $v2) {
  131. if (!empty($v2))
  132. $arr[] = explode(',', $v2);
  133. }
  134. $array_order_desc[$v['order_id']] = $arr;
  135. }
  136. //var_dump($array_order_desc);die;
  137. $sql3 = "select parent_order_id,PROD_START_STATION_DATE as run_date,PROD_START_STATION_TIME as run_time,PROD_START_STATION_AREA_NAME,PROD_START_STATION_RES_NAME,PROD_END_STATION_AREA_NAME,PROD_END_STATION_RES_NAME "
  138. . "from order_main "
  139. . "where parent_order_id in (" . implode(",", $json_id) . ")";
  140. $result3 = $pdo->query($sql3);
  141. $rowset3 = $result3->fetchAll(PDO::FETCH_ASSOC);
  142. foreach ($rowset3 as $v) {
  143. $station[$v['parent_order_id']] = $v;//上车站下车站 详情
  144. }
  145. //获取支付方式
  146. $sql2 = "select a.ORDER_ID,b.PAY_TYPE_ID_1,c.TYPE_NAME from (ORDER_MAIN a left join ORDER_PAY_DETAIL b on a.ORDER_PAY_MAIN_ID=b.pay_main_id)
  147. left join dict_type c on c.id=b.PAY_TYPE_ID_1 "
  148. . " where a.ORDER_ID in (" . implode(",", $json_id) . ")";
  149. $result2 = $pdo->query($sql2);
  150. do {
  151. $rowset2 = $result2->fetchAll(PDO::FETCH_ASSOC);
  152. if ($rowset2) {
  153. $pay_type[] = $rowset2;
  154. }
  155. } while ($result2->nextRowset());
  156. foreach ($pay_type[0] as $v) {
  157. $pay_type_arr[$v['ORDER_ID']] = $v['TYPE_NAME']; //支付方式
  158. }
  159. //支付状态
  160. $sql4 = "select a.ORDER_ID,a.order_status,c.TYPE_NAME from (ORDER_MAIN a left join ORDER_PAY_DETAIL b on a.ORDER_PAY_MAIN_ID=b.pay_main_id)
  161. left join dict_type c on c.id=a.ORDER_STATUS "
  162. . " where a.ORDER_ID in (" . implode(",", $json_id) . ")";
  163. $result4 = $pdo->query($sql4);
  164. do {
  165. $rowset4 = $result4->fetchAll(PDO::FETCH_ASSOC);
  166. if ($rowset4) {
  167. $order_sta[] = $rowset4;
  168. }
  169. } while ($result4->nextRowset());
  170. foreach ($order_sta[0] as $v) {
  171. $order_status[$v['ORDER_ID']] = $v['TYPE_NAME']; //订单的状态
  172. $order_status_id[$v['ORDER_ID']] = $v['order_status'];//订单的状态
  173. }
  174. $array_order_list = array();
  175. //echo count($pay_type_arr),'--', count($json_id);
  176. //var_dump($array_order_desc);die;
  177. $top_org_id = $_COOKIE['top_org_id'];
  178. foreach ($json_id as $v) {
  179. $tic = '';
  180. if ($order_info[$v]['order_prod_type'] == 258 || $order_info[$v]['order_prod_type'] == 259) {
  181. foreach ($array_order_desc[$v] as $v1) {
  182. if( !isset($v1[2]) ) {
  183. continue;
  184. }
  185. $tic .= str_replace('迪士尼剧场', '', $v1[0]) . '×' . $v1[2] . ' ';
  186. if (isset($v1['ifback']))
  187. $ifback = $v1['ifback'];
  188. }
  189. $product_info = $order_info[$v]['prod_name'] . '<br>' . $tic;
  190. $ifdisn = 1;
  191. if ($order_info[$v]['order_prod_type'] == 258) {
  192. $type = "迪士尼门票";
  193. } else {
  194. $type = "迪士尼剧场";
  195. }
  196. if ($top_org_id != 0) {
  197. $go_to = 0;//不显示
  198. } else {
  199. if ($order_status_id[$v] == 145) {
  200. $time_cut = time() - strtotime($order_info[$v]['create_time']);
  201. if ($time_cut > 600) {
  202. $go_to = 0;
  203. } else {
  204. $go_to = 1;
  205. }
  206. } else {
  207. $go_to = '0';
  208. }
  209. }
  210. } else {
  211. if ($bus_type[$v] == 255) {
  212. $type = "直通巴士";
  213. } else {
  214. $type = "穿梭巴士";
  215. }
  216. foreach ($array_order_desc[$v] as $v1) {
  217. if(isset($v1[2])){
  218. $tic .= str_replace('票', '', $v1[0]) . '×' . $v1[2] . ' ';
  219. }else{
  220. continue;
  221. $tic .= str_replace('票', '', $v1[0]);
  222. }
  223. if (isset($v1['ifback']))
  224. $ifback = $v1['ifback'];
  225. }
  226. $product_info = $station[$v]['PROD_START_STATION_AREA_NAME'] . '(' . $station[$v]['PROD_START_STATION_RES_NAME'] . ')' . '-' . $station[$v]['PROD_END_STATION_AREA_NAME'] . '(' . $station[$v]['PROD_END_STATION_RES_NAME'] . ')' . '<br>' . $tic;
  227. $ifdisn = 0;
  228. //退票 去支付 空
  229. if ($top_org_id != 0) {
  230. $time_cut = strtotime($station[$v]['run_date'] . ' ' . $station[$v]['run_time'] . ':01') - time();
  231. if ($order_status_id[$v] == 146) {
  232. if ($time_cut < 1800) {
  233. $go_to = 0;
  234. } else {
  235. $go_to = 2;//退票
  236. }
  237. } else {
  238. $go_to = 0;
  239. }
  240. } else {
  241. $time_cut = strtotime($station[$v]['run_date'] . ' ' . $station[$v]['run_time'] . ':01') - time();
  242. if ($order_status_id[$v] == 146) {
  243. if ($time_cut < 1800) {
  244. $go_to = 0;
  245. } else {
  246. $go_to = 0;//退票
  247. }
  248. } else {
  249. $time_cut = time() - strtotime($order_info[$v]['create_time']);
  250. if ($time_cut > 600) {
  251. $go_to = 0;
  252. } else {
  253. if ($order_status_id[$v] == 145)
  254. $go_to = 1;
  255. else
  256. $go_to = 0;
  257. }
  258. }
  259. }
  260. }
  261. // if($order_info[$v]['order_prod_type']==258 || $order_info[$v]['order_prod_type']==259){
  262. // foreach($array_order_desc[$v] as $v1){
  263. // $tic.= str_replace('迪士尼剧场','',$v1[0]).'×'.$v1[2].' ';
  264. // if(isset($v1['ifback']))
  265. // $ifback=$v1['ifback'];
  266. // }
  267. // $product_info =$order_info[$v]['prod_name'].'<br> '.$tic;
  268. // $ifdisn=0;
  269. // }else{
  270. // foreach($array_order_desc[$v] as $v1){
  271. // $tic.= str_replace('票','',$v1[0]).'×'.$v1[2].' ';
  272. // if(isset($v1['ifback']))
  273. // $ifback=$v1['ifback'];
  274. // }
  275. // $product_info =$station[$v]['PROD_START_STATION_AREA_NAME'].'('.$station[$v]['PROD_START_STATION_RES_NAME'].')'.'-'.$station[$v]['PROD_END_STATION_AREA_NAME'].'('.$station[$v]['PROD_END_STATION_RES_NAME'].')'.'<br> '.$tic;
  276. //
  277. // $ifdisn=1;
  278. // }
  279. $array_order_list[] = array(
  280. 'order_id' => $v,
  281. 'create_time' => $order_info[$v]['create_time'],
  282. 'start_station_area' => $station[$v]['PROD_START_STATION_AREA_NAME'],
  283. 'start_station_name' => $station[$v]['PROD_START_STATION_RES_NAME'],
  284. 'end_station_area' => $station[$v]['PROD_END_STATION_AREA_NAME'],
  285. 'end_station_name' => $station[$v]['PROD_END_STATION_RES_NAME'],
  286. 'product_info' => $product_info,
  287. 'ifdisney' => $ifdisn,
  288. 'run_time' => $station[$v]['run_date'] . ' ' . $station[$v]['run_time'],
  289. 'customer_info' => $order_info[$v]['customer_name'] . ' <br>' . $order_info[$v]['customer_mobile'] . '<br> ' . $order_info[$v]['customer_id_no'],
  290. 'order_pay' => $order_info[$v]['order_price'],
  291. 'order_pay_type' => $pay_type_arr[$v],
  292. 'order_status' => $order_status[$v],
  293. 'go_pay' => $go_to
  294. );
  295. }
  296. $list_count = count($array_order_list);
  297. //echo $list_count;
  298. $array_order_list = array_slice($array_order_list, $list_start, $pagesize);
  299. $data = (array("code" => "0", "info" => "", "list_count" => $list_count, "searchInfo" => $array_order_list));
  300. echo json_encode($data);