admin_customer_tag_311

This commit is contained in:
dengbw
2022-03-11 17:05:53 +08:00
committed by lccsw
parent f64257b3d5
commit 954b393843
9 changed files with 490 additions and 35 deletions
+177
View File
@@ -0,0 +1,177 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Tag extends HD_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('receiver/receiver_customer_tag_model', 'mdCustomerTag');
}
//首页信息
public function index()
{
return $this->lists();
}
//数据列表
public function lists()
{
$params = $this->input->get();
$params['page'] = $params['page'] ? intval($params['page']) : 1;
$params['size'] = $params['size'] ? intval($params['size']) : 20;
$statusAry = $this->mdCustomerTag->statusAry();
$lists = array();
$where = ["status<>-1" => null, 'pid' => 0];
if (strlen($params['status'])) {
$where['status'] = $params['status'];
}
$count = $this->mdCustomerTag->count($where);
if ($count) {
$res = $this->mdCustomerTag->select($where, "sort desc,id desc", $params['page'], $params['size']);
foreach ($res as $key => $value) {
$setValue = array();
$setValue['id'] = $value['id'];
$setValue['name'] = $value['name'];
$setValue['sort'] = $value['sort'];
$setValue['status'] = $value['status'];
$setValue['status_name'] = $statusAry[$value['status']];
$options = '';
$res_tag = $this->mdCustomerTag->select(["status" => 1, 'pid' => $value['id']], "sort desc,id desc", 0, 0, 'id,name,sort');
$res_tag && $options = implode(',', array_column($res_tag, 'name'));
$setValue['options'] = $options;
$lists[] = $setValue;
}
}
$this->data['lists'] = $lists;
$this->data['params'] = $params;
$this->data['showInfo'] = ['statusAry' => $statusAry];
$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);
}
public function get_options()
{
$id = intval($this->input->post('id'));
if (!$id) {
return $this->show_json(SYS_CODE_FAIL, '参数错误!');
}
$res_tag = $this->mdCustomerTag->select(["status" => 1, 'pid' => $id], "sort desc,id desc", 0, 0, 'id,name,sort,status');
$this->data['lists'] = $res_tag;
return $this->show_json(SYS_CODE_SUCCESS);
}
//展示单条数据
public function get()
{
$id = intval($this->input->get('id'));
if ($id) {
$url = "/receiver/tag/edit";
$re = $this->mdCustomerTag->get(['id' => $id]);
if (!$re) {
return $this->show_json(SYS_CODE_FAIL, '客户标签不存在!');
}
$name = $re['name'];
$sort = $re['sort'];
} else {
$url = "/receiver/tag/add";
$name = '';
$sort = 0;
}
$this->data['showInfo'] = ['id' => $id, 'name' => $name, 'sort' => $sort, 'url' => $url];
return $this->show_view('/receiver/tag/edit');
}
//添加单条数据
public function add()
{
$params = $this->input->post();
if (!$params['name']) {
return $this->show_json(SYS_CODE_FAIL, '标签名称不能为空!');
}
$re = $this->mdCustomerTag->get(array('name' => $params['name']));
if ($re) {
return $this->show_json(SYS_CODE_FAIL, '标签名称已存在了!');
}
$this->mdCustomerTag->add(['name' => $params['name'], 'sort' => $params['sort']]);
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
}
//编辑单条数据
public function edit()
{
$params = $this->input->post();
if (!$params['id']) {
return $this->show_json(SYS_CODE_FAIL, '参数错误');
}
if (!$params['name']) {
return $this->show_json(SYS_CODE_FAIL, '请输入标签名称');
}
$re = $this->mdCustomerTag->get(array('name' => $params['name']));
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']]);
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
}
//修改标签选项
function edit_options()
{
$id = $this->input->post('id');
$options = $this->input->post('options');
if (!$id || !$options) {
return $this->show_json(SYS_CODE_FAIL, '参数错误');
}
foreach ($options as $key => $value) {
$data = ['name' => $value['name'], 'status' => $value['status'], 'sort' => intval($value['sort'])];
if ($value['name']) {
if ($value['id']) {//修改
$this->mdCustomerTag->update($data, ['id' => $value['id']]);
} else {//新增
$data['pid'] = $id;
$this->mdCustomerTag->add($data);
}
}
}
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
}
function edit_status()
{
$id = $this->input->post('id');
$stauts = intval($this->input->post('status'));
if (!$id) {
$this->show_json(SYS_CODE_FAIL, '参数错误');
}
$this->mdCustomerTag->update(['status' => $stauts], ['id' => $id]);
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
}
//删除单条数据
public function del()
{
$id = $this->input->post('id');
if (!$id) {
$this->show_json(SYS_CODE_FAIL, '参数错误');
}
$this->mdCustomerTag->update(['status' => '-1'], ['id' => $id]);
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
}
//批量操作(默认修改状态)
public function batch()
{
}
//导出数据列表
public function export()
{
}
}
+20
View File
@@ -0,0 +1,20 @@
<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"/>
<div class="am-form-group">
<label class="am-para-label">名称:</label>
<div class="am-para-input">
<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%">
<input type="text" placeholder="输入排序" value="<?= $showInfo['sort'] ?>" name="sort"/>
<small class="text-muted">越大越靠前</small>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 2rem">
<button class="am-btn ml20 am-btn-sm am-btn-success w100" style="margin-left: 3.5rem" type="submit">保存</button>
</div>
</form>
+222
View File
@@ -0,0 +1,222 @@
<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">
<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="status">
<option value="">选择状态</option>
<? foreach ($showInfo['statusAry'] as $key => $value) { ?>
<option value="<?= $key ?>" <?= strlen($params['status']) && $key == $params['status'] ? 'selected' : '' ?>
><?= $value ?></option>
<? } ?>
</select>
</div>
</div>
<div class="am-form-group fl ml30">
<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">
<button data-modal="/receiver/tag/get" type="button" data-title="新增标签"
class="am-btn am-btn-success am-btn-sm w100">
新增
</button>
</div>
</div>
</div>
</form>
<div class="coms-table-bd" id="vue-show">
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
<table class="am-table am-table-bordered">
<thead>
<tr>
<th width="25%"><span>名称</span></th>
<th width="45%"><span>标签选项</span></th>
<th width="5%"><span>排序</span></th>
<th width="5%"><span>状态</span></th>
</tr>
</thead>
<tbody>
<?php if ($lists) {
foreach ($lists as $v) { ?>
<tr>
<td><?= $v['name'] ?></td>
<td><?= $v['options'] ?></td>
<td><?= $v['sort'] ?></td>
<td><?= $v['status_name'] ?></td>
</tr>
<tr>
<td colspan="4" class="align-r">
<a href="javascript:void(0);" @click="optionsModal(<?= $v['id'] ?>)"
class="am-btn am-btn-primary am-btn-xs">编辑选项</a>
<a href="javascript:void(0);" data-modal="/receiver/tag/get?id=<?= $v['id'] ?>"
data-title="编辑标签" class="am-btn am-btn-primary am-btn-xs">编辑标签</a>
<? if ($v['status'] == 1) { ?>
<a data-ajax="post" data-action="/receiver/tag/edit_status"
class="am-btn am-btn-danger am-btn-xs"
data-params-id="<?= $v['id'] ?>" data-params-status="0">关闭</a>
<?
} ?>
<? if ($v['status'] == 0) { ?>
<a data-ajax="post" data-action="/receiver/tag/edit_status"
class="am-btn am-btn-success am-btn-xs"
data-params-id="<?= $v['id'] ?>" data-params-status="1">开启</a>
<? } ?>
<a data-ajax="post" data-action="/receiver/tag/del" class="am-btn am-btn-danger am-btn-xs"
data-params-id="<?= $v['id'] ?>">删除</a>
</td>
</tr>
<?php }
} ?>
</tbody>
</table>
<div id="options-modal" style="display: none;">
<table class="table table-hover table-middle" style="table-layout:fixed">
<colgroup>
<col width="65%">
<col width="15%">
<col width="">
</colgroup>
<thead>
<tr>
<th class="text-center">标题</th>
<th class="text-center">排序</th>
<th class="text-right">
<a href="javascript:" style="margin-top: 2px;" class="btn btn-primary btn-sm"
@click='addOptions()'>添加</a>
</th>
</tr>
</thead>
<tbody>
<template v-for="(item,index) in optionsList">
<tr v-if="item.status==1">
<td class="text-center">
<input :id="'name_'+index" @blur="editName(index)" class="form-control"
v-model="item.name" placeholder="请输入标题"></td>
<td class="text-center">
<input :id="'group_name_'+index" @blur="editGroupName(index)" class="form-control"
v-model="item.sort" type="number" placeholder="请输入排序值">
</td>
<td class="text-right">
<a href="javascript:void(0);" style="margin-top:2px;"
class="btn btn-danger btn-sm" @click='delOptions(index)'>删除</a>
</td>
</tr>
</template>
</tbody>
</table>
</div>
</div>
<div class="coms-table-ft clearfix">
<div class="hander am-form">
</div>
<div class="coms-pagination fr mr20">
<?php page_view($pager) ?>
</div>
</div>
</div>
<script>
var vue_obj;
$(function () {
vue_obj = new Vue({
el: '#vue-show',
data: {
optionsList: [],
},
mounted: function () {
},
methods: {
optionsModal: function (id) {
layer.open({
type: 1,
area: ['50%', '50%'], //宽高
content: $('#options-modal'),
title: '编辑标签选项',
shade: false,
btn: ['保存', '取消'],
yes: function (index) {
$.ajax({
url: '/receiver/tag/edit_options',
type: 'post',
dataType: 'json',
data: {id: id, options: that.optionsList},
beforeSend: function () {
layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
},
success: function (data) {
if (data['code']) {
layer.msg(data.msg, {
icon: 1,
time: 2000
}, function () {
$.form.reload();
});
} else {
layer.msg(data.msg, {icon: 2});
}
},
complete: function () {
layer.closeAll('loading');
}
});
}
});
var that = this;
$.ajax({
url: '/receiver/tag/get_options',
type: 'post',
dataType: 'json',
data: {id: id},
beforeSend: function () {
},
success: function (re) {
if (re.code) {
that.optionsList = re.data.lists;
} else {
layer.msg(re.msg, {icon: 2});
}
},
complete: function () {
}
});
},
addOptions: function () {
var that = this;
that.optionsList.push({id: 0, name: '', status: 1, sort: 50});
},
delOptions: function (index) {
var that = this;
if (that.optionsList[index]['id'] > 0) {
that.optionsList[index]['status'] = -1;
} else {
that.optionsList.splice(index, 1);
}
},
editName: function (index) {
var name = $("#name_" + index).val();
if (name == '') {
layer.msg("标题不能为空!", {icon: 2});
return false;
}
},
// 修改排序
editGroupName: function (index) {
var order_view = $("#group_name_" + index).val();
if (order_view == '') {
layer.msg("排序值不能为空!", {icon: 2});
return false;
}
this.optionsList.sort(function (a, b) {
return b.sort - a.sort;
})
},
},
watch: {}
});
<?php page_script($pager) ?>
});
</script>
+6 -20
View File
@@ -33,34 +33,20 @@ class Temp extends HD_Controller
!$param['page'] && $param['page'] = 1;
$counts = intval($param['counts']);
ob_start(); //打开缓冲区
$where = array("cf_clues !=''" => null);
$res = $this->mdCustomers->select($where, 'id ASC', $param['page'], $param['size'], 'id,cf_clues');
$where = array("cf_title" => '素材推广');
$res = $this->mdCustomers->select($where, 'id ASC', $param['page'], $param['size'], 'id,cf_title');
if (!$res) {
echo '<br>本次更新客户线下来源完成了:';
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
echo '<br><br><a href="/plan/temp/receiver_customer_of">点击将再次更新客户线下来源>>></a>';
$this->mdCustomers->update(['cf_title' => '自有资源', 'of_id' => 5, 'of2_id' => 53], ['id' => 2873]);
exit;
}
$log = array();
foreach ($res as $key => $value) {
$of_id = 0;
$cf_clues = $value['cf_clues'];
if ($cf_clues == '自然进店') {
$of_id = 1;
} else if ($cf_clues == '外展' || $cf_clues == 'DM' || $cf_clues == '外展外拓') {
$of_id = 4;
} else if ($cf_clues == '转介绍') {
$of_id = 2;
} else if ($cf_clues == '网站' || $cf_clues == '垂直媒体') {
$of_id = 3;
} else if ($cf_clues == '自媒体' || $cf_clues == '其他') {
$of_id = 5;
}
if ($of_id) {
$this->mdCustomers->update(['of_id' => $of_id], ['id' => $value['id']]);
$log[] = array('id' => $value['id'], 'of_id' => $of_id);
$counts++;
}
$this->mdCustomers->update(['cf_title' => '自有资源', 'of_id' => 5, 'of2_id' => 53], ['id' => $value['id']]);
$log[] = array('id' => $value['id'], 'of_id' => 5);
$counts++;
}
echo '<br>成功更新:';
$log && print_r($log);
+24 -9
View File
@@ -55,9 +55,10 @@ class Customers extends Wxapp
'品牌车型' => $brand['name'] . $series['name'],
'颜色型号' => $color . '-' . $version,
'建卡时间' => date('Y-m-d', $row['c_time']),
'客户来源' => $row['cf_title'],
'客户来源' => $this->get_cfTitle($row),
'销售顾问' => isset($admin) ? $admin['uname'] : '',
];
$other_data['销售顾问'] = isset($admin) ? $admin['uname'] : '';
$row['cont_time'] != '0000-00-00 00:00:00' && $other_data['上次联系'] = date('Y-m-d', strtotime($row['cont_time']));
$data = [
'id' => $row['id'],
@@ -88,12 +89,7 @@ class Customers extends Wxapp
throw new Exception('数据不存在', ERR_PARAMS_ERROR);
}
$car_json = json_decode($row['car_json'], true);
$of_title = '';
if ($row['of_id']) {
$of_ary = $this->customers_model->offlineSources()[$row['of_id']];
$of_title = $of_ary['name'];
$row['of2_id'] && $of_title .= '-' . $of_ary['list'][$row['of2_id']];
}
$of_title = $row['of_id'] ? $this->get_cfTitle($row) : '';
$data['baseinfo'] = [
'name' => ['value' => $row['name'], 'cn' => '客户姓名'],
'mobile' => ['value' => $this->get_mobile(['mobile' => $row['mobile'], 'cf_title' => $row['cf_title']]), 'cn' => '客户电话'],
@@ -496,7 +492,8 @@ class Customers extends Wxapp
$count = $this->customers_model->count($where);
$lists = [];
if ($count) {
$fileds = 'id,name,admin_id,mobile,level,car_json,is_top,cf_title,brand_id,s_id,cont_time,c_time,defeat_time';
$fileds = 'id,name,admin_id,mobile,level,car_json,is_top,cf_title,brand_id,s_id,cont_time,c_time,defeat_time
,of_id,of2_id';
$rows = $this->customers_model->select($where, $orderby, $page, $size, $fileds);
//获取管理员
$admin_arr = array_unique(array_column($rows, 'admin_id'));
@@ -527,7 +524,7 @@ class Customers extends Wxapp
'品牌车型' => $brand_name . $serie_name,
'颜色型号' => $color . '-' . $version,
'建卡时间' => date('Y-m-d', $val['c_time']),
'客户来源' => $val['cf_title'],
'客户来源' => $this->get_cfTitle($val),
'销售顾问' => isset($admins[$val['admin_id']]) ? $admins[$val['admin_id']][0]['uname'] : '',
];
$val['cont_time'] != '0000-00-00 00:00:00' && $other_data['上次联系'] = date('Y-m-d', strtotime($val['cont_time']));
@@ -756,6 +753,24 @@ class Customers extends Wxapp
throw new Exception('操作失败', ERR_PARAMS_ERROR);
}
/**
* Notes:来源title
* Created on: 2022/3/11 15:53
* Created by: dengbw
* @param $params
* @return string
*/
private function get_cfTitle($params)
{
$title = $params['cf_title'] ? $params['cf_title'] : '';
if ($title == '自有资源' && $params['of_id']) {//自有资源 取线下来源
$of_ary = $this->customers_model->offlineSources()[$params['of_id']];
$title = $of_ary['name'];
$params['of2_id'] && $title .= '-' . $of_ary['list'][$params['of2_id']];
}
return $title;
}
/**
* Notes:显示电话格式
* Created on: 2022/3/9 14:38
+6 -3
View File
@@ -196,12 +196,13 @@ class Biz extends Wxapp
if (!$re_biz) {
return $this->Hd_exception(SYS_CODE_FAIL, '预约的门店不存在!');
}
$of_id = $of2_id = 0;
if ($type == 'biz') {
$cf_id = 29;
$cf_title = '自有资源';
} else {
$cf_id = $this->cf_id;
$cf_title = '素材推广';
$of_id = 5;
$of2_id = 53;//狸车素材
}
$add_data = [
'name' => $this->session['uname'] ? $this->session['uname'] : '',
@@ -209,12 +210,14 @@ class Biz extends Wxapp
'biz_id' => $biz_id,
'city_id' => $re_biz['city_id'],
'county_id' => $re_biz['county_id'],
'cf_title' => $cf_title,
'cf_title' => '自有资源',
'cf_id' => $cf_id,
't_id' => $t_id,
'p_time' => date('Y-m-d H:i:s'),
'c_time' => time()
];
$of_id && $add_data['of_id'] = $of_id;
$of2_id && $add_data['of2_id'] = $of2_id;
$where = ['biz_id' => $biz_id, 'mobile' => $add_data['mobile']];
$re_cus = $this->mdCustomers->get($where);
if ($re_cus) {
+3 -1
View File
@@ -103,7 +103,9 @@ class Syt_entity
'brand_id' => $brand_id,
'city_id' => $re_biz['city_id'],
'county_id' => $re_biz['county_id'],
'cf_title' => '私域活动',
'cf_title' => '自有资源',
'of_id' => 5,
'of2_id' => 53,//狸车素材
'cf_id' => $cf_id,
't_id' => $params['a_id'],
'p_time' => date('Y-m-d H:i:s'),
@@ -0,0 +1,30 @@
<?php
/**
* Notes:客户标签表
* Created on: 2022/3/10 10:31
* Created by: dengbw
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Receiver_customer_tag_model extends HD_Model
{
private $table_name = 'lc_receiver_customers_tag';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
/**
* Notes:类型
* Created on: 2021/7/27 10:31
* Created by: dengbw
* @return array
*/
public function statusAry()
{
return array(1 => '正常', 0 => '禁用');
}
}
@@ -14,7 +14,7 @@ class Receiver_customers_model extends HD_Model
private $status_arr = [-1 => '删除', 0 => '未见客户', 1 => '到店客户', 2 => '订单客户', 3 => '战败客户'];
private $level = ['H', 'A', 'B', 'C', 'D'];
private $cfrom_arr = ['自有资源', '平台分配', '素材推广', '私域活动'];
private $cfrom_arr = ['自有资源', '平台分配'];
private $cfrom_clues_arr = ['自然进店', '外展', 'DM', '转介绍', '其它', '网站', '外展外拓', '垂直媒体', '自媒体'];
private $buy_time = [3 => '3天(H级)', 7 => '7天(A级)', 15 => '15天(B级)', 30 => '30天 C级)'];
@@ -82,7 +82,7 @@ class Receiver_customers_model extends HD_Model
$arr[2] = ['name' => '转介绍', 'list' => [20 => '其他4S店', 21 => '其他二网', 22 => '汽车美容', 23 => '二手车', 24 => '修车厂', 25 => '驾校', 26 => '老车主']];
$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 => '狸车素材']];
$arr[5] = ['name' => '自媒体', 'list' => [50 => '小红书号', 51 => '咸鱼号', 52 => '抖音号', 53 => '狸车素材', 54 => '知乎号']];
if ($id) {
return $arr[$id];
} else {