This commit is contained in:
xiaoyu
2025-04-06 11:13:15 +08:00
parent 2f91944191
commit 1f68bd2095
3 changed files with 195 additions and 121 deletions
+75 -1
View File
@@ -387,13 +387,87 @@ class Customer extends HD_Controller
public function export()
{
$params = $this->input->get();
if ($params['c_time']) {
$c_time = explode(' ~ ', $params['c_time']);
if ($c_time[0]) {
$where["c_time >="] = $c_time[0] . ' 00:00:00';
}
if ($c_time[1]) {
$where["c_time <="] = $c_time[1] . ' 23:59:59';
}
}
//上传时间
if ($params['p_time']) {
$p_time = explode(' ~ ', $params['p_time']);
if ($p_time[0]) {
$where["p_time >="] = $p_time[0] . ' 00:00:00';
}
if ($p_time[1]) {
$where["p_time <="] = $p_time[1] . ' 23:59:59';
}
}
$province_id = intval($params['province_id']);
$city_id = intval($params['city_id']);
$province_id && $where['province_id'] = $province_id;
$city_id && $where['city_id'] = $city_id;
$params['channel'] && $where['channel'] = $params['channel'];
$params['cfrom_id'] && $where['cfrom'] = $params['cfrom_id'];
$params['cfrom_id2'] && $where['cfrom2'] = $params['cfrom_id2'];
$params['brand_id'] && $where['brand_id'] = $params['brand_id'];
$params['series_id'] && $where['series_id'] = $params['series_id'];
$page = 1;
$size = 10000;
$indexs = [
'mobile' => '手机',
'cfrom' => '来源一',
'cfrom2' => '来源二',
'city_name' => '所在城市',
'channel' => '渠道',
'brand' => '品牌',
'series' => '车型',
"p_time" => "上传时间",
];
$count = $this->autohome_customer_model->count($where);
$data = [];
if ($count) {
$rows = $this->autohome_customer_model->select($where, 'id desc', $page, $size);
$brands = $this->auto_brand_model->get_map_by_ids(array_column($rows, 'brand_id'));
$series = $this->auto_series_model->get_map_by_ids(array_column($rows, 'series_id'));
$map_biz = $this->biz_model->map('biz_name', 'id', ['status' => 1, 'province_id' => 350000], '', 0, 0, 'id,biz_name');
foreach ($rows as $val){
$val['brand'] = $brands[$val['brand_id']][0]['name'];
$val['series'] = $series[$val['series_id']][0]['name'];
if($val['cfrom'] == 1){
$cf2 = $this->cfrom2[$val['cfrom2']];
}else{
$cf2 = $map_biz[$val['cfrom2']];
}
$val['cfrom'] = $this->cfrom[$val['cfrom']];
$val['cfrom2'] = $cf2;
$val['channel'] = $this->channel[$val['channel']];
$data[] = $val;
}
}
$fileName = '客户列表';
array_unshift($data, $indexs);
$this->load->library('excel');
$this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis'));
}
function json_map_cfrom()
{
$pid = $this->input->post('pid');
$map_biz = $this->biz_model->map('biz_name', 'id', ['status' => 1, 'province_id' => 350000, 'type' => 0], '', 0, 0, 'id,biz_name');
$map_biz = $this->biz_model->map('biz_name', 'id', ['status' => 1, 'province_id' => 350000, 'type' => 2], '', 0, 0, 'id,biz_name');
if($pid == 1){
$this->data = $this->cfrom2;
+116 -116
View File
@@ -949,122 +949,7 @@ class Customer extends HD_Controller
public function export()
{
$params = $this->input->get();
$where = $this->get_where($params);
#$where["cs_biz_id >= 0"] = null;
$page = 1;
$size = 10000;
//$params['export_tag'] && $size = 500;
$indexs = [
'id' => 'ID',
'name' => '客户姓名',
'mobile' => '手机',
'level' => '客户等级',
'status_name' => '客户状态',
'city_name' => '所在城市',
'county_name' => '所在地区',
'to_send' => '是否改派',
'c_time' => '建档时间',
"p_time" => "派单时间",
"dt_time" => "到店时间",
"order_time" => "下单时间",
"cont_time" => "最后联系时间",
"of_title_1" => "来源1",
"of_title_2" => "来源2",
"biz_name" => "归属门店",
"admin_name" => "归属顾问",
"wxgr_name" => "加个微",
'brand_detail' => '关注品牌',
'series_detail' => '关注车型'
];
$count = $this->customers_model->count($where);
$data = [];
$offlineSources = $this->customers_model->offlineSources();
$status_arr = $this->customers_model->get_status();
unset($status_arr['-1']);
if ($count) {
$fileds = "id, name, mobile, level, status, cs_biz_id,brand_id,series_id, FROM_UNIXTIME(c_time) as c_time, if(dt_time>0, dt_time,'') as dt_time, p_time, if(order_time>0, order_time,'') as order_time, if(cont_time>0, cont_time,'') as cont_time, c_brand, cf_id, of_id, of2_id, (SELECT biz_name FROM `lc_biz` where id = `lc_receiver_customers`.biz_id) as biz_name, (SELECT uname FROM `lc_app_licheb_users` where id = `lc_receiver_customers`.admin_id) as admin_name, biz_id, admin_id, wxqy, wxgr, (select city_name from lc_area where city_id = lc_receiver_customers.city_id limit 1) as city_name, (select county_name from lc_area where county_id = lc_receiver_customers.county_id limit 1) as county_name";
$rows = $this->customers_model->select($where, 'id desc', $page, $size, $fileds);
$brands = $this->auto_brand_model->get_map_by_ids(array_column($rows, 'brand_id'));
$series = $this->auto_series_model->get_map_by_ids(array_column($rows, 'series_id'));
foreach ($rows as $key => $val) {
$brand_detail = $series_detail = $of_title = '';
$of_title_1 = $of_title_2 = '';
if ($val['of_id']) {
$of_ary = $offlineSources[$val['of_id']];
$of_title = $of_ary['name'];
$of_ary['name'] && $of_title_1 = $of_ary['name'];
$val['of2_id'] && $of_title .= '-' . $of_ary['list'][$val['of2_id']];
$val['of2_id'] && $of_ary['list'][$val['of2_id']] && $of_title_2 = $of_ary['list'][$val['of2_id']];
}
if ($brands[$val['brand_id']]) {
$brand_detail = $brands[$val['brand_id']][0]['name'];
$series_detail = $series[$val['series_id']][0]['name'];
}
$id = $val['id'];
$row = array(
'id' => $id,
'name' => $val['name'],
'mobile' => $this->get_mobile(['of_id' => $val['of_id'], 'mobile' => $val['mobile']]),
'level' => $val['level'],
'status_name' => $status_arr[$val['status']],
'city_name' => $val['city_name'],
'county_name' => $val['county_name'],
'to_send' => $this->customers_model->csbizidAry($val['cs_biz_id'] ? $val['cs_biz_id'] : 0),
'c_time' => $val['c_time'],
'dt_time' => $val['dt_time'],
'p_time' => $val['p_time'],
'order_time' => $val['order_time'],
'cont_time' => $val['cont_time'],
'of_title_1' => $of_title_1,
'of_title_2' => $of_title_2,
'biz_name' => $val['biz_name'],
'admin_name' => $val['admin_name'],
'wxgr_name' => $this->customers_model->wxgrAry($val['wxgr']),
'brand_detail' => $brand_detail,
'series_detail' => $series_detail,
);
if ($params['export_tag']) {
$tag = $this->get_tag($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))) {
$indexs[$tag_key] = $val['name'];
}
}
$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'];
}
}
$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'];
}
}
}
$data[] = $row;
}
}
$fileName = '客户列表';
array_unshift($data, $indexs);
$this->load->library('excel');
$this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis'));
}
public function export_statdata()
@@ -1076,7 +961,122 @@ class Customer extends HD_Controller
}
$where = ['id' => $id];
$re = $this->statplan->get($where);
if (!$re) {
if (!$re) {$params = $this->input->get();
$where = $this->get_where($params);
#$where["cs_biz_id >= 0"] = null;
$page = 1;
$size = 10000;
//$params['export_tag'] && $size = 500;
$indexs = [
'id' => 'ID',
'name' => '客户姓名',
'mobile' => '手机',
'level' => '客户等级',
'status_name' => '客户状态',
'city_name' => '所在城市',
'county_name' => '所在地区',
'to_send' => '是否改派',
'c_time' => '建档时间',
"p_time" => "派单时间",
"dt_time" => "到店时间",
"order_time" => "下单时间",
"cont_time" => "最后联系时间",
"of_title_1" => "来源1",
"of_title_2" => "来源2",
"biz_name" => "归属门店",
"admin_name" => "归属顾问",
"wxgr_name" => "加个微",
'brand_detail' => '关注品牌',
'series_detail' => '关注车型'
];
$count = $this->customers_model->count($where);
$data = [];
$offlineSources = $this->customers_model->offlineSources();
$status_arr = $this->customers_model->get_status();
unset($status_arr['-1']);
if ($count) {
$fileds = "id, name, mobile, level, status, cs_biz_id,brand_id,series_id, FROM_UNIXTIME(c_time) as c_time, if(dt_time>0, dt_time,'') as dt_time, p_time, if(order_time>0, order_time,'') as order_time, if(cont_time>0, cont_time,'') as cont_time, c_brand, cf_id, of_id, of2_id, (SELECT biz_name FROM `lc_biz` where id = `lc_receiver_customers`.biz_id) as biz_name, (SELECT uname FROM `lc_app_licheb_users` where id = `lc_receiver_customers`.admin_id) as admin_name, biz_id, admin_id, wxqy, wxgr, (select city_name from lc_area where city_id = lc_receiver_customers.city_id limit 1) as city_name, (select county_name from lc_area where county_id = lc_receiver_customers.county_id limit 1) as county_name";
$rows = $this->customers_model->select($where, 'id desc', $page, $size, $fileds);
$brands = $this->auto_brand_model->get_map_by_ids(array_column($rows, 'brand_id'));
$series = $this->auto_series_model->get_map_by_ids(array_column($rows, 'series_id'));
foreach ($rows as $key => $val) {
$brand_detail = $series_detail = $of_title = '';
$of_title_1 = $of_title_2 = '';
if ($val['of_id']) {
$of_ary = $offlineSources[$val['of_id']];
$of_title = $of_ary['name'];
$of_ary['name'] && $of_title_1 = $of_ary['name'];
$val['of2_id'] && $of_title .= '-' . $of_ary['list'][$val['of2_id']];
$val['of2_id'] && $of_ary['list'][$val['of2_id']] && $of_title_2 = $of_ary['list'][$val['of2_id']];
}
if ($brands[$val['brand_id']]) {
$brand_detail = $brands[$val['brand_id']][0]['name'];
$series_detail = $series[$val['series_id']][0]['name'];
}
$id = $val['id'];
$row = array(
'id' => $id,
'name' => $val['name'],
'mobile' => $this->get_mobile(['of_id' => $val['of_id'], 'mobile' => $val['mobile']]),
'level' => $val['level'],
'status_name' => $status_arr[$val['status']],
'city_name' => $val['city_name'],
'county_name' => $val['county_name'],
'to_send' => $this->customers_model->csbizidAry($val['cs_biz_id'] ? $val['cs_biz_id'] : 0),
'c_time' => $val['c_time'],
'dt_time' => $val['dt_time'],
'p_time' => $val['p_time'],
'order_time' => $val['order_time'],
'cont_time' => $val['cont_time'],
'of_title_1' => $of_title_1,
'of_title_2' => $of_title_2,
'biz_name' => $val['biz_name'],
'admin_name' => $val['admin_name'],
'wxgr_name' => $this->customers_model->wxgrAry($val['wxgr']),
'brand_detail' => $brand_detail,
'series_detail' => $series_detail,
);
if ($params['export_tag']) {
$tag = $this->get_tag($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))) {
$indexs[$tag_key] = $val['name'];
}
}
$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'];
}
}
$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'];
}
}
}
$data[] = $row;
}
}
$fileName = '客户列表';
array_unshift($data, $indexs);
$this->load->library('excel');
$this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis'));
return $this->show_json(SYS_CODE_FAIL, '计划不存在!');
}
+4 -4
View File
@@ -122,7 +122,7 @@
</div>
</div>
</div>
<div-- class="am-form-group fl" style="margin-bottom: 0px;">
<div class="am-form-group fl" style="margin-bottom: 0px;">
<div class="am-form-group fl ml30">
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
</div>
@@ -132,11 +132,11 @@
<div class="am-form-group fl ml10">
<button type="button" class="am-btn am-btn-success am-btn-sm w100" @click="reset">重置</button>
</div>
<!--div class="am-form-group fl ml10">
<div class="am-form-group fl ml10">
<button type="button" class="am-btn am-btn-success am-btn-sm w100" @click="export_out"
title="最多500条" v-if="export_button">导出
</button>
</div-->
</div>
<div class="am-form-group fl ml10">
<button type="button" class="am-btn am-btn-success am-btn-sm w150" @click="push_search">按搜索结果上传</button>
</div>
@@ -300,7 +300,7 @@
return false;
}
let href = $.menu.parseUri(window.location.href);
href = href.replace("clues?", "clues/export?");
href = href.replace("customer?", "customer/export?");
window.location.href = href;
},
push_search: function (){