This commit is contained in:
xiaoyu
2023-12-19 17:49:39 +08:00
parent 183b0a0be5
commit 8e31aeb2d4
7 changed files with 984 additions and 100 deletions
+807
View File
@@ -0,0 +1,807 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Clues extends HD_Controller
{
private $searchTpAry = array('mobile' => '客户手机号', 'name' => '客户姓名', 'void' => 'voId', );
private $bizs = array(
'100958' => array(
'biz' => '福州齐安路',
'sa' => '陈秋龙',
'mobile' => '17758949069'
),
'101022' => array(
'biz' => '泉州南安中骏',
'sa' => '潘福泉',
'mobile' => '15260424218'
),
'100966' => array(
'biz' => '泉州南环路',
'sa' => '傅玲玲',
'mobile' => '18519510420'
),
'101077' => array(
'biz' => '晋江豪信',
'sa' => '郑晓员',
'mobile' => '13615912658'
),
'100619' => array(
'biz' => '漳州狸车',
'sa' => '陈鸿喜',
'mobile' => '17750151079'
),
'100231' => array(
'biz' => '宁德辉科',
'sa' => '陈玉佑',
'mobile' => '18150878955'
),
'100421' => array(
'biz' => '南平绿衡',
'sa' => '周伟豪',
'mobile' => '16659478792'
),
'100179' => array(
'biz' => '莆田众诚',
'sa' => '林昉',
'mobile' => '18760550059'
),
);
protected $log_dir;
public function __construct()
{
parent::__construct();
$this->load->model('hdcloud/hdcloud_clues_model', 'clues_model');
$this->load->model('hdcloud/hdcloud_clue_oplogs_model', 'clue_oplogs_model');
}
//首页信息
public function index()
{
$this->lists();
}
public function lists($where = array())
{
$statusAry = $this->clues_model->statusAry();
$params = $this->input->get();
$this->data['province_id'] = $province_id = intval($params['province_id']);
$this->data['city_id'] = $city_id = intval($params['city_id']);
$this->data['county_id'] = $county_id = intval($params['county_id']);
$page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
$size = $params['size'] = $params['size'] ? intval($params['size']) : 20;
if ($params['title']) {
$where["{$params['search_tp']} like '%{$params['title']}%'"] = null;
}
//创建时间
if ($params['c_time']) {
$c_time = explode(' ~ ', $params['c_time']);
if ($c_time[0]) {
$where["c_time >="] = strtotime($c_time[0] . ' 00:00:00');
}
if ($c_time[1]) {
$where["c_time <="] = strtotime($c_time[1] . ' 23:59:59');
}
}
strlen($params['status']) && $where["status"] = $params['status'];
strlen($params['status2']) && $where["status2"] = $params['status2'];
$province_id && $where['province_id'] = $province_id;
$city_id && $where['city_id'] = $city_id;
$county_id && $where['county_id'] = $county_id;
$count = $this->clues_model->count($where);
$lists = [];
if ($count) {
$fileds = 'id,void, name,mobile,c_time,admin_id,status,status2';
$rows = $this->clues_model->select($where, 'id desc', $page, $size, $fileds);
foreach ($rows as $key => $val) {
$status_name = $statusAry[$val['status']]['name'];
$val['status2'] && $status_name .= '' . $statusAry[$val['status']]['list'][$val['status2']];
$val['status_name'] = $status_name;
$lists[] = $val;
}
}
$statusList = array();
foreach ($this->clues_model->statusAry() as $key => $value) {
$cate = array();
$where = array("status" => $key);
$count1 = $this->clues_model->count($where);
if ($value['list']) {
foreach ($value['list'] as $key2 => $value2) {
$where['status2'] = $key2;
$count2 = $this->clues_model->count($where);
$cate[] = array("id" => $key2, "name" => $value2, "count" => $count2);
}
}
$statusList[] = array("id" => $key, "name" => $value['name'], "cate" => $cate, "count" => $count1);
}
$this->data['lists'] = $lists;
$this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
$this->data['searchTpAry'] = $this->searchTpAry;
$this->data['params'] = $params;
$this->data['statusList'] = $statusList;
$this->data['maintainAry'] = $this->maintainAry;
$this->data['_title'] = '线索池列表';
return $this->show_view('receiver/clues/lists', true);
}
public function get()
{
$params = $this->input->get();
$id = intval($params['id']);
if (!$id) {
return $this->show_json(SYS_CODE_FAIL, '非法参数!');
}
$statusList = $status2List = $logsList = [];
$re = $this->clues_model->get(array('id' => $id));
if (!$re || empty($re)) {
return $this->show_json(SYS_CODE_FAIL, '线索不存在!');
}
$dataInfo = $re;
foreach ($this->clues_model->statusAry() as $key => $value) {
$statusList[] = array("id" => $key, "name" => $value['name']);
}
if (strlen($re['status'])) {
foreach ($this->clues_model->statusAry($re['status'])['list'] as $key => $value) {
$status2List[] = array("id" => $key, "name" => $value);
}
}
$dataInfo['editType'] = 0;
$re_cf = $this->clues_cfrom_model->get(array('id' => $re['cf_id']));
$re_cf_title_p = '';
if ($re_cf && $re_cf['pid']) {
$re_cf_pid = $this->clues_cfrom_model->get(array('id' => $re_cf['pid']));
$re_cf_title_p = $re_cf_pid['title'] ? $re_cf_pid['title'] . '-' : '';
}
$info_show['cfrom_title'] = $re_cf['title'] ? $re_cf_title_p . $re_cf['title'] : '';
$info_show['statusList'] = $statusList;
$info_show['status2List'] = $status2List;
$info_show['c_time'] = date('Y-m-d H:i', $re['c_time']);
$info_show['logsList'] = $logsList;
//意向信息
$jsondata = $re['jsondata'] ? json_decode($re['jsondata'], true) : [];
//获取城市区域
$dataInfo['city_id'] = $re['city_id'];
$dataInfo['county_id'] = $re['county_id'];
//获取已分配店铺
$cus = $this->customers_model->select(['rid' => $re['id']], '', '', '', 'biz_id');
$biz_arr = [];
if ($cus) {
$biz_ids = implode(array_column($cus, 'biz_id'), ',');
if ($biz_ids) {
$where_biz["id in ($biz_ids)"] = null;
$cus_biz = $this->biz_model->select($where_biz, '', '', '', 'biz_name');
$biz_arr = array_column($cus_biz, 'biz_name');
}
}
$info_show['cus_bizs'] = implode($biz_arr, ',');
//附近门店
if ($re['lat'] && $re['lng']) {
$info_show['near_bizs'] = $this->biz_model->nearby($re['lat'], $re['lng'], 1, 3, 'id,biz_name');
} else {
$typeAry = $this->biz_model->type_ary();
$type_ids = implode(',', array_keys($typeAry));
$info_show['near_bizs'] = $this->biz_model->select(['city_id' => $re['city_id'], 'county_id' => $re['county_id'], "type in ($type_ids)" => null, 'status' => 1], 'id desc', 1, 3, 'id,biz_name');
}
//获取分销用户
$cf_user = '';
if ($dataInfo['recommend_id']) {
$this->load->model('app/liche/app_liche_users_model');
$user = $this->app_liche_users_model->get(['id' => $dataInfo['recommend_id']], 'id,nickname,up_uid');
$user['up_uid'] && $up_user = $this->app_liche_users_model->get(['id' => $user['up_uid']], 'id,nickname'); //上一级分销用户
if ($up_user) {
$cf_user = "{$up_user['nickname']}(一级) => {$user['nickname']}(二级)";
} else {
$cf_user = $user['nickname'];
}
}
$info_show['cf_user'] = $cf_user;
$this->data['info'] = $dataInfo;
$this->data['info_show'] = $info_show;
$this->data['_title'] = '线索详情';
return $this->show_view('receiver/clues/edit', true);
}
/**
* 新增
* @return bool
*/
function get_add()
{
$id = $this->input->get('id');
if ($id) {
$row = $this->clues_model->get(array('id' => $id));
if (!$row) {
return $this->show_json(SYS_CODE_FAIL, '记录不存在');
}
$cf_id1 = '';
$cf_id2 = '';
if ($row['cf_id']) {
$row_cfrom = $this->clues_cfrom_model->get(array('id' => $row['cf_id']));
if ($row_cfrom['pid']) {
$cf_id1 = $row_cfrom['pid'];
$cf_id2 = $row['cf_id'];
} else {
$cf_id1 = $row['cf_id'];
}
}
$info = array(
'name' => $row['name'],
'mobile' => $row['mobile'],
'cf_id1' => $cf_id1,
'cf_id2' => $cf_id2,
);
$title = "编辑线索";
$action = "edit";
} else {
$info = array(
'name' => '',
'mobile' => '',
'cf_id1' => '',
'cf_id2' => '',
);
$title = "新增线索";
$action = "add";
}
$where = array('status' => 1, 'pid' => 0);
$select = 'id, title';
$map_cfrom = $this->clues_cfrom_model->map('id', 'title', $where, '', 0, 0, $select);
$this->data['info'] = $info;
$this->data['cfromAry'] = $map_cfrom;
$this->data['action'] = $action;
$this->data['_title'] = $title;
return $this->show_view('receiver/clues/get');
}
//添加单条数据
public function add()
{
$info = $this->input->post('info');
if (!$info['name']) {
return $this->show_json(SYS_CODE_FAIL, '请填写姓名');
}
if (!mobile_valid($info['mobile'])) {
return $this->show_json(SYS_CODE_FAIL, '手机号码不准确');
}
if ($this->clues_model->get(['mobile' => $info['mobile']])) {
return $this->show_json(SYS_CODE_FAIL, '手机号已存在');
}
$cf_id = 0;
if ($info['cf_id2']) {
$cf_id = $info['cf_id2'];
} else if ($info['cf_id1']) {
$cf_id = $info['cf_id1'];
}
$add = array(
'name' => $info['name'],
'mobile' => $info['mobile'],
'cf_id' => $cf_id,
'admin_id' => $this->uid,
'c_time' => time(),
);
$ret = $this->clues_model->add($add);
if (!$ret) {
debug_log("[error]# add fail; " . $this->clues_model->db->last_query(), __FUNCTION__, $this->log_dir);
return $this->show_json(SYS_CODE_FAIL, '添加失败');
}
return $this->show_json(SYS_CODE_SUCCESS, '添加成功');
}
public function add_log()
{
$params = $this->input->post();
if (!$params['id']) {
return $this->show_json(SYS_CODE_FAIL, '参数错误!');
}
if (!$params['log']) {
return $this->show_json(SYS_CODE_FAIL, '请输入内容!');
}
$addData = array(
'clue_id' => $params['id'],
'uid' => $this->uid,
'uname' => $this->username,
'type' => intval($params['type']),
'log' => $params['log'],
'c_time' => time()
);
$id = $this->mdOplogs->add($addData);
if ($id) {
return $this->show_json(SYS_CODE_SUCCESS, '添加成功');
} else {
return $this->show_json(SYS_CODE_FAIL, '添加失败');
}
}
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(),
'cfrom' => $objWorksheet->getCell('C' . $_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 edit()
{
$info = $this->input->post('info');
if (!$info) {
return $this->show_json(SYS_CODE_FAIL, '非法参数!');
}
$re = $this->clues_model->get(array('id' => $info['id']));
if (!$re || empty($re)) {
return $this->show_json(SYS_CODE_FAIL, '线索不存在!');
}
$msg = '修改成功';
$code = SYS_CODE_SUCCESS;
if ($info['editType'] == 1) {
$statusAry = $this->clues_model->statusAry();
if ($info['status'] == $re['status'] && $info['status2'] == $re['status2']) {
return $this->show_json(SYS_CODE_FAIL, '状态未修改!');
}
$status_name = $statusAry[$re['status']]['name'];
$status_name_up = $statusAry[$info['status']]['name'];
if ($info['status2']) {
$status_name .= '-' . $statusAry[$re['status']]['list'][$re['status2']];
$status_name_up .= '-' . $statusAry[$info['status']]['list'][$info['status2']];
}
$log = '更新状态(' . $status_name . ')为(' . $status_name_up . ')';
$ret = $this->clues_model->update(array('status' => $info['status'], 'status2' => $info['status2']), array('id' => $info['id']));
if (!$ret) {
$code = SYS_CODE_FAIL;
$msg = '修改状态失败';
} else {
$msg = '修改状态成功';
$this->addLog(array('clue_id' => $info['id'], 'type' => 0, 'log' => $log));
}
} else if ($info['editType'] == 2) {
if ($info['name'] == $re['name']) {
return $this->show_json(SYS_CODE_FAIL, '客户姓名未修改!');
}
$log = '更新客户姓名(' . $re['name'] . ')为(' . $info['name'] . ')';
$ret = $this->clues_model->update(array('name' => $info['name']), array('id' => $info['id']));
if (!$ret) {
$code = SYS_CODE_FAIL;
$msg = '修改用户信息失败';
} else {
$msg = '修改用户信息成功';
$this->addLog(array('clue_id' => $info['id'], 'type' => 0, 'log' => $log));
}
} else if ($info['editType'] == 3) {
$up_data = [
'city_id' => $info['city_id'],
'county_id' => $info['county_id']
];
$ret = $this->clues_model->update($up_data, array('id' => $info['id']));
if (!$ret) {
$code = SYS_CODE_FAIL;
$msg = '修改意向信息失败';
} else {
$msg = '修改意向信息成功';
$this->addLog(array('clue_id' => $info['id'], 'type' => 0, 'log' => '修改意向信息'));
}
}
return $this->show_json($code, $msg);
}
/**
* Notes:增加日志
* Created on: 2021/7/23 10:48
* Created by: dengbw
* @param array $ary
* @return mixed
*/
private function addLog($ary = array())
{
$id = 0;
if ($ary['log']) {
$addData = array(
'clue_id' => $ary['clue_id'],
'uid' => $this->uid,
'uname' => $this->username,
'type' => intval($ary['type']),
'log' => $ary['log'],
'c_time' => time()
);
$id = $this->mdOplogs->add($addData);
}
return $id;
}
//删除单条数据
public function del()
{
}
//批量操作(默认修改状态)
public function batch()
{
$id = intval($this->input->post('id'));
$status = $this->input->post('value');
if (!$id || !$status) {
$this->show_json(0, '参数错误');
}
$status_ary = explode('-', $status);
$up_data['status'] = intval($status_ary[0]);
$up_data['status2'] = intval($status_ary[1]);
$this->clues_model->update($up_data, ['id' => $id]);
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
}
//导出数据列表
public function export()
{
}
//分配
public function get_adviser()
{
$ids = $this->input->get('ids');
if ($this->input->method() == 'post') {
$city_id = $this->input->post('city_id');
$county_id = $this->input->post('county_id');
$where = [
'status' => 1,
];
$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, '操作成功');
}
$this->data['ids'] = $ids;
return $this->show_view('receiver/clues/get_adviser');
}
public function edit_adviser()
{
$this->load->library('receiver/clues_entity');
$this->load->library('receiver/customers_entity');
$biz_id = $this->input->post('biz_id');
$ids = $this->input->post('ids');
$ids_arr = explode(',', $ids);
$biz = $this->biz_model->get(['id' => $biz_id]);
if (!$biz) {
return $this->show_json(SYS_CODE_FAIL, '请选择分配门店!');
}
if (!is_array($ids_arr)) {
return $this->show_json(SYS_CODE_FAIL, '参数错误!');
}
$where = [
"id in ($ids)" => null
];
$clues_rows = $this->clues_model->map('id', '', $where);
foreach ($ids_arr as $val) {
$clues_row = $clues_rows[$val][0];
//判断是否已分配
$cus_row = $this->customers_model->get(['rid' => $val, 'status>=' => 0]);
if ($clues_row && !$cus_row) {
$jsondata = json_decode($clues_row['jsondata'], true);
$add_data = [
'rid' => $val,
'name' => $clues_row['name'],
'mobile' => $clues_row['mobile'],
'biz_id' => $biz_id,
'city_id' => $biz['city_id'],
'county_id' => $biz['county_id'],
'brand_id' => $clues_row['brand_id'],
's_id' => $clues_row['s_id'],
'if_driver' => $clues_row['if_driver'],
'cf_title' => '平台分配',
'of_id' => 3,
'of2_id' => 37,
'cf_id' => $clues_row['cf_id'],
'p_time' => date('Y-m-d H:i:s'),
'c_time' => $clues_row['en_time'] == '0000-00-00 00:00:00' ? $clues_row['c_time'] : strtotime($clues_row['en_time'])
];
if ($biz['type'] == 5) {//异业店
$add_data['cf_clues'] = '异业店';
}
if ($jsondata['car']) {
isset($jsondata['car']['version']) && $add_data['v_id'] = $jsondata['car']['version']['id'];
$add_data['car_json'] = json_encode($jsondata['car'], JSON_UNESCAPED_UNICODE);
unset($jsondata['car']);
}
$jsondata && $add_data['jsondata'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
$customers_id = $this->customers_model->add($add_data);
if ($customers_id) {
$this->clues_model->update(['status' => 1], ['id' => $val]);
//同步线索日志到客户日志
$this->customers_entity->syn_clues($customers_id, $val);
$this->customers_entity->add_log($customers_id, $this->uid, $this->username, "平台分配", 0, 'admin');
$this->clues_entity->add_log($val, $this->uid, $this->username, "分配给【{$biz['biz_name']}】商家");
}
}
}
return $this->show_json(SYS_CODE_SUCCESS, '分配成功!');
}
public function lists_call()
{
$this->load->model('sys/sys_admin_model', 'mdAdmin');
$cache = &load_cache('redis');
$xz_admin_phone = $cache->get($this->cacheKeyPhone);
$params = $this->input->get();
$username = $params['username'];
$params['page'] = $params['page'] ? intval($params['page']) : 1;
$params['size'] = $params['size'] ? intval($params['size']) : 20;
$lists = array();
$where['status'] = 1;
if (!empty($username)) $where["username like '%$username%'"] = null;
if (!empty($params['mobile'])) $where['mobile'] = $params['mobile'];
$count = $this->mdAdmin->count($where);
if ($count) {
$res = $this->mdAdmin->select($where, 'id desc', $params['page'], $params['size'], 'id,username,mobile');
foreach ($res as $key => $value) {
$setValue = array();
$setValue['id'] = $value['id'];
$setValue['username'] = $value['username'];
$setValue['mobile'] = $value['mobile'];
$phone = $xz_admin_phone['admins'][$value['id']];
if ($phone) {
$phone_btn = '<a class="am-btn am-btn-danger am-btn-xs" data-action="/receiver/clues/edit_call" data-ajax="post"
data-params-type="1" data-params-id="' . $value['id'] . '" >取消分配</a>';
} else {
$phone = '未分配';
$phone_btn = '<a class="am-btn am-btn-primary am-btn-xs" data-action="/receiver/clues/edit_call" data-ajax="post"
data-params-type="0" data-params-id="' . $value['id'] . '" >分配号码</a>';
}
$setValue['phone'] = $phone;
$setValue['phone_btn'] = $phone_btn;
$lists[] = $setValue;
}
}
$this->data['params'] = $params;
$this->data['_title'] = '虚似号分配';
$this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count);
$this->data['lists'] = $lists;
return $this->show_view('receiver/clues/lists_call', true);
}
public function edit_call()
{
$id = intval($this->input->post('id'));
$type = $this->input->post('type');
if ($type != 3 && !$id) {
return $this->show_json(SYS_CODE_FAIL, '参数错误');
}
$cache = &load_cache('redis');
$xz_admin_phone = $cache->get($this->cacheKeyPhone);
$this->config->load('xcall', TRUE);
$mobiles = $this->config->item('mobile_list', 'xcall');
$mobiles && shuffle($mobiles);
if ($type == 0) {//分配手机
if (!$mobiles) {
return $this->show_json(SYS_CODE_FAIL, '无号码库!');
}
$number = '';
foreach ($mobiles as $key => $value) {
if (!$xz_admin_phone['numbers'][$value]) {
$number = $value;
break;
}
}
if ($number) {
$xz_admin_phone['admins'][$id] = $number;
$xz_admin_phone['numbers'][$number] = $id;
$cache->save($this->cacheKeyPhone, $xz_admin_phone);
return $this->show_json(SYS_CODE_SUCCESS, '分配号码成功');
} else {
return $this->show_json(SYS_CODE_FAIL, '号码已全部分配完了');
}
} else if ($type == 1) {//取消分配
$number = $xz_admin_phone['admins'][$id];
unset($xz_admin_phone['admins'][$id]);
unset($xz_admin_phone['numbers'][$number]);
$cache->save($this->cacheKeyPhone, $xz_admin_phone);
return $this->show_json(SYS_CODE_SUCCESS, '取消分配成功');
} else if ($type == 3) {//全部重新分配
if (!$mobiles) {
return $this->show_json(SYS_CODE_FAIL, '无号码库!');
}
if (!$xz_admin_phone['admins']) {
return $this->show_json(SYS_CODE_FAIL, '未分配号码,不能重置');
}
$xz_admin_phone_new = array();
$i = 0;
foreach ($xz_admin_phone['admins'] as $key => $value) {
$number = $mobiles[$i];
$id = $key;
if ($number) {
$xz_admin_phone_new['admins'][$id] = $number;
$xz_admin_phone_new['numbers'][$number] = $id;
}
$i++;
}
$cache->save($this->cacheKeyPhone, $xz_admin_phone_new);
return $this->show_json(SYS_CODE_SUCCESS, '重置已分配成功');
}
}
/**
* 返回map select数据
* @return bool
*/
function json_map_cfrom()
{
$pid = $this->input->post('pid');
$status = $this->input->post('status');
$where = array();
if (strlen($pid) > 0) {
$where['pid'] = $pid;
}
if (strlen($status) > 0) {
$where['status'] = $status;
} else {
$where["status>-1"] = null;
}
$total = $this->clues_cfrom_model->count($where);
$map = array();
if ($total) {
$orderby = 'id desc';
$select = 'id, title';
$rows = $this->clues_cfrom_model->select($where, $orderby, 0, 0, $select);
foreach ($rows as $v) {
$map[$v['id']] = $v['title'];
}
}
$this->data = $map;
return $this->show_json(SYS_CODE_SUCCESS);
}
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']);
}
}
/**
* 批量新增
* @param $lists
* @return int
*/
private function add_batch($lists)
{
$done = 0;
$adds = array();
$where = array('status' => 1);
$select = 'id, title';
$map_cfrom = $this->clues_cfrom_model->map('title', 'id', $where, '', 0, 0, $select);
$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->clues_model->get(['mobile' => $v['mobile']])) {
$fails[] = array('data' => $v, 'msg' => '手机号已存在');
continue;
}
$cf_id = $map_cfrom[$v['cfrom']];
$adds[] = array(
'name' => $v['name'],
'mobile' => $v['mobile'],
'cf_id' => $cf_id ? $cf_id : 0,
'c_time' => time(),
);
$done++;
}
$fails && debug_log('[warning]# fails=' . json_encode($fails), __FUNCTION__, $this->log_dir);
if ($adds) {
$ret = $this->clues_model->add_batch($adds);
if (!$ret) {
debug_log("[error] add_batch fail; " . $this->clues_model->db->last_query(), __FUNCTION__, $this->log_dir);
$done = 0;
}
}
return $done;
}
//获取线索来源
public function get_cfroms()
{
$id = $this->input->get('id');
$where = [
'status' => 1,
'pid' => 0
];
$id && $where['pid'] = $id;
if ($this->role == 37) {
!$id && $where['id'] = 36;
}
$rows = $this->clues_cfrom_model->select($where, 'id desc', '', '', 'id,title');
$this->data['data'] = $rows;
return $this->show_json(SYS_CODE_SUCCESS);
}
public function get_bizInfo()
{
$id = $this->input->get('id');
$info = $this->biz_model->get(['id' => $id], 'city_id,county_id,address');
$city = $this->area_model->get(['county_id' => $info['county_id']]);
$bizinfo['city_name'] = $city['city_name'];
$bizinfo['county_name'] = $city['county_name'];
$bizinfo['address'] = $info['address'];
$this->data['bizinfo'] = $bizinfo;
return $this->show_json(SYS_CODE_SUCCESS);
}
}
+18 -93
View File
@@ -67,7 +67,7 @@
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w100">报名位置</label>
<label class="am-para-label w100">所在地区</label>
<div class="am-form-group am-para-inline w150">
<select name="city_id" v-model="city_id">
<option value="0">城市</option>
@@ -76,17 +76,9 @@
</template>
</select>
</div>
<div class="am-form-group am-para-inline w150">
<select name="county_id" v-model="county_id">
<option value="0">行政区</option>
<template v-for="(v,i) in countyAry">
<option :value="v.id">{{v.name}}</option>
</template>
</select>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w100">线索来源:</label>
<!--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>
@@ -94,7 +86,7 @@
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
</div-->
<div class="am-form-group am-para-inline w150">
<select name="cfrom_id2" v-model="cfrom_id2">
<option value=0>请选择</option>
@@ -125,26 +117,6 @@
</div>
</div>
</div>
<div class="am-form-group">
<div class="am-form-group" style="margin-bottom: 0px;"></div>
<label class="am-para-label w100">最后报名时间:</label>
<div class="am-form-group fl">
<div class="am-para-inline w300">
<input id="id-en-time" name="en_time" type="text" value="<?= $params['en_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-source="id-en-time">今天</a>
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="yesterday"
data-source="id-en-time">昨日</a>
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="weeks"
data-source="id-en-time">本周</a>
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="month"
data-source="id-en-time">本月</a>
</div>
</div>
</div>
<div class="am-form-group fl" style="margin-bottom: 0px;">
<div class="am-form-group fl ml10">
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
@@ -177,59 +149,30 @@
<table class="am-table am-table-bordered">
<thead>
<tr>
<th width="3%"><label class="checkall">
<th width="5%"><label class="checkall">
<input type="checkbox" data-check-target=".order-ids"> 全选</label></th>
<th width="5%"><span>客户姓名</span></th>
<th width="5%"><span>客户电话</span></th>
<th width="8%"><span>线索来源</span></th>
<th width="8%"><span>状态</span></th>
<th width="4%"><span>跟进人</span></th>
<th width="7%"><span>创建时间</span></th>
<th width="7%"><span>最后报名时间</span></th>
<th width="10%"><span>ID</span></th>
<th width="10%"><span>客户姓名</span></th>
<th width="10%"><span>客户电话</span></th>
<th width="10%"><span>所在地区</span></th>
<th width="10%"><span>状态</span></th>
<th width="15%"><span>创建时间</span></th>
<th width="15%"><span>操作</span></th>
</tr>
</thead>
<tbody>
<? if ($lists) {
foreach ($lists as $v) { ?>
<tr>
<td><input type="checkbox" name="ids[]" class="order-ids"
value="<?= $v['id'] ?>"/></td>
<td><input type="checkbox" name="ids[]" class="order-ids" value="<?= $v['id'] ?>"/></td>
<td><?= $v['void'] ?></td>
<td><?= $v['name'] ?></td>
<td><?= $v['mobile_sub'] ?></td>
<td><?= $v['cf_title'] ?></td>
<td><? if ($v['cf_id'] == 36 || $v['cf_id'] == 37) { ?>
<input type="hidden" class="clues-id-<?= $v['id'] ?>" name="id" value="<?= $v['id'] ?>"
checked>
<select data-update-group="" data-list-target=".clues-id-<?= $v['id'] ?>"
data-action="/receiver/clues/batch" data-field=""
style="height: 26px;width: 100px;">
<? foreach ($maintainAry as $key => $val) { ?>
<option value="<?= $key ?>" <?= $key == $v['status'] . '-' . $v['status2'] ? 'selected' : '' ?>><?= $val ?></option>
<? } ?>
</select>
<? } else { ?>
<?= $v['status_name'] ?>
<? } ?>
</td>
<td><?= $v['admin_name'] ?></td>
<td><?= $v['mobile'] ?></td>
<td><?= $v['poi'] ?></td>
<td><?= $v['status_name'] ?></td>
<td><?= date('Y-m-d H:i:s', $v['c_time']) ?></td>
<td><?= $v['en_time'] ?></td>
</tr>
<tr>
<td colspan="8">
<div class="row">
<div class="col-md-4 align-l">
</div>
<div class="col-md-8 align-r" style="padding-right: 30px;">
<a data-modal="/common/bind_mobile?id=<?= $v['id'] ?>&type=clues"
href="javascript:void(0);" class="am-btn am-btn-primary am-btn-xs"
data-title="获取手机号">拨打电话</a>
<a data-modal="/common/show_sms?id=<?= $v['id'] ?>&type=clues"
href="javascript:void(0);" class="am-btn am-btn-primary am-btn-xs"
data-title="发送短信">短信</a>
<a data-open="/receiver/clues/get?id=<?= $v['id'] ?>&type=clues"
href="javascript:void(0);" class="am-btn am-btn-primary am-btn-xs">查看详情</a>
</div>
<td><a data-open="/receiver/clues/get?id=<?= $v['id'] ?>&type=clues" href="javascript:void(0);" class="am-btn am-btn-primary am-btn-xs">详情</a>
<a data-open="/receiver/clues/get?id=<?= $v['id'] ?>&type=clues" href="javascript:void(0);" class="am-btn am-btn-primary am-btn-xs">分配</a>
</td>
</tr>
<? }
@@ -290,24 +233,6 @@
vm.cityAry = response.data;
}
});
if (vm.city_id > 0) {
$.get('common/area', {id: vm.city_id, key: 'county', type: 1}, function (response) {
if (response.code == 1) {
vm.countyAry = response.data;
}
});
}
},
getCfroms: function () {
var that = this
$.get('/receiver/CluesCfrom/json_get', function (result) {
that.cfroms = result.data.data
});
if (that.cfrom_id > 0) {
$.get('/receiver/CluesCfrom/json_get', {'id': that.cfrom_id}, function (result) {
that.cfroms2 = result.data.data
});
}
},
reset: function () {
var that = this;
@@ -0,0 +1,31 @@
<?php
/**
* Created by Vim
* User: lcc
* Date: 2021/06/29
* Time: 13:47
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Hdcloud_clue_oplogs_model extends HD_Model
{
private $table_name = 'lc_hdcloud_clue_oplogs';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
/**
* Notes:类型
* Created on: 2021/7/27 10:31
* Created by: dengbw
* @return array
*/
public function typeAry()
{
return array(0 => '小记', 1 => '发短信', 2 => '拨打号码');
}
}
@@ -0,0 +1,45 @@
<?php
/**
* Created by Vim
* User: lcc
* Date: 2021/06/29
* Time: 13:47
*/
defined('BASEPATH') or exit('No direct script access allowed');
class Hdcloud_clues_model extends HD_Model
{
private $table_name = 'lc_hdcloud_clues';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
/**
* Notes:线索状态
* Created on: 2021/9/15 10:25
* Created by: dengbw
* @param $status
* @return array
*/
public function statusAry($status = '')
{
$status_ary[0] = array('name' => '待处理', 'list' => array());
$status_ary[1] = array('name' => '已分配', 'list' => array(1 => '强意向', 2 => '中意向', 3 => '弱意向'));
$status_ary[3] = array('name' => '无效线索', 'list' => array(7 => '明确拒绝', 8 => '误点', 9 => '战败'));
if (strlen($status)) {
$return_status = $status_ary[$status];
} else {
$return_status = $status_ary;
}
return $return_status;
}
//关联订单
public function count_order($where)
{
return $this->select_order($where, '', '', '', '', 1);
}
}
+16 -7
View File
@@ -4,28 +4,37 @@ defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index(){
echo "<h1>404</h1>";exit;
//echo "<h1>404</h1>";exit;
//生产地址
$url = 'https://salesapp.hozonauto.com/appservice/app/if/salesclue/createSalesclue';
//测试地址
//$url = 'https://salespp-sit.hozonauto.com/appservice/app/if/salesclue/createSalesclue';
$name = '活动客户';
$comments = '100832';
$mobile = '13450948193';
$samobile = '15815718662';
$name = '依维柯'; //客户姓名
$mobile = '15305033630';//客户手机
$comments = '100619'; //门店编码
$samobile = '17750151079';//销售手机
$city_id = '350200';
$voId = $city_id . date('mdHis') . sprintf("%06d", rand(1,999999));
$data[] = array(
'cusSource3' => '011404',
'voId' => $voId,
'cusSource3' => '023409',
'customerName' => $name,
'dealerCode' => $comments,
'fromSystem' => "好店云",
'mobile' => $mobile,
'saMobile' => $samobile,
'cusType' => '30111001',
'remark' => "云河十分宠爱购车节",
'remark' => "征信不好",
'intentModel' => "哪吒X",
);
print_r(json_encode($data,JSON_UNESCAPED_UNICODE));
$data = json_encode($data, JSON_UNESCAPED_UNICODE);
$ch = curl_init();
+58
View File
@@ -0,0 +1,58 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Cloud extends CI_Controller
{
public function index()
{
//echo "<h1>404</h1>";exit;
//生产地址
$url = 'https://salesapp.hozonauto.com/appservice/app/if/salesclue/createSalesclue';
//测试地址
//$url = 'https://salespp-sit.hozonauto.com/appservice/app/if/salesclue/createSalesclue';
$name = '测试';
$comments = '101207';
$mobile = '18150117877';
$samobile = '18150117877';
$data[] = array(
'cusSource3' => '023409',
'customerName' => $name,
'dealerCode' => $comments,
'fromSystem' => "好店云",
'mobile' => $mobile,
'saMobile' => $samobile,
'cusType' => '30111001',
'remark' => "区域云店测试",
);
print_r(json_encode($data,JSON_UNESCAPED_UNICODE));exit;
$data = json_encode($data, JSON_UNESCAPED_UNICODE);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//https
if (strlen($url) > 5 && strtolower(substr($url, 0, 5)) == "https") {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($data)
)
);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
var_dump($response);
}
}
@@ -56,6 +56,11 @@
alt="#">
<div class="space-nowrap con-min60 font-22">领取家电好物礼</div>
</a>
<a class="fn-flex-item pl20 pr20" flexsize="0" href="javascript:;" @click="showCode" v-if="info.a_id == 25 && info.live_status == 0">
<img class="imgsize-50X50" src="https://img.liche.cn/liche/market/202310/p_812aba80492024d60ca31c5049235182.png"
alt="#">
<div class="space-nowrap con-min60 font-22">预约试驾</div>
</a>
<a class="fn-flex-item pl20 pr20" flexsize="0" :href="info.my_url">
<img class="imgsize-50X50" src="https://qs.haodian.cn/web/images/project/H5-ShiYu/icon-wode.png"
alt="#">
@@ -73,6 +78,10 @@
href="https://www.liche.cn/h5/market/sylive2/item/detail?skey=YV9pZD0yMyZpdGVtSWQ9MzA">
立即支付99元权益金
</a>
<a class="block bg-1a1a1a pt20 pb20 text-center font-36 color-fff ulib-r20" v-else-if="info.a_id == 25"
href="https://www.liche.cn/h5/market/sylive2/item/detail?skey=YV9pZD0yNSZpdGVtSWQ9MzM">
立即支付10元宠爱金
</a>
<a class="block bg-1a1a1a pt20 pb20 text-center font-36 color-fff ulib-r20" v-else
href="javascript:;" @click="showCode">
<!--<i class="iconfont icon-tixing mr10"></i>-->