|
- <?php
- //Author:fuhc
- //Date:20160919
- //房型信息
- require_once "Api/ApiBase.php";
- require_once "Lib/Action/HTRoomList.class.php";
-
-
- //不用HTcontrol.php//
- //require_once __DIR__."/../ApiBase.php";
- //require_once __DIR__."/../../Lib/Action/HTRoomList.class.php";
- //require_once __DIR__."/../../Lib/Action/HTRoomList.class.php";
- class RoomList extends APiBase{
-
-
- function __construct(){
-
- }
-
-
- // 得到房型信息
- function getRoomList(){
- date_default_timezone_set('prc');
- $cur_date=date("Y-m-d");
- $hotel_id=isset($_POST['hotel_id'])?$_POST['hotel_id']:(isset($_GET['hotel_id'])?$_GET['hotel_id']:""); // 不为空
- $start_date=isset($_POST['start_date'])?$_POST['start_date']:(isset($_GET['start_date'])?$_GET['start_date']:$cur_date); // 不为空 默认给今天
- $sale_status=isset($_POST['sale_status'])?$_POST['sale_status']:(isset($_GET['sale_status'])?$_GET['sale_status']:""); // 可为空
- $current = isset($_REQUEST['current'])?$_REQUEST['current']:'1';
- $page_size = isset($_REQUEST['page_size'])?$_REQUEST['page_size']:'5';
- if($sale_status==""){$sale_status="-1";} //与存储过程约定 全部传<0的数
-
-
- if($hotel_id==""){
- $data['code']="3";
- $data['info']="缺少hotel_id参数";
- return $data;
- }
- $roomList=new HTRoomList;
- $data=$roomList->getRoomList($hotel_id,$start_date,$sale_status,$current,$page_size);
- //date1 :库存类型id,库存类型str,total_count,已售,采购价,满
- // foreach($data['room_list'] as $k=>$v){
- // $temp1="";$temp2="";$temp3="";$temp4="";$temp5="";$temp6="";$temp7="";
- // $date1=explode(',',$v['date1']);
- // $date2=explode(',',$v['date2']);
- // $date3=explode(',',$v['date3']);
- // $date4=explode(',',$v['date4']);
- // $date5=explode(',',$v['date5']);
- // $date6=explode(',',$v['date6']);
- // $date7=explode(',',$v['date7']);
- //
- //// echo json_encode($temp1);exit();
- // $data['room_list'][$k]['date1']=$this->setTempByDate($date1);
- // $data['room_list'][$k]['date2']=$this->setTempByDate($date2);
- // $data['room_list'][$k]['date3']=$this->setTempByDate($date3);
- // $data['room_list'][$k]['date4']=$this->setTempByDate($date4);
- // $data['room_list'][$k]['date5']=$this->setTempByDate($date5);
- // $data['room_list'][$k]['date6']=$this->setTempByDate($date6);
- // $data['room_list'][$k]['date7']=$this->setTempByDate($date7);
- // }
- // $new_room_list=$data['room_list'];
- // $arr = array();
- // // 将儿子加进父亲里面
- // foreach($new_room_list as $k1=>$v1){
- // if($v1['parent_room_type']=="0"){
- //
- //
- // foreach($new_room_list as $k2=>$v2){
- // if($v2['parent_room_type']==$v1['room_type']){
- // $v1['child'][]=$v2;
- // $arr[]=$v1;
- // }
- // }
- // }
- // }
- // echo json_encode($arr);exit();
-
- return $data;
- }
- // 处理一周的返回结果
- function setTempByDate($date){
- $temp['inventory_type']=isset($date[0])?$date[0]:"0";
- $temp['inventory_type_str']=isset($date[1])?$date[1]:"";
- $temp['total_count']=isset($date[2])?$date[2]:"0";
- $temp['sale_count']=isset($date[3])?$date[3]:"0";
- $temp['base_price']=isset($date[4])?$date[4]:"0";
- $temp['is_closed']=isset($date[5])?$date[5]:"0";
- return $temp;
- }
- }
-
- $roomList=new RoomList;
-
- $data=array();
- $data['code']="0";
- $data['info']="";
- $data=$roomList->getRoomList();
- echo json_encode($data);
-
|