This commit is contained in:
lin fan
2024-11-21 11:16:45 +08:00
parent ddbc7de320
commit 3997c42926
8 changed files with 941 additions and 13 deletions
+423
View File
@@ -0,0 +1,423 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Customer extends HD_Controller
{
private $cfrom = [1 => '空间站', 2 => '车卖场'];
private $cfrom2 = [11 => '厦门', 12 => '海口', 13 => '长沙', 14 => '佛山', 15 => '贵阳'];
private $channel = [1 => '抖音直播', 2 => '其他'];
private $push_status = ['0' => '未上传', '-1' => '上传失败'];
private $dis_status = [0 => '未分发', 2 => '分发失败'];
private $pushAppKey = '0d14a33984239fd744fa47719de5f916';
private $keySupplyBusinessId = '67';
private $keyOutsidePvareaidId = '303556333';
private $keyExt5 = '10477';
public function __construct()
{
parent::__construct();
$this->load->model('autohome/autohome_customer_model');
$this->load->model("area_model");
$this->load->model("biz/biz_model");
$this->load->model("auto/auto_brand_model");
$this->load->model("auto/auto_series_model");
$this->load->helper('order');
$this->load->library('mycurl');
}
public function index()
{
$params = $this->input->get();
list($lists, $count) = $this->lists();
$this->data['province_id'] = intval($params['province_id']);
$this->data['city_id'] = intval($params['city_id']);
$this->data['provinces'] = $this->province_ary();
$this->data['lists'] = $lists;
$this->data['params'] = $params;
$this->data['cfromAry'] = $this->cfrom;
$this->data['channelAry'] = $this->channel;
$this->data['export_button'] = SUPER_ADMIN == $this->role ? 1 : 0;
$this->data['_title'] = '线索列表';
return $this->show_view('autohome/lists', true);
}
public function lists($push = false)
{
$params = $this->input->get();
$where = [];
$page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
$size = $params['size'] = $params['size'] ? intval($params['size']) : 20;
if (strlen($params['push_id'])) {
switch ($params['push_id']){
case '0':
$where["push_id"] = 0;
break;
case '-1':
$where["push_id"] = -1;
break;
default:
$where["push_id not in ('0', '-1')"] = null;
}
}
if ($params['mobile']) {
$where["{$params['mobile']} like '{$params['mobile']}'"] = null;
}
//创建时间
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['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'];
$count = $this->autohome_customer_model->count($where);
$lists = [];
if ($count) {
$rows = $this->autohome_customer_model->select($where, '', $page, $size);
$city_id_arr = array_filter(array_unique(array_column($rows, 'city_id')));
if ($city_id_arr) {
$str_ids = implode(',', $city_id_arr);
$map_area_city = $this->area_model->map('city_id', '', ["city_id in ({$str_ids})" => null], '', 0, $size, 'city_id,province_name,city_name');
}
$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){
$area = $map_area_city[$val['city_id']][0];
$val['area_title'] = "{$area['province_name']}-{$area['city_name']}";
$val['car_title'] = $brands[$val['brand_id']][0]['name']." ".$series[$val['series_id']][0]['name'];
if($val['cfrom'] == 1){
$cf2 = $this->cfrom2[$val['cfrom2']];
}else{
$cf2 = $map_biz[$val['cfrom2']];
}
$val['cf_title'] = $this->cfrom[$val['cfrom']]." ".$cf2;
$val['channel'] = $this->channel[$val['channel']];
$val['push_status'] = $this->push_status[$val['push_id']] ? $this->push_status[$val['push_id']] : '上传成功';
$val['dis_status'] = $this->dis_status[$val['dis_status']];
}
$lists[] = $val;
}
$this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count);
return [$lists, $count];
}
public function get()
{
$id = intval($this->input->get('id'));
$info = ['province_id' => 0];
if ($id) {
$info = $this->item_model->get(['id' => $id]);
$info['src_img'] = build_qiniu_image_url($info['img']);
}
$this->data['provinces'] = $this->province_ary();
$this->data['info'] = $info;
$this->data['_title'] = $id ? '编辑' : '新增';
return $this->show_view('/receiver/items/edit', true);
}
public function add()
{
$info = $this->input->post();
$data = [
'title' => $info['title'],
's_time' => $info['s_time'],
'e_time' => $info['e_time'],
'img' => $info['img'],
'province_id' => $info['province_id'],
'descrip' => $info['descrip'],
];
$res = $this->item_model->add($data);
if (!$res) {
return $this->show_json(SYS_CODE_FAIL, '保存失败');
}
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
}
//编辑单条数据
public function edit()
{
$info = $this->input->post();
$row = $this->item_model->get(['id' => $info['id']]);
if (!$row) return $this->show_json(SYS_CODE_FAIL, '数据不存在');
$up_data = [
'title' => $info['title'],
's_time' => $info['s_time'],
'e_time' => $info['e_time'],
'img' => $info['img'],
'province_id' => $info['province_id'],
'descrip' => $info['descrip'],
];
$res = $this->item_model->update($up_data, ['id' => $info['id']]);
if (!$res) {
return $this->show_json(SYS_CODE_FAIL, '保存失败');
}
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
}
public function del()
{
}
public function batch()
{
}
function add_excel()
{
require_once COMMPATH . '/third_party/PHPExcel/IOFactory.php';
$res = $this->upload();
if (!$res['code']) {
return $this->show_json(0, $res['message']);
}
$file = $res['path'];
if ($res['file_ext'] == '.xls') {
$reader = \PHPExcel_IOFactory::createReader('Excel5'); // 读取 excel 文档
} elseif ($res['file_ext'] == '.xlsx') {
$reader = \PHPExcel_IOFactory::createReader('Excel2007'); // 读取 excel 文档
} else {
return $this->show_json(SYS_CODE_FAIL, '文件无法识别');
}
$PHPExcel = $reader->load($file); // 文档名称
$objWorksheet = $PHPExcel->getActiveSheet();
$rowCnt = $objWorksheet->getHighestRow(); //获取总行数
if ($rowCnt > 800) {
@unlink($file);
return $this->show_json(0, '数据大于800请拆分多个表格导入');
}
$data = array();
for ($_row = 2; $_row <= $rowCnt; $_row++) { //读取内容
$data[] = array(
'name' => $objWorksheet->getCell('A' . $_row)->getValue(),
'mobile' => $objWorksheet->getCell('B' . $_row)->getValue(),
'cfrom1' => $objWorksheet->getCell('C' . $_row)->getValue(),
'cfrom2' => $objWorksheet->getCell('D' . $_row)->getValue(),
'channel' => $objWorksheet->getCell('E' . $_row)->getValue(),
'province_name' => $objWorksheet->getCell('F' . $_row)->getValue(),
'city_name' => $objWorksheet->getCell('G' . $_row)->getValue(),
'brand_id' => $objWorksheet->getCell('H' . $_row)->getValue(),
'series_id' => $objWorksheet->getCell('I' . $_row)->getValue(),
);
}
$done = $this->add_batch($data);
@unlink($file);
$this->data['load_num'] = count($data);
$this->data['done'] = $done;
return $this->show_json(SYS_CODE_SUCCESS, "成功导入{$done}");
}
public function add_batch($lists=array())
{
$done = 0;
$adds = $map_province = $map_city = $map_county = $map_biz = [];
$cfrom_f = array_flip($this->cfrom);
$cfrom2_f = array_flip($this->cfrom2);
$map_biz = $this->biz_model->map('biz_name', 'id', ['status' => 1, 'province_id' => 350000], '', 0, 0, 'id,biz_name');
$province_strings = implode("','", array_unique(array_column($lists, 'province_name')));
if ($province_strings) $where = ["province_name in ('{$province_strings}')" => null];
$province_strings && $map_province = $this->area_model->map('province_name', 'province_id', $where, '', 0, 0, 'DISTINCT(province_id),province_name');
$city_strings = implode("','", array_unique(array_column($lists, 'city_name')));
if ($city_strings) $where = ["city_name in ('{$city_strings}')" => null];
$city_strings && $map_city = $this->area_model->map('city_name', 'city_id', $where, '', 0, 0, 'DISTINCT(city_id),city_name');
$fails = array();
foreach ($lists as $k => $v) {
if (!$v['name']) {
$fails[] = array('data' => $v, 'msg' => 'name is null');
continue;
}
if (!mobile_valid($v['mobile'])) {
$fails[] = array('data' => $v, 'msg' => 'mobile valid fail');
continue;
}
if ($this->autohome_customer_model->count(['mobile' => $v['mobile']])) {
$fails[] = array('data' => $v, 'msg' => 'mobile duplicate');
continue;
}
$cf_id = $cfrom_f[$v['cfrom1']];
if($cf_id == 1){
$cf2_id = $cfrom2_f[$v['cfrom2']];
}else{
$cf2_id = $map_biz[$v['cfrom2']];
}
$temp = array(
'name' => $v['name'],
'mobile' => $v['mobile'],
'cfrom' => $cf_id ? $cf_id : 0,
'cfrom2' => $cf2_id ? $cf2_id : 0,
'channel' => $v['channel'] ? $v['channel'] : '',
'brand_id' => $v['brand_id'] ? $v['brand_id'] : '',
'series_id' => $v['series_id'] ? $v['series_id'] : '',
'province_id' => $map_province[$v['province_name']] ? $map_province[$v['province_name']] : 0,
'city_id' => $map_city[$v['city_name']] ? $map_city[$v['city_name']] : 0,
'c_time' => date('Y-m-d H:i:s'),
);
$adds[] = $temp;
$done++;
}
$fails && debug_log('[warning]# fails=' . json_encode($fails), __FUNCTION__, $this->log_dir);
if ($adds) {
$ret = $this->autohome_customer_model->add_batch($adds);
if (!$ret) {
debug_log("[error] add_batch fail; " . $this->autohome_customer_model->db->last_query(), __FUNCTION__, $this->log_dir);
$done = 0;
}
}
return $done;
}
private function upload()
{
$config['upload_path'] = $_SERVER['DOCUMENT_ROOT'] . '/temp/';
$config['allowed_types'] = 'xls|xlsx';
$config['max_size'] = 5120;
$config['file_name'] = 'receiver_clues' . time() . rand(1, 99999);
$this->load->library('upload', $config);
if (!$this->upload->do_upload('file')) {
return array('code' => SYS_CODE_FAIL, 'message' => $this->upload->display_errors('', ''));
} else {
$data = $this->upload->data();
return array('code' => SYS_CODE_SUCCESS, 'path' => $data['full_path'], 'file_ext' => $data['file_ext']);
}
}
public function export()
{
}
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');
if($pid == 1){
$this->data = $this->cfrom2;
}else{
$this->data = array_flip($map_biz);
}
return $this->show_json(SYS_CODE_SUCCESS);
}
public function push_search(){
$url = 'https://autoapi.autohome.com.cn/ggxt/xsyw/api/clues/push';
list($lists, $count) = $this->lists(1);
$succ = $fail = $undo = 0;
if($lists){
foreach ($lists as $v){
if($v['push_id']){
$undo++;
continue;
}
$flowOrderNo = addslashes(json_encode(array('flowOrderNo' => create_customer_no())));
$push_data = array(
'pushAppKey' => $this->pushAppKey,
'keySupplyBusinessId' => $this->keySupplyBusinessId,
'keyOutsidePvareaidId' => $this->keyOutsidePvareaidId,
'keyExt5' => $this->keyExt5,
'keyExt12' => $flowOrderNo,
'splitCode' => '123',
'keyPrivateFlag' => '0',
'keyTypeId' => '2',
'keyOrderTime' => $v['c_time'],
'keyOrderCityId' => $v['city_id'] ? $v['city_id'] : '110100',
'keyName' => '客户'.$v['id'],
'keyPhone' => $v['mobile'],
'keyPurposeBrandId' => $v['brand_id'] ? $v['brand_id'] : null,
'keyPurposeFactoryId' => null,
'keyCarAudiId' => $v['series_id'] ? $v['series_id'] : null,
'keyCarTypeId' => null,
'keyCardCityId' => $v['city_id'] ? $v['city_id'] : '110100',
);
$res = $this->mycurl->httpPost($url, $push_data, 'is_json');
if($res){
$res = json_decode($res, true);
if(!$res['status']){
$up = array(
'push_json' => json_encode($push_data),
'push_id' => $res['result']['pushId'],
'p_time' => date('Y-m-d H:i:s'),
);
$succ++;
}else{
$push_data['res'] = $res;
$up = array(
'push_json' => json_encode($push_data),
'push_id' => -1,
'p_time' => date('Y-m-d H:i:s'),
);
$fail++;
}
$this->autohome_customer_model->update($up, array('id' => $v['id']));
}
}
$this->data['succ'] = $succ;
$this->data['fail'] = $fail;
$this->data['undo'] = $undo;
return $this->show_json(SYS_CODE_SUCCESS);
}
}
public function get_dis_status(){
$url = 'https://autoapi.autohome.com.cn/pj-clues-handler/api/queryCluesInfo';
$push_data = array(
'appKey' => $this->pushAppKey,
'keySupplyBusinessId' => $this->keySupplyBusinessId,
'pushIds' => '1725586964500443136',
);
$res = $this->mycurl->httpPost($url, $push_data, 'is_json');
if($res){
print_r($res);
}
}
}
-3
View File
@@ -782,9 +782,6 @@ class Clues extends HD_Controller
];
$city_id && $where['city_id'] = $city_id;
$county_id && $where['county_id'] = $county_id;
$typeAry = $this->biz_model->type_ary();
$type_ids = implode(',', array_keys($typeAry));
$type_ids && $where["type in ($type_ids)"] = null;
$bizList = $this->biz_model->select($where, '', '', '', 'id,biz_name');
$this->data['bizList'] = $bizList;
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
+492
View File
@@ -0,0 +1,492 @@
<link rel="stylesheet" type="text/css" href="/static/css/font-awesome.min.css?v=1581252500">
<div class="bs-example bs-example-tabs" data-example-id="togglable-tabs" style="font-size:15px;">
<div id="recom-stat"></div>
</div>
<div class="coms-table-wrap mt10">
<form class="form-search coms-table-hd clearfix no-border" onsubmit="return false" action="/autohome/customer" id="search_form">
<div class="am-form am-form-horizontal">
<div class="am-form-group fl">
<label class="am-para-label w100">客户搜索:</label>
</div>
<div class="am-form-group fl">
<div class="am-para-inline w200">
<input name="mobile" type="text" placeholder="输入手机号查询" value="<?= $params['mobile'] ?>"/>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w80">上传状态:</label>
<div class="am-para-inline w100">
<select name="push_id">
<option value=''>请选择</option>
<option value='0' <?php if($params['push_id'] == '0'){?> selected="selected" <?php }?> >未上传</option>
<option value='1' <?php if($params['push_id'] == '1'){?> selected="selected" <?php }?> >上传成功</option>
<option value='-1' <?php if($params['push_id'] == '-1'){?> selected="selected" <?php }?> >上传失败</option>
</select>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w80">分发状态:</label>
<div class="am-para-inline w100">
<select name="dis_status">
<option value=''>请选择</option>
<option value='0' <?php if($params['dis_status'] == '0'){?> selected="selected" <?php }?> >未分发</option>
<option value='1' <?php if($params['dis_status'] == '1'){?> selected="selected" <?php }?> >分发成功</option>
<option value='2' <?php if($params['dis_status'] == '2'){?> selected="selected" <?php }?> >分发失败</option>
</select>
</div>
</div>
<div class="fl" style="width:1920px">
<label class="am-para-label w100">线索来源:</label>
<div class="am-form-group am-para-inline w150">
<select name="cfrom_id" v-model="cfrom_id">
<option value=0>请选择</option>
<option :value="i" v-for="(v,i) in cfromAry">{{v}}</option>
</select>
</div>
<div class="am-form-group am-para-inline w150">
<select name="cfrom_id2" v-model="cfrom_id2">
<option value=0>请选择</option>
<option :value="i" v-for="(v,i) in cfromAry2">{{v}}</option>
</select>
</div>
<label class="am-para-label w100">线索渠道:</label>
<div class="am-form-group am-para-inline w150">
<select name="channel" v-model="channel">
<option value=0>请选择</option>
<option :value="i" v-for="(v,i) in channelAry">{{v}}</option>
</select>
</div>
</div>
<div class="fl">
<label class="am-para-label w100">所属地区:</label>
<div class="am-form-group am-para-inline w150">
<select name="province_id" v-model="province_id">
<option value="0">省份</option>
<option :value="v.id" v-for="(v,i) in provinceAry">{{v.name}}</option>
</select>
</div>
<div class="am-form-group am-para-inline w150">
<select name="city_id" v-model="city_id">
<option value="0">城市</option>
<option :value="v.id" v-for="(v,i) in cityAry">{{v.name}}</option>
</select>
</div>
<label class="am-para-label w100">品牌车型:</label>
<div class="am-para-inline w120">
<select name="brand_id" v-model="brand_id">
<option :value="v.id" v-for="(v,i) in brandAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w120">
<select name="series_id" v-model="series_id">
<option :value="v.id" v-for="(v,i) in seryAry">{{v.name}}</option>
</select>
</div>
</div>
<div class="fl" style="width:1920px">
<label class="am-para-label w100">创建时间:</label>
<div class="am-form-group fl">
<div class="am-para-inline w300">
<input id="id-create-time" name="c_time" type="text" value="<?= $params['c_time'] ?>"
placeholder="创建时间范围" autocomplete="off"/>
</div>
<div class="am-para-inline" style="padding-top: 5px;">
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="today" data-btn="create"
data-source="id-create-time">今日</a>
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="yesterday" data-btn="create"
data-source="id-create-time">昨日</a>
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="weeks" data-btn="create"
data-source="id-create-time">本周</a>
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="month" data-btn="create"
data-source="id-create-time">本月</a>
</div>
</div>
</div>
<div class="fl" style="width:1920px">
<label class="am-para-label w100">上传时间:</label>
<div class="am-form-group fl">
<div class="am-para-inline w300">
<input id="id-push-time" name="p_time" type="text" value="<?= $params['p_time'] ?>"
placeholder="上传时间范围" autocomplete="off"/>
</div>
<div class="am-para-inline" style="padding-top: 5px;">
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="today" data-btn="push"
data-source="id-push-time">今日</a>
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="yesterday" data-btn="push"
data-source="id-push-time">昨日</a>
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="weeks" data-btn="push"
data-source="id-push-time">本周</a>
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="month" data-btn="push"
data-source="id-push-time">本月</a>
</div>
</div>
</div>
<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>
<div class="am-form-group fl ml10">
<button type="button" id="import" class="am-btn am-btn-success am-btn-sm w100">导入</button>
</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>
<!--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 class="am-form-group fl ml10">
<button type="button" class="am-btn am-btn-success am-btn-sm w150" @click="push_search">按搜索结果上传</button>
</div>
</div>
</div>
</form>
<div class="coms-table-bd">
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
<table class="am-table am-table-bordered ">
<thead>
<tr>
<th width="15%"><span>客户</span></th>
<th width="15%"><span>所属地区</span></th>
<th width="15%"><span>品牌车型</span></th>
<th width="15%"><span>线索来源</span></th>
<th width="15%"><span>线索渠道</span></th>
<th width="10%"><span>上传状态</span></th>
<th width="10%"><span>分发状态</span></th>
<th width="15%"><span>上传时间</span></th>
</tr>
</thead>
<tbody>
<? if ($lists) {
foreach ($lists as $v) { ?>
<tr>
<td style="vertical-align: middle;"><a
data-open="/receiver/clues/get?id=<?= $v['id'] ?>&type=clues"
href="javascript:void(0);"><?= $v['name'] ?><br><?= $v['mobile'] ?></a></td>
<td style="vertical-align: middle;"><?= $v['area_title'] ?></td>
<td style="vertical-align: middle;"><?= $v['car_title'] ?></td>
<td style="vertical-align: middle;"><?= $v['cf_title'] ?></td>
<td style="vertical-align: middle;"><?= $v['channel'] ?></td>
<td style="vertical-align: middle;"><?= $v['push_status'] ?></td>
<td style="vertical-align: middle;"><?= $v['dis_status'] ?></td>
<td style="vertical-align: middle;"><?=$v['c_time']?></td>
</tr>
<? }
} ?>
</tbody>
</table>
</div>
<div class="coms-table-ft clearfix">
<div class="hander am-form">
</div>
<div class="coms-pagination fr mr20">
<? page_view($pager) ?>
</div>
</div>
<div id="cule-modal" style="display: none;padding: 10px">
<div class="modal-body">
<div class="text-center">
<h2><i class="fa fa-info-circle"></i> 请上传Excel文件</h2>
<p>Excel文件格式必须与模板保持一致,否则无法导入</p>
<div class="form-group-action">
<a href="/temp/clues.xlsx" target="_blank" class="btn btn-default">查看模板</a>
<label href="javascript:" class="btn btn-primary" style="margin-left: 10px;">
<form id="import-form">
<input type="file" id="clue-file" name="file" accept=".xls,.xlsx"
style="left:-9999px;position:absolute;" onchange="load_clue()">
</form>
<span>上传Excel文件</span>
</label>
</div>
</div>
</div>
</div>
</div>
<script>
$(function () {
vue_obj = new Vue({
el: '#search_form',
data: {
province_id: <?=$params['province_id'] ? $params['province_id'] : 0?>,
city_id: <?=$params['city_id'] ? $params['city_id'] : 0?>,
cfrom_id: <?=$params['cfrom_id'] ? $params['cfrom_id'] : 0?>,
cfrom_id2: <?=$params['cfrom_id2'] ? $params['cfrom_id2'] : 0?>,
brand_id: <?=$params['brand_id'] ? $params['brand_id'] : 0?>,
series_id: <?=$params['series_id'] ? $params['series_id'] : 0?>,
channel: <?=$params['channel'] ? $params['channel'] : 0?>,
cfromAry: [],
cfromAry2: [],
channelAry: [],
provinceAry: [],
cityAry: [],
brandAry: [],
seryAry: [],
export_button: 1
},
mounted: function () {
this.init_provinces();
this.init_citys();
this.cfromAry = <?=json_encode($cfromAry, JSON_UNESCAPED_UNICODE)?>;
this.channelAry = <?=json_encode($channelAry, JSON_UNESCAPED_UNICODE)?>;
this.init_brands();
this.get_series();
this.init_cfrom2();
},
methods: {
init_brands: function () {
var vm = this;
$.get('/common/auto', {'type': 1, 'tp': 0}, function (response) {
vm.brandAry = response.data;
})
},
get_series: function () {
var vm = this;
vm.seryAry = {};
$.get('/common/auto', {'type': 2, 'tp': 0, 'pid': vm.brand_id}, function (response) {
vm.seryAry = response.data;
})
},
init_provinces: function () {
var vm = this;
$.get('common/area', {}, function (response) {
if (response.code == 1) {
vm.provinceAry = response.data;
}
});
},
init_citys: function () {
var vm = this;
$.get('common/area', {id: vm.province_id, key: 'city', type: 1}, function (response) {
if (response.code == 1) {
vm.cityAry = response.data;
}
});
},
init_cfrom2: function () {
var vm = this;
$.get('autohome/customer/json_map_cfrom', {pid: vm.cfrom_id}, function (response) {
if (response.code == 1) {
vm.cfromAry2 = response.data;
}
});
},
reset: function () {
var that = this;
$('#search_tp').val('mobile');
$('#title').val('');
$('#id-create-time').val('');
$('#id-push-time').val('');
that.province_id = 0;
that.city_id = 0;
that.cfrom_id = 0;
that.cfrom2_id = 0;
that.brand_id = 0;
that.series_id = 0;
that.channel = 0;
},
export_out: function () {
var that = this;
if (that.export_button == 0) {
layer.msg('无权限导出');
return false;
}
let count = <?=$pager['totle']?>;
if (count == 0) {
layer.msg('没有数据可导出');
return false;
}
let href = $.menu.parseUri(window.location.href);
href = href.replace("clues?", "clues/export?");
window.location.href = href;
},
push_search: function (){
let queryString = window.location.hash.split("?")[1];
params = queryString.substring(1).split('&');
paramsObj = {};
params.forEach(param => {
[key, value] = param.split('=');
paramsObj[key] = decodeURIComponent(value);
});
$.get('autohome/customer/push_search', paramsObj, function (response) {
if (response.code == 1) {
layer.msg('上传成功:'+ response.data.succ+' '+'上传失败:' + response.data.fail+' '+'未处理:' + response.data.undo);
}
});
}
},
watch: {
'brand_id': function (nv, ov) {
if (nv !== '') {
this.get_series()
}
},
'province_id': function (nv, ov) {
var that = this;
if (nv == '') {
that.cityAry = [];
that.city_id = '0';
} else {
$.get('common/area', {id: nv, key: 'city', type: 1}, function (response) {
if (response.code == 1) {
that.cityAry = response.data;
if (that.city_id > 0) {
var city_id = '0';
for (var i in that.cityAry) {
var city = that.cityAry[i];
if (city.id == that.city_id) {
city_id = city.id;
break;
}
}
that.city_id = city_id;
}
}
});
}
},
'city_id': function (nv, ov) {
var that = this;
if (nv == '') {
that.countyAry = [];
that.county_id = '0';
} else {
$.get('common/area', {id: nv, key: 'county', type: 1}, function (response) {
if (response.code == 1) {
that.countyAry = response.data;
if (that.county_id > 0) {
var county_id = '0';
for (var i in that.countyAry) {
var county = that.countyAry[i];
if (county.id == that.county_id) {
county_id = county.id;
break;
}
}
that.county_id = county_id;
}
}
});
}
},
'cfrom_id': function (nv, ov) {
var that = this;
that.cfrom_id2 = 0;
if (nv == '') {
that.cfromAry2 = [];
} else {
$.post('/autohome/customer/json_map_cfrom', {pid: nv}, function (result) {
that.cfromAry2 = result.data;
if (that.cfrom_id2 > 0) {
var of2_id = '';
for (var i in that.show_info.cfromAry2) {
if (i == that.cfrom_id2) {
of2_id = i;
break;
}
}
that.cfrom_id2 = of2_id;
}
});
}
}
}
});
$("#import").click(function () {
$("#clue-file").val('');
layer.open({
type: 1,
area: ['40%'], //宽高
content: $('#cule-modal'),
title: '导入线索',
shade: false,
btn: ['完成'],
yes: function (index) {
layer.close(index);
}
});
});
});
require(['laydate', 'autocomplete'], function (laydate) {
laydate.render({
elem: '#id-create-time', range: '~'
});
laydate.render({
elem: '#id-push-time', range: '~'
});
$('.id-day-btn').click(function () {
var type = $(this).data('date'), date = '', nowDate = new Date();
var source_id = $(this).data('source') || 'id-create-time';
var beginDate = '', endDate = '';
switch (type) {
case 'today':
beginDate = endDate = nowDate.Format('yyyy-MM-dd');
break;
case 'yesterday':
beginDate = endDate = (new Date(nowDate.getTime() - 86400000)).Format('yyyy-MM-dd');
break;
case 'weeks':
nowDate.setDate(nowDate.getDate() - nowDate.getDay() + 1);
beginDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-" + nowDate.getDate();
nowDate.setDate(nowDate.getDate() + 6);
endDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-" + nowDate.getDate();
break;
case 'month':
beginDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-01";
var day = new Date(nowDate.getFullYear(), nowDate.getMonth() + 1, 0);
endDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-" + day.getDate();
break;
}
date = beginDate + ' ~ ' + endDate;
//$('#' + source_id).val(date);
switch ($(this).data('btn')) {
case 'create':
$('#id-create-time').val(date);
break;
case 'push':
$('#id-push-time').val(date);
break;
}
});
});
function load_clue() {
var file = $("#clue-file");
if (file.val() == '') {
layer.msg('文件是空的');
return 0;
}
var loading = layer.load(1, {
shade: [0.1, '#fff'] //0.1透明度的白色背景
});
var options = {
url: "/autohome/customer/add_excel",
type: "post",
dataType: "json",
data: {},
success: function (res) {
if (1 == res.code) {
layer.msg(res.msg, {
icon: 1,
time: 2000
}, function () {
$.form.reload();
});
}
},
complete: function () {
file.val('');
layer.close(loading);
}
};
$("#import-form").ajaxSubmit(options);
}
</script>
+9 -1
View File
@@ -33,7 +33,15 @@
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w80">客户状态:</label>
<label class="am-para-label w80">客户<div class="am-form-group fl">
<label class="am-para-label w80">客户状态:</label>
<div class="am-para-inline w100">
<select name="status" v-model="params.status">
<option value=''>请选择</option>
<option :value="i" v-for="(v,i) in status_arr">{{v}}</option>
</select>
</div>
</div>状态:</label>
<div class="am-para-inline w100">
<select name="status" v-model="params.status">
<option value=''>请选择</option>
+1 -3
View File
@@ -47,9 +47,7 @@ class City extends Wxapp
$biz_ids = implode(',', $biz_id_arr);
$biz_where["id in ({$biz_ids})"] = null;
}
$typeAry = $this->biz_model->type_ary();
$type_ids = implode(',', array_keys($typeAry));
$type_ids && $biz_where["type in ($type_ids)"] = null;
$biz_rows = $this->biz_model->select_groupby('city_id', $biz_where, '', '', '', 'id,city_id');
$city_ids = implode(',', array_column($biz_rows, 'city_id'));
$city_ids && $where["city_id in ($city_ids)"] = null;
+2 -6
View File
@@ -50,9 +50,7 @@ class Statistics extends Wxapp{
$city_id && $o_where = ['city_id'=>$city_id];
$bizs_lists = $this->biz_model->get_by_id_arr($biz_id_arr,$o_where,$fileds);
}else{
$typeAry = $this->biz_model->type_ary();
$type_ids = implode(',',array_keys($typeAry));
$bizs_lists = $this->biz_model->select(['status'=>1,'city_id'=>$city_id,"type in ($type_ids)" => null],'id desc','','',$fileds);
$bizs_lists = $this->biz_model->select(['status'=>1,'city_id'=>$city_id],'id desc','','',$fileds);
}
if($bizs_lists){
$bizs = array_column($bizs_lists,'biz_name');
@@ -132,9 +130,7 @@ class Statistics extends Wxapp{
$city_id && $o_where = ['city_id'=>$city_id];
$bizs_lists = $this->biz_model->get_by_id_arr($biz_id_arr,$o_where,$fileds);
}else{
$typeAry = $this->biz_model->type_ary();
$type_ids = implode(',',array_keys($typeAry));
$bizs_lists = $this->biz_model->select(['status'=>1,'city_id'=>$city_id,"type in ($type_ids)" => null],'id desc','','',$fileds);
$bizs_lists = $this->biz_model->select(['status'=>1,'city_id'=>$city_id],'id desc','','',$fileds);
}
if($bizs_lists){
$bizs = array_column($bizs_lists,'biz_name');
@@ -0,0 +1,14 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Autohome_customer_model extends HD_Model
{
private $table_name = 'lc_autohome_customers';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
Binary file not shown.