You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

149 lines
4.0 KiB

  1. <?php
  2. namespace backend\modules\hotel\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "channel_hotel_mapping".
  6. *
  7. * @property integer $ID
  8. * @property string $create_time
  9. * @property integer $create_user_id
  10. * @property integer $update_user_id
  11. * @property string $update_time
  12. * @property integer $cancel_flag
  13. * @property integer $channel_id
  14. * @property integer $master_hotel_id
  15. * @property integer $sub_hotel_id
  16. * @property integer $hotel_id
  17. * @property integer $onsale
  18. * @property string $start_date
  19. * @property string $end_date
  20. * @property string $start_time
  21. * @property string $end_time
  22. * @property integer $end_time_type
  23. * @property string $apply_week
  24. */
  25. class ChannelHotelMapping extends \yii\db\ActiveRecord
  26. {
  27. /**
  28. * @inheritdoc
  29. */
  30. public static function tableName()
  31. {
  32. return 'channel_hotel_mapping';
  33. }
  34. /**
  35. * @inheritdoc
  36. */
  37. public function rules()
  38. {
  39. return [
  40. [['master_hotel_id'], 'required'],
  41. [['create_time', 'update_time'], 'safe'],
  42. [['create_user_id', 'update_user_id', 'cancel_flag', 'channel_id', 'master_hotel_id', 'sub_hotel_id', 'hotel_id', 'onsale', 'end_time_type'], 'integer'],
  43. [['start_date', 'end_date'], 'string', 'max' => 15],
  44. [['start_time', 'end_time', 'apply_week'], 'string', 'max' => 10],
  45. ];
  46. }
  47. /**
  48. * @inheritdoc
  49. */
  50. public function attributeLabels()
  51. {
  52. return [
  53. 'create_time' => 'Create Time',
  54. 'create_user_id' => 'Create User ID',
  55. 'update_user_id' => 'Update User ID',
  56. 'update_time' => 'Update Time',
  57. 'cancel_flag' => 'Cancel Flag',
  58. 'channel_id' => 'Channel ID',
  59. 'master_hotel_id' => 'Master Hotel ID',
  60. 'sub_hotel_id' => 'Sub Hotel ID',
  61. 'hotel_id' => 'Hotel ID',
  62. 'onsale' => 'Onsale',
  63. 'start_date' => 'Start Date',
  64. 'end_date' => 'End Date',
  65. 'start_time' => 'Start Time',
  66. 'end_time' => 'End Time',
  67. 'end_time_type' => 'End Time Type',
  68. 'apply_week' => 'Apply Week',
  69. ];
  70. }
  71. public function getBaseSupplier()
  72. {
  73. return $this->hasOne(BaseSupplier::className(), ['ID' => 'channel_id']);
  74. }
  75. public function beforeSave($insert)
  76. {
  77. if ($this->isNewRecord) {
  78. $this->create_time = date('Y-m-d H:i:s');
  79. $this->create_user_id = Yii::$app->user->id;
  80. $this->cancel_flag = 0;
  81. } else {
  82. $this->update_time = date('Y-m-d H:i:s');
  83. $this->update_user_id = Yii::$app->user->id;
  84. }
  85. return parent::beforeSave($insert);
  86. }
  87. /**
  88. * des:获取母物理房型
  89. * author:guhh
  90. */
  91. public function getMasterBasicroomList($params)
  92. {
  93. }
  94. /**
  95. * Des:获取详细 根据子酒店 ID
  96. * Name: getInfoBySubHotel
  97. * @param $params
  98. * @return array
  99. * @author 倪宗锋
  100. */
  101. public function getInfoBySubHotel($params)
  102. {
  103. $where = [
  104. 'and',
  105. ['=', 'sub_hotel_id', $params['sub_hotel_id']],
  106. ['=', 'cancel_flag', 0],
  107. ];
  108. if (empty($params['channel_id']) == false) {
  109. $where[] = ['=', 'channel_id', $params['channel_id']];
  110. }
  111. $info = self::find()
  112. ->where($where)
  113. ->asArray()
  114. ->one();
  115. return $info;
  116. }
  117. /**
  118. * Function Description:根据渠道和子酒店编号获取蜘蛛酒店编号
  119. * Function Name: getHotelIdBySub
  120. * @param $channel_id
  121. * @param $sub_hotel_id
  122. *
  123. * @return mixed
  124. *
  125. * @author 娄梦宁
  126. */
  127. public static function getHotelIdBySub($channel_id,$sub_hotel_id){
  128. $result=self::find()->select('hotel_id')->from(ChannelHotelMapping::tableName())
  129. ->where(['and',['=','channel_id',$channel_id],['=','sub_hotel_id',$sub_hotel_id],['=','cancel_flag',0]])
  130. ->asArray()
  131. ->one();
  132. return $result['hotel_id'];
  133. }
  134. }