customer_tag_315_3

This commit is contained in:
dengbw
2022-03-15 17:52:00 +08:00
parent 564c45d8d5
commit c617a99ffb
8 changed files with 181 additions and 10 deletions
+72 -1
View File
@@ -20,6 +20,8 @@ class Customer extends HD_Controller
parent::__construct();
$this->load->model('receiver/receiver_customers_model', 'customers_model');
$this->load->model('receiver/receiver_customer_oplogs_model', 'customer_oplogs_model');
$this->load->model('receiver/receiver_customer_tag_model', 'mdCustomerTag');
$this->load->model('receiver/receiver_customer_tagdata_model', 'mdCustomerTagdata');
$this->load->model('receiver/receiver_clues_model', 'clues_model');
$this->load->model('receiver/receiver_clues_cfrom_model', 'clues_cfrom_model');
$this->load->model('receiver/receiver_xz_model');
@@ -291,6 +293,7 @@ class Customer extends HD_Controller
$of_title = $of_ary['name'];
$row['of2_id'] && $of_title .= '-' . $of_ary['list'][$row['of2_id']];
}
$info = array(
'id' => $row['id'],
'name' => $row['name'],
@@ -301,6 +304,7 @@ class Customer extends HD_Controller
'cf_user' => $cf_user,
'c_time' => date('Y-m-d H:i:s', $row['c_time']),
'status' => $row['status'],
'tag' => $this->get_tag($row['id']),
);
//到店信息
@@ -460,8 +464,46 @@ class Customer extends HD_Controller
$msg = '修改用户信息成功';
$this->addLog(array('customer_id' => $info['id'], 'type' => 0, 'log' => $log));
}
} else if ($info['editType'] == 3) {
$id = $info['id'];
//客户标签
if (!$info['tag']) {
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) {
foreach ($val['list'] as $key2 => $val2) {
if ($val['type'] == 'checkbox') {
if ($val2['checked'] == 'true') {
if (!$tag_data || !in_array($val2['id'], $tag_data)) {//未加标签,新增
$add_tag[] = ['c_id' => $id, 't_id' => $val2['id'], 'c_time' => time()];
}
} else {
if ($tag_data && in_array($val2['id'], $tag_data)) {//删除标签
$this->mdCustomerTagdata->delete(['c_id' => $id, 't_id' => $val2['id']]);
}
}
} else {
if ($val['value'] == $val2['id']) {
if (!$tag_data || !in_array($val2['id'], $tag_data)) {//未加标签,新增
$add_tag[] = ['c_id' => $id, 't_id' => $val2['id'], 'c_time' => time()];
}
} else {
if ($tag_data && in_array($val2['id'], $tag_data)) {//删除标签
$this->mdCustomerTagdata->delete(['c_id' => $id, 't_id' => $val2['id']]);
}
}
}
}
}
if ($add_tag && count($add_tag)) {
$this->mdCustomerTagdata->add_batch($add_tag);
}
$this->addLog(array('customer_id' => $info['id'], 'type' => 0, 'log' => '修改用户画像'));
}
return $this->show_json($code, $msg);
}
@@ -540,5 +582,34 @@ class Customer extends HD_Controller
return $id;
}
private function get_tag($id)
{
$show = $res_td = [];
$res = $this->mdCustomerTag->select(['status' => 1, 'pid' => 0], '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')) : '';
foreach ($res as $key => $val) {
$list = [];
$value = '';
$res2 = $this->mdCustomerTag->select(['status' => 1, 'pid' => $val['id']], 'sort desc,id desc', 0, 0, 'id,name');
foreach ($res2 as $key2 => $val2) {
//检查是否选中标签
$setValue = ['id' => $val2['id'], 'name' => $val2['name']];
if ($val['type'] == 'checkbox') {
$setValue['checked'] = $tag_data && in_array($val2['id'], $tag_data) ? true : false;
} else {
if ($tag_data && in_array($val2['id'], $tag_data)) {
$value = $val2['id'];
}
}
$list[] = $setValue;
}
$show[] = ['id' => $val['id'], 'name' => $val['name'], 'type' => $val['type'], 'value' => $value, 'list' => $list];
}
}
return $show;
}
}
+13 -4
View File
@@ -24,11 +24,15 @@ class Tag extends HD_Controller
$params['page'] = $params['page'] ? intval($params['page']) : 1;
$params['size'] = $params['size'] ? intval($params['size']) : 20;
$statusAry = $this->mdCustomerTag->statusAry();
$typeAry = $this->mdCustomerTag->typeAry();
$lists = array();
$where = ["status<>-1" => null, 'pid' => 0];
if (strlen($params['status'])) {
$where['status'] = $params['status'];
}
if ($params['type']) {
$where['type'] = $params['type'];
}
$count = $this->mdCustomerTag->count($where);
if ($count) {
$res = $this->mdCustomerTag->select($where, "sort desc,id desc", $params['page'], $params['size']);
@@ -37,6 +41,7 @@ class Tag extends HD_Controller
$setValue['id'] = $value['id'];
$setValue['name'] = $value['name'];
$setValue['sort'] = $value['sort'];
$setValue['type_name'] = $typeAry[$value['type']];
$setValue['status'] = $value['status'];
$setValue['status_name'] = $statusAry[$value['status']];
$options = '';
@@ -48,7 +53,7 @@ class Tag extends HD_Controller
}
$this->data['lists'] = $lists;
$this->data['params'] = $params;
$this->data['showInfo'] = ['statusAry' => $statusAry];
$this->data['showInfo'] = ['statusAry' => $statusAry, 'typeAry' => $typeAry];
$this->data['_title'] = '客户标签列表';
$this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count);
return $this->show_view('/receiver/tag/lists', true);
@@ -77,12 +82,15 @@ class Tag extends HD_Controller
}
$name = $re['name'];
$sort = $re['sort'];
$type = $re['type'];
} else {
$url = "/receiver/tag/add";
$name = '';
$sort = 0;
$type = 'checkbox';
}
$this->data['showInfo'] = ['id' => $id, 'name' => $name, 'sort' => $sort, 'url' => $url];
$this->data['showInfo'] = ['id' => $id, 'name' => $name, 'sort' => $sort, 'type' => $type,
'typeAry' => $this->mdCustomerTag->typeAry(), 'url' => $url];
return $this->show_view('/receiver/tag/edit');
}
@@ -97,7 +105,7 @@ class Tag extends HD_Controller
if ($re) {
return $this->show_json(SYS_CODE_FAIL, '标签名称已存在了!');
}
$this->mdCustomerTag->add(['name' => $params['name'], 'sort' => $params['sort']]);
$this->mdCustomerTag->add(['name' => $params['name'], 'sort' => $params['sort'], 'type' => $params['type']]);
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
}
@@ -115,7 +123,8 @@ class Tag extends HD_Controller
if ($re && $re['id'] != $params['id']) {
return $this->show_json(SYS_CODE_FAIL, '标签名称已存在了!');
}
$this->mdCustomerTag->update(['name' => $params['name'], 'sort' => $params['sort']], ['id' => $params['id']]);
$this->mdCustomerTag->update(['name' => $params['name'], 'sort' => $params['sort'], 'type' => $params['type']]
, ['id' => $params['id']]);
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
}
+55 -1
View File
@@ -130,6 +130,61 @@
</div>
</div>
</div>
<div class="am-u-lg-12">
<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(3)"><i class="fa fa-edit"></i></a>
</span>
</div>
<div class="am-panel-bd am-g">
<table width="100%" style="margin:10px 10px 10px 20px;">
<template v-for="(v,i) in info.tag">
<tr>
<td class="table-td" style="width: 80%">
<table>
<tr v-if="v.type=='checkbox'">
<td>{{v.name}}</td>
<td style="padding-left: 30px;">
<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>{{v.name}}</td>
<td style="padding-left: 30px;">
<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==3">
<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">
@@ -231,7 +286,6 @@
methods: {
editType: function (index) {
var vm = this;
if (vm.edit_index == index) {
vm.edit_index = 0;
} else {
+11
View File
@@ -7,6 +7,17 @@
<input type="text" placeholder="输入名称" value="<?= $showInfo['name'] ?>" name="name"/>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">选项类型:</label>
<div class="am-para-input" style="width: 30%">
<select name="type">
<? foreach ($showInfo['typeAry'] as $key => $value) { ?>
<option value="<?= $key ?>" <?= $key == $showInfo['type'] ? 'selected' : '' ?>
><?= $value ?></option>
<? } ?>
</select>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">排序:</label>
<div class="am-para-input" style="width: 30%">
+15 -1
View File
@@ -2,6 +2,18 @@
<form id="vue-app" class=" form-search coms-table-hd clearfix no-border" onsubmit="return false"
action="receiver/tag">
<div class="am-form am-form-horizontal">
<div class="am-form-group fl">
<label class="am-para-label w100">类型:</label>
<div class="am-para-inline w100">
<select name="type">
<option value="">选择类型</option>
<? foreach ($showInfo['typeAry'] as $key => $value) { ?>
<option value="<?= $key ?>" <?= $key == $params['type'] ? 'selected' : '' ?>
><?= $value ?></option>
<? } ?>
</select>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w100">状态:</label>
<div class="am-para-inline w100">
@@ -34,6 +46,7 @@
<tr>
<th width="25%"><span>名称</span></th>
<th width="45%"><span>标签选项</span></th>
<th width="7%"><span>类型</span></th>
<th width="5%"><span>排序</span></th>
<th width="5%"><span>状态</span></th>
</tr>
@@ -44,11 +57,12 @@
<tr>
<td><?= $v['name'] ?></td>
<td><?= $v['options'] ?></td>
<td><?= $v['type_name'] ?></td>
<td><?= $v['sort'] ?></td>
<td><?= $v['status_name'] ?></td>
</tr>
<tr>
<td colspan="4" class="align-r">
<td colspan="5" class="align-r">
<a href="javascript:void(0);" @click="optionsModal(<?= $v['id'] ?>,'<?= $v['name'] ?>')"
class="am-btn am-btn-primary am-btn-xs">编辑选项</a>
<a href="javascript:void(0);" data-modal="/receiver/tag/get?id=<?= $v['id'] ?>"
+2 -2
View File
@@ -109,7 +109,7 @@ class Customers extends Wxapp
{
$id = intval($this->input_param('id'));
$show = $res_td = [];
$res = $this->mdCustomerTag->select(['status' => 1, 'pid' => 0], 'sort desc,id desc', 0, 0, 'id,name');
$res = $this->mdCustomerTag->select(['status' => 1, 'pid' => 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');
@@ -123,7 +123,7 @@ class Customers extends Wxapp
$checked = $tag_data && in_array($val2['id'], $tag_data) ? true : false;
$list[] = ['id' => $val2['id'], 'name' => $val2['name'], 'checked' => $checked];
}
$show[] = ['id' => $val['id'], 'name' => $val['name'], 'list' => $list];
$show[] = ['id' => $val['id'], 'name' => $val['name'],'type' => $val['type'], 'list' => $list];
}
}
return $show;
@@ -16,6 +16,17 @@ class Receiver_customer_tag_model extends HD_Model
parent::__construct($this->table_name, 'default');
}
/**
* Notes:选项类型
* Created on: 2022/3/15 14:07
* Created by: dengbw
* @return array
*/
public function typeAry()
{
return array('checkbox' => '多选', 'radio' => '单选');
}
/**
* Notes:状态
* Created on: 2021/7/27 10:31
@@ -79,7 +79,8 @@ class Receiver_customers_model extends HD_Model
public function offlineSources($id = 0)
{
$arr[1] = ['name' => '自然到店', 'list' => []];
$arr[2] = ['name' => '转介绍', 'list' => [20 => '其他4S店', 21 => '其他二网', 22 => '汽车美容', 23 => '二手车', 24 => '修车厂', 25 => '驾校', 26 => '老车主']];
$arr[2] = ['name' => '转介绍', 'list' => [20 => '其他4S店', 21 => '其他二网', 22 => '汽车美容', 23 => '二手车'
, 24 => '修车厂', 25 => '驾校', 26 => '老车主', 27 => '亲朋好友']];
$arr[3] = ['name' => '网络推广', 'list' => [30 => '抖音', 31 => '区域媒体', 32 => '懂车帝', 33 => '易车', 34 => '汽车之家', 35 => '网红']];
$arr[4] = ['name' => '外展外拓', 'list' => [40 => '巡展', 41 => '车展', 42 => '静展', 43 => '大客户']];
$arr[5] = ['name' => '自媒体', 'list' => [50 => '小红书号', 51 => '咸鱼号', 52 => '抖音号', 53 => '狸车素材', 54 => '知乎号']];