renderSuccess(compact('info')); } public function setData(): Json { $price = helper::number2($this->request->post('price')); if ($price <= 0) { return $this->renderError('价格不能为空'); } $year = intval($this->request->post('year')); if ($year <= 0) { return $this->renderError('年限不能为空'); } $info = \app\store\model\wholesaler\Set::detail(); $model = new \app\store\model\wholesaler\Set(); if (!empty($info->id)) { $res = $model->edit(compact('price', 'year')); } else { $res = $model->add(compact('price', 'year')); } if ($res) { return $this->renderSuccess('操作成功'); } return $this->renderError('操作失败'); } }