| | |
| | | <?php
|
| | |
|
| | | namespace app\shop\controller\plus\region;
|
| | |
|
| | | use app\shop\controller\Controller;
|
| | | use app\shop\model\plus\region\User as UserModel;
|
| | | use app\shop\model\plus\region\Setting as SettingModel;
|
| | | use app\shop\model\plus\region\Referee as RefereeModel;
|
| | | use app\shop\model\plus\region\Grade as GradeModel;
|
| | | /**
|
| | | * 分销控制器
|
| | | */
|
| | | class User extends Controller
|
| | | {
|
| | | /**
|
| | | * 队长申请列表
|
| | | */
|
| | | public function index($nick_name = '')
|
| | | {
|
| | | $model = new UserModel;
|
| | | $list = $model->getList($nick_name);
|
| | |
|
| | | foreach ($list as $key => $val) {
|
| | | $list[$key]['cash_total'] = sprintf('%.2f', $val['moeny'] + $val['freeze_money'] + $val['total_money']);
|
| | | }
|
| | | $basicSetting = SettingModel::getItem('basic');
|
| | | return $this->renderSuccess('', compact('list', 'basicSetting'));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 编辑队长
|
| | | */
|
| | | public function edit()
|
| | | {
|
| | | if ($this->request->isGet()) {
|
| | | $gradeList = GradeModel::getUsableList();
|
| | | return $this->renderSuccess('', compact('gradeList'));
|
| | | }
|
| | | $user_id = $this->postData('user_id');
|
| | | $model = UserModel::detail($user_id);
|
| | | if ($model->edit($this->postData())) {
|
| | | return $this->renderSuccess('更新成功');
|
| | | }
|
| | | return $this->renderError($model->getError() ?: '更新失败');
|
| | | }
|
| | |
|
| | | /**
|
| | | * 队长用户列表
|
| | | */
|
| | | public function fans($user_id, $level = -1)
|
| | | {
|
| | | $model = new RefereeModel;
|
| | | $list = $model->getList($user_id, $level);
|
| | | $basicSetting = SettingModel::getItem('basic');
|
| | | return $this->renderSuccess('', compact('list', 'basicSetting'));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 软删除队长用户
|
| | | */
|
| | | public function delete($user_id)
|
| | | {
|
| | | $model = UserModel::detail($user_id);
|
| | | if (!$model->setDelete()) {
|
| | | return $this->renderError('删除失败');
|
| | | }
|
| | | return $this->renderSuccess('删除成功');
|
| | | }
|
| | |
|
| | | } |
| | | <?php |
| | | |
| | | namespace app\shop\controller\plus\region; |
| | | |
| | | use app\shop\controller\Controller; |
| | | use app\shop\model\plus\operations\User as UserLoginModel; |
| | | use app\shop\model\plus\region\Grade as GradeModel; |
| | | use app\shop\model\plus\region\Referee as RefereeModel; |
| | | use app\shop\model\plus\region\Setting as SettingModel; |
| | | use app\shop\model\plus\region\User as UserModel; |
| | | |
| | | /** |
| | | * 分销控制器 |
| | | */ |
| | | class User extends Controller |
| | | { |
| | | /** |
| | | * 队长申请列表 |
| | | */ |
| | | public function index($nick_name = '') |
| | | { |
| | | $model = new UserModel; |
| | | $list = $model->getList($nick_name); |
| | | |
| | | foreach ($list as $key => $val) { |
| | | $list[$key]['cash_total'] = sprintf('%.2f', $val['moeny'] + $val['freeze_money'] + $val['total_money']); |
| | | // 检查是否已有管理员账号 |
| | | $hasLogin = UserLoginModel::where('user_id', '=', $val['user_id']) |
| | | ->where('is_delete', '=', 0) |
| | | ->count(); |
| | | $list[$key]['has_login'] = $hasLogin > 0; |
| | | } |
| | | $basicSetting = SettingModel::getItem('basic'); |
| | | return $this->renderSuccess('', compact('list', 'basicSetting')); |
| | | } |
| | | |
| | | /** |
| | | * 编辑队长 |
| | | */ |
| | | public function edit() |
| | | { |
| | | if ($this->request->isGet()) { |
| | | $gradeList = GradeModel::getUsableList(); |
| | | $user_id = $this->getData('user_id'); |
| | | $model = UserModel::detail($user_id); |
| | | |
| | | // 检查是否已有管理员账号 |
| | | $hasLogin = UserLoginModel::where('user_id', '=', $user_id) |
| | | ->where('is_delete', '=', 0) |
| | | ->count(); |
| | | |
| | | $model['has_login'] = $hasLogin > 0; |
| | | |
| | | return $this->renderSuccess('', compact('gradeList', 'model')); |
| | | } |
| | | $data = $this->postData(); |
| | | $model = UserModel::detail($data['user_id']); |
| | | if ($model->edit($data)) { |
| | | return $this->renderSuccess('更新成功'); |
| | | } |
| | | return $this->renderError($model->getError() ?: '更新失败'); |
| | | } |
| | | |
| | | /** |
| | | * 队长用户列表 |
| | | */ |
| | | public function fans($user_id, $level = -1) |
| | | { |
| | | $model = new RefereeModel; |
| | | $list = $model->getList($user_id, $level); |
| | | $basicSetting = SettingModel::getItem('basic'); |
| | | return $this->renderSuccess('', compact('list', 'basicSetting')); |
| | | } |
| | | |
| | | /** |
| | | * 软删除队长用户 |
| | | */ |
| | | public function delete($user_id) |
| | | { |
| | | $model = UserModel::detail($user_id); |
| | | if (!$model->setDelete()) { |
| | | return $this->renderError('删除失败'); |
| | | } |
| | | return $this->renderSuccess('删除成功'); |
| | | } |
| | | |
| | | /** |
| | | * 添加区域代理 |
| | | */ |
| | | public function add() |
| | | { |
| | | if ($this->request->isGet()) { |
| | | $gradeList = GradeModel::getUsableList(); |
| | | return $this->renderSuccess('', compact('gradeList')); |
| | | } |
| | | $data = $this->postData(); |
| | | $model = new UserModel; |
| | | if ($model->addRegionUser($data)) { |
| | | return $this->renderSuccess('添加成功'); |
| | | } |
| | | return $this->renderError($model->getError() ?: '添加失败'); |
| | | } |
| | | |
| | | } |