Commit cd510d72 authored by hujun's avatar hujun

录音下载

parent 3447c5cc
...@@ -4,8 +4,7 @@ error_reporting(E_ERROR | E_PARSE); ...@@ -4,8 +4,7 @@ error_reporting(E_ERROR | E_PARSE);
define('_MESSAGE_TYPE','SecretReport'); define('_MESSAGE_TYPE','SecretReport');
define('_QUEUE_NAME','Alicom-Queue-1186048444498461-SecretReport'); define('_QUEUE_NAME','Alicom-Queue-1186048444498461-SecretReport');
define('_EXPIRATION',date('Y-m-d H:i:s',time()+518400));//手机号码保留七天 define('_EXPIRATION',date('Y-m-d H:i:s',time()+518400));//手机号码保留七天
define('_POOLKEY','FC100000022056027');
define('_TLSYPoolKey','FC100000022056027');
return [ return [
'jwt_key' => 'tonglian+123', 'jwt_key' => 'tonglian+123',
// 应用模式状态 // 应用模式状态
......
...@@ -262,7 +262,7 @@ class PlsDemo ...@@ -262,7 +262,7 @@ class PlsDemo
$request = new QueryRecordFileDownloadUrlRequest(); $request = new QueryRecordFileDownloadUrlRequest();
//必填:号池Key //必填:号池Key
$request->setPoolKey("FC123456"); $request->setPoolKey(_POOLKEY);
//必填: 对应的产品类型,目前一共支持三款产品AXB_170,AXN_170,AXN_95 //必填: 对应的产品类型,目前一共支持三款产品AXB_170,AXN_170,AXN_95
$request->setProductType("AXB_170"); $request->setProductType("AXB_170");
......
...@@ -38,4 +38,59 @@ function check_phone($phone){ ...@@ -38,4 +38,59 @@ function check_phone($phone){
} }
return $result; return $result;
}
/**
* 浏览器下载
*
* @param $archivo
* @param null $downloadfilename
*/
function download_file($archivo, $downloadfilename = null) {
$downloadfilename = $downloadfilename !== null ? $downloadfilename : basename($archivo);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $downloadfilename);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($archivo));
return ;
}
/**
* 文件下载
*
* @param $url
* @param $dir
* @param string $filename
* @return bool|string
*/
function down_file($url, $dir, $filename=''){
if(empty($url)){
return false;
}
$date = date('Ymd');
$ext = strrchr($url, '.');
$dir = $dir.DS.$date;
if (!file_exists($dir)) {
mkdir($dir, 0777);
}
//目录+文件
$filename = (empty($filename) ? time().''.$ext : $filename);
$filename = $dir .DS. $filename;
//开始捕捉
ob_start();
readfile($url);
$img = ob_get_contents();
ob_end_clean();
$fp2 = fopen($filename , "a");
fwrite($fp2, $img);
fclose($fp2);
return $filename;
} }
\ No newline at end of file
...@@ -16,6 +16,8 @@ define('ADMIN_URL_TL','https://admin.tonglianjituan.com/'); //B端网址 ...@@ -16,6 +16,8 @@ define('ADMIN_URL_TL','https://admin.tonglianjituan.com/'); //B端网址
define('CURRENT_URL', 'http://'.$_SERVER['HTTP_HOST'].'/'); //取当前域名地址 define('CURRENT_URL', 'http://'.$_SERVER['HTTP_HOST'].'/'); //取当前域名地址
define('HEADERIMGURL', CURRENT_URL . 'static'. DS . 'head_portrait/'); //头像地址 define('HEADERIMGURL', CURRENT_URL . 'static'. DS . 'head_portrait/'); //头像地址
define('CK_IMG_URL', CURRENT_URL . '/resource/lib/Attachments/'); //ck 资源文件 define('CK_IMG_URL', CURRENT_URL . '/resource/lib/Attachments/'); //ck 资源文件
define('_POOLKEY','FC100000022056027');//隐私号码
define('_TLSYPoolKey','FC100000022056027');//隐私号码池
return [ return [
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | 应用设置 // | 应用设置
......
...@@ -213,7 +213,8 @@ Route::group('api', [ ...@@ -213,7 +213,8 @@ Route::group('api', [
Route::group('task',[ Route::group('task',[
'exclusiveExpirationTime' => [ 'task/exclusive/exclusiveExpirationTime', [ 'method' => 'get' ]], //独家过期时间 'exclusiveExpirationTime' => [ 'task/exclusive/exclusiveExpirationTime', [ 'method' => 'get' ]], //独家过期时间
'addReport' => [ 'task/PrivacyNumber/addReport', [ 'method' => 'get|post' ]] //阿里大于隐私号码回调 'addReport' => [ 'task/PrivacyNumber/addReport', [ 'method' => 'get|post' ]], //阿里大于隐私号码回调
'queryRecordFile' => [ 'task/PrivacyNumber/queryRecordFile', [ 'method' => 'get' ]] //下载录音
]); ]);
Route::group('broker', [ Route::group('broker', [
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace app\task\controller; namespace app\task\controller;
use app\api_broker\untils\PlsDemo;
use app\model\SecretReport; use app\model\SecretReport;
use think\Db; use think\Db;
use think\Log; use think\Log;
...@@ -36,4 +37,36 @@ class PrivacyNumber ...@@ -36,4 +37,36 @@ class PrivacyNumber
Log::write(serialize($post_data[0]),'AliYunSecretReport'); //记录日志 Log::write(serialize($post_data[0]),'AliYunSecretReport'); //记录日志
return json_encode(['code'=>0,'msg'=>'接收成功']); return json_encode(['code'=>0,'msg'=>'接收成功']);
} }
/**
* 高峰期 一般是早上9-11点 下午2-4点
*
* @throws \Aliyun\Core\Exception\ClientException
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function queryRecordFile() {
$down_data = Db::table('aliyun_secret_report')->field('id,call_id,call_time')
->where('record_down' ,0)->whereTime('call_time','<',time()-900)->select();
foreach ($down_data as $k => $v) {
$result_data = PlsDemo::queryRecordFileDownloadUrl($v['call_id'], $v['call_time']);
if ($result_data->Message == 'OK') {
$down_url = explode('?',$result_data->DownloadUrl);
$is_down = down_file($down_url[0], ROOT_PATH.'public'.DS.'static'.DS.'voice',basename($down_url[0]));
if (file_exists($is_down)) {
$data['id'] = $v['id'];
$data['record_down'] = 1;
$data['voice_file'] = basename($is_down);
Db::table('aliYun_secret_report')->update($data);
}
}
}
return ;
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment