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.
 
 
 
 

99 lines
2.7 KiB

  1. <?php
  2. //Author:gaoh
  3. //Date:20161031
  4. //酒店列表
  5. require_once "Api/ApiBase.php";
  6. require_once "Lib/Action/HotellistAction.class.php";
  7. class HotelList extends ApiBase
  8. {
  9. //获取酒店列表
  10. public function showlist()
  11. {
  12. $hotel_name = isset($_POST['hotel_name']) ? $_POST['hotel_name'] : "";
  13. $current = $_REQUEST['current'];
  14. $page_size = $_REQUEST['page_size'];
  15. //分页开始的条数
  16. $begin = ($current - 1) * $page_size;
  17. $HT = new HotellistAction();
  18. $res = $HT->getlist($hotel_name, $begin, $page_size);
  19. $data = array();
  20. $data['info'] = $res['info'];
  21. $data['code'] = $res['code'];
  22. $data['hotel_list'] = $res['rowset'];
  23. $data['current'] = $current;
  24. $data['page_size'] = $page_size;
  25. $data['total'] = $res['total'];
  26. $data['total_page'] = $res['total_page'];
  27. return $data;
  28. }
  29. //修改酒店停售
  30. public function stopsell()
  31. {
  32. $id = $_POST['id'];
  33. $ST = new HotellistAction();
  34. $res = $ST->stopsell($id);
  35. $data = array();
  36. if ($res['code'] != '0') {
  37. $data['code'] = $res['code'];
  38. $data['info'] = "停售失败";
  39. // var_dump($data);
  40. return $data;
  41. } else {
  42. $data['code'] = $res['code'];
  43. $data['info'] = "停售成功";
  44. // var_dump($data);
  45. return $data;
  46. }
  47. }
  48. //修改酒店在售
  49. public function onsell()
  50. {
  51. $id = $_POST['id'];
  52. $ST = new HotellistAction();
  53. $res = $ST->onsell($id);
  54. $data = array();
  55. // var_dump($res);
  56. if ($res['code'] != '0') {
  57. $data['code'] = $res['code'];
  58. $data['info'] = "开售失败";
  59. // var_dump($data);
  60. return $data;
  61. } else {
  62. $data['code'] = $res['code'];
  63. $data['info'] = "开售成功";
  64. // var_dump($data);
  65. return $data;
  66. }
  67. }
  68. //酒店信息
  69. public function getDetail(){
  70. $id = $_POST['hotel_id'];
  71. $ST = new HotellistAction();
  72. $res = $ST->getDetail($id);
  73. $data = array();
  74. if ($res['code'] != '0') {
  75. $data['code'] = $res['code'];
  76. $data['info'] = "获取酒店数据失败";
  77. return $data;
  78. } else {
  79. return $res;
  80. }
  81. }
  82. }
  83. $op = $_REQUEST['op'];
  84. $obj = new HotelList();
  85. if ($op == 1) {
  86. $data = $obj->showlist();
  87. } elseif ($op == 2) {
  88. $data = $obj->stopsell();
  89. } elseif ($op == 3) {
  90. $data = $obj->onsell();
  91. } elseif (method_exists($obj, $op)){
  92. $data = call_user_func(array($obj, $op));
  93. }
  94. echo json_encode($data);