getList($this->request->param()); return $this->renderSuccess(compact('list')); } /** * 添加活动 * @return Json */ public function add(): Json { // 新增记录 $model = new ActiveMainModal; if ($model->add($this->postForm())) { return $this->renderSuccess('添加成功'); } return $this->renderError($model->getError() ?: '添加失败'); } /** * 更新活动 * @param int $activeId * @return Json */ public function edit(int $activeId): Json { // 协议详情 $model = ActiveMainModal::detail($activeId); // 更新记录 if ($model->edit($this->postForm())) { return $this->renderSuccess('更新成功'); } return $this->renderError($model->getError() ?: '更新失败'); } /** * 删除活动 * @param int $activeId * @return Json */ public function delete(int $activeId): Json { // 先看是否在副表中有数据 $model = new ActiveColModal; $list = $model->getList($activeId); if (count($list) > 0) { return $this->renderError('请先删除活动栏目'); } $model = ActiveMainModal::detail($activeId); if ($model->setDelete()) { return $this->renderSuccess('删除成功'); } return $this->renderError($model->getError() ?: '删除失败'); } /** * 根据活动 id 获取活动的模块列表 * @param init $activeId */ public function colList(int $activeId): Json { $model = new ActiveColModal; $list = $model->getList($activeId); return $this->renderSuccess(compact('list')); } /** * 添加活动模块 * @return Json */ public function colAdd(): Json { // 新增记录 $model = new ActiveColModal; if ($model->add($this->postForm())) { return $this->renderSuccess('添加成功'); } return $this->renderError($model->getError() ?: '添加失败'); } /** * 更新活动模块 * @param int $activeColId * @return Json */ public function colEdit(int $activeColId): Json { $model = ActiveColModal::detail($activeColId); // 更新记录 if ($model->edit($this->postForm())) { return $this->renderSuccess('更新成功'); } return $this->renderError($model->getError() ?: '更新失败'); } /** * 删除活动模块 * @param int $activeColId * @return Json */ public function colDelete(int $activeColId): Json { $model = ActiveColModal::detail($activeColId); if ($model->setDelete()) { return $this->renderSuccess('删除成功'); } return $this->renderError($model->getError() ?: '删除失败'); } /** * goodsList 获取商品列表 * @return Json */ public function goodsList(string $goodsIds): Json { $goodsIds = explode(',', $goodsIds); $model = new GoodsModal; $list = $model->getListByIds($goodsIds); return $this->renderSuccess(compact('list')); } }