postData(); $list = $model->getList($postData, $this->getBranchId()); return $this->renderSuccess('', compact('list')); } /** * 分会列表(不分页) */ public function lists() { $model = new BranchModel; $postData = $this->postData(); $list = $model->getAll($postData, $this->getBranchId()); return $this->renderSuccess('', compact('list')); } /** * 添加分会 */ public function add() { $model = new BranchModel; // $category = CategoryModel::getALL(); // $region = AreaModel::getALL(); // if($this->request->isGet()){ // return $this->renderSuccess('', compact('category','region')); // } // 新增记录 if ($model->add($this->postData(), $this->getBranchId())) { return $this->renderSuccess('', '添加成功'); } return $this->renderError($model->getError() ?: '添加失败'); } /** * 编辑分会 */ public function edit($branch_id = 0) { $model = BranchModel::detail($branch_id, ['superUser.user']); if($this->request->isGet()){ $branchList = BranchModel::getALL(['branch_type' => 10], $this->getBranchId()); // 获取总会列表 $areaList = RegionModel::getCacheTree(); return $this->renderSuccess('', compact('model', 'branchList', 'areaList')); } if ($model->edit($this->postData())) { 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 recycle($branch_id, $is_recycle) { // 商品详情 $model = BranchModel::detail($branch_id); if (!$model->setRecycle($is_recycle)) { return $this->renderError('操作失败'); } return $this->renderSuccess('操作成功'); } /** * 二维码 */ public function qrcode($branch_id, $source) { $Qrcode = new BranchService($branch_id, $source); return $Qrcode->getImage(); } /** * 排行榜 */ public function rank($date = null) { $model = new ActivityModel; $list = $model->getBranchRankList($date, $this->getBranchId()); return $this->renderSuccess('', compact('list')); } }