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.
 
 
 
 

166 lines
6.7 KiB

  1. <?php
  2. //Author:fuhc
  3. //Date:20160919
  4. //房型信息
  5. require_once "Api/ApiBase.php";
  6. require_once "Lib/Action/HTRoomInfo.class.php";
  7. //不用HTcontrol.php//
  8. //require_once __DIR__."/../ApiBase.php";
  9. //require_once __DIR__."/../../Lib/Action/HTRoomInfo.class.php";
  10. //require_once __DIR__."/../../Lib/Action/HTRoomInfo.class.php";
  11. class RoomList extends APiBase
  12. {
  13. // 得到房型信息
  14. function getRoomList()
  15. {
  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($_POST['current']) ? $_POST['current'] : (isset($_GET['current']) ? $_GET['current'] : "1");
  22. $page_size = isset($_POST['page_size']) ? $_POST['page_size'] : (isset($_GET['page_size']) ? $_GET['page_size'] : "5");
  23. $base_room_type = isset($_REQUEST['base_room_type']) ? $_REQUEST['base_room_type'] : '';
  24. if ($sale_status == "") {
  25. $sale_status = "-1";
  26. } //与存储过程约定 全部传<0的数
  27. if ($hotel_id == "") {
  28. $data['code'] = "16";
  29. $data['info'] = "错误的请求参数";
  30. return $data;
  31. }
  32. $roomInfo = new HTRoomInfo;
  33. $data = $roomInfo->getRoomList($hotel_id, $start_date, $sale_status, $current, $page_size,$base_room_type);
  34. //date1 :库存类型id,库存类型str,total_count,已售,采购价,满
  35. // var_dump($data);exit();
  36. $data1 = $this->setData($data);
  37. $data1['currpage'] = $data['room_list'][0][0]['currpage'];
  38. $data1['total_page'] = $data['room_list'][0][0]['total_page'];
  39. $data1['total'] = $data['room_list'][0][0]['total'];
  40. $data1['page_size'] = $data['room_list'][0][0]['page_size'];
  41. // $arr = array();
  42. // // 将儿子加进父亲里面 不这样处理前端好处理
  43. // foreach($data['room_list'] as $k1=>$v1){
  44. // if($v1['parent_room_type']=="0"){
  45. // foreach($data['room_list'] as $k2=>$v2){
  46. // if($v2['parent_room_type']==$v1['room_type'] && $v2['parent_room_type']!="0"){
  47. // $v1['child_list'][]=$v2;
  48. // $arr=$v1;
  49. // }
  50. // }
  51. // $arr_list[]=$arr;
  52. // }
  53. // }
  54. // $data['room_list']=$arr_list;
  55. return $data1;
  56. }
  57. // 子房型处理一周的返回结果
  58. function setTempByDateChild($date)
  59. {
  60. $temp['price_buyout'] = isset($date[0]) ? $date[0] : "";
  61. $temp['price_reserve'] = isset($date[1]) ? $date[1] : "";
  62. $temp['price_inquiry'] = isset($date[2]) ? $date[2] : "";
  63. $temp['is_closed'] = isset($date[3]) ? $date[3] : "";
  64. return $temp;
  65. }
  66. //父房型
  67. function setTempByDate($date)
  68. {
  69. $temp['saled_count'] = isset($date[0]) ? $date[0] : "";
  70. $temp['buyout_count'] = isset($date[1]) ? $date[1] : "";
  71. $temp['reserve_count'] = isset($date[2]) ? $date[2] : "";
  72. $temp['inquiry_count'] = isset($date[3]) ? $date[3] : "";
  73. $temp['remain_count'] = isset($date[4]) ? $date[4] : "";
  74. return $temp;
  75. }
  76. function setData($data)
  77. {
  78. $tp1 = array();
  79. $tp2 = array();
  80. //1.将父集与子集分开存
  81. foreach ($data['room_list'][1] as $k => $v) {
  82. $tp1[] = $v;
  83. }
  84. foreach ($data['room_list'][2] as $k => $v) {
  85. $tp2[] = $v;
  86. }
  87. $temp = array();
  88. //2.将父集与子集并列2
  89. foreach ($tp1 as $k1 => $v1) {
  90. $temp[] = $v1;
  91. foreach ($tp2 as $k2 => $v2) {
  92. if ($v1['room_type'] == $v2['parent_room_type']) {
  93. $temp[] = $v2;
  94. }
  95. }
  96. }
  97. $data['room_list'] = $temp;
  98. foreach ($data['room_list'] as $k => $v) {
  99. $date1 = explode(',', $v['date1']);
  100. $date2 = explode(',', $v['date2']);
  101. $date3 = explode(',', $v['date3']);
  102. $date4 = explode(',', $v['date4']);
  103. $date5 = explode(',', $v['date5']);
  104. $date6 = explode(',', $v['date6']);
  105. $date7 = explode(',', $v['date7']);
  106. // echo json_encode($temp1);exit();
  107. //子房型
  108. if ($v['parent_room_type'] > 0) {
  109. $data['room_list'][$k]['date1'] = $this->setTempByDateChild($date1);
  110. $data['room_list'][$k]['date2'] = $this->setTempByDateChild($date2);
  111. $data['room_list'][$k]['date3'] = $this->setTempByDateChild($date3);
  112. $data['room_list'][$k]['date4'] = $this->setTempByDateChild($date4);
  113. $data['room_list'][$k]['date5'] = $this->setTempByDateChild($date5);
  114. $data['room_list'][$k]['date6'] = $this->setTempByDateChild($date6);
  115. $data['room_list'][$k]['date7'] = $this->setTempByDateChild($date7);
  116. } else {
  117. $data['room_list'][$k]['date1'] = $this->setTempByDate($date1);
  118. $data['room_list'][$k]['date2'] = $this->setTempByDate($date2);
  119. $data['room_list'][$k]['date3'] = $this->setTempByDate($date3);
  120. $data['room_list'][$k]['date4'] = $this->setTempByDate($date4);
  121. $data['room_list'][$k]['date5'] = $this->setTempByDate($date5);
  122. $data['room_list'][$k]['date6'] = $this->setTempByDate($date6);
  123. $data['room_list'][$k]['date7'] = $this->setTempByDate($date7);
  124. }
  125. }
  126. return $data;
  127. }
  128. function modifyChildRoom()
  129. {
  130. $user_id = $this->login_user_id;
  131. $hotel_id = isset($_REQUEST['hotel_id']) ? $_REQUEST['hotel_id'] : "";
  132. $room_type = isset($_REQUEST['room_type']) ? $_REQUEST['room_type'] : "";
  133. $parent_room_type = isset($_REQUEST['parent_room_type']) ? $_REQUEST['parent_room_type'] : "";
  134. $data_child_room_name = isset($_REQUEST['data_child_room_name']) ? $_REQUEST['data_child_room_name'] : "";
  135. $checkin_people = isset($_REQUEST['checkin_people']) ? $_REQUEST['checkin_people'] : "";
  136. $breakfast = isset($_REQUEST['breakfast']) ? $_REQUEST['breakfast'] : "";
  137. $roomInfo = new HTRoomInfo;
  138. $data = $roomInfo->modifyChildRoom($hotel_id, $room_type, $parent_room_type, $data_child_room_name, $checkin_people, $user_id, $breakfast);
  139. return $data;
  140. }
  141. }
  142. $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : "getRoomList";
  143. $roomList = new RoomList;
  144. if ($op == 'modifyRoom') {
  145. $data = $roomList->modifyChildRoom();
  146. } else {
  147. $data = $roomList->getRoomList();
  148. };
  149. echo json_encode($data);