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.
 
 
 
 

100 lines
3.3 KiB

  1. <?php
  2. //Author:fuhc
  3. //Date:20160919
  4. //房型信息
  5. require_once "Api/ApiBase.php";
  6. require_once "Lib/Action/HTRoomList.class.php";
  7. //不用HTcontrol.php//
  8. //require_once __DIR__."/../ApiBase.php";
  9. //require_once __DIR__."/../../Lib/Action/HTRoomList.class.php";
  10. //require_once __DIR__."/../../Lib/Action/HTRoomList.class.php";
  11. class RoomList extends APiBase{
  12. function __construct(){
  13. }
  14. // 得到房型信息
  15. function getRoomList(){
  16. date_default_timezone_set('prc');
  17. $cur_date=date("Y-m-d");
  18. $hotel_id=isset($_POST['hotel_id'])?$_POST['hotel_id']:(isset($_GET['hotel_id'])?$_GET['hotel_id']:""); // 不为空
  19. $start_date=isset($_POST['start_date'])?$_POST['start_date']:(isset($_GET['start_date'])?$_GET['start_date']:$cur_date); // 不为空 默认给今天
  20. $sale_status=isset($_POST['sale_status'])?$_POST['sale_status']:(isset($_GET['sale_status'])?$_GET['sale_status']:""); // 可为空
  21. $current = isset($_REQUEST['current'])?$_REQUEST['current']:'1';
  22. $page_size = isset($_REQUEST['page_size'])?$_REQUEST['page_size']:'5';
  23. if($sale_status==""){$sale_status="-1";} //与存储过程约定 全部传<0的数
  24. if($hotel_id==""){
  25. $data['code']="3";
  26. $data['info']="缺少hotel_id参数";
  27. return $data;
  28. }
  29. $roomList=new HTRoomList;
  30. $data=$roomList->getRoomList($hotel_id,$start_date,$sale_status,$current,$page_size);
  31. //date1 :库存类型id,库存类型str,total_count,已售,采购价,满
  32. // foreach($data['room_list'] as $k=>$v){
  33. // $temp1="";$temp2="";$temp3="";$temp4="";$temp5="";$temp6="";$temp7="";
  34. // $date1=explode(',',$v['date1']);
  35. // $date2=explode(',',$v['date2']);
  36. // $date3=explode(',',$v['date3']);
  37. // $date4=explode(',',$v['date4']);
  38. // $date5=explode(',',$v['date5']);
  39. // $date6=explode(',',$v['date6']);
  40. // $date7=explode(',',$v['date7']);
  41. //
  42. //// echo json_encode($temp1);exit();
  43. // $data['room_list'][$k]['date1']=$this->setTempByDate($date1);
  44. // $data['room_list'][$k]['date2']=$this->setTempByDate($date2);
  45. // $data['room_list'][$k]['date3']=$this->setTempByDate($date3);
  46. // $data['room_list'][$k]['date4']=$this->setTempByDate($date4);
  47. // $data['room_list'][$k]['date5']=$this->setTempByDate($date5);
  48. // $data['room_list'][$k]['date6']=$this->setTempByDate($date6);
  49. // $data['room_list'][$k]['date7']=$this->setTempByDate($date7);
  50. // }
  51. // $new_room_list=$data['room_list'];
  52. // $arr = array();
  53. // // 将儿子加进父亲里面
  54. // foreach($new_room_list as $k1=>$v1){
  55. // if($v1['parent_room_type']=="0"){
  56. //
  57. //
  58. // foreach($new_room_list as $k2=>$v2){
  59. // if($v2['parent_room_type']==$v1['room_type']){
  60. // $v1['child'][]=$v2;
  61. // $arr[]=$v1;
  62. // }
  63. // }
  64. // }
  65. // }
  66. // echo json_encode($arr);exit();
  67. return $data;
  68. }
  69. // 处理一周的返回结果
  70. function setTempByDate($date){
  71. $temp['inventory_type']=isset($date[0])?$date[0]:"0";
  72. $temp['inventory_type_str']=isset($date[1])?$date[1]:"";
  73. $temp['total_count']=isset($date[2])?$date[2]:"0";
  74. $temp['sale_count']=isset($date[3])?$date[3]:"0";
  75. $temp['base_price']=isset($date[4])?$date[4]:"0";
  76. $temp['is_closed']=isset($date[5])?$date[5]:"0";
  77. return $temp;
  78. }
  79. }
  80. $roomList=new RoomList;
  81. $data=array();
  82. $data['code']="0";
  83. $data['info']="";
  84. $data=$roomList->getRoomList();
  85. echo json_encode($data);