edit-api-xz

This commit is contained in:
lccsw
2021-07-27 15:01:11 +08:00
parent a129700f8c
commit b447a30341
6 changed files with 74 additions and 8 deletions
+12
View File
@@ -0,0 +1,12 @@
<?php
/**
* Created by Vim
* User: lcc
* Desc: 晓致小号
* Date: 2021/7/27
* Time: 11:32
*/
$config['mobile_list'] = array(
'18916751561','18916739316'
);
+25 -2
View File
@@ -17,6 +17,9 @@ class Xzcall extends HD_Controller
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/order/receiver_orders_model','orders_model');
}
public function index()
@@ -46,6 +49,7 @@ class Xzcall extends HD_Controller
if ($row['cf_id'] && $row['cf_platform'] == 'admin' && $row['cf_title'] == 'clues') { //后台线索池拨打电话回调
$admin_id = $row['cf_uid'];
$this->load->model('sys/sys_admin_model');
$this->load->model('receiver/receiver_clue_oplogs_model','mdOplogs');
$admin = $this->sys_admin_model->get(array('id' => $admin_id));
$addData = array(
'clue_id' => $row['cf_id'],
@@ -60,6 +64,24 @@ class Xzcall extends HD_Controller
$xcall = new Xcall();
//解绑
$xcall->SWunbind($data['to'], $data['virtualMobile']);
}elseif($row['cf_id'] && $row['cf_platform'] == 'api'){ //狸车宝
require_once COMMPATH.'third_party/Xcall/Xcall.php';
$xcall = new Xcall();
//解绑
$result = $xcall -> SWunbind($data['to'],$data['virtualMobile']);
if($row['cf_title']=='order'){ //订单
$cust = $this->orders_model->get(['id'=>$row['cf_id']]);
$this->load->library('receiver/orders_entity');
$this->orders_entity->add_log($cust['id'],$row['cf_uid'],$data['uname'],$row['id'],2);
}else{ //客户
$cust = $this->customers_model->get(['id'=>$row['cf_id']]);
$this->load->library('receiver/customers_entity');
$this->customers_entity->add_log($cust['id'],$row['cf_uid'],$data['uname'],$row['id'],2);
}
//删除redis
$cache_key = "XZ_LICHEB_MOBILEB_{$cust['mobile']}_{$row['cf_uid']}";
$redis = &load_cache('redis');
$redis->delete($cache_key);
}
} else {
debug_log("error: 未找到拨打记录", $this->log_file);
@@ -84,8 +106,9 @@ class Xzcall extends HD_Controller
$result = $xcall->getFile($data['getFileUrl'], $data['mid'], $data['tag']);
if ($result['code']) { //上传七牛
$this->load->library('qiniu');
$filename = $this->qiniu->getFileName($data['mid'], 'mp3', 'xz_video_');
$q_res = $this->qiniu->save($filename, $result['data']);
$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 {
@@ -36,8 +36,11 @@ 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,'log,type,c_time');
$rows = $this->customer_oplogs_model->select($where,'id desc',$page,$size,'log,uname,type,c_time');
foreach($rows as $key => $val){
if($val['type']==2){
$val['log'] = '拨打电话';
}
$lists[] = [
'content' => $val['log'],
'c_time' => date('Y.m.d',$val['c_time'])
+5 -5
View File
@@ -11,8 +11,6 @@ defined('WXAPP_APP') OR exit('No direct script access allowed');
require_once APPPATH.'controllers/wxapp/Wxapp.php';
class Xz extends Wxapp{
private $log_file = 'call.log';
private $log_dir = 'xiaozhi';
function __construct($inputs, $app_key){
parent::__construct($inputs, $app_key);
@@ -22,8 +20,9 @@ class Xz extends Wxapp{
$this->load->model('receiver/order/receiver_orders_model','orders_model');
$this->load->model('receiver/receiver_xz_model');
$this->log_file = 'call.log';
}
public function get(){
protected function get(){
$id = $this->input_param('id');
$type = intval($this->input_param('type'));
!$type && $type = 0;
@@ -31,14 +30,15 @@ class Xz extends Wxapp{
$admin_id = $session['uid'];
if($type==1){ //订单
$row = $this->orders_model->get(['id'=>$id]);
$cf_title = 'order';
}else{//客户
$cf_title = 'customer';
$row = $this->customers_model->get(['id'=>$id]);
}
if(!$row || !$row['mobile']){
throw new Hd_Exception('用户不存在', API_CODE_INVILD_PARAM);
}
$customer_mobile = $row['mobile'];
$redis = &load_cache('redis');
$cache_key = "XZ_LICHEB_MOBILEB_{$customer_mobile}_{$admin_id}";
$call_mobile = $redis->get($cache_key);
@@ -46,7 +46,7 @@ class Xz extends Wxapp{
$this->config->load('xcall', TRUE);
$mobile_list = $this->config->item('mobile_list', 'xcall');//晓智号码库
require_once COMMPATH.'third_party/Xcall/Xcall.php';
$seq_id = 'liche_'.create_order_no();
$seq_id = create_order_no();
$result = '';
//循环绑定
$xcall = new Xcall();
@@ -31,7 +31,12 @@ class Customers_entity{
];
$uname && $add_data['uname'] = $uname;
$type && $add_data['type'] = $type;
$cf_platform && $add_data['cf_platform'] = $cf_platform;
$result = $this->ci->customer_oplogs_model->add($add_data);
if($type==2 && $result){ //更新最后联系时间
$this->ci->load->model('receiver/receiver_customers_model');
$this->ci->receiver_customers_model->update(['cont_time'=>date('Y-m-d H:i:s')],['id'=>$customer_id]);
}
return $result;
}
/**
@@ -176,6 +176,29 @@ class Orders_entity{
$result = $this->ci->orders_model->update($update,['id'=>$row['id']]);
return $result;
}
/**
* 添加日志
* @param $o_id int 订单id
* @param $uid int 操作用户id
* @param $uname int 操作用户名
* @param $content string 日志内容
* @param $type int 操作类型 (0普通日志 1短信 2拨打电话)
* @param $cf_platform string 来源 (wxapp小程序 admin后台)
*/
public function add_log($o_id,$uid,$uname,$content,$type='',$cf_platform='wxapp'){
$this->ci->load->model('receiver/order/receiver_order_oplogs_model','order_oplogs_model');
$add_data = [
'order_id' => $o_id,
'uid' => $uid,
'log' => $content,
'c_time' => time()
];
$uname && $add_data['uname'] = $uname;
$type && $add_data['type'] = $type;
$cf_platform && $add_data['cf_platform'] = $cf_platform;
$result = $this->ci->order_oplogs_model->add($add_data);
return $result;
}
}
?>