getList($this->postData()); return $this->renderSuccess('', compact('list')); } /** * 添加团购活动 */ public function add() { $model = new ActiveModel(); if ($this->request->isGet()) { return $this->renderSuccess('', []); } $data = $this->postData(); if ($model->add($data)) { return $this->renderSuccess('添加成功'); } return $this->renderError($model->getError() ?: '添加失败'); } /** * 编辑团购活动 */ public function edit($groupbuy_active_id) { $model = ActiveModel::detail($groupbuy_active_id); if (!$model) { return $this->renderError('活动不存在'); } if ($this->request->isGet()) { return $this->renderSuccess('', compact('model')); } $data = $this->postData(); if ($model->edit($data)) { return $this->renderSuccess('更新成功'); } return $this->renderError($model->getError() ?: '更新失败'); } /** * 删除团购活动 */ public function delete($groupbuy_active_id) { $model = ActiveModel::detail($groupbuy_active_id); if (!$model) { return $this->renderError('活动不存在'); } if ($model->remove()) { return $this->renderSuccess('删除成功'); } return $this->renderError('删除失败'); } /** * 更新活动状态 */ public function updateStatus($groupbuy_active_id, $status) { $model = ActiveModel::detail($groupbuy_active_id); if (!$model) { return $this->renderError('活动不存在'); } if ($model->updateStatus($status)) { return $this->renderSuccess('状态更新成功'); } return $this->renderError('状态更新失败'); } }