From e9959a66a07209468fb213eea72214abf54a24b2 Mon Sep 17 00:00:00 2001 From: dengbw Date: Tue, 27 Jul 2021 15:33:27 +0800 Subject: [PATCH] admin_clues_727 --- admin/controllers/Common.php | 28 ++-- admin/controllers/receiver/Clues.php | 133 ++++++++++++++++-- admin/views/receiver/clues/lists_call.php | 67 +++++++++ .../receiver/Receiver_clue_oplogs_model.php | 11 ++ common/models/receiver/Receiver_xz_model.php | 21 +++ 5 files changed, 231 insertions(+), 29 deletions(-) create mode 100644 admin/views/receiver/clues/lists_call.php diff --git a/admin/controllers/Common.php b/admin/controllers/Common.php index 104ca5ca..e2640eaf 100644 --- a/admin/controllers/Common.php +++ b/admin/controllers/Common.php @@ -1077,7 +1077,7 @@ class Common extends CI_Controller return $this->show_json(SYS_CODE_FAIL, '短信最多300个字'); } if ($type == 1) { - $content = '【星盟卡】' . $content; + $content = '【狸车】' . $content; } else if ($type == 2) { $content = '【好店云】' . $content; } @@ -1098,16 +1098,16 @@ class Common extends CI_Controller $this->data['result'] = $plaintext; if ($plaintext) { if ($id && $type == 1) { - $this->load->model('app/jdb/receiver_oplogs_model', 'mdReceiverOplogs'); + $this->load->model('receiver/receiver_clue_oplogs_model', 'mdOplogs'); $data = array( - 'rc_id' => $id, - 'admin_id' => $this->uid, - 'admin_name' => $this->username, - 'type' => 2, + 'clue_id' => $id, + 'uid' => $this->uid, + 'uname' => $this->username, + 'type' => 1, 'log' => $content, 'c_time' => time() ); - $this->mdReceiverOplogs->add($data);//增加操作记录 + $this->mdOplogs->add($data);//增加操作记录 } return $this->show_json(SYS_CODE_SUCCESS, '发送短信成功'); } else { @@ -1344,16 +1344,16 @@ class Common extends CI_Controller $page = $this->input->post('page') ? intval($this->input->post('page')) : 1; $size = $this->input->post('size') ? intval($this->input->post('size')) : 10; $where = "status=1 "; - $brand_id && $where.=" and brand_id=$brand_id"; - $s_id && $where.=" and s_id=$s_id"; - $v_id && $where.=" and v_id=$v_id"; - $cor_id && $where.=" and cor_id=$cor_id"; - $incor_id && $where.=" and incor_id=$incor_id"; - if($select_id){ + $brand_id && $where .= " and brand_id=$brand_id"; + $s_id && $where .= " and s_id=$s_id"; + $v_id && $where .= " and v_id=$v_id"; + $cor_id && $where .= " and cor_id=$cor_id"; + $incor_id && $where .= " and incor_id=$incor_id"; + if ($select_id) { $fhwhere = [ "($where) or (id=$select_id)" => null ]; - }else{ + } else { $fhwhere = [ "($where)" => null ]; diff --git a/admin/controllers/receiver/Clues.php b/admin/controllers/receiver/Clues.php index 846102d0..2ea48383 100644 --- a/admin/controllers/receiver/Clues.php +++ b/admin/controllers/receiver/Clues.php @@ -4,7 +4,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); class Clues extends HD_Controller { private $searchTpAry = array('mobile' => '客户手机号', 'name' => '客户姓名'); - + private $cacheKeyPhone = 'xz_admin_phone'; protected $log_dir; public function __construct() @@ -14,6 +14,7 @@ class Clues extends HD_Controller $this->load->model('receiver/receiver_clues_cfrom_model', 'clues_cfrom_model'); $this->load->model('receiver/receiver_customers_model', 'customers_model'); $this->load->model('receiver/receiver_clue_oplogs_model', 'mdOplogs'); + $this->load->model('receiver/receiver_xz_model', 'mdReceiverXz'); $this->load->model('app/licheb/app_licheb_users_model'); $this->load->model("biz/biz_model"); $this->load->model('auto/auto_brand_model', 'mdAutoBrand'); @@ -108,8 +109,19 @@ class Clues extends HD_Controller $setValue = array(); $setValue['uname'] = $value['uname']; $setValue['log'] = $value['log']; - $setValue['type_name'] = '小记'; + $setValue['type_name'] = $this->mdOplogs->typeAry()[$value['type']]; $setValue['c_time'] = date('Y-m-d H:i', $value['c_time']); + $rec_url = $rec_text = ''; + if ($value['type'] == 2) {//拨打电话 + $rec_text = '未接通'; + $row = $this->mdReceiverXz->get(array('id' => $value['log'])); + if ($row['duration']) { + $rec_url = $row['rec_url'] ? build_qiniu_image_url($row['rec_url'], 0,0,'video') : ''; + $rec_text = '录音文件未生成'; + } + } + $setValue['rec_url'] = $rec_url; + $setValue['rec_text'] = $rec_text; $logsList[] = $setValue; } $info_show['logsList'] = $logsList; @@ -144,16 +156,17 @@ class Clues extends HD_Controller * 新增 * @return bool */ - function get_add(){ + function get_add() + { $id = $this->input->get('id'); - if($id){ + if ($id) { $row = $this->clues_model->get(array('id' => $id)); - if(!$row){ + if (!$row) { return $this->show_json(SYS_CODE_FAIL, '记录不存在'); } - $info = array( + $info = array( 'name' => $row['name'], 'mobile' => $row['mobile'], 'cf_id' => $row['cf_id'], @@ -468,14 +481,7 @@ class Clues extends HD_Controller } $mobile = $re['mobile']; $cache = &load_cache('redis'); - $cache_key = "xz_admin_phone"; - $xz_admin_phone = $cache->get($cache_key); -// $xz_admins_numbers = array(); -// $xz_admins_numbers['admins'][$this->uid] = '18916751561'; -// $xz_admins_numbers['numbers']['18916751561'] = $this->uid; -// $cache->save($cache_key, $xz_admins_numbers); -// echo json_encode($xz_admin_phone,JSON_UNESCAPED_UNICODE); -// exit; + $xz_admin_phone = $cache->get($this->cacheKeyPhone); $middleNumber = ''; if ($xz_admin_phone) { $middleNumber = $xz_admin_phone['admins'][$this->uid]; @@ -498,7 +504,6 @@ class Clues extends HD_Controller } if ($result['code']) { $this->data['middlenumber'] = $result['data']['virtualMobile']; - $this->load->model('receiver/receiver_xz_model', 'mdReceiverXz'); $add_data = [ 'call_id' => $seq_id, 'display_number' => $result['data']['virtualMobile'], @@ -517,6 +522,104 @@ class Clues extends HD_Controller $this->show_view('receiver/clues/edit_xbind'); } + 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); + $mobiles = $this->mdReceiverXz->get_mobiles('admin'); + 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, '暂无虚似号'); + } + $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, '重置已分配成功'); + } + } + private function upload() { $config['upload_path'] = $_SERVER['DOCUMENT_ROOT'] . '/temp/'; diff --git a/admin/views/receiver/clues/lists_call.php b/admin/views/receiver/clues/lists_call.php new file mode 100644 index 00000000..bb5b8f34 --- /dev/null +++ b/admin/views/receiver/clues/lists_call.php @@ -0,0 +1,67 @@ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + +
ID用户名手机号分配号码操作
+
+
+
+
+
+ +
+
\ No newline at end of file diff --git a/common/models/receiver/Receiver_clue_oplogs_model.php b/common/models/receiver/Receiver_clue_oplogs_model.php index 937bc667..0ad6848a 100644 --- a/common/models/receiver/Receiver_clue_oplogs_model.php +++ b/common/models/receiver/Receiver_clue_oplogs_model.php @@ -17,4 +17,15 @@ class Receiver_clue_oplogs_model extends HD_Model 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 => '拨打号码'); + } + } diff --git a/common/models/receiver/Receiver_xz_model.php b/common/models/receiver/Receiver_xz_model.php index 93229f50..7909fc82 100644 --- a/common/models/receiver/Receiver_xz_model.php +++ b/common/models/receiver/Receiver_xz_model.php @@ -15,4 +15,25 @@ class Receiver_xz_model extends HD_Model { parent::__construct($this->table_name, 'default'); } + + /** + * Notes:虚似号码 + * Created on: 2021/7/26 14:20 + * Created by: dengbw + * @param string $type + * @return array + */ + public function get_mobiles($type = 'admin') + { + if ($type == 'api') {//小程序接口专用 + $mobile = array( + '18916735350','18916689195', + ); + } else {//后台专用 + $mobile = array( + '18916735350','18916689195', + ); + } + return $mobile; + } }