add-custer-tag_type

This commit is contained in:
lccsw
2023-02-03 09:50:10 +08:00
parent 981857ba6a
commit db1687e52e
11 changed files with 102 additions and 21 deletions
+11 -6
View File
@@ -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')) : '';
+5 -1
View File
@@ -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()
{
+20 -7
View File
@@ -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']) {
+55
View File
@@ -187,6 +187,61 @@
</div>
</div>
</div>
<div class="am-u-lg-12" v-if="info.status==3">
<div class="am-panel am-panel-default">
<div class="am-panel-hd">
<span href="javascript:void(0)" style="font-size: 20px">
战败标签
</span>
<span style="float:right;margin-top:5px;">
<a href="javascript:" @click="editType(4)"><i class="fa fa-edit"></i></a>
</span>
</div>
<div class="am-panel-bd am-g">
<table width="100%" style="margin-left: 10px;margin-right: 10px;">
<template v-for="(v,i) in info.invalid_user_tag">
<tr>
<td class="table-td" style="width: 80%">
<table>
<tr v-if="v.type=='checkbox'">
<td style="min-width: 80px">{{v.name}}:</td>
<td>
<template v-for="(v2,i2) in v.list">
<input type="checkbox" :value='v2.checked'
v-model="v2.checked"> {{v2.name}}&nbsp;
</template>
</td>
</tr>
<tr v-else>
<td style="min-width: 80px">{{v.name}}:</td>
<td>
<template v-for="(v2,i2) in v.list">
<input type="radio" :value='v2.id'
v-model="v.value"> {{v2.name}}&nbsp;
</template>
</td>
</tr>
</table>
</td>
</tr>
</template>
<tr v-if="edit_index==4">
<td>
<div class="am-form-inline" style="padding-right: 30px;padding-top: 10px;">
<div class="text-left pt10">
<div class="am-form-group ml10">
<a href="javascript:void(0)"
class="am-btn am-btn-sm am-btn-success"
@click="saveEdit()">保存战败标签</a>
</div>
</div>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="am-u-lg-12">
<div class="am-panel am-panel-default">
<div class="am-panel-hd">
+1
View File
@@ -1,6 +1,7 @@
<form id="vue-edit" class="am-form am-form-horizontal" action="<?= $showInfo['url'] ?>" data-auto="true"
method="post" style="width: 90%;padding-top: 10px" onsubmit="return false">
<input type="hidden" value="<?= $showInfo['id'] ?>" name="id"/>
<input type="hidden" value="<?= $showInfo['tag_type'] ?>" name="tag_type"/>
<div class="am-form-group">
<label class="am-para-label">名称:</label>
<div class="am-para-input">
+2 -1
View File
@@ -13,6 +13,7 @@
<div class="coms-table-wrap mt10">
<form id="vue-app" class=" form-search coms-table-hd clearfix no-border" onsubmit="return false"
action="receiver/tag">
<input type="hidden" value="<?=$params['tag_type']?>" name="tag_type">
<div class="am-form am-form-horizontal">
<div class="am-form-group fl">
<label class="am-para-label w80">类型:</label>
@@ -55,7 +56,7 @@
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
</div>
<div class="am-form-group fl ml10">
<button data-modal="/receiver/tag/get" type="button" data-title="新增标签"
<button data-modal="/receiver/tag/get?tag_type=<?=$params['tag_type']?>" type="button" data-title="新增标签"
class="am-btn am-btn-success am-btn-sm w100">
新增
</button>
+3 -2
View File
@@ -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']];
+2 -1
View File
@@ -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');
+1 -1
View File
@@ -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');
+1 -1
View File
@@ -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) {
+1 -1
View File
@@ -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) {