From e4712f0f7921d8f34ed21491bc23308fcd38a718 Mon Sep 17 00:00:00 2001 From: lccsw <805383944@qq.com> Date: Fri, 9 Dec 2022 14:11:16 +0800 Subject: [PATCH] edit-sylive-org_select --- home/controllers/h5/market/sylive2/User.php | 169 ++++++++++ .../controllers/h5/market/sylive2/Welcome.php | 2 +- home/views/h5/market/sylive2/biz/index.php | 3 + home/views/h5/market/sylive2/index.php | 2 +- home/views/h5/market/sylive2/user/index.php | 17 +- home/views/h5/market/sylive2/user/team.php | 319 ------------------ 6 files changed, 184 insertions(+), 328 deletions(-) create mode 100644 home/controllers/h5/market/sylive2/User.php delete mode 100644 home/views/h5/market/sylive2/user/team.php diff --git a/home/controllers/h5/market/sylive2/User.php b/home/controllers/h5/market/sylive2/User.php new file mode 100644 index 00000000..4170b669 --- /dev/null +++ b/home/controllers/h5/market/sylive2/User.php @@ -0,0 +1,169 @@ +load->model('market/Market_sylive_organization_model', 'mdSyliveOrganization'); + $this->load->library('market/sylive_entity'); + $this->biz_id = 0; + $this->session['org_id']; + } + + public function index() + { + $row = $this->market_sylive_organization_model->get(['organizationId' => $this->biz_id]); + $headimg = $row['logo'] ? build_qiniu_image_url($row['logo']) : Sylive_entity::HD_IMG; + $this->data['headimg'] = $headimg; + $this->data['biz_name'] = $row['organizationName']; + $this->data['biz_id'] = $this->biz_id; + //微信分享 + $wx_info = $this->share_info(); + $this->data['sign_package'] = $wx_info['sign_package']; + $this->show_view('h5/market/sylive2/user/index'); + } + + public function lists() + { + $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, + "organizationId in (select organizationId from lc_market_sylive_organization where parentId={$this->biz_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() + { + $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_org = $this->market_sylive_organization_model->get(['parentId' => $this->biz_id, 'organizationType' => 4 + , 'status' => 0]); + if (!$re_org) { + $this->show_json('', 400, '门店未添加顾问类型,请联系管理员'); + } + $organizationId = $re_org['organizationId']; + $topOrgId = $this->getTopOrgId($organizationId); + $re = $this->user_model->get(['mobile' => $mobile, 'topOrgId' => $topOrgId]); + if ($re && $re['status'] != -1) { + if ($re['teamId'] || $re['organizationId']) { + $this->show_json('', 400, '手机号已存在'); + } + } + $addDate = ['topOrgId' => $topOrgId, 'organizationId' => $organizationId, 'biz_id' => $this->biz_id, + 'uname' => $uname, 'status' => 0, 'teamId' => 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() + { + $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, 'topOrgId' => $re['topOrgId']]); + 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() + { + $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, '操作成功'); + } + + /** + * Notes:获取顶级机构id + * Created on: 2022/12/8 14:39 + * Created by: dengbw + * @param $organizationId + * @param $topOrgId + * @return mixed + */ + private function getTopOrgId($organizationId, $topOrgId = 0) + { + $re = $this->mdSyliveOrganization->get(['organizationId' => $organizationId], 'organizationId,parentId'); + if (!$re) { + return $topOrgId; + } else { + $topOrgId = $re['organizationId']; + if ($re['parentId']) { + return $this->getTopOrgId($re['parentId'], $topOrgId); + } else { + return $topOrgId; + } + } + } + +} \ No newline at end of file diff --git a/home/controllers/h5/market/sylive2/Welcome.php b/home/controllers/h5/market/sylive2/Welcome.php index 614f14dc..afbd07a1 100644 --- a/home/controllers/h5/market/sylive2/Welcome.php +++ b/home/controllers/h5/market/sylive2/Welcome.php @@ -27,7 +27,7 @@ class Welcome extends Admin { 'url' => "/h5/market/sylive2/welcome/org?org_id={$levl_top['organizationId']}&userId={$val['userId']}" ]; - $org_lists[$temp['organizationId']] = $temp; + $org_lists[$levl_top['organizationId']] = $temp; } $_SESSION[self::SESSION_KEY]['multi_org'] = 1; $this->data['org_lists'] = $org_lists; diff --git a/home/views/h5/market/sylive2/biz/index.php b/home/views/h5/market/sylive2/biz/index.php index 069beb9e..f033ca15 100644 --- a/home/views/h5/market/sylive2/biz/index.php +++ b/home/views/h5/market/sylive2/biz/index.php @@ -6,6 +6,9 @@ 退出 + + 顾问管理 + 切换机构 diff --git a/home/views/h5/market/sylive2/index.php b/home/views/h5/market/sylive2/index.php index e97f7181..f5c1048d 100644 --- a/home/views/h5/market/sylive2/index.php +++ b/home/views/h5/market/sylive2/index.php @@ -8,7 +8,7 @@
- +
diff --git a/home/views/h5/market/sylive2/user/index.php b/home/views/h5/market/sylive2/user/index.php index 5de15778..485124ac 100644 --- a/home/views/h5/market/sylive2/user/index.php +++ b/home/views/h5/market/sylive2/user/index.php @@ -59,7 +59,10 @@ 新增顾问 - load->view('h5/market/sylive/nav') ?> + + +
首页
+
@@ -191,7 +194,7 @@ params['size'] = this.size; } //请求接口 - $.get('/h5/market/sylive/user/lists', params, function (result) { + $.get('/h5/market/sylive2/user/lists', params, function (result) { that.loading = false; that.isRefresh = false; if (result.code == 200) { @@ -241,13 +244,13 @@ }); } else { that.isSubmiting = true; - let url = '/h5/market/sylive/user/add'; + let url = '/h5/market/sylive2/user/add'; let params = {}; params['uname'] = that.uname; params['mobile'] = that.mobile; params['biz_id'] = ; if (that.formIndex > -1) { - url = '/h5/market/sylive/user/edit'; + url = '/h5/market/sylive2/user/edit'; params['userId'] = this.list[that.formIndex].userId; } $.post(url, params, function (response) { @@ -280,7 +283,7 @@ params['userId'] = that.list[that.ableIndex].userId; params['status'] = that.list[that.ableIndex].status == 1 ? 0 : 1; //执行接口 - $.post('/h5/market/sylive/user/status', params, function (response) { + $.post('/h5/market/sylive2/user/status', params, function (response) { mDialog.msg({content: response.msg}); if (response.code == 200) { that.list[that.ableIndex].status = that.list[that.ableIndex].status == 1 ? 0 : 1; @@ -300,7 +303,7 @@ let params = {}; params['userId'] = that.list[that.delIndex].userId; params['status'] = -1; - $.post('/h5/market/sylive/user/status', params, function (response) { + $.post('/h5/market/sylive2/user/status', params, function (response) { mDialog.msg({content: response.msg}); if (response.code == 200) { that.isShowDel = false; @@ -316,5 +319,5 @@ }, }) -load->view('h5/market/sylive/hidden_wx_share') ?> +load->view('h5/market/sylive2/hidden_wx_share') ?> \ No newline at end of file diff --git a/home/views/h5/market/sylive2/user/team.php b/home/views/h5/market/sylive2/user/team.php deleted file mode 100644 index 09a1e09e..00000000 --- a/home/views/h5/market/sylive2/user/team.php +++ /dev/null @@ -1,319 +0,0 @@ - -
-
-
-
-
- # - {{info.title}} -
-
-
-
- -
-
-
-
- -
-
-
{{item.uname}}·{{item.mobile}}
-
- # - {{item.wxuname}} -
-
暂未绑定微信
-
-
- 修改 - | - 删除 - | - 启用 - 禁用 -
-
- -
- -
暂无数据
-
请稍等... -
-
我们是有底线的
-
-
-
- load->view('h5/market/sylive/nav') ?> -
-
- - 绑定微信后,信息无法修改 -
- 新增团员 -
-
-
-
-
-
-
- -
-
- -
-
- -
-
-
- -
-
-
-
-
确认删除{{list[delIndex].uname}}"吗?"
-
- 确定 - 取消 -
-
-
-
- -
-
-
-
-
- {{list[ableIndex].status==1?'确认启用':'确认禁用'}}{{list[ableIndex].uname}}"吗?" -
-
- 确定 - 取消 -
-
-
-
- -
- - -load->view('h5/market/sylive/hidden_wx_share') ?> - \ No newline at end of file