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.
 
 
 
 

58 lines
1.7 KiB

  1. <?php
  2. /*
  3. Author:ZSQ
  4. Compeny:Spiders Travel
  5. */
  6. require_once '../Common/Mysql.php';
  7. header("Access-Control-Allow-Origin:*");
  8. $keywords=isset($_GET['keywords'])?$_GET['keywords']:'';
  9. $isonsale=isset($_GET['saleStyle'])?$_GET['saleStyle']:'';
  10. $currpage=isset($_GET['currpage'])?(empty($_GET['currpage'])?1:$_GET['currpage']):1;
  11. $pagesize=isset($_GET['pagesize'])?(empty($_GET['pagesize'])?1:$_GET['pagesize']):1;
  12. $user_id=getUserId();
  13. if ($user_id ===false){
  14. echo json_encode(array("errcode"=>1,"errinfo"=>"用户未登录"));
  15. exit;
  16. }
  17. $pdo=conn();
  18. $sql="CALL HT_GET_SEARCH_LIST_BYKEWORDS('".$keywords."',{$isonsale},".$currpage.",".$pagesize.")";
  19. $result=$pdo->query($sql);
  20. $data=array();
  21. do{
  22. $rowset=$result->fetchAll(PDO::FETCH_ASSOC);
  23. if($rowset){
  24. $data[]=$rowset;
  25. }
  26. }while ($result->nextRowset());
  27. //print_r($data);
  28. $common_array = $data[1];
  29. $extra_array = array();
  30. foreach( $data[2] as $temp_info ) {
  31. $parent_id = $temp_info['parentID'];
  32. $proid=$temp_info['pro_id'];
  33. if( !isset($extra_array[$parent_id])) {
  34. $extra_array[$parent_id] = array();
  35. }
  36. $extra_array[$parent_id][] = $temp_info;
  37. }
  38. $jason_array = array();
  39. $jason_array["code"] = "0";
  40. $jason_array["info"] = "";
  41. $jason_array["totalNum"] = $data[0][0]["totalNum"];
  42. $jason_array["parent"] = array();
  43. foreach( $common_array as $common_key => $common_info ) {
  44. $extra_info = isset($extra_array[$common_info['PROPERTY']]) ? $extra_array[$common_info['PROPERTY']] : array();
  45. $jason_parent_info = array();
  46. $jason_parent_info["hotelName"] = $common_info["RES_NAME"];
  47. $jason_parent_info["hotelId"] = $common_info["PROPERTY"];
  48. $jason_parent_info["children"] = $extra_info;
  49. $jason_array["parent"][] = $jason_parent_info;
  50. }
  51. echo json_encode($jason_array);
  52. exit();