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 @@
新增顾问
- $this->load->view('h5/market/sylive/nav') ?>
+
+
+