TimestampBehavior::class, 'value' => time() ] ]; } public function beforeSave($insert) { if (parent::beforeSave($insert)) { $is = self::findOne(['level' => $this->level, 'store_id' => $this->store_id, 'is_delete' => self::SHARE_NOT_DELETE]); if ($is) { $open = false; if ($this->id && $this->id !== $is->id) { $open = true; } if (!$this->id) { $open = true; } if ($open) { $this->addError('level', '操作失败,当前等级不可用'); return false; } } // if ($this->type && !in_array($this->type, self::$valid_type_arr)) { // $this->addError('type', '操作失败,升级条件类型信息错误'); // return false; // } if ($this->status && !in_array($this->status, self::$valid_status_arr)) { $this->addError('status', '操作失败,启用状态错误'); return false; } if ($this->profit_type && !in_array($this->profit_type, self::$valid_profit_arr)) { $this->addError('profit_type', '操作失败,分销佣金类型错误'); return false; } if ($this->is_auto_upgrade && !in_array($this->is_auto_upgrade, self::$valid_auto_upgrade_arr)) { $this->addError('is_auto_upgrade', '操作失败,是否自动升级类型错误'); return false; } } return true; } /** * @inheritdoc */ public function attributeLabels() { return [ "id" => "ID", "name" => "名称", "level" => "等级", "is_auto_upgrade" => "是否自动升级", "type" => "升级条件类型", "value" => "升级条件值", "condition" => "升级条件值", "profit_type" => "分销佣金类型", "first_profit" => "一级佣金", "second_profit" => "二级佣金", "third_profit" => "三级佣金", "status" => "启用状态", "desc" => "等级说明", "store_id" => "Store Id", "is_delete" => "is Delete", "created_at" => "创建时间", "updated_at" => "修改时间", ]; } }