|
- <?php
- //Author:gaoh
- //Date:20161031
- //酒店列表
- require_once "Api/ApiBase.php";
- require_once "Lib/Action/HotellistAction.class.php";
-
- class HotelList extends ApiBase
- {
- //获取酒店列表
- public function showlist()
- {
- $hotel_name = isset($_POST['hotel_name']) ? $_POST['hotel_name'] : "";
- $current = $_REQUEST['current'];
- $page_size = $_REQUEST['page_size'];
- //分页开始的条数
- $begin = ($current - 1) * $page_size;
- $HT = new HotellistAction();
- $res = $HT->getlist($hotel_name, $begin, $page_size);
- $data = array();
- $data['info'] = $res['info'];
- $data['code'] = $res['code'];
- $data['hotel_list'] = $res['rowset'];
- $data['current'] = $current;
- $data['page_size'] = $page_size;
- $data['total'] = $res['total'];
- $data['total_page'] = $res['total_page'];
- return $data;
- }
-
- //修改酒店停售
- public function stopsell()
- {
- $id = $_POST['id'];
- $ST = new HotellistAction();
- $res = $ST->stopsell($id);
- $data = array();
- if ($res['code'] != '0') {
- $data['code'] = $res['code'];
- $data['info'] = "停售失败";
- // var_dump($data);
- return $data;
- } else {
- $data['code'] = $res['code'];
- $data['info'] = "停售成功";
- // var_dump($data);
- return $data;
- }
- }
-
- //修改酒店在售
- public function onsell()
- {
- $id = $_POST['id'];
- $ST = new HotellistAction();
- $res = $ST->onsell($id);
- $data = array();
- // var_dump($res);
- if ($res['code'] != '0') {
- $data['code'] = $res['code'];
- $data['info'] = "开售失败";
- // var_dump($data);
- return $data;
- } else {
- $data['code'] = $res['code'];
- $data['info'] = "开售成功";
- // var_dump($data);
- return $data;
- }
- }
-
- //酒店信息
- public function getDetail(){
- $id = $_POST['hotel_id'];
- $ST = new HotellistAction();
- $res = $ST->getDetail($id);
- $data = array();
- if ($res['code'] != '0') {
- $data['code'] = $res['code'];
- $data['info'] = "获取酒店数据失败";
- return $data;
- } else {
- return $res;
- }
- }
- }
-
- $op = $_REQUEST['op'];
- $obj = new HotelList();
- if ($op == 1) {
- $data = $obj->showlist();
- } elseif ($op == 2) {
- $data = $obj->stopsell();
- } elseif ($op == 3) {
- $data = $obj->onsell();
- } elseif (method_exists($obj, $op)){
- $data = call_user_func(array($obj, $op));
- }
- echo json_encode($data);
|