service == null) { $this->service = new Hotel(); } return $this->service; } /** * Des:获取酒店信息 * Name: actionGetInfo * @return string * @author 倪宗锋 */ public function actionGetInfo() { $params = [ 'hotel_id' => $this->_post('hotel_id', ''),//酒店ID 必传 'start_date' => $this->_post('start_date', ''),//入住时间 必传 'end_date' => $this->_post('end_date', ''),//离店时间 必传 ]; $getInfo = $this->service()->getInfo($params); return json_encode($getInfo); } /** * Des:获取房型列表 * Name: actionGetRoomList * @return string * @author 倪宗锋 */ public function actionGetRoomList() { $params = [ 'hotel_id' => $this->_post('hotel_id', ''),//酒店ID 必传 'start_date' => $this->_post('start_date', ''),//入住时间 必传 'end_date' => $this->_post('end_date', ''),//离店时间 必传 'room_id' => $this->_post('room_id', '')//房型ID 非必传 ]; $result = $this->service()->getRoomList($params); return Util::returnJsSu('', $result); } /** * Des:酒店下单接口 * Name: actionMakeOrder * @return string * @author 倪宗锋 */ public function actionMakeOrder() { $result = $this->service()->makeOrder(); return json_encode($result); } /** * Function Description:获取酒店列表 * Function Name: actionGetHotelList * * @return string * * @author 娄梦宁 */ public function actionGetHotelList() { $params = [ 'area_id' => $this->_post('area_id', '800'),//地区id 'start_date' => $this->_post('start_date', '2018-01-20'),//入住时间 必传 'end_date' => $this->_post('end_date', '2018-01-22'),//离店时间 必传 'search_more' => $this->_post('search_more', ''),//名称,商圈 'sort' => Yii::$app->request->post('sort', '-1'),//排序规则 -1:综合排序,0价格高到低,1:价格低到高 'breakfast_include' => $this->_post('breakfast_include', '0'),//早餐标识 'hotel_label' => $this->_post('hotel_label', ''),//设施服务 'star_type' => $this->_post('star_type', '0'),//星级及类型 'price_type' => $this->_post('price_type', '0'),//价格区间 'bed_type' => $this->_post('bed_type', '0'),//床型 'brand' => $this->_post('brand', '0'),//品牌 'current_page' => $this->_post('current_page', 1), 'page_size' => $this->_post('page_size', 10), ]; $result = $this->service()->getHotelList($params); return json_encode($result); } /** * Function Description:获取酒店列表缓存 * Function Name: actionCacheHotel * * * @author 娄梦宁 */ public function actionCacheHotel() { $curlInterface = new CurlInterface(); $siteConfig = Util::getSiteConfig(); $url = $siteConfig['adm_host1'] . '/hotel/api/get-hotel-list-cache'; $result = $curlInterface->execute($url); if ($result['code'] == 0) { $mHotel = new MHotel(); $mBaseUnique = new MBaseUnique(); $new_time_stamp = $result['data'][0]['time_stamp']; $collection = $mHotel->getCollection(); foreach ($result['data'] as $val) { $collection->insert($val); } $mBaseUnique::updateAll(['time_stamp' => $new_time_stamp], ['type' => 1]); $mHotel->deleteAll(['!=', 'time_stamp', $new_time_stamp]); } } /** * Function Description:获取酒店筛选条件 * Function Name: actionGetHotelType * * @return string * * @author 李健 */ public function actionGetHotelType() { $result = $this->service()->getHotelType(); return json_encode($result); } /** * Des:下单页可定检查 * Name: actionCheckHotel * @return string * @author 倪宗锋 */ public function actionCheckHotel() { $params = [ 'total_details' => $this->_post('total_details', ''),//每日单价 'hotel_id' => $this->_post('hotel_id', ''),//酒店ID 必传 'start_date' => $this->_post('start_date', ''),//入住时间 必传 'end_date' => $this->_post('end_date', ''),//离店时间 必传 'room_id' => $this->_post('room_id', ''),//房型ID 必传 'prod_cnt' => $this->_post('prod_cnt', ''),//房间数量 必传 ]; $result = OrderUtil::checkHotel($params); return json_encode($result); } /** * Function Description:获取酒店所在城市 * Function Name: actionGetHotelArea * @return bool|string * @author 田玲菲 */ public function actionGetHotelArea() { $result = $this->service()->getHotelArea(); return json_encode($result); } /** * Des:返回微信官网接口 * Name: actionGetWwwHotelList * @return string * @author 倪宗锋 */ public function actionGetWwwHotelList() { //先从缓存中获取数据不存在则 从cs接口获取 $cache = Yii::$app->cache; $key = 'WWW_HOTEL_LIST' . YII_ENV; $list = $cache->get($key); if (empty($list)) { //调用cs接口获取列表 $result = Util::sendCs([], '/hotel/api/get-www-hotel-list', 2); $list = $result['data']; if (empty($list[0]['hotel_id'])) { return json_encode([]); } foreach ($list as &$hotel) { $hotel['category_id'] = '3'; $hotel['pro_cate_id'] = $hotel['hotel_id']; $hotel['pro_cate_name'] = $hotel['hotel_name']; $hotel['show_price'] = $hotel['min_price']; unset($hotel['hotel_id']); unset($hotel['hotel_name']); unset($hotel['min_price']); } //保存到memcache中 $cache->set($key, $list, 3600);//缓存10分钟 } return json_encode($list); } }