getList($nickName, $gender, $grade); // 会员等级列表 $gradeList = GradeModel::getUsableList(); return $this->fetch('index', compact('list', 'gradeList')); } /** * 编辑会员 * @param $user_id * @return array|bool|mixed * @throws \think\exception\DbException */ public function edit($user_id) { // 会员等级详情 $model = UserModel::detail($user_id); if (!$this->request->isAjax()) { return $this->fetch('edit', compact('model')); } // 编辑记录 $post = $this->postData('user'); $post['user_id'] = $user_id; if ($model->edit($post)) { return $this->renderSuccess('更新成功', url('user/index')); } return $this->renderError($model->getError() ?: '更新失败'); } /** * 删除用户 * @param $user_id * @return array * @throws \think\exception\DbException */ public function delete($user_id) { // 用户详情 $model = UserModel::detail($user_id); if ($model->setDelete()) { return $this->renderSuccess('删除成功'); } return $this->renderError($model->getError() ?: '删除失败'); } /** * 用户充值 * @param $user_id * @param int $source 充值类型 * @return array|bool * @throws \think\Exception * @throws \think\exception\DbException */ public function recharge($user_id, $source) { // 用户详情 $model = UserModel::detail($user_id); if ($model->recharge($this->store['user']['user_name'], $source, $this->postData('recharge'))) { return $this->renderSuccess('操作成功'); } return $this->renderError($model->getError() ?: '操作失败'); } /** * 修改会员等级 * @param $user_id * @return array|bool * @throws \think\Exception * @throws \think\exception\DbException */ public function grade($user_id) { // 用户详情 $model = UserModel::detail($user_id); if ($model->updateGrade($this->postData('grade'))) { return $this->renderSuccess('操作成功'); } return $this->renderError($model->getError() ?: '操作失败'); } }