isNewRecord) { $this->create_time = Yii::$app->formatter->asTimestamp('now'); } else { $this->update_time = Yii::$app->formatter->asTimestamp('now'); } return true; } else { return false; } } /** * 获取指定日期最后的一条记录(stage max) */ public static function getMaxStage($date = '') { if(!$date){ $date = date('Y-m-d'); } return self::find()->where(['date' => $date])->orderBy(['stage' => SORT_DESC])->one(); } public static function addOneRecord($start_height,$end_height,$stage) { $coin_lottery = new self(); $coin_lottery->stage = $stage; $coin_lottery->start_height = $start_height; $coin_lottery->end_height = $end_height; $coin_lottery->date = date('Y-m-d'); $coin_lottery->save(); } }