diff --git a/home/controllers/h5/market/sylive/Team.php b/home/controllers/h5/market/sylive/Team.php index 1b1fbc7b..56bd85cb 100644 --- a/home/controllers/h5/market/sylive/Team.php +++ b/home/controllers/h5/market/sylive/Team.php @@ -45,7 +45,7 @@ class Team extends Admin{ $row = $this->market_sylive_team_model->get(['teamId'=>$team_id]); $this->data['headimg'] = Sylive_entity::DF_IMG; $this->data['biz_name'] = $row['teamName']; - $this->data['team_id'] = $this->input->get('team_id'); + $this->data['team_id'] = $team_id; $this->data['teamLevel'] = $this->teamLevel; //微信分享 $wx_info = $this->share_info(); diff --git a/home/controllers/h5/market/sylive/User.php b/home/controllers/h5/market/sylive/User.php index 0124e68d..0ac288ec 100644 --- a/home/controllers/h5/market/sylive/User.php +++ b/home/controllers/h5/market/sylive/User.php @@ -13,9 +13,12 @@ class User extends Admin $this->load->model('market/Market_sylive_organization_model', 'mdSyliveOrganization'); $this->load->library('market/sylive_entity'); $this->group_id = $this->sylive_entity->get_level($this->session['org_id']); - $biz_id = intval($this->input->get('biz_id')); - !$biz_id && $biz_id = intval($this->input->post('biz_id')); - $this->group_id == 2 && $biz_id = $this->session['org_id']; + if ($this->group_id == 2) { + $biz_id = $this->session['org_id']; + } else { + $biz_id = intval($this->input->get('biz_id')); + !$biz_id && $biz_id = intval($this->input->post('biz_id')); + } $this->biz_id = $biz_id; } diff --git a/home/controllers/h5/market/sylive/UserTeam.php b/home/controllers/h5/market/sylive/UserTeam.php new file mode 100644 index 00000000..afb797b6 --- /dev/null +++ b/home/controllers/h5/market/sylive/UserTeam.php @@ -0,0 +1,166 @@ +load->model('market/Market_sylive_user_model', 'mdSyliveUser'); + $this->load->model('market/Market_sylive_team_model', 'mdSyliveTeam'); + $this->load->library('market/sylive_entity'); + $this->teamLevel = $this->sylive_entity->get_team_level($this->session['teamId']); + if ($this->teamLevel == 1) { + $team_id = $this->session['teamId']; + } else { + $team_id = intval($this->input->get('team_id')); + !$team_id && $team_id = intval($this->input->post('team_id')); + } + $this->team_id = $team_id; + } + + public function index() + { + if ($this->teamLevel != 1) { + throw new Hd_exception('权限不足', 400); + } + $row = $this->mdSyliveTeam->get(['teamId' => $this->team_id]); + $this->data['headimg'] = Sylive_entity::DF_IMG; + $this->data['team_name'] = $row['teamName']; + $this->data['team_id'] = $this->team_id; + //微信分享 + $wx_info = $this->share_info(); + $this->data['sign_package'] = $wx_info['sign_package']; + $this->show_view('h5/market/sylive/user/team'); + } + + public function lists() + { + if ($this->teamLevel != 1) { + $this->show_json('', 400, '权限不足'); + } + $keyWord = $this->input->get('keyWord'); + $page = intval($this->input->get('page')); + $size = intval($this->input->get('size')); + !$page && $page = 1; + !$size && $size = 10; + $where = [ + 'status<>' => -1, + "teamId in (select teamId from lc_market_sylive_team where parentId={$this->team_id})" => null + ]; + $keyWord && $where["uname like '%{$keyWord}%'"] = null; + $total = $this->user_model->count($where); + $lists = []; + if ($total) { + $res = $this->user_model->select($where, 'userId desc', $page, $size, 'userId,mobile,uname,nickname,headimg,status'); + foreach ($res as $val) { + $temp = [ + 'userId' => $val['userId'], + 'status' => $val['status'], + 'uname' => $val['uname'], + 'mobile' => $val['mobile'], + 'wxuname' => $val['nickname'], + 'wxheadimg' => $val['headimg'] + ]; + $lists[] = $temp; + } + } + $data['list'] = $lists; + $data['total'] = $total; + $this->show_json($data, 200); + } + + public function add() + { + if ($this->teamLevel != 1) { + $this->show_json('', 400, '权限不足'); + } + $uname = $this->input->post('uname'); + $mobile = $this->input->post('mobile'); + if (!$uname) { + $this->show_json('', 400, '请输入团员姓名'); + } + if (!mobile_valid($mobile)) { + $this->show_json('', 400, '请输入正确手机号'); + } + $re_team = $this->mdSyliveTeam->get(['parentId' => $this->team_id, 'teamType' => 3, 'status' => 0]); + if (!$re_team) { + $this->show_json('', 400, '门店未添加团员类型,请联系管理员'); + } + $teamId = $re_team['teamId']; + $re = $this->user_model->get(['mobile' => $mobile]); + if ($re && $re['status'] != -1) { + if ($re['teamId'] || $re['organizationId']) { + $this->show_json('', 400, '手机号已存在'); + } + } + $addDate = ['teamId' => $teamId, 'uname' => $uname, 'status' => 0, 'organizationId' => 0]; + if ($re['userId']) { + $this->user_model->update($addDate, ['userId' => $re['userId']]); + $this->show_json('', 200, '绑定用户成功'); + } else { + $addDate['mobile'] = $mobile; + $addDate['createTime'] = date('Y-m-d H:i:s'); + $id = $this->user_model->add($addDate); + if (!$id) { + $this->show_json('', 400, '添加用户失败'); + } + $this->show_json('', 200, '操作成功'); + } + } + + public function edit() + { + if ($this->teamLevel != 1) { + $this->show_json('', 400, '权限不足'); + } + $uname = $this->input->post('uname'); + $mobile = $this->input->post('mobile'); + $userId = intval($this->input->post('userId')); + if (!$userId) { + $this->show_json('', 400, '参数错误'); + } + if (!$uname) { + $this->show_json('', 400, '请输入团员姓名'); + } + if (!mobile_valid($mobile)) { + $this->show_json('', 400, '请输入正确手机号'); + } + $re = $this->user_model->get(['userId' => $userId]); + if (!$re) { + $this->show_json('', 400, '无此团员'); + } + if ($re['mobile'] == $mobile) { + $uppDate = ['uname' => $uname]; + } else { + $re = $this->user_model->get(['mobile' => $mobile]); + if ($re && $re['status'] != -1) { + if ($re['teamId'] || $re['organizationId']) { + $this->show_json('', 400, '手机号已存在'); + } + } + $uppDate = ['uname' => $uname, 'mobile' => $mobile]; + } + $this->user_model->update($uppDate, ['userId' => $re['userId']]); + $this->show_json('', 200, '操作成功'); + } + + public function status() + { + if ($this->teamLevel != 1) { + $this->show_json('', 400, '权限不足'); + } + $userId = intval($this->input->post('userId')); + $status = intval($this->input->post('status')); + if (!$userId) { + $this->show_json('', 400, '参数错误'); + } + $this->user_model->update(['status' => $status], ['userId' => $userId]); + $this->show_json('', 200, '操作成功'); + } + +} \ No newline at end of file diff --git a/home/views/h5/market/sylive/team/index.php b/home/views/h5/market/sylive/team/index.php index baa49a5f..b92c3a39 100644 --- a/home/views/h5/market/sylive/team/index.php +++ b/home/views/h5/market/sylive/team/index.php @@ -1,13 +1,14 @@