| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace app\modules\admin\models\pond;
- use yii\base\Model;
- /**
- * @property \app\models\PondSetting $model;
- */
- class PondSettingForm extends Model
- {
- public $store_id;
- public $model;
- public $start_time;
- public $end_time;
- public $integral;
- public $rule;
- public function rules()
- {
- return [
- [['store_id', 'integral'], 'integer'],
- [['start_time', 'end_time'], 'required'],
- [['rule'], 'string', 'max' => 1000],
- ];
- }
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'store_id' => 'Store ID',
- 'start_time' => '开始时间',
- 'end_time' => '结束时间',
- 'rule' => '规则说明',
- 'integral' => '单次扣减积分数量'
- ];
- }
- public function save()
- {
- if (!$this->validate()) {
- return $this->errorResponse;
- }
- if ($this->integral <= 0) {
- return [
- 'code' => 1,
- 'msg' => '参数错误:积分数量错误'
- ];
- }
- $this->model->store_id = $this->store_id;
- $this->model->rule = $this->rule;
- $this->model->start_time = $this->start_time;
- $this->model->end_time = $this->end_time;
- $this->model->integral = intval($this->integral);
- if ($this->model->save()) {
- return [
- 'code' => 0,
- 'msg' => '保存成功'
- ];
- } else {
- return $this->getErrorResponse($this->model);
- }
- }
- }
|