admin_customer_315

This commit is contained in:
dengbw
2023-03-15 16:51:52 +08:00
committed by lccsw
parent 10397dd947
commit bac4e9d49e
3 changed files with 311 additions and 96 deletions
+87 -53
View File
@@ -11,7 +11,7 @@ class Customer extends HD_Controller
{
private $searchTpAry = array('mobile' => '客户手机号', 'name' => '客户姓名');
private $searchTimeAry = array('c_time' => '创建时间', 'p_time' => '分配时间', 'cont_time' => '最后联系时间', 'u_time' => '最后操作时间'
, 'dt_time' => '首次到店时间', 'order_time' => '下单时间', 'def_time'=>'战败时间');
, 'dt_time' => '首次到店时间', 'order_time' => '下单时间', 'def_time' => '战败时间');
protected $log_dir;
@@ -92,6 +92,10 @@ class Customer extends HD_Controller
}
$tag_data = $params['tags'] ? explode(',', $params['tags']) : '';
$show_info['tags'] = $this->get_tag(0, 0, $tag_data);
$tag_data = $params['tagsIntention'] ? explode(',', $params['tagsIntention']) : '';
$show_info['tagsIntention'] = $this->get_tag(0, 2, $tag_data);
$tag_data = $params['tagsDefeat'] ? explode(',', $params['tagsDefeat']) : '';
$show_info['tagsDefeat'] = $this->get_tag(0, 1, $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');
@@ -113,7 +117,8 @@ class Customer extends HD_Controller
return $this->show_view('receiver/customer/lists', true);
}
private function get_where(&$params){
private function get_where(&$params)
{
!$params['biz_id'] && $params['biz_id'] = '';
!strlen($params['cs_biz_id']) && $params['cs_biz_id'] = '';
!$params['cf_title'] && $params['cf_title'] = '';
@@ -123,6 +128,8 @@ class Customer extends HD_Controller
!$params['of2_id'] && $params['of2_id'] = '';
!$params['biz_type'] && $params['biz_type'] = '';
!$params['tags'] && $params['tags'] = '';
!$params['tagsIntention'] && $params['tagsIntention'] = '';
!$params['tagsDefeat'] && $params['tagsDefeat'] = '';
$where = array('status>=0' => null);
if ($_SESSION['admin_info']['biz_id']) {
$biz_ids = implode(',', $_SESSION['admin_info']['biz_id']);
@@ -232,39 +239,15 @@ 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;
}
$where = $this->tagWhere($where, $params['tags']);
} else if ($params['tagsIntention']) {
$where = $this->tagWhere($where, $params['tagsIntention']);
} else if ($params['tagsDefeat']) {
$where['status'] = 3;
$where = $this->tagWhere($where, $params['tagsDefeat']);
}
// 指定顾问的回访客户,通过 vsid + vdststus 时间
if ($vsid = $params['vsid']){
if ($vsid = $params['vsid']) {
$vdststus = $params['vdststus'] ? intval($params['vdststus']) : 0;
$vdststus_parm = $vdststus ? " and lc_vd.status = {$vdststus}" : "";
$where["id in(select lc_vd.c_id from lc_receiver_customer_visit_data lc_vd join lc_receiver_customer_visit_sales lc_vs on lc_vd.biz_id = lc_vs.biz_id and lc_vd.sales_id = lc_vs.sales_id and lc_vd.t_day = lc_vs.t_day and lc_vs.id = {$vsid} {$vdststus_parm})"] = null;
@@ -323,15 +306,18 @@ class Customer extends HD_Controller
$row['of2_id'] && $of_title .= '-' . $of_ary['list'][$row['of2_id']];
}
$tag = $tag_group = [];
$tag_defeat = $tag_intention = '';
$biz_type = intval($row_biz['type']);
if ($biz_type == 5) {
$jsondata = $row['jsondata'] ? json_decode($row['jsondata'], true) : [];
$jsondata['tag_group'] && $tag_group = $jsondata['tag_group'];
} else {
$tag = $this->get_tag($row['id']);
if ($row['status'] == 3) {
$tag_defeat = $this->get_tag($row['id'], 1, '', 1);
}
$tag_intention = $this->get_tag($row['id'], 2, '', 1);
}
$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 = '已改派';
@@ -347,13 +333,14 @@ class Customer extends HD_Controller
'of_title' => $of_title,
'wxqy_name' => $this->customers_model->wxqyAry($row['wxqy']),
'wxgr_name' => $this->customers_model->wxgrAry($row['wxgr']),
'wx_name' => '企微:'.$this->customers_model->wxqyAry($row['wxqy']).' 个微:'.$this->customers_model->wxgrAry($row['wxgr']),
'wx_name' => '企微:' . $this->customers_model->wxqyAry($row['wxqy']) . ' 个微:' . $this->customers_model->wxgrAry($row['wxgr']),
'cf_user' => $cf_user,
'to_send' => $to_send,
'c_time' => date('Y-m-d H:i:s', $row['c_time']),
'status' => $row['status'],
'tag' => $tag,
'invalid_user_tag' => $invalid_user_tag,
'tag_defeat' => $tag_defeat,
'tag_intention' => $tag_intention,
'tag_group' => $tag_group,
'biz_type' => $biz_type,
);
@@ -518,14 +505,14 @@ class Customer extends HD_Controller
} else if ($info['editType'] == 3 || $info['editType'] == 4) {
$id = $info['id'];
//客户标签
if (!$info['tag'] && $info['editType']==3) {
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')) : '';
$tag_lists = $info['editType']==3 ? $info['tag'] : $info['invalid_user_tag'];
$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') {
@@ -554,7 +541,7 @@ class Customer extends HD_Controller
if ($add_tag && count($add_tag)) {
$this->mdCustomerTagdata->add_batch($add_tag);
}
$log_msg = $info['editType']==3 ? '修改用户画像' : '修改战败标签';
$log_msg = $info['editType'] == 3 ? '修改用户画像' : '修改战败标签';
$this->addLog(array('customer_id' => $info['id'], 'type' => 0, 'log' => $log_msg));
}
return $this->show_json($code, $msg);
@@ -582,7 +569,7 @@ class Customer extends HD_Controller
public function export()
{
if ($this->uid != 1){
if ($this->uid != 1) {
return $this->show_json(SYS_CODE_FAIL, '无权限导出');
}
@@ -652,20 +639,29 @@ class Customer extends HD_Controller
);
$tag = $this->get_tag($id);
foreach ($tag as $key => $val){
$tag_key = 'tag__'.$val['id'];
foreach ($tag as $key => $val) {
$tag_key = 'tag__' . $val['id'];
$row[$tag_key] = $val['value_str'];
if (!in_array($tag_key, array_keys($indexs))){
if (!in_array($tag_key, array_keys($indexs))) {
$indexs[$tag_key] = $val['name'];
}
}
$tag_defeat = $this->get_tag($id, 1);
foreach ($tag_defeat as $key => $val){
$tag_key = 'tag__'.$val['id'];
$tag_intention = $this->get_tag($id, 2);
foreach ($tag_intention as $key => $val) {
$tag_key = 'tag__' . $val['id'];
$row[$tag_key] = $val['value_str'];
if (!in_array($tag_key, array_keys($indexs))){
$indexs[$tag_key] = '战败-'.$val['name'];
if (!in_array($tag_key, array_keys($indexs))) {
$indexs[$tag_key] = '意向-' . $val['name'];
}
}
$tag_defeat = $this->get_tag($id, 1);
foreach ($tag_defeat as $key => $val) {
$tag_key = 'tag__' . $val['id'];
$row[$tag_key] = $val['value_str'];
if (!in_array($tag_key, array_keys($indexs))) {
$indexs[$tag_key] = '战败-' . $val['name'];
}
}
@@ -729,7 +725,41 @@ class Customer extends HD_Controller
return $id;
}
private function get_tag($id, $tag_type = 0, $tag_data = '')
private function tagWhere($where, $tags)
{
$pidAry = [];
$res_tag = $this->mdCustomerTag->select(["id in ({$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;
}
private function get_tag($id, $tag_type = 0, $tag_data = '', $check_show = 0)
{
$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');
@@ -739,20 +769,23 @@ class Customer extends HD_Controller
$res_td && $tag_data = array_unique(array_column($res_td, 't_id'));
}
foreach ($res as $key => $val) {
$list = [];
$list = $value_arr = [];
$value = '';
$value_arr = array();
$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;
$setValue['checked'] && $value_arr[] = $val2['name'];
if ($setValue['checked']) {
$value_arr[] = $val2['name'];
$check_show && $check_show = 0;
}
} else {
if ($tag_data && in_array($val2['id'], $tag_data)) {
$value = $val2['id'];
$value_arr[] = $val2['name'];
$check_show && $check_show = 0;
}
}
$list[] = $setValue;
@@ -761,6 +794,7 @@ class Customer extends HD_Controller
$show[] = ['id' => $val['id'], 'name' => $val['name'], 'type' => $val['type'], 'value' => $value, 'value_str' => $value_str, 'list' => $list];
}
}
$check_show && $show = '';
return $show;
}
+35 -36
View File
@@ -36,7 +36,7 @@
<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(2)"><i class="fa fa-edit"></i></a>
@@ -124,7 +124,7 @@
<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;" v-if="info.biz_type!=5">
<a href="javascript:" @click="editType(3)"><i class="fa fa-edit"></i></a>
@@ -187,57 +187,56 @@
</div>
</div>
</div>
<div class="am-u-lg-12" v-if="info.status==3">
<div class="am-u-lg-12" v-if="info.tag_intention">
<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>
<template v-for="(v,i) in info.tag_intention">
<tr v-if="v.value_str">
<td class="table-td" style="width: 80%">
<table>
<tr v-if="v.type=='checkbox'">
<tr>
<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>
{{v.value_str}}
</td>
</tr>
</table>
</td>
</tr>
</template>
</table>
</div>
</div>
</div>
<div class="am-u-lg-12" v-if="info.tag_defeat">
<div class="am-panel am-panel-default">
<div class="am-panel-hd">
<span href="javascript:void(0)" style="font-size: 20px">
战败标签
</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.tag_defeat">
<tr v-if="v.value_str">
<td class="table-td" style="width: 80%">
<table>
<tr>
<td style="min-width: 80px">{{v.name}}:</td>
<td>
{{v.value_str}}
</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>
+189 -7
View File
@@ -153,15 +153,21 @@
<? } ?>
<div class="am-form-group" style="margin-bottom: 0px;"></div>
<div class="am-form-group fl" style="margin-bottom: 0px;">
<div class="am-form-group fl ml10">
<input type="button" @click="btnTimes" value="筛选时间" class="am-btn am-btn-success am-btn-sm">
</div>
<div class="am-form-group fl ml10">
<input type="button" @click="btnTags" value="客户画像" class="am-btn am-btn-success am-btn-sm">
</div>
<div class="am-form-group fl ml10">
<input type="button" @click="btnTagsIntention" value="客户意向" class="am-btn am-btn-success am-btn-sm">
</div>
<div class="am-form-group fl ml10">
<input type="button" @click="btnTagsDefeat" value="战败标签" class="am-btn am-btn-success am-btn-sm">
</div>
<div class="am-form-group fl ml10">
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
</div>
<div class="am-form-group fl ml10">
<input type="button" @click="btnTimes" value="选择筛选时间" class="am-btn am-btn-success am-btn-sm">
</div>
<div class="am-form-group fl ml10">
<input type="button" @click="btnTags" value="搜索客户画像" class="am-btn am-btn-success am-btn-sm">
</div>
<div class="am-form-group fl ml10">
<button type="button" class="am-btn am-btn-success am-btn-sm w100" @click="reset">重置</button>
</div>
@@ -172,6 +178,8 @@
</div>
<input name="status" value="<?= $params['status'] ?>" type="hidden">
<input type="hidden" id="id_tags" name="tags" value="<?= $params['tags'] ?>">
<input type="hidden" id="id_tagsIntention" name="tagsIntention" value="<?= $params['tagsIntention'] ?>">
<input type="hidden" id="id_tagsDefeat" name="tagsDefeat" value="<?= $params['tagsDefeat'] ?>">
</form>
<div class="coms-table-bd">
@@ -290,6 +298,69 @@
</template>
</div>
</div>
<div id="tags-intention-modal" style="display: none;">
<div class="modal-body">
<template v-for="(v,i) in show_info.tagsIntention">
<tr>
<td class="table-td" style="width: 80%">
<table>
<tr v-if="v.type=='checkbox'">
<td style="min-width: 100px">{{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: 100px">{{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>
</div>
</div>
<div id="tags-defeat-modal" style="display: none;">
<div class="modal-body">
<template v-for="(v,i) in show_info.tagsDefeat">
<tr>
<td class="table-td" style="width: 80%">
<table>
<tr v-if="v.type=='checkbox'">
<td style="min-width: 100px">{{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: 100px">{{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>
</div>
</div>
</div>
<script>
@@ -336,7 +407,8 @@
lists: [],
qdjl_lists: [],
admins: {cityAry: [], countyAry: [], bizAry: [], list: []},
show_info: {levelAry: [], offlineSourcesAry: [], wxqyAry: [], wxgrAry: [], csbizidAry: [], tags: []},
show_info: {levelAry: [], offlineSourcesAry: [], wxqyAry: [], wxgrAry: [], csbizidAry: [], tags: []
, tagsIntention: [], tagsDefeat: []},
of2Ary: [],
bizTypeAry: [],
export_button: 0,
@@ -418,6 +490,8 @@
return $.msg.tips('请选择需要搜索的数据!');
}
$('#id_tags').val(ids);
$('#id_tagsIntention').val('');
$('#id_tagsDefeat').val('');
$('#vue-app').submit();
layer.close(index);
},
@@ -440,6 +514,112 @@
}
});
},
btnTagsIntention: function () {
var vm = this;
layer.open({
type: 1,
area: ['50%'], //宽高
content: $('#tags-intention-modal'),
title: '搜索客户意向',
shade: false,
btn: ['点击搜索', '重置意向', '取消搜索'],
yes: function (index) {
var ids = '';
vm.show_info.tagsIntention.map(function (item1) {
for (var i in item1.list) {
var item2 = item1.list[i];
if (item1.type == 'checkbox') {
if (item2.checked) {
ids = ids ? ids + ',' + item2.id : item2.id;
}
} else {
if (item1.value == item2.id) {
ids = ids ? ids + ',' + item2.id : item2.id;
}
}
}
});
if (ids.length < 1) {
return $.msg.tips('请选择需要搜索的数据!');
}
$('#id_tagsIntention').val(ids);
$('#id_tags').val('');
$('#id_tagsDefeat').val('');
$('#vue-app').submit();
layer.close(index);
},
btn2: function () {
vm.show_info.tagsIntention.map(function (item1) {
for (var i in item1.list) {
var item2 = item1.list[i];
if (item1.type == 'checkbox') {
item2.checked = false;
} else {
item1.value = '';
}
}
});
$('#id_tagsIntention').val('');
return false;
},
btn3: function (index) {
layer.close(index);
}
});
},
btnTagsDefeat: function () {
var vm = this;
layer.open({
type: 1,
area: ['50%'], //宽高
content: $('#tags-defeat-modal'),
title: '搜索战败标签',
shade: false,
btn: ['点击搜索', '重置战败', '取消搜索'],
yes: function (index) {
var ids = '';
vm.show_info.tagsDefeat.map(function (item1) {
for (var i in item1.list) {
var item2 = item1.list[i];
if (item1.type == 'checkbox') {
if (item2.checked) {
ids = ids ? ids + ',' + item2.id : item2.id;
}
} else {
if (item1.value == item2.id) {
ids = ids ? ids + ',' + item2.id : item2.id;
}
}
}
});
if (ids.length < 1) {
return $.msg.tips('请选择需要搜索的数据!');
}
$('#id_tagsDefeat').val(ids);
$('#id_tags').val('');
$('#id_tagsIntention').val('');
$('#vue-app').submit();
layer.close(index);
},
btn2: function () {
vm.show_info.tagsDefeat.map(function (item1) {
for (var i in item1.list) {
var item2 = item1.list[i];
if (item1.type == 'checkbox') {
item2.checked = false;
} else {
item1.value = '';
}
}
});
$('#id_tagsDefeat').val('');
return false;
},
btn3: function (index) {
layer.close(index);
}
});
},
saveEdit: function () {
$("form").submit();
},
@@ -472,6 +652,8 @@
that.params.of_id = '';
that.params.of2_id = '';
$('#id_tags').val('');
$('#id_tagsIntention').val('');
$('#id_tagsDefeat').val('');
$('#cf_time').val('');
$(".order-times").map(function () {
var id = this.value;