From 4d1e6d3a0fc667e767e484b1ee6839744ae64e98 Mon Sep 17 00:00:00 2001 From: qianhy Date: Mon, 22 May 2023 11:08:37 +0800 Subject: [PATCH] licheb user add group1 about --- admin/controllers/app/licheb/Channel.php | 26 +- admin/controllers/app/licheb/Member.php | 69 ++++- admin/views/app/licheb/member/get.php | 256 +++++++++++++++++- admin/views/app/licheb/member/lists.php | 14 +- api/controllers/wxapp/Wxapp.php | 12 + api/controllers/wxapp/licheb/User.php | 82 ++++++ .../licheb/App_licheb_channel_biz1_model.php | 18 ++ .../app/licheb/App_licheb_users_model.php | 2 +- 8 files changed, 447 insertions(+), 32 deletions(-) create mode 100644 common/models/app/licheb/App_licheb_channel_biz1_model.php diff --git a/admin/controllers/app/licheb/Channel.php b/admin/controllers/app/licheb/Channel.php index fb4c9dd4..3c5568ce 100644 --- a/admin/controllers/app/licheb/Channel.php +++ b/admin/controllers/app/licheb/Channel.php @@ -83,13 +83,15 @@ class Channel extends HD_Controller private function dataSelect($params) { + $channel_biz_table = $params['group_id1'] ? 'lc_app_licheb_channel_biz1' : 'lc_app_licheb_channel_biz'; $lists = []; $where['lc_biz.status'] = 1; $_title = '门店列表'; if ($params['uid']) { - $where['lc_app_licheb_channel_biz.uid'] = $params['uid']; + $where[$channel_biz_table.'.uid'] = $params['uid']; $re = $this->mdUsers->get(array('id' => $params['uid'])); - $re['uname'] && $_title = $re['uname'] . '_门店列表'; + $group = $params['group_id1'] ? ' (第二角色)' :''; + $re['uname'] && $_title = $re['uname'] .$group. '_门店列表'; } !$params['city_id'] && $params['city_id'] = ''; !$params['county_id'] && $params['county_id'] = ''; @@ -102,20 +104,20 @@ class Channel extends HD_Controller if ($params['county_id']) { $where['lc_biz.county_id'] = $params['county_id']; } - $count = $this->db->select('lc_app_licheb_channel_biz.biz_id') - ->join('lc_biz', 'lc_biz.id = lc_app_licheb_channel_biz.biz_id', 'left') + $count = $this->db->select($channel_biz_table.'.biz_id') + ->join('lc_biz', 'lc_biz.id = '.$channel_biz_table.'.biz_id', 'left') ->where($where) - ->count_all_results('lc_app_licheb_channel_biz'); + ->count_all_results($channel_biz_table); if ($count) { $offset = ($params['page'] - 1) * $params['size']; $limit = $params['size']; - $this->db->from('lc_app_licheb_channel_biz'); - $this->db->join('lc_biz', "lc_biz.id = lc_app_licheb_channel_biz.biz_id", 'left'); + $this->db->from($channel_biz_table); + $this->db->join('lc_biz', "lc_biz.id = ".$channel_biz_table.".biz_id", 'left'); $this->db->select('lc_biz.id,lc_biz.biz_name,lc_biz.county_id,lc_biz.c_time'); $this->db->where($where); - $this->db->order_by('lc_app_licheb_channel_biz.id Desc'); + $this->db->order_by($channel_biz_table.'.id Desc'); $this->db->limit($limit, $offset); - !$params['uid'] && $this->db->group_by('lc_app_licheb_channel_biz.biz_id'); + !$params['uid'] && $this->db->group_by($channel_biz_table.'.biz_id'); $res = $this->db->get()->result_array(); $county_id_arr = array_unique(array_column($res, 'county_id')); $Areas = $this->mdArea->get_map_by_county_ids($county_id_arr, 'city_name,county_name,county_id', 'county_id'); @@ -131,10 +133,10 @@ class Channel extends HD_Controller $setValue['orders'] = $this->mdOrders->count(['biz_id' => $value['id'], 'status>=' => 0, 'brand_id<>' => 3, 'biz_id<>' => 1]); $setValue['days'] = round((time() - $value['c_time']) / 3600 / 24) . '天'; if (!$params['uid']) { - $this->db->from('lc_app_licheb_channel_biz'); - $this->db->join('lc_app_licheb_users', "lc_app_licheb_users.id = lc_app_licheb_channel_biz.uid", 'left'); + $this->db->from($channel_biz_table); + $this->db->join('lc_app_licheb_users', "lc_app_licheb_users.id = ".$channel_biz_table.".uid", 'left'); $this->db->select('lc_app_licheb_users.uname'); - $this->db->where(['lc_app_licheb_channel_biz.biz_id' => $value['id']]); + $this->db->where([$channel_biz_table.'.biz_id' => $value['id']]); $res_u = $this->db->get()->result_array(); $unames = $res_u ? implode(',', array_column($res_u, 'uname')) : ''; $setValue['uname'] = $unames; diff --git a/admin/controllers/app/licheb/Member.php b/admin/controllers/app/licheb/Member.php index 820377d9..228fd2b7 100755 --- a/admin/controllers/app/licheb/Member.php +++ b/admin/controllers/app/licheb/Member.php @@ -12,6 +12,7 @@ class Member extends HD_Controller parent::__construct(); $this->load->model('app/licheb/App_licheb_users_model', 'userM'); $this->load->model('app/licheb/App_licheb_channel_biz_model', 'mdChannelBiz'); + $this->load->model('app/licheb/App_licheb_channel_biz1_model', 'mdChannelBiz1'); $this->load->model("biz/biz_model"); } @@ -63,6 +64,17 @@ class Member extends HD_Controller } $lists[$key]['biz_name'] = $biz_name; $lists[$key]['group_name'] = $this->groups[$val['group_id']]; + + $biz_name = ''; + if ($val['group_id1'] == 4) { + $biz_name = ' 门店列表'; + } else if ($val['biz_id1']) { + $re_biz = $this->biz_model->get(['id' => $val['biz_id1']], 'biz_name'); + $re_biz && $biz_name = $re_biz['biz_name']; + } + $lists[$key]['biz_name1'] = $biz_name; + $lists[$key]['group_name1'] = $this->groups[$val['group_id1']]; + if (SUPER_ADMIN == $this->role) {//超级管理员才允许操作用户的披上超级马甲 $majia = array(); if ($val['jsondata']) { @@ -90,6 +102,7 @@ class Member extends HD_Controller $id = $this->input->get('id'); $row = $this->userM->get(['id' => $id]); $selectedBrands = []; + $selectedBrands1 = []; if ($id) { $info = array( 'id' => $row['id'], @@ -98,6 +111,9 @@ class Member extends HD_Controller 'group_id' => $row['group_id'], 'biz_id' => $row['biz_id'], 'city_id' => $row['city_id'], + 'group_id1' => $row['group_id1'], + 'biz_id1' => $row['biz_id1'], + 'city_id1' => $row['city_id1'], ); if ($row['group_id'] == 4) { $this->load->model('app/licheb/App_licheb_channel_biz_model', 'mdChannelBiz'); @@ -116,6 +132,24 @@ class Member extends HD_Controller $selectedBrands[] = ['biz_id' => $re_biz['id'], 'name' => $re_biz['biz_name']]; } } + # group_id1 + if ($row['group_id1'] == 4) { + $this->load->model('app/licheb/App_licheb_channel_biz1_model', 'mdChannelBiz1'); + $res_biz = $this->mdChannelBiz1->select(['uid' => $id], 'id desc', 0, 0, 'biz_id'); + $res_biz && $biz_id_arr = array_unique(array_column($res_biz, 'biz_id')); + if ($res_biz) { + $biz_id_arr = array_unique(array_column($res_biz, 'biz_id')); + $ids = implode(',', $biz_id_arr); + $typeAry = $this->biz_model->type_ary(); + $type_ids = implode(',',array_keys($typeAry)); + $selectedBrands1 = $this->biz_model->select(["id in ($ids)" => null, "type in ($type_ids)" => null, 'status' => 1], '', 0, 0, 'id as biz_id,biz_name as name'); + } + } else if ($row['biz_id1']) { + $re_biz = $this->biz_model->get(["id" => $row['biz_id1'], 'status' => 1], 'id ,biz_name'); + if ($re_biz) { + $selectedBrands1[] = ['biz_id' => $re_biz['id'], 'name' => $re_biz['biz_name']]; + } + } $action = '/app/licheb/member/edit'; $_title = '编辑用户'; } else { @@ -135,6 +169,7 @@ class Member extends HD_Controller #$show_info['typeAry'] = $this->biz_model->type_ary(); $show_info['cityList'] = $this->mdSysCity->select(['status' => 1], 'id desc', 0, 0, 'city_id,name'); $this->data['selectedBrands'] = $selectedBrands; + $this->data['selectedBrands1'] = $selectedBrands1; $this->data['show_info'] = $show_info; $this->data['info'] = $info; $this->data['groups'] = $this->groups; @@ -153,6 +188,10 @@ class Member extends HD_Controller $bizs = $info['bizs']; $city_id = $info['city_id']; $biz_id_arr = array_column($bizs, 'biz_id'); + $group_id1 = $info['group_id1']; + $bizs1 = $info['bizs1']; + $city_id1 = $info['city_id1']; + $biz_id_arr1 = is_array($bizs1) ? array_column($bizs1, 'biz_id') : ''; if (!mobile_valid($mobile)) { return $this->show_json(SYS_CODE_FAIL, '输入正确手机号'); @@ -170,15 +209,22 @@ class Member extends HD_Controller 'mobile' => $mobile, 'uname' => $uname, 'city_id' => $city_id, + 'city_id1' => $city_id1, 'status' => 1, 'c_time' => time(), ); $group_id && $add['group_id'] = $group_id; $biz_id_arr && $add['biz_id'] = implode(',', $biz_id_arr); + $group_id1 && $add['group_id1'] = $group_id1; + $biz_id_arr1 && $add['biz_id1'] = implode(',', $biz_id_arr1); + $id = $this->userM->add($add); if ($id && $group_id == 4 && $biz_id_arr) {//加狸车宝渠道门店 $this->channel_biz(["uid" => $id, 'biz_id_arr' => $biz_id_arr]); } + if ($id && $group_id1 == 4 && $biz_id_arr1) {//加狸车宝渠道门店 group_id1 + $this->channel_biz(["uid" => $id, 'biz_id_arr' => $biz_id_arr1, 'edit' => 1, 'group_id1'=>true]); + } return $this->show_json(SYS_CODE_SUCCESS, '操作成功', '/app/licheb/member'); } @@ -194,10 +240,17 @@ class Member extends HD_Controller $bizs = $info['bizs']; $city_id = $info['city_id']; $biz_id_arr = is_array($bizs) ? array_column($bizs, 'biz_id') : ''; + $group_id1 = $info['group_id1']; + $bizs1 = $info['bizs1']; + $city_id1 = $info['city_id1']; + $biz_id_arr1 = is_array($bizs1) ? array_column($bizs1, 'biz_id') : ''; if (!mobile_valid($mobile)) { return $this->show_json(SYS_CODE_FAIL, '输入正确手机号'); } + if (!$uname) { + return $this->show_json(SYS_CODE_FAIL, '请输入姓名'); + } $exist = $this->userM->get(array('mobile' => $mobile, 'status in (0, 1)' => null, 'id <>' => $id)); if ($exist) { @@ -207,10 +260,13 @@ class Member extends HD_Controller $upd = array( 'mobile' => $mobile, 'city_id' => $city_id, + 'city_id1' => $city_id1, ); $upd['group_id'] = $group_id ? $group_id : 0; $upd['biz_id'] = $biz_id_arr ? implode(',', $biz_id_arr) : 0; + $upd['group_id1'] = $group_id1 ? $group_id1 : 0; + $upd['biz_id1'] = $biz_id_arr1 ? implode(',', $biz_id_arr1) : 0; $nickname && $upd['nickname'] = $nickname; $uname && $upd['uname'] = $uname; @@ -219,6 +275,9 @@ class Member extends HD_Controller if ($id && $group_id == 4) {//加狸车宝渠道门店 $this->channel_biz(["uid" => $id, 'biz_id_arr' => $biz_id_arr, 'edit' => 1]); } + if ($id && $group_id1 == 4) {//加狸车宝渠道门店 group_id1 + $this->channel_biz(["uid" => $id, 'biz_id_arr' => $biz_id_arr1, 'edit' => 1, 'group_id1'=>true]); + } return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); } @@ -319,10 +378,12 @@ class Member extends HD_Controller function channel_biz($json = []) { $biz_ids = $json['biz_id_arr'] ? implode(',', $json['biz_id_arr']) : 0; + $group_id1 = $json['group_id1'] ? true : false; if ($json['edit'] == 1) {//编辑删除未添加的 $where_d['uid'] = $json['uid']; $biz_ids && $where_d["biz_id not in({$biz_ids})"] = null; - $this->mdChannelBiz->delete($where_d); + !$group_id1 && $this->mdChannelBiz->delete($where_d); + $group_id1 && $this->mdChannelBiz1->delete($where_d); } if (!$biz_ids) { return; @@ -330,10 +391,12 @@ class Member extends HD_Controller $res_b = $this->biz_model->select(["id in({$biz_ids})" => null], '', 0, 0, 'id as biz_id'); foreach ($res_b as $key => $value) { $where = ["uid" => $json['uid'], 'biz_id' => $value['biz_id']]; - $re_cb = $this->mdChannelBiz->get($where); + !$group_id1 && $re_cb = $this->mdChannelBiz->get($where); + $group_id1 && $re_cb = $this->mdChannelBiz1->get($where); if (!$re_cb) { $where['c_time'] = time(); - $this->mdChannelBiz->add($where); + !$group_id1 && $this->mdChannelBiz->add($where); + $group_id1 && $this->mdChannelBiz1->add($where); } } } diff --git a/admin/views/app/licheb/member/get.php b/admin/views/app/licheb/member/get.php index b6d0c26b..0ece07f6 100755 --- a/admin/views/app/licheb/member/get.php +++ b/admin/views/app/licheb/member/get.php @@ -2,20 +2,20 @@ style="width: 90%;padding-top: 10px">
- -
+ +
- -
+ +
- -
+ +
@@ -32,8 +32,8 @@
- -
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+
+
+
@@ -134,6 +164,96 @@
+
+ + +