diff --git a/admin/controllers/hdcloud/Clues.php b/admin/controllers/hdcloud/Clues.php new file mode 100644 index 00000000..b2b236e3 --- /dev/null +++ b/admin/controllers/hdcloud/Clues.php @@ -0,0 +1,807 @@ + '客户手机号', '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 = '取消分配'; + } else { + $phone = '未分配'; + $phone_btn = '分配号码'; + } + $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); + } +} diff --git a/admin/views/receiver/clues/lists.php b/admin/views/receiver/clues/lists.php index 5a965e68..9f63ece7 100644 --- a/admin/views/receiver/clues/lists.php +++ b/admin/views/receiver/clues/lists.php @@ -67,7 +67,7 @@
- +
-
- -
- +
-
-
- 今天 - 昨日 - 本周 - 本月 -
-
-
@@ -177,59 +149,30 @@ - - - - - - - - + + + + + + + - + + - - - - + + + - - - - 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; diff --git a/common/models/hdcloud/Hdcloud_clue_oplogs_model.php b/common/models/hdcloud/Hdcloud_clue_oplogs_model.php new file mode 100644 index 00000000..2024ad70 --- /dev/null +++ b/common/models/hdcloud/Hdcloud_clue_oplogs_model.php @@ -0,0 +1,31 @@ +table_name, 'default'); + } + + /** + * Notes:类型 + * Created on: 2021/7/27 10:31 + * Created by: dengbw + * @return array + */ + public function typeAry() + { + return array(0 => '小记', 1 => '发短信', 2 => '拨打号码'); + } + +} diff --git a/common/models/hdcloud/Hdcloud_clues_model.php b/common/models/hdcloud/Hdcloud_clues_model.php new file mode 100644 index 00000000..f3a85c34 --- /dev/null +++ b/common/models/hdcloud/Hdcloud_clues_model.php @@ -0,0 +1,45 @@ +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); + } +} diff --git a/home/controllers/Welcome.php b/home/controllers/Welcome.php index c3b619fb..86f2cbe4 100644 --- a/home/controllers/Welcome.php +++ b/home/controllers/Welcome.php @@ -4,28 +4,37 @@ defined('BASEPATH') OR exit('No direct script access allowed'); class Welcome extends CI_Controller { public function index(){ - echo "

404

";exit; + //echo "

404

";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(); diff --git a/home/controllers/neta/Cloud.php b/home/controllers/neta/Cloud.php new file mode 100644 index 00000000..a216a0b9 --- /dev/null +++ b/home/controllers/neta/Cloud.php @@ -0,0 +1,58 @@ +404";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); + } +} + + + diff --git a/home/views/h5/market/sylive2/act/index.php b/home/views/h5/market/sylive2/act/index.php index 77f77003..1f92328f 100644 --- a/home/views/h5/market/sylive2/act/index.php +++ b/home/views/h5/market/sylive2/act/index.php @@ -56,6 +56,11 @@ alt="#">
领取家电好物礼
+ + # +
预约试驾
+
# @@ -73,6 +78,10 @@ href="https://www.liche.cn/h5/market/sylive2/item/detail?skey=YV9pZD0yMyZpdGVtSWQ9MzA"> 立即支付99元权益金 + + 立即支付10元宠爱金 +
客户姓名客户电话线索来源状态跟进人创建时间最后报名时间ID客户姓名客户电话所在地区状态创建时间操作
- - - - - -
-
-
-
- +
详情 + 分配