255], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'ID' => 'ID', 'create_time' => 'Create Time', 'create_user_id' => 'Create User ID', 'update_user_id' => 'Update User ID', 'update_time' => 'Update Time', 'channel_id' => 'Channel ID', 'cancel_flag' => 'Cancel Flag', 'master_hotel_id' => 'Master Hotel ID', 'sub_hotel_id' => 'Sub Hotel ID', 'hotel_id' => 'Hotel ID', 'master_base_room_id' => 'Master Base Room ID', 'sub_base_room_id' => 'Sub Base Room ID', 'base_room_id' => 'Base Room ID', 'master_base_room_name' => 'Master Base Room Name', 'master_base_room_name_en' => 'Master Base Room Name En', 'base_room_is_add' => 'Base Room Is Add', ]; } public function getOperaHotelBaseRoom() { return $this->hasOne(OperaHotelBaseRoom::className(), ['MAIN_ID' => 'base_room_id', 'HOTEL_ID' => 'hotel_id']) ->andOnCondition([OperaHotelBaseRoom::tableName() . '.cancel_flag' => 0]); } /** * des:根据子酒店ID 获取母物理房型列表 * author:guhh */ public function getMasterBaseRoomList($params) { $select = [ 'a.master_hotel_id', 'a.sub_hotel_id', 'a.hotel_id', 'a.master_base_room_id', 'a.sub_base_room_id', 'a.base_room_id', 'a.master_base_room_name', 'a.master_base_room_name_en', 'a.base_room_is_add', ]; $where = [ 'and', ['=', 'a.sub_hotel_id', $params['sub_hotel_id']], ['=', 'a.channel_id', $params['channel_id']], ['=', 'a.cancel_flag', 0] ]; $query = self::find()->select($select) ->from(self::tableName() . ' a') ->joinWith('operaHotelBaseRoom') ->where($where); $dataProvider = new ActiveDataProvider([ 'query' => $query, 'sort' => false, 'pagination' => [ 'pagesize' => 100, ], ]); return $dataProvider; } /** * Des:根据主房型id获取数据 * Name: getInfoByMasterRoomId * @param $masterRoomId * @param $channel_id * @return array * @author 倪宗锋 */ public function getInfoByMasterRoomId($masterRoomId, $channel_id = '') { $select = [ 'a.ID', 'a.master_hotel_id', 'a.sub_hotel_id', 'a.hotel_id', 'a.master_base_room_id', 'a.sub_base_room_id', 'a.base_room_id', 'a.master_base_room_name', 'a.master_base_room_name_en', 'a.base_room_is_add', 'b.base_room_name' ]; $where = [ 'and', ['=', 'a.master_base_room_id', $masterRoomId], ['=', 'a.cancel_flag', 0], ]; if (empty($channel_id) == false) { $where[] = ['=', 'a.channel_id', $channel_id]; } $info = self::find()->select($select) ->from(self::tableName() . ' a') ->leftJoin(OperaHotelBaseRoom::tableName() . ' b', 'b.MAIN_ID = a.base_room_id') ->where($where) ->asArray() ->one(); return $info; } /** * Des:修改基本信息 * Name: editInfo * @param $params * @param $master_base_room_id * @param $sub_hotel_id * @param $channel_arr * @return bool * @author 倪宗锋 */ public function editInfo($params, $master_base_room_id, $sub_hotel_id, $channel_arr) { $params['update_time'] = date('Y-m-d H:i:s'); $where = [ 'master_base_room_id' => $master_base_room_id, 'sub_hotel_id' => $sub_hotel_id, 'channel_id' => $channel_arr ]; $flag = self::updateAll($params, $where); if ($flag == false) { return false; } return true; } /** * Des:修改基本信息 * Name: editInfo * @param $roomInfo * @param $channel_arr * @author 倪宗锋 */ public function editRow($roomInfo, $channel_arr) { $params = [ 'update_time' => date('Y-m-d H:i:s'), 'sub_base_room_id' => $roomInfo['roomTypeId'], ]; if (empty($roomInfo['roomTypeId']) == false) { $params['base_room_is_add'] = 1; } self::updateAll( $params, 'master_base_room_id=:master_base_room_id and channel_id in (:channel_id)', [ ':master_base_room_id' => $roomInfo['masterBasicRoomTypeId'], ':channel_id' => implode(',', $channel_arr) ] ); } /** * Des:添加关联关系 * Name: addRows * @param $roomInfo * @param $hotelInfo * @param $channel_arr * @author 倪宗锋 */ public function addRows($roomInfo, $hotelInfo, $channel_arr) { //获取cookies $cookies = Yii::$app->request->cookies; //账号权限 $user_id = $cookies->getValue('user_id'); foreach ($channel_arr as $channel_id) { try { $values = [ 'create_time' => date('Y-m-d H:i:s'), 'create_user_id' => empty($user_id) ? 0 : $user_id, 'channel_id' => $channel_id, 'master_hotel_id' => $hotelInfo['master_hotel_id'], 'sub_hotel_id' => $hotelInfo['sub_hotel_id'], 'hotel_id' => $hotelInfo['hotel_id'], 'master_base_room_id' => $roomInfo['masterBasicRoomId'], 'master_base_room_name' => $roomInfo['basicRoomName'], 'master_base_room_name_en' => $roomInfo['basicRoomNameEn'] ]; if (empty($basicRoomTyp) == false) { $values['base_room_is_add'] = 1; } $table = new ChannelBaseRoomMapping(); $table->isNewRecord = true; $table->setAttributes($values); $flag = $table->save(); $a = $table->getErrors(); $s = $flag; } catch (Exception $e) { } } } /** * Des:已经不存在的基础房型删除 * Name: delRow * @author 倪宗锋 */ public function delRow($sub_hotel_id, $channel_arr, $ctripMasterRoomId) { $params = [ 'update_time' => date('Y-m-d H:i:s'), 'cancel_flag' => 1, ]; $master_base_room_id = implode(',', $ctripMasterRoomId); $channel_id = implode(',', $channel_arr); $where = "channel_id in ({$channel_id}) and sub_hotel_id = {$sub_hotel_id}"; if ( !empty($master_base_room_id)){ $where .= " and master_base_room_id not in ({$master_base_room_id})"; } self::updateAll($params,$where); } /** * Des:删除基础房型的管理关系 * Name: delMapping * @param $param * @param $channel_arr * @author 倪宗锋 */ public function delBaseRoomMapping($param, $channel_arr) { $data = [ 'base_room_id' => null ]; $where = [ 'base_room_id' => $param['base_room_id'], 'channel_id' => $channel_arr ]; self::updateAll($data, $where); } }