50], [['hotel_name', 'hotel_address', 'hotel_address_en'], 'string', 'max' => 255], [['hotel_star'], 'string', 'max' => 10], [['hotel_phone'], 'string', 'max' => 20], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'ID' => 'ID', 'create_user_id' => '记录创建人', 'create_time' => '记录创建时间', 'update_user_id' => '记录更新人', 'update_time' => '记录更新时间', 'cancel_flag' => '有效标示 0:有效 1:无效', 'city_id' => '城市ID', 'city_name' => '名称', 'hotel_name' => '酒店名称', 'hotel_star' => '星级', 'star_licence' => '是否确认为挂牌星级 0:不挂牌星级 1:挂牌星级', 'hotel_address' => '酒店地址', 'hotel_address_en' => '英文酒店地址', 'hotel_phone' => '电话', 'master_hotel_id' => '母酒店ID', 'can_add_hotel' => '是否可添加子酒店 0:不能 1:能', 'glat' => 'google纬度', 'glng' => 'google经度', 'gDlat' => '高德纬度', 'gDlng' => '高德经度', 'bDlat' => '百度纬度对应表的lat字段', 'bDlng' => '百度经度对应表的lon字段', ]; } public function getCtripCityList() { return $this->hasOne(CtripCityList::className(), ['city_id' => 'city_id']); } public function getMasterHotelList($params) { //todo:这里关联的时候需要加入渠道的筛选 $query = self::find() ->joinWith('ctripCityList', false) ->leftJoin('channel_hotel_mapping', 'a.master_hotel_id=channel_hotel_mapping.master_hotel_id and channel_hotel_mapping.channel_id='.$params['channel_id']) ->leftJoin('base_supplier', 'channel_hotel_mapping.channel_id=base_supplier.ID and base_supplier.SUPPLIER_TYPE=301') ->from('ctrip_hotel_list a') ->where(['a.cancel_flag' => 0, 'ctrip_city_list.cancel_flag' => 0]); $query -> select(['a.*', 'base_supplier.SUPPLIER_NAME as channel_name', 'channel_hotel_mapping.sub_hotel_id as switch_hotel_id', 'channel_hotel_mapping.hotel_id as zz_hotel_id', 'channel_hotel_mapping.channel_id as channel_id', ]); if($params['country_id']) { $query->andFilterWhere(['ctrip_city_list.country_id' => $params['country_id']]); } if($params['city_id'] || $params['city_id'] == 'empty') { $query->andFilterWhere(['ctrip_city_list.city_id' => $params['city_id']]); } if($params['hotel_name']) { $query->andFilterWhere(['like', 'a.hotel_name', trim($params['hotel_name'])]); } // 根据当前渠道查询母酒店数据信息 $sql=$query->createCommand()->getRawSql(); $dataProvider = new ActiveDataProvider([ 'query' => $query, 'sort' => false, 'pagination' => [ 'pagesize' => 25, ], ]); return $dataProvider; } }