0.01, 'max' => 99999999], [['send_integral'], 'number', 'min' => 0, 'max' => 99999999], [['send_integral'], 'default', 'value' => 0], ]; } public function attributeLabels() { return [ 'name' => '充值名称!', 'pay_price' => '支付金额', 'send_integral' => '赠送金额', 'first_commission' => '一级佣金', 'second_commission' => '二级佣金', 'third_commission' => '三级佣金', 'state' => '是否启用', 'original_price' => '原价', ]; } public function save() { if (!$this->validate()) { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0], ]; } if ($this->model->isNewRecord) { $this->model->store_id = $this->store_id; $this->model->is_delete = 0; $this->model->created_at = time(); } $_attributes = $this->attributes; $this->model->attributes = $_attributes; if ($this->model->save()) { return [ 'code' => 0, 'msg' => '成功' ]; } else { return [ 'code' => 1, 'msg' => '保存失败', 'err' => $this->model->errors ]; } } }