Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b11441c590 | |||
| 4a598a7233 |
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
require_once APPPATH . 'controllers/pingan/BaseController.php';
|
||||
|
||||
class Log extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('receiver/receiver_call_model', 'callModel');
|
||||
$this->load->model('receiver/receiver_clues_model', 'cluesModel');
|
||||
$this->cluesModel->set_db('ssdb');
|
||||
$this->callModel->set_db('ssdb');
|
||||
}
|
||||
|
||||
public function page_get()
|
||||
{
|
||||
$params = $this->input_param();
|
||||
$page = $params['page'] ?: 1;
|
||||
$limit = $params['limit'] ?: 10;
|
||||
$sort_order = 'id desc';
|
||||
$where = $this->buildWhere();
|
||||
$count = $this->callModel->count($where);
|
||||
$list = [];
|
||||
if ($count) {
|
||||
$rows = $this->callModel->select($where, $sort_order, $page, $limit);
|
||||
foreach ($rows as $v) {
|
||||
$temp = $v;
|
||||
$temp['customerPhoneNo'] = mobile_asterisk($v['customerPhoneNo']);
|
||||
$temp['finishTypeCn'] = Receiver_call_model::finishTypeList[$v['finishType']] ?: '';
|
||||
$temp['callTypeCn'] = Receiver_call_model::callTypeList[$v['callType']] ?: '';
|
||||
$temp['hangupTypeCn'] = Receiver_call_model::hangupTypeList[$v['hangupType']] ?: '';
|
||||
$list[] = $temp;
|
||||
}
|
||||
}
|
||||
$data = ['list' => $list, 'count' => $count];
|
||||
$this->return_response_list($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索条件
|
||||
* @return void
|
||||
*/
|
||||
public function search_get()
|
||||
{
|
||||
$data = [];
|
||||
$data['finishTypeList'] = Receiver_call_model::finishTypeList;;
|
||||
$data['callTypeList'] = Receiver_call_model::callTypeList;
|
||||
$data['hangupTypeList'] = Receiver_call_model::hangupTypeList;
|
||||
$this->return_response_list($data);
|
||||
}
|
||||
|
||||
private function buildWhere()
|
||||
{
|
||||
$params = $this->input_param();
|
||||
$where = [
|
||||
'cfUid' => $_SESSION['id']
|
||||
];
|
||||
$params['orderId'] && $where["orderId like '%{$params['orderId']}%'"] = null;
|
||||
$params['agentId'] && $where['agentId'] = $params['agentId'];
|
||||
$params['voiceId'] && $where['voiceId'] = $params['voiceId'];
|
||||
$params['customerPhoneNo'] && $where['customerPhoneNo'] = $params['customerPhoneNo'];
|
||||
strlen($params['finishType']) && $where['finishType'] = $params['finishType'];
|
||||
strlen($params['callType']) && $where['callType'] = $params['callType'];
|
||||
strlen($params['hangupType']) && $where['hangupType'] = $params['hangupType'];
|
||||
if ($params['startTime'][0] && $params['startTime'][1]) {
|
||||
$where['startTime >='] = $params['startTime'][0] . ' 00:00:00';
|
||||
$where['startTime <='] = $params['startTime'][1] . ' 23:59:59';
|
||||
}
|
||||
if ($params['endTime'][0] && $params['endTime'][1]) {
|
||||
$where['endTime >='] = $params['endTime'][0] . ' 00:00:00';
|
||||
$where['endTime <='] = $params['endTime'][1] . ' 23:59:59';
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ class Clues extends BaseController
|
||||
$this->mdReceiverXz->set_db('ssdb');
|
||||
$this->mdOplogs->set_db('ssdb');
|
||||
$this->receiver_enroll_model->set_db('ssdb');
|
||||
$this->load->library('api/callPhone');
|
||||
}
|
||||
|
||||
public function page_get()
|
||||
@@ -380,5 +381,23 @@ class Clues extends BaseController
|
||||
}
|
||||
$this->return_response();
|
||||
}
|
||||
|
||||
/**
|
||||
* 拨打电话
|
||||
* @return void
|
||||
*/
|
||||
public function call_post()
|
||||
{
|
||||
$params = $this->input_param();
|
||||
if (!$params['id']) {
|
||||
$this->return_json('参数错误!');
|
||||
}
|
||||
$callPhone = new CallPhone();
|
||||
$result = $callPhone->Call(Receiver_call_model::CF_TYPE_CLUE, $params['id'], $_SESSION['id'], $_SESSION['username'], $_SESSION['userCode']);
|
||||
if (!$result->isSuccess()) {
|
||||
$this->return_json($result->getMessage());
|
||||
}
|
||||
$this->return_response();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,9 @@ class UserInfo extends BaseController
|
||||
'bankCardNum' => $row['bankCardNum'] ?: '',
|
||||
'bankName' => $row['bankName'] ?: '',
|
||||
'cardA' => $row['cardA'] ? changeImg(explode(',', $row['cardA'])) : [],
|
||||
'cardB' => $row['cardB'] ? changeImg(explode(',', $row['cardB'])) : []
|
||||
'cardB' => $row['cardB'] ? changeImg(explode(',', $row['cardB'])) : [],
|
||||
'mobile' => $row['mobile'],
|
||||
'cti' => $row['cti']
|
||||
];
|
||||
$this->return_response($data);
|
||||
}
|
||||
@@ -56,4 +58,23 @@ class UserInfo extends BaseController
|
||||
}
|
||||
$this->return_response();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改手机号
|
||||
* @return void
|
||||
*/
|
||||
public function mobile_put()
|
||||
{
|
||||
$userId = $_SESSION['id'];
|
||||
$params = $this->input_param();
|
||||
$upData = [
|
||||
'mobile' => $params['mobile'] ?: '',
|
||||
'cti' => $params['cti'] ?: ''
|
||||
];
|
||||
$res = $this->userData->update($upData, ['userId' => $userId]);
|
||||
if (!$res) {
|
||||
$this->return_json("更新失败");
|
||||
}
|
||||
$this->return_response();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
class CallPhone
|
||||
{
|
||||
private $ci;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->ci = &get_instance();
|
||||
$this->ci->load->model('agent/pingan/pingan_users_data_model', 'userData');
|
||||
$this->ci->load->model('receiver/receiver_clues_model', 'clues_model');
|
||||
$this->ci->load->model('receiver/receiver_clue_oplogs_model', 'mdOplogs');
|
||||
$this->ci->load->model('receiver/receiver_call_model', 'callModel');
|
||||
$this->ci->clues_model->set_db('ssdb');
|
||||
$this->ci->mdOplogs->set_db('ssdb');
|
||||
$this->ci->callModel->set_db('ssdb');
|
||||
$this->ci->load->library('carHome/CallOut');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $cfType int 类型 1线索
|
||||
* @param $cfId int 来源id
|
||||
* @param $cfUid int 用户id
|
||||
* @param $cfName string 操作用户名
|
||||
* @return MyResponse
|
||||
*/
|
||||
public function Call($cfType, $cfId, $cfUid, $cfName, $userCode)
|
||||
{
|
||||
$this->ci->callModel->db->trans_begin();
|
||||
try {
|
||||
$userData = $this->ci->userData->get(['userId' => $cfUid]);
|
||||
if (!$userData['mobile']) {
|
||||
throw new Exception('请先配置分机号');
|
||||
}
|
||||
$agentPhoneNo = $userData['mobile'];
|
||||
$agentId = $userData['cti'];
|
||||
$agentUm = $userCode;
|
||||
$cityId = 350200;
|
||||
if ($cfType == Receiver_call_model::CF_TYPE_CLUE) {
|
||||
$clues = $this->ci->clues_model->get(['id' => $cfId]);
|
||||
if (!$clues) {
|
||||
throw new Exception('线索不存在');
|
||||
}
|
||||
$orderId = $clues['sid'];
|
||||
$customerPhoneNo = $clues['mobile'];
|
||||
$clues['city_id'] && $cityId = $clues['city_id'];
|
||||
} else {
|
||||
throw new Exception('来源类型错误');
|
||||
}
|
||||
$requestId = create_order_no($cityId, 'pingan');
|
||||
$callOut = new CallOut();
|
||||
$callReq = $callOut->call($orderId, $requestId, $agentPhoneNo, $customerPhoneNo, $agentId, $agentUm);
|
||||
if (!$callReq->isSuccess()) {
|
||||
throw new Exception($callReq->getMessage());
|
||||
}
|
||||
$callData = [
|
||||
'reqId' => $requestId,
|
||||
'orderId' => $orderId,
|
||||
'customerPhoneNo' => $customerPhoneNo,
|
||||
'agentPhoneNo' => $agentPhoneNo,
|
||||
'apiResult' => json_encode($callReq->getData(), JSON_UNESCAPED_UNICODE),
|
||||
'cfUid' => $cfUid,
|
||||
'cfId' => $cfId,
|
||||
'cfType' => $cfType,
|
||||
'cfPlatform' => Receiver_call_model::CF_PLATFORM_AGENT_PINGAN,
|
||||
'createTime' => time(),
|
||||
];
|
||||
$callLogId = $this->ci->callModel->add($callData);
|
||||
if (!is_numeric($callLogId)) {
|
||||
throw new Exception('添加通话记录失败');
|
||||
}
|
||||
if ($cfType == Receiver_call_model::CF_TYPE_CLUE) {
|
||||
$optLogId = $this->ci->mdOplogs->add([
|
||||
'clue_id' => $cfId,
|
||||
'pingan_user_id' => $cfUid,
|
||||
'uname' => $cfName,
|
||||
'type' => Receiver_clue_oplogs_model::OP_TYPE_AUTO_CALL,
|
||||
'log' => '',
|
||||
'c_time' => time()
|
||||
]);
|
||||
if (!is_numeric($optLogId)) {
|
||||
throw new Exception('添加操作日志失败');
|
||||
}
|
||||
}
|
||||
$this->ci->callModel->db->trans_commit();
|
||||
return new MyRESPONSE(EXIT_SUCCESS, '提交成功');
|
||||
} catch (Exception $e) {
|
||||
$this->ci->callModel->db->trans_rollback();
|
||||
return new MyResponse(EXIT_ERROR, "参数错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,9 @@ class Welcome extends CI_Controller
|
||||
|
||||
public function test()
|
||||
{
|
||||
$this->load->library('carHome/callOut');
|
||||
$callOut = new CallOut();
|
||||
// $callOut->call();
|
||||
// $this->load->model('receiver/receiver_customers_model', 'customers_model');
|
||||
// $rid = 17418;
|
||||
// $bizId = 57;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* 平安电话推送地址
|
||||
*/
|
||||
class CallBack extends CI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1105,7 +1105,7 @@ class Customers extends Wxapp
|
||||
$customer_id = $this->customers_model->add($addData);
|
||||
if ($customer_id) {
|
||||
//初始门店更改-1,理车宝过滤
|
||||
$this->customers_model->update(['cs_biz_id' => -1], ["id" => $id]);
|
||||
// $this->customers_model->update(['cs_biz_id' => -1], ["id" => $id]);
|
||||
//删除未回访计划
|
||||
$this->mdCustomerVisitData->delete(['c_id' => $id, 'biz_id' => $re['biz_id'], 'status<>' => 2, 't_day >=' => date('Y-m-d')]);
|
||||
//同步客户标签
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
|
||||
/**
|
||||
* 汽车之家外呼接口
|
||||
*/
|
||||
class CallOut
|
||||
{
|
||||
const METHOD_GET = 'GET';
|
||||
const METHOD_POST = 'POST';
|
||||
|
||||
protected $baseUrl = 'http://202.105.128.251:18082/bas_car_home_ping_tai/car/v1/call'; //正式接口地址
|
||||
protected $aesKey = 'AmUFhqX2IOI48BwdgAXVsQgvncCD0f5X'; //AES秘钥
|
||||
protected $ctiType = 'QCZJ'; //平台类型,固定QCZJ
|
||||
protected $ci;
|
||||
protected $client;
|
||||
// 生产环境:
|
||||
// 汽车之家外呼接口(互联网主线): http://202.105.128.251:18082/bas_car_home_ping_tai/car/v1/call
|
||||
// 汽车之家外呼接口(互联网备线): http://218.18.234.155:18082/bas_car_home_ping_tai/car/v1/call
|
||||
// 测试环境:
|
||||
// 汽车之家外呼接口(互联网主线): http://202.105.128.251:18081/bas_car_home_ping_tai/car/v1/call
|
||||
// 汽车之家外呼接口(互联网备线): http://218.18.234.155:18081/bas_car_home_ping_tai/car/v1/call
|
||||
private $logDir = 'carHome';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->ci = &get_instance();
|
||||
$this->client = new Client();
|
||||
if (!is_product()) { //测试环境
|
||||
$this->baseUrl = 'http://202.105.128.251:18081/bas_car_home_ping_tai/car/v1/call';
|
||||
$this->aesKey = 'JKCDlCxTvwNumLQVAMQltfpuOSCSa6J9';
|
||||
}
|
||||
}
|
||||
|
||||
public function call($orderId, $requestId, $agentPhoneNo, $customerPhoneNo, $agentId = '', $agentUm = '', $pushUrl = '')
|
||||
{
|
||||
$logPath = 'call.log';
|
||||
try {
|
||||
// $agentPhoneNo = '18350451617';
|
||||
// $customerPhoneNo = '13365081602';
|
||||
debug_log("加密前手机号:" . json_encode(['agentPhoneNo' => $agentPhoneNo, 'customerPhoneNo' => $customerPhoneNo]), $logPath, $this->logDir);
|
||||
$enAgentPhoneNo = $this->aesEcbPkcs5Encrypt($agentPhoneNo, $this->aesKey);
|
||||
$enCustomerPhoneNo = $this->aesEcbPkcs5Encrypt($customerPhoneNo, $this->aesKey);
|
||||
$params = [
|
||||
'orderId' => $orderId, //必选 String 订单号
|
||||
'agentPhoneNo' => $enAgentPhoneNo, //必选 String 坐席分机。坐席分机如采用AES加密,汽车之家系统传加密后的号码
|
||||
'customerPhoneNo' => $enCustomerPhoneNo, //必选 String 客户手机号码。加密规则与坐席分机一致
|
||||
'displayedPhoneNo' => '0', //必选 String 外显号码(传“0”和空值均为云中继外显)
|
||||
];
|
||||
$agentId && $params['agentId'] = $agentId; //备选 String 坐席工号(汽车之家上报开通的中兴平台唯一cti号码)
|
||||
$agentUm && $params['agentUm'] = $agentUm; //备选 String 坐席Um(汽车之家人员um账号)
|
||||
$pushUrl && $params['pushUrl'] = $pushUrl; //如果有传此字段,那么推送话单数据,就推到这里
|
||||
$reqParams = [
|
||||
'ctiType' => $this->ctiType,
|
||||
'requestId' => $requestId,
|
||||
'para' => $params
|
||||
];
|
||||
debug_log("请求参数:" . json_encode($reqParams, JSON_UNESCAPED_UNICODE), $logPath, $this->logDir);
|
||||
list($req, $header, $httpStatus) = $this->send($this->baseUrl, $reqParams, self::METHOD_POST);
|
||||
debug_log("响应状态码:" . $httpStatus, $logPath, $this->logDir);
|
||||
debug_log("响应结果:" . $req, $logPath, $this->logDir);
|
||||
$reqArr = json_decode($req, true);
|
||||
if (isset($reqArr['code']) && intval($reqArr['code']) == 200) {
|
||||
return new Myresponse(EXIT_SUCCESS, '操作成功', $reqArr);
|
||||
} else {
|
||||
throw new Exception($reqArr['msg']);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return new MyResponse(EXIT_ERROR, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* AES-ECB模式加密,使用PKCS5Padding填充
|
||||
* @param string $data 待加密的数据
|
||||
* @param string $key 加密密钥(16/24/32字节,对应AES-128/192/256)
|
||||
* @return string 加密后的base64字符串
|
||||
*/
|
||||
function aesEcbPkcs5Encrypt($data, $key)
|
||||
{
|
||||
// 检查密钥长度
|
||||
$keyLength = strlen($key);
|
||||
if (!in_array($keyLength, [16, 24, 32])) {
|
||||
throw new InvalidArgumentException("密钥长度必须是16、24或32字节");
|
||||
}
|
||||
|
||||
// 根据密钥长度确定AES模式
|
||||
$cipher = 'AES-' . ($keyLength * 8) . '-ECB';
|
||||
|
||||
// 执行加密,OPENSSL_RAW_DATA表示输出原始二进制,默认使用PKCS5填充
|
||||
$encrypted = openssl_encrypt($data, $cipher, $key, OPENSSL_RAW_DATA, '');
|
||||
|
||||
// 返回base64编码结果(也可根据需要改为bin2hex输出16进制)
|
||||
return bin2hex($encrypted);
|
||||
}
|
||||
|
||||
/**
|
||||
* AES-ECB模式解密,对应HEX格式的加密数据
|
||||
* @param string $hexData 加密后的十六进制字符串
|
||||
* @param string $key 解密密钥(与加密密钥相同)
|
||||
* @return string 解密后的原始数据
|
||||
*/
|
||||
function aesEcbPkcs5DecryptFromHex($hexData, $key)
|
||||
{
|
||||
$keyLength = strlen($key);
|
||||
if (!in_array($keyLength, [16, 24, 32])) {
|
||||
throw new InvalidArgumentException("密钥长度必须是16、24或32字节");
|
||||
}
|
||||
|
||||
$cipher = 'AES-' . ($keyLength * 8) . '-ECB';
|
||||
|
||||
// 先将十六进制转回二进制,再解密
|
||||
$decrypted = openssl_decrypt(hex2bin($hexData), $cipher, $key, OPENSSL_RAW_DATA, '');
|
||||
return $decrypted;
|
||||
}
|
||||
|
||||
public function send($url, $data = [], $type = self::METHOD_GET)
|
||||
{
|
||||
try {
|
||||
$options = [
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json'
|
||||
],
|
||||
];
|
||||
if ($data) {
|
||||
$options['json'] = $data;
|
||||
}
|
||||
$response = $this->client->request($type, $url, $options);
|
||||
// $response = $this->client->post($url, [
|
||||
// 'form_params' => $data,
|
||||
// // 可选:设置超时时间
|
||||
// 'timeout' => 5.0,
|
||||
// ]);
|
||||
return [$response->getBody()->getContents(), $options, $response->getStatusCode()];
|
||||
} catch (Exception $e) {
|
||||
debug_log($e->getMessage() . ' URL: ' . $url . ' Data: ' . json_encode($data));
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class Receiver_call_model extends HD_Model
|
||||
{
|
||||
private $table_name = 'lc_receiver_call';
|
||||
// cfType 类型 1线索
|
||||
const CF_TYPE_CLUE = 1;
|
||||
// cfPlatform 来源平台
|
||||
const CF_PLATFORM_AGENT_PINGAN = 'AgentPingAn';
|
||||
const finishTypeList = [0 => '通话未完成', 1 => '通话完成', 2 => '通话失败'];
|
||||
const callTypeList = [0 => '呼入', 1 => '呼出'];
|
||||
const hangupTypeList = [0 => '客户挂断', 1 => '坐席挂断'];
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->table_name, 'default');
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,12 @@
|
||||
* Time: 13:47
|
||||
*/
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class Receiver_clue_oplogs_model extends HD_Model
|
||||
{
|
||||
private $table_name = 'lc_receiver_clue_oplogs';
|
||||
const OP_TYPE_AUTO_CALL = 4; //汽车之家外呼
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -25,7 +26,8 @@ class Receiver_clue_oplogs_model extends HD_Model
|
||||
*/
|
||||
public function typeAry()
|
||||
{
|
||||
return array(0 => '小记', 1 => '发短信', 2 => '拨打电话', 3 => '新增', 9 => '系统');
|
||||
//4 汽车之家外呼拨打拨打电话
|
||||
return array(0 => '小记', 1 => '发短信', 2 => '拨打电话', 3 => '新增', 4 => '拨打电话', 9 => '系统');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user