0], [['mall_id','title','contact','mobile','price','start_time','end_time','p_commission','pp_commission'],'required'], ['content','default','value'=>''], ['mobile',MobieValidator::class,'message'=>'手机号格式不正确'], [['price'],'number','min'=>0], [['p_commission','pp_commission'],'number','min'=>1], [['p_commission','pp_commission'], 'match', 'pattern' => '/^\d+(\.\d{1,2})?$/i','message'=>'佣金最多只能有两位小数'] ]; } public function attributeLabels() { return [ 'mall_id' => '活动门店', 'title' => '活动标题', 'contact' => '联系人', 'mobile' => '联系电话', 'price' => '活动价格', 'start_time' => '活动开始时间', 'end_time' => '活动结束时间', 'p_commission' => '上级返佣', 'pp_commission' => '上上级返佣' ]; } public function save() { if (!$this->validate()) { throw new Exception($this->getErrorMsg($this)); } if($this->id){ $model = Activity::find()->where([ 'id' => $this->id, 'is_delete' => 0 ])->one(); if(!$model){ throw new Exception('活动不存在'); } }else{ $model = new Activity(); } $model->attributes = $this->attributes; $model->start_time = strtotime($this->start_time); $model->end_time = strtotime($this->end_time); $model->saveOrFail(); return []; } }