postData(); $list = $model->getListForAdmin($postData, $this->branch['branch_id']); return $this->renderSuccess('', compact('list')); } /** * 添加分会 */ public function add() { $model = new BranchModel; $data = json_decode($this->request->post('formData', '', null), true); // 新增记录 if ($model->add($data, $this->branch['branch_id'])) { return $this->renderSuccess('添加成功'); } return $this->renderError($model->getError() ?: '添加失败'); } /** * 编辑分会 */ public function edit($branch_id) { $model = BranchModel::detail($branch_id, ['superUser.user']); if($this->request->isGet()){ $regionData = RegionModel::getRegionForApi(); return $this->renderSuccess('', compact('model', 'regionData')); } $data = json_decode($this->request->post('formData', '', null), true); if ($model->edit($data)) { return $this->renderSuccess('更新成功'); } return $this->renderError($model->getError() ?: '更新失败'); } /** * 删除分会 */ public function delete($branch_id) { // 分会详情 $model = BranchModel::detail($branch_id); if (!$model->setDelete()) { return $this->renderError('删除失败'); } return $this->renderSuccess('', $model->getError() ?: '删除成功'); } /** * 排行榜 */ public function ranking($date = null) { $model = new ActivityModel; $list = $model->getBranchRankList($date, $this->branch['branch_id']); return $this->renderSuccess('', compact('list')); } }