|
- <?php
-
- namespace backend\modules\hotel\models;
-
- use common\models\zModel;
-
- /**
- * This is the model class for table "order_ht_status_log".
- *
- * @property integer $ID
- * @property integer $ORDER_ID
- * @property integer $ORDER_STATUS
- * @property integer $BEFORE_STATUS
- * @property integer $CANCEL_FLAG
- * @property integer $CREATE_USER_ID
- * @property string $CREATE_TIME
- * @property integer $UPDATE_USER_ID
- * @property string $UPDATE_TIME
- */
- class OrderHtStatusLog extends zModel
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'order_ht_status_log';
- }
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['ORDER_ID', 'ORDER_STATUS'], 'required'],
- [['ORDER_ID', 'ORDER_STATUS', 'BEFORE_STATUS', 'CANCEL_FLAG', 'CREATE_USER_ID', 'UPDATE_USER_ID'], 'integer'],
- [['CREATE_TIME', 'UPDATE_TIME'], 'string', 'max' => 20],
- ];
- }
-
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'ID' => 'ID',
- 'ORDER_ID' => '订单ID,ORDER_MAIN.ORDER_ID',
- 'ORDER_STATUS' => 'Order Status',
- 'BEFORE_STATUS' => 'Before Status',
- 'CANCEL_FLAG' => '记录有效性标记,CANCEL_FLAG=0记录有效;CANCEL_FLAG=1,记录已删除',
- 'CREATE_USER_ID' => '记录创建用户ID',
- 'CREATE_TIME' => '记录创建时间',
- 'UPDATE_USER_ID' => '记录最后更新用户ID',
- 'UPDATE_TIME' => '记录最后更新时间',
- ];
- }
-
- public function getUser()
- {
- return $this->hasOne(User::className(), ['ID' => 'CREATE_USER_ID']);
- }
-
- public function beforeSave($insert)
- {
- if ($this->isNewRecord) {
- $this->CANCEL_FLAG = 0;
- $this->CREATE_TIME = date('Y-m-d H:i:s', time());
- }else{
- $this->UPDATE_TIME=date('Y-m-d H:i:s', time());
- }
- return parent::beforeSave($insert);
- }
- }
|