getRoomList($hotel_id, $start_date, $sale_status, $current, $page_size,$base_room_type); //date1 :库存类型id,库存类型str,total_count,已售,采购价,满 // var_dump($data);exit(); $data1 = $this->setData($data); $data1['currpage'] = $data['room_list'][0][0]['currpage']; $data1['total_page'] = $data['room_list'][0][0]['total_page']; $data1['total'] = $data['room_list'][0][0]['total']; $data1['page_size'] = $data['room_list'][0][0]['page_size']; // $arr = array(); // // 将儿子加进父亲里面 不这样处理前端好处理 // foreach($data['room_list'] as $k1=>$v1){ // if($v1['parent_room_type']=="0"){ // foreach($data['room_list'] as $k2=>$v2){ // if($v2['parent_room_type']==$v1['room_type'] && $v2['parent_room_type']!="0"){ // $v1['child_list'][]=$v2; // $arr=$v1; // } // } // $arr_list[]=$arr; // } // } // $data['room_list']=$arr_list; return $data1; } // 子房型处理一周的返回结果 function setTempByDateChild($date) { $temp['price_buyout'] = isset($date[0]) ? $date[0] : ""; $temp['price_reserve'] = isset($date[1]) ? $date[1] : ""; $temp['price_inquiry'] = isset($date[2]) ? $date[2] : ""; $temp['is_closed'] = isset($date[3]) ? $date[3] : ""; return $temp; } //父房型 function setTempByDate($date) { $temp['saled_count'] = isset($date[0]) ? $date[0] : ""; $temp['buyout_count'] = isset($date[1]) ? $date[1] : ""; $temp['reserve_count'] = isset($date[2]) ? $date[2] : ""; $temp['inquiry_count'] = isset($date[3]) ? $date[3] : ""; $temp['remain_count'] = isset($date[4]) ? $date[4] : ""; return $temp; } function setData($data) { $tp1 = array(); $tp2 = array(); //1.将父集与子集分开存 foreach ($data['room_list'][1] as $k => $v) { $tp1[] = $v; } foreach ($data['room_list'][2] as $k => $v) { $tp2[] = $v; } $temp = array(); //2.将父集与子集并列2 foreach ($tp1 as $k1 => $v1) { $temp[] = $v1; foreach ($tp2 as $k2 => $v2) { if ($v1['room_type'] == $v2['parent_room_type']) { $temp[] = $v2; } } } $data['room_list'] = $temp; foreach ($data['room_list'] as $k => $v) { $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(); //子房型 if ($v['parent_room_type'] > 0) { $data['room_list'][$k]['date1'] = $this->setTempByDateChild($date1); $data['room_list'][$k]['date2'] = $this->setTempByDateChild($date2); $data['room_list'][$k]['date3'] = $this->setTempByDateChild($date3); $data['room_list'][$k]['date4'] = $this->setTempByDateChild($date4); $data['room_list'][$k]['date5'] = $this->setTempByDateChild($date5); $data['room_list'][$k]['date6'] = $this->setTempByDateChild($date6); $data['room_list'][$k]['date7'] = $this->setTempByDateChild($date7); } else { $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); } } return $data; } function modifyChildRoom() { $user_id = $this->login_user_id; $hotel_id = isset($_REQUEST['hotel_id']) ? $_REQUEST['hotel_id'] : ""; $room_type = isset($_REQUEST['room_type']) ? $_REQUEST['room_type'] : ""; $parent_room_type = isset($_REQUEST['parent_room_type']) ? $_REQUEST['parent_room_type'] : ""; $data_child_room_name = isset($_REQUEST['data_child_room_name']) ? $_REQUEST['data_child_room_name'] : ""; $checkin_people = isset($_REQUEST['checkin_people']) ? $_REQUEST['checkin_people'] : ""; $breakfast = isset($_REQUEST['breakfast']) ? $_REQUEST['breakfast'] : ""; $roomInfo = new HTRoomInfo; $data = $roomInfo->modifyChildRoom($hotel_id, $room_type, $parent_room_type, $data_child_room_name, $checkin_people, $user_id, $breakfast); return $data; } } $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : "getRoomList"; $roomList = new RoomList; if ($op == 'modifyRoom') { $data = $roomList->modifyChildRoom(); } else { $data = $roomList->getRoomList(); }; echo json_encode($data);