0], [['over_diy'], 'integer', 'min' => 0], [['over_file'], 'integer', 'min' => 0], [['max_picture'], 'number', 'min' => 0], [['over_picture', 'over_diy'], 'default', 'value' => 0], [['max_picture'], 'default', 'value' => 1], [['max_diy'], 'default', 'value' => 20], ]; } /** * @return array * @throws \yii\db\Exception */ public function save() { if (!$this->validate()) { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0] ]; } if (!isset($this->max_file)) { $this->max_file = $this->max_picture; } Option::set('overrun', Json::encode([ 'max_picture' => $this->max_picture, 'max_diy' => $this->max_diy, 'max_file' => $this->max_file, 'over_picture' => $this->over_picture, 'over_diy' => $this->over_diy, 'over_file' => $this->over_file, ]), get_store_id(), 'store'); return [ 'code' => 0, 'msg' => '保存成功' ]; } public function search() { $data = Option::get('overrun', get_store_id(), 'store')['value']; $data = Json::decode($data); if (!$data) { $data = [ 'max_picture' => 1, 'max_diy' => 20, 'max_file' => 20, 'over_picture' => 0, 'over_diy' => 0, 'over_file' => 0, ]; } if (!isset($data['max_file'])) { $data['max_file'] = $data['max_picture']; } if (!isset($data['over_file'])) { $data['over_file'] = $data['over_picture']; } return [ 'code' => 0, 'msg' => '', 'data' => $data ]; } }