diff --git a/admin/controllers/receiver/Customer.php b/admin/controllers/receiver/Customer.php index 62d3994a..9e059524 100644 --- a/admin/controllers/receiver/Customer.php +++ b/admin/controllers/receiver/Customer.php @@ -88,6 +88,8 @@ class Customer extends HD_Controller ); } } + $tag_data = $params['tags'] ? explode(',', $params['tags']) : ''; + $show_info['tags'] = $this->get_tag(0, 0, $tag_data); //渠道经理 $qdjl_lists = $this->app_licheb_users_model->select(array('group_id' => 4, 'status' => 1, 'biz_id<>' => '0'), 'id desc', 0, 0, 'id,uname as name'); $show_info['levelAry'] = $this->customers_model->get_sdata('level'); @@ -116,6 +118,7 @@ class Customer extends HD_Controller !$params['of_id'] && $params['of_id'] = ''; !$params['of2_id'] && $params['of2_id'] = ''; !$params['biz_type'] && $params['biz_type'] = ''; + !$params['tags'] && $params['tags'] = ''; $where = array('status>=0' => null); if ($_SESSION['admin_info']['biz_id']) { $biz_ids = implode(',', $_SESSION['admin_info']['biz_id']); @@ -214,6 +217,37 @@ class Customer extends HD_Controller } } } + if ($params['tags']) { + $pidAry = []; + $res_tag = $this->mdCustomerTag->select(["id in ({$params['tags']})" => null], 'id desc', 0, 0, 'pid,id'); + foreach ($res_tag as $v) { + $v['pid'] && $pidAry[$v['pid']][] = $v['id']; + } + $str_c_ids = $res_tag_data = ''; + foreach ($pidAry as $v) { + if ($v) { + $where_tag = []; + $str_ids = implode(',', $v); + $where_tag["t_id in({$str_ids})"] = null; + if ($str_c_ids) { + $where_tag["c_id in({$str_c_ids})"] = null; + } + $res_tag_data = $this->mdCustomerTagdata->select_groupby('c_id', $where_tag, "id desc", 0, 0, "c_id"); + if (!$res_tag_data) { + break; + } + if ($res_tag_data) { + $str_c_ids = implode(',', array_column($res_tag_data, 'c_id')); + } + } + } + if ($res_tag_data) { + $str_cids = implode(',', array_column($res_tag_data, 'c_id')); + $where["id in({$str_cids})"] = null; + } else { + $where["id"] = -1; + } + } return $where; } @@ -643,13 +677,15 @@ class Customer extends HD_Controller return $id; } - private function get_tag($id,$tag_type=0) + private function get_tag($id, $tag_type = 0, $tag_data = '') { $show = $res_td = []; $res = $this->mdCustomerTag->select(['status' => 1, 'pid' => 0, 'show<>' => 1, 'tag_type' => $tag_type], 'sort desc,id desc', 0, 0, 'id,name,type'); if ($res) { - $id && $res_td = $this->mdCustomerTagdata->select(['c_id' => $id], 'id desc', 0, 0, 't_id');//查找用户选择 - $tag_data = $res_td ? array_unique(array_column($res_td, 't_id')) : ''; + if ($id) { + $res_td = $this->mdCustomerTagdata->select(['c_id' => $id], 'id desc', 0, 0, 't_id');//查找用户选择 + $res_td && $tag_data = array_unique(array_column($res_td, 't_id')); + } foreach ($res as $key => $val) { $list = []; $value = ''; diff --git a/admin/controllers/receiver/Owners.php b/admin/controllers/receiver/Owners.php index 0b68d967..9118f835 100644 --- a/admin/controllers/receiver/Owners.php +++ b/admin/controllers/receiver/Owners.php @@ -54,6 +54,7 @@ class Owners extends HD_Controller !$params['brand_id'] && $params['brand_id'] = ''; !$params['s_id'] && $params['s_id'] = ''; !$params['v_id'] && $params['v_id'] = ''; + !$params['tags'] && $params['tags'] = ''; if (strlen($params['status'])) { $where["a.status"] = $params['status']; } else { @@ -117,6 +118,37 @@ class Owners extends HD_Controller } else if ($params['city_id_admin']) { $where["b.biz_id in(select id from lc_biz where city_id={$params['city_id_admin']})"] = null; } + if ($params['tags']) { + $pidAry = []; + $res_tag = $this->mdOwnersTag->select(["id in ({$params['tags']})" => null], 'id desc', 0, 0, 'pid,id'); + foreach ($res_tag as $v) { + $v['pid'] && $pidAry[$v['pid']][] = $v['id']; + } + $str_o_ids = $res_tag_data = ''; + foreach ($pidAry as $v) { + if ($v) { + $where_tag = []; + $str_ids = implode(',', $v); + $where_tag["t_id in({$str_ids})"] = null; + if ($str_o_ids) { + $where_tag["o_id in({$str_o_ids})"] = null; + } + $res_tag_data = $this->mdOwnersTagdata->select_groupby('o_id', $where_tag, "id desc", 0, 0, "o_id"); + if (!$res_tag_data) { + break; + } + if ($res_tag_data) { + $str_o_ids = implode(',', array_column($res_tag_data, 'o_id')); + } + } + } + if ($res_tag_data) { + $str_oids = implode(',', array_column($res_tag_data, 'o_id')); + $where["a.id in({$str_oids})"] = null; + } else { + $where["a.id"] = -1; + } + } $lists = []; $wxqyAry = $this->mdOwners->wxqyAry(); $statusAry = $this->mdOwners->statusAry(); @@ -145,8 +177,8 @@ class Owners extends HD_Controller #$str_biz_ids = implode(',', array_unique(array_column($res, 'biz_id'))); #$map_bizs = $this->mdBiz->map('id', 'biz_name', ["id in({$str_biz_ids})" => null]); $arr_biz_id = array_unique(array_column($res, 'biz_id')); - foreach ($arr_biz_id as $k => $v){ - if ($v == null || $v == ''){ + foreach ($arr_biz_id as $k => $v) { + if ($v == null || $v == '') { unset($arr_biz_id[$k]); } } @@ -155,8 +187,8 @@ class Owners extends HD_Controller #$str_admin_ids = implode(',', array_unique(array_column($res, 'admin_id'))); #$map_admins = $this->mdLichebUsers->map('id', 'uname', ["id in({$str_admin_ids})" => null]); $arr_admin_id = array_unique(array_column($res, 'admin_id')); - foreach ($arr_admin_id as $k => $v){ - if ($v == null || $v == ''){ + foreach ($arr_admin_id as $k => $v) { + if ($v == null || $v == '') { unset($arr_admin_id[$k]); } } @@ -202,6 +234,8 @@ class Owners extends HD_Controller ]; } } + $tag_data = $params['tags'] ? explode(',', $params['tags']) : ''; + $show_info['tags'] = $this->get_tag(0, $tag_data); $show_info['searchTpAry'] = $this->searchTpAry; $show_info['wxqyAry'] = $wxqyAry; $show_info['statusAry'] = $statusAry; @@ -454,11 +488,11 @@ class Owners extends HD_Controller $temp['u_time'] = $value['u_time']; $tag = $this->get_tag($value['id']); - foreach ($tag as $key2 => $val2){ + foreach ($tag as $key2 => $val2) { $tag_id_key = 'tag_id_' . $val2['id']; $tag_name = $val2['name']; $tag_value = $val2['value_name']; - if (!in_array($tag_id_key, array_keys($indexs_tags))){ + if (!in_array($tag_id_key, array_keys($indexs_tags))) { $indexs_tags[$tag_id_key] = $tag_name; } $temp[$tag_id_key] = $tag_value; @@ -520,15 +554,18 @@ class Owners extends HD_Controller * Created on: 2022/6/16 14:47 * Created by: dengbw * @param $id + * @param $tag_data * @return array */ - private function get_tag($id) + private function get_tag($id, $tag_data = '') { $show = $res_td = []; $res = $this->mdOwnersTag->select(['status' => 1, 'pid' => 0], 'sort desc,id desc', 0, 0, 'id,name,type'); if ($res) { - $id && $res_td = $this->mdOwnersTagdata->select(['o_id' => $id], 'id desc', 0, 0, 't_id');//查找用户选择 - $tag_data = $res_td ? array_unique(array_column($res_td, 't_id')) : ''; + if ($id) { + $res_td = $this->mdOwnersTagdata->select(['o_id' => $id], 'id desc', 0, 0, 't_id');//查找用户选择 + $tag_data = $res_td ? array_unique(array_column($res_td, 't_id')) : ''; + } foreach ($res as $key => $val) { $list = []; $value = ''; diff --git a/admin/views/receiver/customer/lists.php b/admin/views/receiver/customer/lists.php index e21cd6eb..86f58ad2 100644 --- a/admin/views/receiver/customer/lists.php +++ b/admin/views/receiver/customer/lists.php @@ -18,8 +18,6 @@