|
- <?php
-
- namespace backend\modules\hotel\models;
-
- use Yii;
-
- /**
- * This is the model class for table "channel_hotel_mapping".
- *
- * @property integer $ID
- * @property string $create_time
- * @property integer $create_user_id
- * @property integer $update_user_id
- * @property string $update_time
- * @property integer $cancel_flag
- * @property integer $channel_id
- * @property integer $master_hotel_id
- * @property integer $sub_hotel_id
- * @property integer $hotel_id
- * @property integer $onsale
- * @property string $start_date
- * @property string $end_date
- * @property string $start_time
- * @property string $end_time
- * @property integer $end_time_type
- * @property string $apply_week
- */
- class ChannelHotelMapping extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'channel_hotel_mapping';
- }
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['master_hotel_id'], 'required'],
- [['create_time', 'update_time'], 'safe'],
- [['create_user_id', 'update_user_id', 'cancel_flag', 'channel_id', 'master_hotel_id', 'sub_hotel_id', 'hotel_id', 'onsale', 'end_time_type'], 'integer'],
- [['start_date', 'end_date'], 'string', 'max' => 15],
- [['start_time', 'end_time', 'apply_week'], 'string', 'max' => 10],
- ];
- }
-
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'create_time' => 'Create Time',
- 'create_user_id' => 'Create User ID',
- 'update_user_id' => 'Update User ID',
- 'update_time' => 'Update Time',
- 'cancel_flag' => 'Cancel Flag',
- 'channel_id' => 'Channel ID',
- 'master_hotel_id' => 'Master Hotel ID',
- 'sub_hotel_id' => 'Sub Hotel ID',
- 'hotel_id' => 'Hotel ID',
- 'onsale' => 'Onsale',
- 'start_date' => 'Start Date',
- 'end_date' => 'End Date',
- 'start_time' => 'Start Time',
- 'end_time' => 'End Time',
- 'end_time_type' => 'End Time Type',
- 'apply_week' => 'Apply Week',
- ];
- }
-
- public function getBaseSupplier()
- {
- return $this->hasOne(BaseSupplier::className(), ['ID' => 'channel_id']);
- }
-
- public function beforeSave($insert)
- {
- if ($this->isNewRecord) {
- $this->create_time = date('Y-m-d H:i:s');
- $this->create_user_id = Yii::$app->user->id;
- $this->cancel_flag = 0;
-
- } else {
- $this->update_time = date('Y-m-d H:i:s');
- $this->update_user_id = Yii::$app->user->id;
- }
-
- return parent::beforeSave($insert);
- }
-
- /**
- * des:获取母物理房型
- * author:guhh
- */
- public function getMasterBasicroomList($params)
- {
-
- }
-
- /**
- * Des:获取详细 根据子酒店 ID
- * Name: getInfoBySubHotel
- * @param $params
- * @return array
- * @author 倪宗锋
- */
- public function getInfoBySubHotel($params)
- {
- $where = [
- 'and',
- ['=', 'sub_hotel_id', $params['sub_hotel_id']],
- ['=', 'cancel_flag', 0],
- ];
- if (empty($params['channel_id']) == false) {
- $where[] = ['=', 'channel_id', $params['channel_id']];
- }
- $info = self::find()
- ->where($where)
- ->asArray()
- ->one();
- return $info;
- }
-
- /**
- * Function Description:根据渠道和子酒店编号获取蜘蛛酒店编号
- * Function Name: getHotelIdBySub
- * @param $channel_id
- * @param $sub_hotel_id
- *
- * @return mixed
- *
- * @author 娄梦宁
- */
- public static function getHotelIdBySub($channel_id,$sub_hotel_id){
- $result=self::find()->select('hotel_id')->from(ChannelHotelMapping::tableName())
- ->where(['and',['=','channel_id',$channel_id],['=','sub_hotel_id',$sub_hotel_id],['=','cancel_flag',0]])
- ->asArray()
- ->one();
- return $result['hotel_id'];
- }
-
- }
|