diff --git a/admin/controllers/receiver/Customer.php b/admin/controllers/receiver/Customer.php index edede350..2201dbb1 100644 --- a/admin/controllers/receiver/Customer.php +++ b/admin/controllers/receiver/Customer.php @@ -270,6 +270,8 @@ class Customer extends HD_Controller } else { $tag = $this->get_tag($row['id']); } + $invalid_user_tag = []; + $row['status']==3 && $invalid_user_tag = $this->get_tag($row['id'],1); $to_send = ''; if ($row['cs_biz_id'] == -1) { $to_send = '已改派'; @@ -288,6 +290,7 @@ class Customer extends HD_Controller 'c_time' => date('Y-m-d H:i:s', $row['c_time']), 'status' => $row['status'], 'tag' => $tag, + 'invalid_user_tag' => $invalid_user_tag, 'tag_group' => $tag_group, 'biz_type' => $biz_type, ); @@ -449,17 +452,18 @@ class Customer extends HD_Controller $msg = '修改用户信息成功'; $this->addLog(array('customer_id' => $info['id'], 'type' => 0, 'log' => $log)); } - } else if ($info['editType'] == 3) { + } else if ($info['editType'] == 3 || $info['editType'] == 4) { $id = $info['id']; //客户标签 - if (!$info['tag']) { + if (!$info['tag'] && $info['editType']==3) { return $this->show_json(SYS_CODE_FAIL, '客户画像不存在!'); } $add_tag = []; //查找已加入标签 $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')) : ''; - foreach ($info['tag'] as $key => $val) { + $tag_lists = $info['editType']==3 ? $info['tag'] : $info['invalid_user_tag']; + foreach ($tag_lists as $key => $val) { foreach ($val['list'] as $key2 => $val2) { if ($val['type'] == 'checkbox') { if ($val2['checked'] == 'true') { @@ -487,7 +491,8 @@ class Customer extends HD_Controller if ($add_tag && count($add_tag)) { $this->mdCustomerTagdata->add_batch($add_tag); } - $this->addLog(array('customer_id' => $info['id'], 'type' => 0, 'log' => '修改用户画像')); + $log_msg = $info['editType']==3 ? '修改用户画像' : '修改战败标签'; + $this->addLog(array('customer_id' => $info['id'], 'type' => 0, 'log' => $log_msg)); } return $this->show_json($code, $msg); } @@ -631,10 +636,10 @@ class Customer extends HD_Controller return $id; } - private function get_tag($id) + private function get_tag($id,$tag_type=0) { $show = $res_td = []; - $res = $this->mdCustomerTag->select(['status' => 1, 'pid' => 0, 'show<>' => 1], 'sort desc,id desc', 0, 0, 'id,name,type'); + $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')) : ''; diff --git a/admin/controllers/receiver/OwnersTag.php b/admin/controllers/receiver/OwnersTag.php index b7839119..adcbf72f 100644 --- a/admin/controllers/receiver/OwnersTag.php +++ b/admin/controllers/receiver/OwnersTag.php @@ -4,7 +4,11 @@ defined('BASEPATH') OR exit('No direct script access allowed'); class OwnersTag extends HD_Controller { - private $tabAry = [1 => ['title' => '客户标签', 'url' => '/receiver/tag'], 2 => ['title' => '车主标签', 'url' => '/receiver/ownersTag']]; + private $tabAry = [ + 1 => ['title' => '客户标签', 'url' => '/receiver/tag'], + 2 => ['title' => '车主标签', 'url' => '/receiver/ownersTag'], + 3 => ['title' => '战败标签', 'url' => '/receiver/tag?tag_type=1'] + ]; public function __construct() { diff --git a/admin/controllers/receiver/Tag.php b/admin/controllers/receiver/Tag.php index bc7d60ab..d11947dc 100644 --- a/admin/controllers/receiver/Tag.php +++ b/admin/controllers/receiver/Tag.php @@ -4,7 +4,11 @@ defined('BASEPATH') OR exit('No direct script access allowed'); class Tag extends HD_Controller { - private $tabAry = [1 => ['title' => '客户标签', 'url' => '/receiver/tag'], 2 => ['title' => '车主标签', 'url' => '/receiver/ownersTag']]; + private $tabAry = [ + 1 => ['title' => '客户标签', 'url' => '/receiver/tag'], + 2 => ['title' => '车主标签', 'url' => '/receiver/ownersTag'], + 3 => ['title' => '战败标签', 'url' => '/receiver/tag?tag_type=1'] + ]; public function __construct() { @@ -24,12 +28,13 @@ class Tag extends HD_Controller $params = $this->input->get(); $params['page'] = $params['page'] ? intval($params['page']) : 1; $params['size'] = $params['size'] ? intval($params['size']) : 20; - $params['tab'] = 1; + $params['tab'] = $params['tag_type'] ? 3 : 1; $statusAry = $this->mdCustomerTag->statusAry(); $typeAry = $this->mdCustomerTag->typeAry(); $showAry = $this->mdCustomerTag->showAry(); $lists = array(); $where = ["status<>-1" => null, 'pid' => 0]; + $where['tag_type'] = $params['tag_type'] ? 1 : 0; if (strlen($params['status'])) { $where['status'] = $params['status']; } @@ -81,6 +86,8 @@ class Tag extends HD_Controller public function get() { $id = intval($this->input->get('id')); + $tag_type = $this->input->get('tag_type'); + !$tag_type && $tag_type = 0; if ($id) { $url = "/receiver/tag/edit"; $re = $this->mdCustomerTag->get(['id' => $id]); @@ -98,7 +105,7 @@ class Tag extends HD_Controller $type = 'checkbox'; } $this->data['showInfo'] = ['id' => $id, 'name' => $name, 'sort' => $sort, 'type' => $type, 'show' => $show, - 'typeAry' => $this->mdCustomerTag->typeAry(), 'showAry' => $this->mdCustomerTag->showAry(), 'url' => $url]; + 'typeAry' => $this->mdCustomerTag->typeAry(), 'showAry' => $this->mdCustomerTag->showAry(), 'url' => $url,'tag_type'=>$tag_type]; return $this->show_view('/receiver/tag/edit'); } @@ -113,8 +120,14 @@ class Tag extends HD_Controller if ($re) { return $this->show_json(SYS_CODE_FAIL, '标签名称已存在了!'); } - $id = $this->mdCustomerTag->add(['name' => $params['name'], 'sort' => $params['sort'], 'type' => $params['type'] - , 'show' => $params['show']]); + $add_data = [ + 'name' => $params['name'], + 'sort' => $params['sort'], + 'type' => $params['type'], + 'show' => $params['show'] + ]; + $params['tag_type'] && $add_data['tag_type'] = 1; + $id = $this->mdCustomerTag->add($add_data); if (!$id) { return $this->show_json(SYS_CODE_FAIL, '保存失败'); } @@ -180,7 +193,7 @@ class Tag extends HD_Controller $add_tag = $del_tag = $edit_tag = []; foreach ($options as $key => $value) { $sort = intval($value['sort']); - $data = ['name' => $value['name'], 'status' => $value['status'], 'sort' => $sort]; + $data = ['name' => $value['name'], 'status' => $value['status'], 'sort' => $sort, 'tag_type' => $re['tag_type']]; if ($value['status'] == -1 && $value['qy_id']) {//删除标签 $del_tag[] = $value['qy_id']; } @@ -197,7 +210,7 @@ class Tag extends HD_Controller } } } - if (false !== strpos($_SERVER['HTTP_HOST'], 'admin.liche.cn')) {//正试才能修改企业标签 + if (false !== strpos($_SERVER['HTTP_HOST'], 'admin.liche.cn') && !$re['tag_type']) {//正试才能修改企业标签 $this->load->library('wx_qyapi', ['app' => 'lichene']); if (count($add_tag)) {//新增标签 if (!$re['qy_id']) { diff --git a/admin/views/receiver/customer/get.php b/admin/views/receiver/customer/get.php index 7fcdbd45..2e46066b 100644 --- a/admin/views/receiver/customer/get.php +++ b/admin/views/receiver/customer/get.php @@ -187,6 +187,61 @@ +
+
+
+ + 战败标签 + + + + +
+
+ + + + + +
+
+ +
+
+
+
+
diff --git a/admin/views/receiver/tag/edit.php b/admin/views/receiver/tag/edit.php index 9acfd542..bea5d10e 100644 --- a/admin/views/receiver/tag/edit.php +++ b/admin/views/receiver/tag/edit.php @@ -1,6 +1,7 @@
+
diff --git a/admin/views/receiver/tag/lists.php b/admin/views/receiver/tag/lists.php index 5cf9a49c..60757d8e 100644 --- a/admin/views/receiver/tag/lists.php +++ b/admin/views/receiver/tag/lists.php @@ -13,6 +13,7 @@
+
@@ -55,7 +56,7 @@
- diff --git a/api/controllers/wechat/Lichene.php b/api/controllers/wechat/Lichene.php index 7eb561cb..36f40166 100644 --- a/api/controllers/wechat/Lichene.php +++ b/api/controllers/wechat/Lichene.php @@ -356,7 +356,7 @@ Class Lichene extends HD_Controller $add_tag = $tag_data_new = []; //选择现有标签 foreach ($param['tag'] as $key => $val) { - $re_tag = $this->mdCustomerTag->get(['qy_id' => $val, 'status' => 1], 'id'); + $re_tag = $this->mdCustomerTag->get(['qy_id' => $val, 'status' => 1, 'tag_type' => 0], 'id'); if ($re_tag) { $tag_data_new[] = $re_tag['id']; if (!$tag_data || !in_array($re_tag['id'], $tag_data)) {//未加标签,新增 @@ -396,6 +396,7 @@ Class Lichene extends HD_Controller $where = ["status" => 1, 'pid' => 0]; $select = 'id,name,qy_id,sort'; } + $where['tag_type'] = 0; $list = []; $res = $this->mdCustomerTag->select($where, "sort desc,id desc", 0, 0, $select); foreach ($res as $key => $value) { @@ -491,7 +492,7 @@ Class Lichene extends HD_Controller { $this->load->model('receiver/receiver_customer_tag_model', 'mdCustomerTag'); $this->load->library('wx_qyapi', ['app' => 'lichene']); - $res = $this->mdCustomerTag->select(["status" => 1, 'pid' => 0], "sort desc,id desc", 0, 0); + $res = $this->mdCustomerTag->select(["status" => 1, 'pid' => 0, 'tag_type' => 0], "sort desc,id desc", 0, 0); $addTag = []; foreach ($res as $key => $value) { $add_corp_tag = ['url' => 'add_corp_tag', 'group_id' => '', 'group_name' => $value['name'], 'order' => $value['sort']]; diff --git a/api/controllers/wxapp/app/Tag.php b/api/controllers/wxapp/app/Tag.php index d4747ac7..b1905766 100644 --- a/api/controllers/wxapp/app/Tag.php +++ b/api/controllers/wxapp/app/Tag.php @@ -25,7 +25,8 @@ class Tag extends Wxapp{ $where = [ 'pid' => $pid, - 'status' => 1 + 'status' => 1, + 'tag_type' => 0 ]; $count = $this->receiver_customer_tag_model->count($where); $list = $this->receiver_customer_tag_model->select($where,'sort desc,id desc',$page,$size,'id,name'); diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php index 0abaa2dc..27bde5a2 100644 --- a/api/controllers/wxapp/licheb/Customers.php +++ b/api/controllers/wxapp/licheb/Customers.php @@ -138,7 +138,7 @@ class Customers extends Wxapp } } } else { - $res = $this->mdCustomerTag->select(['status' => 1, 'pid' => 0, 'show<>' => 1], 'sort desc,id desc', 0, 0, 'id,name,type'); + $res = $this->mdCustomerTag->select(['status' => 1, 'pid' => 0, 'show<>' => 1, 'tag_type' => 0], 'sort desc,id desc', 0, 0, 'id,name,type'); if ($res) { if ($id) { $res_td = $this->mdCustomerTagdata->select(['c_id' => $id], 'id desc', 0, 0, 't_id'); diff --git a/home/controllers/h5/Lichene.php b/home/controllers/h5/Lichene.php index b951b191..1e375629 100644 --- a/home/controllers/h5/Lichene.php +++ b/home/controllers/h5/Lichene.php @@ -112,7 +112,7 @@ class Lichene extends CI_Controller } $userInfo['c_id'] = $c_id; //标签 - $res = $this->mdCustomerTag->select(['status' => 1, 'pid' => 0], 'sort desc,id desc', 0, 0, 'id,name,type'); + $res = $this->mdCustomerTag->select(['status' => 1, 'pid' => 0, 'tag_type' => 0], 'sort desc,id desc', 0, 0, 'id,name,type'); if ($res) { $key_tag_id = $c_id ? 'id' : 'qy_id';//比对key值 foreach ($res as $key => $val) { diff --git a/home/controllers/h5/Persona.php b/home/controllers/h5/Persona.php index 556a2199..060316a8 100644 --- a/home/controllers/h5/Persona.php +++ b/home/controllers/h5/Persona.php @@ -153,7 +153,7 @@ class Persona extends CI_Controller } $userInfo['c_id'] = $c_id; //标签 - $res = $this->mdCustomerTag->select(['status' => 1, 'pid' => 0], 'sort desc,id desc', 0, 0, 'id,name,type'); + $res = $this->mdCustomerTag->select(['status' => 1, 'pid' => 0, 'tag_type' => 0], 'sort desc,id desc', 0, 0, 'id,name,type'); if ($res) { $key_tag_id = $c_id ? 'id' : 'qy_id';//比对key值 foreach ($res as $key => $val) {