增加晓致虚拟电话

This commit is contained in:
lcc
2024-09-03 17:45:08 +08:00
parent 9e0385630c
commit a6dc8037bf
11 changed files with 641 additions and 22 deletions
+7 -2
View File
@@ -24,6 +24,7 @@ class Customer extends HD_Controller
$this->load->model('receiver/receiver_clues_model', 'clues_model');
$this->load->model('receiver/receiver_clues_cfrom_model', 'clues_cfrom_model');
$this->load->model('receiver/receiver_yx_model');
$this->load->model('receiver/receiver_xz_model');
$this->load->model('app/licheb/app_licheb_users_model');
$this->load->model("biz/biz_model");
$this->load->model('area_model');
@@ -646,9 +647,13 @@ class Customer extends HD_Controller
foreach ($rows_log as $key => $value) {
$rec_text = $rec_url = '';
if ($value['type'] == 2) {
$rec_row = $this->receiver_yx_model->get(['id' => $value['log']], 'rec_url,duration');
if ($value['sub_type'] == Receiver_customer_oplogs_model::SUB_TYPE_XZ) {
$rec_row = $this->receiver_xz_model->get(['id' => $value['log']], 'rec_url,duration');
} else {
$rec_row = $this->receiver_yx_model->get(['id' => $value['log']], 'rec_url,duration');
}
if ($rec_row['duration']) {
$rec_row['rec_url'] && $rec_url = get_yx_video($rec_row['rec_url']);
$rec_row['rec_url'] && $rec_url = $rec_row['rec_url'];
!$rec_row['rec_url'] && $rec_text = '录音暂未生成';
} else {
$rec_text = '未接通';
+3 -9
View File
@@ -7,13 +7,7 @@
* Time: 11:32
*/
$config['app_id'] = 1216;
$config['app_key'] = 'V44SK7UJMUN1SH9FETN8QRT2';
$config['app_id'] = 1428;
$config['app_key'] = 'S3WMWHBGKSDZP5SYYVDV4JZK';
$config['mobile_list'] = array(
'18017420332','18017414423','15317304631','15317106841',
'15317082243','15317373459','15317373449','15317373340',
'15317373147','15317373143','15317372640','15317371423',
'15317371412','15317371405','15317370437','15317368843',
'15317367941','15317367402','15317364837',
);
$config['mobile_list'] = [];
+176
View File
@@ -0,0 +1,176 @@
<?php
/**
* Created by Vim
* User: lcc
* Desc: 晓致拨号回调
* Date: 2021/4/14
* Time: 19:15
*/
require_once COMMPATH . 'third_party/Xcall/Xcall.php';
class Xzcall extends HD_Controller
{
private $log_file;
private $admin_config = [
'app_id' => 1206,
'app_key' => 'WX6HDVZX3AYSZDR1739332ZM'
];
public function __construct()
{
parent::__construct();
$this->log_file = 'call_xz.log';
$this->load->model('receiver/receiver_xz_model');
$this->load->model('receiver/receiver_customers_model', 'customers_model');
$this->load->model('receiver/receiver_customer_oplogs_model', 'mdOplogs');
}
public function index()
{
debug_log("start function:" . __FUNCTION__, $this->log_file);
$data = $this->input->post();
debug_log('data:' . json_encode($data, JSON_UNESCAPED_UNICODE), $this->log_file);
if ($data && $data['seqId']) {
$row = $this->receiver_xz_model->get(array('call_id' => $data['seqId']));
if ($row) {
$jsondata = json_decode($row['json_data'], true);
$data['uname'] = $jsondata['uname'];
$data['brand_id'] = $jsondata['brand_id'];
$up_data['caller_state'] = $data['status'];
$up_data['status'] = 1;
$data['mid'] && $up_data['mid'] = $data['mid'];
$data['to'] && $up_data['called_num'] = $data['to'];
$data['from'] && $up_data['caller_num'] = $data['from'];
if ($data['callAnswer']) {
$up_data['duration'] = $data['callEnd'] - $data['callAnswer'];
$up_data['answer_time'] = $this->getMsecToMescdate($data['callAnswer']);
}
$data['callStart'] && $up_data['start_time'] = $this->getMsecToMescdate($data['callStart']);
$data['callEnd'] && $up_data['end_time'] = $this->getMsecToMescdate($data['callEnd']);
$up_data['json_data'] = json_encode($data, JSON_UNESCAPED_UNICODE);
$this->receiver_xz_model->update($up_data, ['id' => $row['id']]);
if ($row['cf_id'] && $row['cf_platform'] == 'admin') { //后台
$admin_id = $row['cf_uid'];
$this->load->model('sys/sys_admin_model');
$admin = $this->sys_admin_model->get(array('id' => $admin_id));
$addData = array(
'uid' => $admin_id,
'uname' => $admin['username'] ? $admin['username'] : '',
'type' => 2,//类型 0 普通 1短信 2电话
'log' => $row['id'],
'c_time' => time()
);
if ($row['cf_title'] == 'clues') {//线索拨打电话回调
$this->load->model('receiver/receiver_clue_oplogs_model', 'mdOplogs');
$addData['clue_id'] = $row['cf_id'];
} else if ($row['cf_title'] == 'customer') {//客户拨打电话回调
$addData['customer_id'] = $row['cf_id'];
$addData['sub_type'] = Receiver_customer_oplogs_model::SUB_TYPE_XZ;
} else if ($row['cf_title'] == 'owners') {//车主拨打电话回调
$this->load->model('receiver/receiver_owners_oplogs_model', 'mdOplogs');
$addData['own_id'] = $row['cf_id'];
}
$this->mdOplogs->add($addData);
$xcall = new Xcall($this->admin_config);
//解绑
$xcall->SWunbind($data['to'], $data['virtualMobile']);
} elseif ($row['cf_id'] && $row['cf_platform'] == 'api') { //狸车宝
$this->config->load('xcall');
$params = [
'app_id' => $this->config->item('app_id'),
'app_key' => $this->config->item('app_key'),
];
$xcall = new Xcall($params);
//解绑
$result = $xcall->AXBUnbind($data['to'], $data['from'], $data['virtualMobile']);
//删除redis
$cache_key = "XZ_LICHEB_MOBILEA_{$data['from']}_MOBILEB_{$data['to']}_{$row['cf_uid']}";
$redis = &load_cache('redis');
$redis->delete($cache_key);
$cust = $this->customers_model->get(['id' => $row['cf_id']]);
$this->load->library('receiver/customers_entity');
$visit = $row['cf_title'] == 'customer' ? 1 : 0;
$this->customers_entity->add_log_visit($cust['id'], $row['cf_uid'], $data['uname'], $row['id'], 2, $visit, [], 'wxapp', Receiver_customer_oplogs_model::SUB_TYPE_XZ);
}
} else {
// if ($data['virtualMobile'] == '13391247942') { //推送test环境
// $url = "https://api.lc.haodian.cn/plan/xzcall";
// $this->load->library('mycurl');
// $res = $this->mycurl->httpPost($url, $data);
// debug_log('结束,推送test环境:' . json_encode($res, JSON_UNESCAPED_UNICODE), $this->log_file);
// }
debug_log("error: 未找到拨打记录", $this->log_file);
}
}
debug_log("end " . __FUNCTION__, $this->log_file);
echo '{"result":"0","error":""}';
}
//录音推送地址
public function video()
{
$data = $this->input->post();
debug_log("start function:" . __FUNCTION__, $this->log_file);
debug_log('data:' . json_encode($data, JSON_UNESCAPED_UNICODE), $this->log_file);
$row = $this->receiver_xz_model->get(array('mid' => $data['mid']));
if ($row) {
$jsondata = json_decode($row['json_data'], true);
if ($data['getFileUrl']) {
if ($data['id'] == $this->admin_config['app_id']) {
$params = $this->admin_config;
} else {
$this->config->load('xcall');
$params = [
'app_id' => $this->config->item('app_id'),
'app_key' => $this->config->item('app_key'),
];
}
$xcall = new Xcall($params);
$result = $xcall->getFile($data['getFileUrl'], $data['mid'], $data['tag']);
if ($result['code']) { //上传七牛
$this->load->library('qiniu');
$qiniu = new Qiniu(['type' => 'video']);
$filename = $qiniu->getFileName($data['mid'], 'mp3', 'xz_video_');
$q_res = $qiniu->save($filename, $result['data']);
if (!$q_res) {
debug_log('error:文件上传七牛失败', $this->log_file);
} else {
$up_data['rec_url'] = $q_res['url'];
}
} else {
debug_log('error:' . json_encode($result, JSON_UNESCAPED_UNICODE), $this->log_file);
}
}
$jsondata['file_info'] = $data;
$up_data['json_data'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
$this->receiver_xz_model->update($up_data, ['id' => $row['id']]);
} else {
//推送test环境
// $url = "https://api.ss.haodian.cn/plan/xzcall/video";
// $this->load->library('mycurl');
// $res = $this->mycurl->httpPost($url, $data);
// debug_log('结束,推送test环境:' . json_encode($res, JSON_UNESCAPED_UNICODE), $this->log_file);
}
debug_log("end " . __FUNCTION__, $this->log_file);
echo '{"result":"0","error":""}';
}
/**
* 毫秒转日期
*/
private function getMsecToMescdate($msectime)
{
$msectime = $msectime * 0.001;
if (strstr($msectime, '.')) {
sprintf("%01.3f", $msectime);
list($usec, $sec) = explode(".", $msectime);
$sec = str_pad($sec, 3, "0", STR_PAD_RIGHT);
} else {
$usec = $msectime;
$sec = "000";
}
$date = date("Y-m-d H:i:s.x", $usec);
return $mescdate = str_replace('x', $sec, $date);
}
}
+1 -1
View File
@@ -68,7 +68,7 @@ class Yxcall extends HD_Controller
$result = $ycall->AXBUnbind($data['displayNumber'], $data['calleeNumber'], $data['callerNumber']);
//删除redis
$cache_key = "XZ_LICHEB_MOBILEA_{$data['calleeNumber']}_MOBILEB_{$data['callerNumber']}_{$row['cf_uid']}";
$redis = &load_cache('redis');
$redis = &load_cache();
$redis->delete($cache_key);
$cust = $this->customers_model->get(['id' => $row['cf_id']]);
$visit = $row['cf_title'] == 'customer' ? 1 : 0;
+11 -4
View File
@@ -25,6 +25,7 @@ class Customerlogs extends Wxapp
$this->load->model('receiver/receiver_customer_oplogs_model', 'customer_oplogs_model');
$this->load->model('receiver/receiver_comments_model', 'mdComments');
$this->load->model('receiver/receiver_yx_model');
$this->load->model('receiver/receiver_xz_model');
}
protected function get()
@@ -40,7 +41,7 @@ class Customerlogs extends Wxapp
$count = $this->customer_oplogs_model->count($where);
$lists = [];
if ($count) {
$rows = $this->customer_oplogs_model->select($where, 'id desc', $page, $size, 'id,log,uname,type,c_time,imgs');
$rows = $this->customer_oplogs_model->select($where, 'id desc', $page, $size, 'id,log,uname,type,c_time,imgs,sub_type');
foreach ($rows as $key => $val) {
$record = '';
$second = 0;
@@ -53,11 +54,17 @@ class Customerlogs extends Wxapp
}
}
if ($val['type'] == 2) {
$rec_row = $this->receiver_yx_model->get(['id' => $val['log']], 'rec_url,duration');
$content = '拨打电话';
if ($val['sub_type'] == Receiver_customer_oplogs_model::SUB_TYPE_XZ) {
$rec_row = $this->receiver_xz_model->get(['id' => $val['log']], 'rec_url,duration');
$rec_row['rec_url'] && $record = $rec_row['rec_url'];
$rec_row['duration'] && $second = intval($rec_row['duration'] / 1000);
} else {
$rec_row = $this->receiver_yx_model->get(['id' => $val['log']], 'rec_url,duration');
$rec_row['rec_url'] && $record = get_yx_video($rec_row['rec_url']);
$rec_row['duration'] && $second = intval($rec_row['duration']);
}
!$rec_row['duration'] && $content .= '(未接通)';
$rec_row['rec_url'] && $record = get_yx_video($rec_row['rec_url']);
$rec_row['duration'] && $second = intval($rec_row['duration']);
}
$comments = [];
$res = $this->mdComments->select(['pid' => $val['id'], 'status' => 1, 'type' => 0], 'id asc', 0, 0
+132
View File
@@ -0,0 +1,132 @@
<?php
defined('WXAPP_APP') or exit('No direct script access allowed');
/**
* Created by Vim.
* User: lcc
* Desc: 晓致虚拟号
* Date: 2021/07/26
* Time: 10:17
*/
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
require_once COMMPATH . 'third_party/Xcall/Xcall.php';
class Xz extends Wxapp
{
function __construct($inputs, $app_key)
{
parent::__construct($inputs, $app_key);
$this->login_white = array();//登录白名单
$this->load->model('receiver/receiver_customers_model', 'customers_model');
$this->load->model('receiver/receiver_xz_model');
$this->log_file = 'call.log';
}
protected function get()
{
$id = $this->input_param('id');
$type = intval($this->input_param('type'));
!$type && $type = 0;
$session = $this->session;
$admin_id = $session['uid'];
$cf_title = 'customer';
$cus_id = $id;
$row = $this->customers_model->get(['id' => $cus_id]);
if (!$row || !$row['mobile']) {
throw new Hd_Exception('用户不存在', API_CODE_INVILD_PARAM);
}
$customer_mobile = $row['mobile'];
$user_mobile = $session['mobile'];
$json = $session['jsondata'] ? json_decode($session['jsondata'], true) : array();
if ($json && $json['hdy'] && $json['hdy']['tel']) {
$user_mobile = $json['hdy']['tel'];
}
$redis = &load_cache('redis');
$cache_key = "XZ_LICHEB_MOBILEA_{$user_mobile}_MOBILEB_{$customer_mobile}_{$admin_id}";
$call_mobile = $redis->get($cache_key);
if (!$call_mobile) {
$this->config->load('xcall');
$params = [
'app_id' => $this->config->item('app_id'),
'app_key' => $this->config->item('app_key'),
];
$seq_id = create_order_no();
$xcall = new Xcall($params);
$maxBindingTime = 10;//绑定时间
$result = $xcall->ABXbind($user_mobile, $customer_mobile, $seq_id, $maxBindingTime);
if (!$result['code']) { //绑定失败
debug_log("xz_failed_bind:customer_mobile【{$customer_mobile}", $this->log_file);
debug_log("xz_result:" . json_encode($result, JSON_UNESCAPED_UNICODE), $this->log_file);
throw new Hd_Exception($result['msg'], API_CODE_FAIL);
} else {
$this->data['middlenumber'] = $result['data']['virtualMobile'];
$add_data = [
'call_id' => $seq_id,
'display_number' => $result['data']['virtualMobile'],
'biz_id' => $row['biz_id'],
'cf_id' => $cus_id,
'cf_uid' => $admin_id,
'cf_title' => $cf_title,
'cf_platform' => 'api',
'json_data' => json_encode(['uname' => $session['uname']], JSON_UNESCAPED_UNICODE),
'c_time' => time()
];
$this->receiver_xz_model->add($add_data);
$call_mobile = $result['data']['virtualMobile'];
$redis->save($cache_key, $call_mobile, $maxBindingTime * 60);
}
}
$data['mobile'] = $call_mobile;
return $data;
}
//电话统计
protected function get_stat()
{
$biz_id = $this->input_param('biz_id');
$day = $this->input_param('day');
$admin_id = $this->input_param('admin_id');
if (!$biz_id) {
throw new Hd_Exception('参数错误', API_CODE_INVILD_PARAM);
}
//接通次数
$where1 = [
'cf_title' => 'customer',
'cf_platform' => 'api',
'biz_id' => $biz_id,
'status' => 1,
];
if ($day) {
$s_time = date('Y-m-d 00:00:00', strtotime($day));
$e_time = date('Y-m-t 23:59:59', strtotime($day));
$where1["c_time>="] = strtotime($s_time);
$where1["c_time<="] = strtotime($e_time);
}
$admin_id && $where1['cf_uid'] = $admin_id;
$where2 = [
'duration' => 0
];
$where = array_merge($where1, $where2);
$num = $this->receiver_xz_model->count($where);
$where2 = [
'duration>' => 0
];
$where = array_merge($where1, $where2);
$count_call = $this->receiver_xz_model->count($where); //接通次数
$sum_call = $this->receiver_xz_model->sum('duration', $where); //接通总时长
$call_time = $sum_call['duration'] / 60000;
if ($call_time) {
$avg_time = $call_time / $count_call;
}
$data = [
'call_time' => round($call_time, 2),
'avg_time' => round($avg_time, 2),
'unget_num' => $num
];
return $data;
}
}
+246
View File
@@ -0,0 +1,246 @@
<?php
/**
* 通用curl
* User: bleachin
*/
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Mycurl
{
private $host = '';
private $user_agent = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36';
private $cookie = '';
private $headers = array();
private $post_data = '';
public function __construct()
{
$this->setHeaders();
}
public function setHost($host='')
{
$this->host = $host;
}
public function setUserAgent($user_agent='')
{
$this->user_agent = $user_agent;
}
public function setCookie($cookie='')
{
$this->cookie = $cookie;
}
public function setHeaders($headers='')
{
if($headers&&is_array($headers)){
$_headers = $headers;
}else{
$_headers = array();
$_headers[] = $this->host;
// $_headers[] = 'Accept-Encoding: gzip, deflate, sdch';
$_headers[] = $this->user_agent;
$_headers[] = $this->cookie;
$headers && $_headers[] = $headers;
}
$this->headers = $_headers;
}
public function httpGet($url='', $data=array())
{
$res = false;
if (!$url) return $res;
if ($data)
{
$url = $url.'?'.$this->buildGetQuery($data);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//关闭https验证
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
if($this->headers)
{
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
}
$res = curl_exec($ch);
curl_close($ch);
return $res;
}
/**
* post 通用方法
* @param string $url [description]
* @param [type] $data [description]
* @param string $type post请求的数据类型
* @param string $file_path 文件的绝对路径,类似APPPATH.'public/img/'.$photo_path
* @return [type] [description]
*/
public function httpPost($url='', $data, $type='', $file_path='',$time_out = 60)
{
$res = false;
if (!$url) return $res;
if ($file_path) $file_path = realpath($file_path);
if (!$type || $type=='is_file'|| $type=='xml') {
$this->post_data = $data;
}elseif($data && $type=='is_json'){
$this->post_data = $this->buildJsonQuery($data);
$this->headers[] = 'Content-Type: application/json; charset=UTF-8';
}elseif($data && $type=='is_form')
{
$this->post_data = http_build_query($data);
$this->headers[] = 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8';
}elseif($data && $type=='xml'){
$this->headers[] = 'Content-type: text/xml';
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_ENCODING, ''); // 重要,否则采集数据时会乱码,乱码检测的编码格式为cp936
//关闭https验证
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
if ($file_path && $type=='is_file')
{
if (class_exists('\CURLFile'))
{
$file_path = new \CURLFile($file_path);
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true); // >=5.5.0
}
else
{
if (defined('CURLOPT_SAFE_UPLOAD')) // 非5.6.0,是5.5.0以下手动设置了true
{
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false); // <=5.5.0
}
$file_path = "@".$file_path; //@’符号告诉服务器为上传资源
}
}
if($this->headers) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->post_data);
if($time_out){ //超时时间
// 在尝试连接时等待的秒数
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , $time_out);
// 最大执行时间
curl_setopt($ch, CURLOPT_TIMEOUT, $time_out);
}
$res = curl_exec($ch);
if(curl_errno( $ch )) {
$errno = curl_errno( $ch );
$info = curl_getinfo( $ch );
print_r($errno);
print_r($info);
}
$httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch);
return $res;
}
/**
* put 通用方法
* @param string $url [description]
* @param [type] $data [description]
* @param string $type put请求的数据类型
* @return [type] [description]
*/
public function httpPut($url='', $data, $type='',$time_out = 60){
$res = false;
if (!$url) return $res;
if (!$type || $type=='is_file'|| $type=='xml') {
$this->post_data = $data;
}elseif($data && $type=='is_json'){
$this->post_data = $this->buildJsonQuery($data);
$this->headers[] = 'Content-Type: application/json; charset=UTF-8';
}elseif($data && $type=='is_form')
{
$this->post_data = http_build_query($data);
$this->headers[] = 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8';
}elseif($data && $type=='xml'){
$this->headers[] = 'Content-type: text/xml';
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); //定义请求类型
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->post_data);
if($this->headers) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
}
if($time_out){ //超时时间
// 在尝试连接时等待的秒数
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , $time_out);
// 最大执行时间
curl_setopt($ch, CURLOPT_TIMEOUT, $time_out);
}
$res = curl_exec($ch);
if(curl_errno( $ch )) {
$errno = curl_errno( $ch );
$info = curl_getinfo( $ch );
print_r($errno);
print_r($info);
}
$httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch);
return $res;
}
private function buildGetQuery($data)
{
$querystring = '';
if (is_array($data)) {
foreach ($data as $key => $val) {
if (is_array($val)) {
foreach ($val as $val2) {
$querystring .= urlencode($key).'='.urlencode($val2).'&';
}
} else {
$querystring .= urlencode($key).'='.urlencode($val).'&';
}
}
$querystring = substr($querystring, 0, -1);
} else {
$querystring = $data;
}
return $querystring;
}
private function buildJsonQuery($data)
{
$querystring = '';
if (is_array($data)) {
$querystring=json_encode($data);
}
return $querystring;
}
}
@@ -29,11 +29,11 @@ class Customers_entity
* @param string $cf_platform
* @return mixed
*/
public function add_log_visit($customer_id, $uid, $uname, $content, $type = '', $visit = 0, $imgs = [], $cf_platform = 'wxapp')
public function add_log_visit($customer_id, $uid, $uname, $content, $type = '', $visit = 0, $imgs = [], $cf_platform = 'wxapp', $sub_type = '')
{
$result = '';
if ($content) {
$result = $this->add_log($customer_id, $uid, $uname, $content, $type, $cf_platform, $imgs);
$result = $this->add_log($customer_id, $uid, $uname, $content, $type, $cf_platform, $imgs, '', $sub_type);
}
if ($visit && ($result || !$content)) {//更新客户已跟进
if ($type == 1 || $type == 2) {//1发短信2拨打号码 不算入已跟进
@@ -61,7 +61,7 @@ class Customers_entity
* @param $c_time int 创建日期
* @return string
*/
public function add_log($customer_id, $uid, $uname, $content, $type = '', $cf_platform = 'wxapp', $imgs = [], $c_time = '')
public function add_log($customer_id, $uid, $uname, $content, $type = '', $cf_platform = 'wxapp', $imgs = [], $c_time = '', $sub_type = '')
{
$this->ci->load->model('receiver/receiver_customer_oplogs_model', 'customer_oplogs_model');
if ($type == 4 || $type == 5) {//到店或试驾,一天只记录一次
@@ -104,6 +104,7 @@ class Customers_entity
$uname && $add_data['uname'] = $uname;
$type && $add_data['type'] = $type;
$cf_platform && $add_data['cf_platform'] = $cf_platform;
$sub_type && $add_data['sub_type'] = $sub_type;
$imgs && $add_data['imgs'] = json_encode($imgs, JSON_UNESCAPED_UNICODE);
$result = $this->ci->customer_oplogs_model->add($add_data);
if (($type == 2 || $type == 1) && $result) { //更新最后联系时间
@@ -6,12 +6,14 @@
* Time: 13:47
*/
defined('BASEPATH') OR exit('No direct script access allowed');
defined('BASEPATH') or exit('No direct script access allowed');
class Receiver_customer_oplogs_model extends HD_Model
{
private $table_name = 'lc_receiver_customer_oplogs';
const SUB_TYPE_XZ = 'xz';
public function __construct()
{
parent::__construct($this->table_name, 'default');
@@ -0,0 +1,56 @@
<?php
/**
* Notes:晓致虚拟号通话记录
* Created on: 2021/7/26 13:38
* Created by: dengbw
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Receiver_xz_model extends HD_Model
{
private $table_name = 'lc_receiver_xz';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
//获取晓致状态
public function get_xz_status($status=''){
$arr = [
-1 => '实时来电通知(是否接听状态未知,非话单记录)',
0 => '正常接听',
1 => '未应答',
2 => '黑名单来电,拒接',
3 => '虚号关机状态,未接听',
4 => '未绑定号码',
5 => '遇忙未接听'
];
if(strlen($status)){
return $arr[$status] ? $arr[$status] : '未知状态';
}else{
return $arr;
}
}
//获取晓致noAnswerReaso对应错误码
public function get_xz_noAnswerReason($noAnswerReason=''){
$arr = [
11 => '主叫挂机',
12 => '被叫挂机',
13 => '被叫正在通话中',
14 => '被叫无人接听',
15 => '被叫无法接通',
16 => '被叫关机',
17 => '被叫空号',
18 => '被叫暂停服务',
19 => '被叫转接失败',
];
if(strlen($noAnswerReason)){
return $arr[$noAnswerReason] ? $arr[$noAnswerReason] : '';
}else{
return $arr;
}
}
}
+2 -2
View File
@@ -8,8 +8,8 @@
class Xcall{
private $id = '1206';
private $key = 'WX6HDVZX3AYSZDR1739332ZM';
private $id = 1428;
private $key = 'S3WMWHBGKSDZP5SYYVDV4JZK';
private $api_url = 'http://api.teleii.com/';
private $ci;
private $log_file = 'xcall.log';