Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
aa9bfca7
Commit
aa9bfca7
authored
Jun 24, 2019
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
下载录音
parent
a3ca70f8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
202 additions
and
5 deletions
+202
-5
common.php
application/common.php
+80
-0
AliyunVoiceDown.php
application/model/AliyunVoiceDown.php
+11
-1
route.php
application/route.php
+3
-3
PrivacyNumber.php
application/task/controller/PrivacyNumber.php
+108
-1
No files found.
application/common.php
View file @
aa9bfca7
...
@@ -103,6 +103,48 @@ function down_file($url, $dir, $filename='', $date){
...
@@ -103,6 +103,48 @@ function down_file($url, $dir, $filename='', $date){
return
$filename
;
return
$filename
;
}
}
/**
* 文件下载
*
* @param $url
* @param $dir
* @param string $filename
* @param $date
* @return bool|string
*/
function
down_file_name
(
$url
,
$dir
,
$file_name
,
$date
){
if
(
empty
(
$url
)){
return
false
;
}
if
(
empty
(
$date
))
{
$date
=
date
(
'Ymd'
);
}
else
{
$date
=
date
(
'Ymd'
,
strtotime
(
$date
));
}
$ext
=
strrchr
(
$url
,
'.'
);
$dir
=
$dir
.
DS
.
$date
;
if
(
!
file_exists
(
$dir
))
{
mkdir
(
$dir
,
0777
);
}
//目录+文件
$tmp_name
=
(
empty
(
$file_name
)
?
time
()
.
''
.
$ext
:
$file_name
);
$save_file_path
=
$dir
.
DS
.
$tmp_name
;
//开始捕捉
ob_start
();
readfile
(
$url
);
$img
=
ob_get_contents
();
ob_end_clean
();
$fp2
=
fopen
(
$save_file_path
,
"a"
);
fwrite
(
$fp2
,
$img
);
fclose
(
$fp2
);
return
$date
.
'/'
.
$file_name
;
}
/**
/**
* 隐藏客户手机号中间几位
* 隐藏客户手机号中间几位
...
@@ -183,4 +225,41 @@ function big_log($content,$filename='find_bug'){
...
@@ -183,4 +225,41 @@ function big_log($content,$filename='find_bug'){
$content
=
$time_str
.
$content
.
"
\r\n
"
;
$content
=
$time_str
.
$content
.
"
\r\n
"
;
file_put_contents
(
$filenames
,
$content
,
FILE_APPEND
);
file_put_contents
(
$filenames
,
$content
,
FILE_APPEND
);
}
/**
* @param $url
* @param array $params
* @param int $timeout
* @return bool|string
*/
function
curl_get
(
$url
,
array
$params
=
array
(),
$timeout
=
5
)
{
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$ch
,
CURLOPT_CONNECTTIMEOUT
,
$timeout
);
$file_contents
=
curl_exec
(
$ch
);
curl_close
(
$ch
);
return
$file_contents
;
}
/**
* @param $url
* @param array $params
* @param $timeout
* @return bool|string
*/
function
curl_post
(
$url
,
array
$params
=
array
(),
$timeout
)
{
$ch
=
curl_init
();
//初始化
curl_setopt
(
$ch
,
CURLOPT_URL
,
$url
);
//抓取指定网页
curl_setopt
(
$ch
,
CURLOPT_HEADER
,
0
);
//设置header
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
//要求结果为字符串且输出到屏幕上
curl_setopt
(
$ch
,
CURLOPT_CONNECTTIMEOUT
,
$timeout
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
//post提交方式
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$params
);
$data
=
curl_exec
(
$ch
);
//运行curl
curl_close
(
$ch
);
return
(
$data
);
}
}
\ No newline at end of file
application/model/AliyunVoiceDown.php
View file @
aa9bfca7
...
@@ -8,7 +8,7 @@ use think\Db;
...
@@ -8,7 +8,7 @@ use think\Db;
class
AliyunVoiceDown
extends
BaseModel
class
AliyunVoiceDown
extends
BaseModel
{
{
protected
$table
=
'
office_g_room
'
;
protected
$table
=
'
aliyun_voice_down
'
;
private
$db_
;
private
$db_
;
public
function
__construct
(
$data
=
[])
public
function
__construct
(
$data
=
[])
...
@@ -26,4 +26,13 @@ class AliyunVoiceDown extends BaseModel
...
@@ -26,4 +26,13 @@ class AliyunVoiceDown extends BaseModel
return
$this
->
db_
->
insertAll
(
$data
);
return
$this
->
db_
->
insertAll
(
$data
);
}
}
/**
* @param $data
* @return int|string
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public
function
updateData
(
$data
)
{
return
$this
->
db_
->
update
(
$data
);
}
}
}
\ No newline at end of file
application/route.php
View file @
aa9bfca7
...
@@ -665,9 +665,9 @@ Route::group('task', [
...
@@ -665,9 +665,9 @@ Route::group('task', [
'rongStatusInformUrl'
=>
[
'task/PrivacyNumber/rongStatusInformUrl'
,
[
'method'
=>
'post | get'
]],
//隐私号码回调[状态通知]
'rongStatusInformUrl'
=>
[
'task/PrivacyNumber/rongStatusInformUrl'
,
[
'method'
=>
'post | get'
]],
//隐私号码回调[状态通知]
'defaultFollowUp'
=>
[
'task/PrivacyNumber/defaultFollowUp'
,
[
'method'
=>
'post | get'
]],
//默认跟进
'defaultFollowUp'
=>
[
'task/PrivacyNumber/defaultFollowUp'
,
[
'method'
=>
'post | get'
]],
//默认跟进
'callBackDownVoice'
=>
[
'task/PrivacyNumber/callBackDownVoice'
,
[
'method'
=>
'post | get'
]],
//回调录音
'callBackDownVoice'
=>
[
'task/PrivacyNumber/callBackDownVoice'
,
[
'method'
=>
'post | get'
]],
//回调录音
'getDownVoiceParams'
=>
[
'task/PrivacyNumber/getDownVoiceParams'
,
[
'method'
=>
'post | get'
]],
//
回调录音
'getDownVoiceParams'
=>
[
'task/PrivacyNumber/getDownVoiceParams'
,
[
'method'
=>
'post | get'
]],
//
获取下载参数
'downVoiceByParams'
=>
[
'task/PrivacyNumber/downVoiceByParams'
,
[
'method'
=>
'post | get'
]],
//下载录音
'updateDownVoiceId'
=>
[
'task/PrivacyNumber/updateDownVoiceId'
,
[
'method'
=>
'post | get'
]],
//更新下载数据库
'updateShopTask'
=>
[
'task/JobTask/updateShopTask'
,
[
'method'
=>
'post | get'
]],
//默认跟进
'updateShopTask'
=>
[
'task/JobTask/updateShopTask'
,
[
'method'
=>
'post | get'
]],
//默认跟进
'updateShopImageIdTask'
=>
[
'task/JobTask/updateShopImageIdTask'
,
[
'method'
=>
'post | get'
]],
//默认图片
'updateShopImageIdTask'
=>
[
'task/JobTask/updateShopImageIdTask'
,
[
'method'
=>
'post | get'
]],
//默认图片
'image'
=>
[
'task/JobTask/image'
,
[
'method'
=>
'post | get'
]],
//压缩图片
'image'
=>
[
'task/JobTask/image'
,
[
'method'
=>
'post | get'
]],
//压缩图片
...
...
application/task/controller/PrivacyNumber.php
View file @
aa9bfca7
...
@@ -22,6 +22,7 @@ use app\model\BindingPhone;
...
@@ -22,6 +22,7 @@ use app\model\BindingPhone;
use
app\model\GLandlordPhone
;
use
app\model\GLandlordPhone
;
use
app\model\TAgentTotalCallModel
;
use
app\model\TAgentTotalCallModel
;
use
app\model\Users
;
use
app\model\Users
;
use
Rest
;
use
think\Log
;
use
think\Log
;
use
think\Request
;
use
think\Request
;
use
think\Response
;
use
think\Response
;
...
@@ -704,12 +705,117 @@ class PrivacyNumber
...
@@ -704,12 +705,117 @@ class PrivacyNumber
return
$return
;
return
$return
;
}
}
/**
* 为录音服务器和备份服务器下载提供参数
*
* @return Response|\think\response\Json|\think\response\Jsonp|\think\response\Redirect|\think\response\View|\think\response\Xml
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getDownVoiceParams
()
public
function
getDownVoiceParams
()
{
{
$params
=
Request
::
instance
()
->
param
();
$params
=
Request
::
instance
()
->
param
();
if
(
!
in_array
(
$params
[
'source'
],
[
1
,
2
]))
{
if
(
!
in_array
(
$params
[
'source'
],
[
1
,
2
]))
{
Response
::
create
([
'code'
=>
101
,
'msg'
=>
'参数错误'
],
'json'
);
return
Response
::
create
([
'code'
=>
101
,
'msg'
=>
'参数错误'
],
'json'
);
}
if
(
$params
[
'source'
]
==
1
)
{
$where
[
'is_down'
]
=
0
;
}
else
{
$where
[
'is_down'
]
=
1
;
}
$where
[
'is_del'
]
=
0
;
$field
=
'id,call_id,call_time,voice_file,type,mp3_url,is_down'
;
$list
=
$this
->
m_down
->
getList
(
1
,
3000
,
''
,
$field
,
$where
);
return
Response
::
create
([
'code'
=>
200
,
'msg'
=>
''
,
'data'
=>
$list
],
'json'
);
}
/**
* 更新已下载
*/
public
function
updateDownVoiceId
()
{
$params
=
Request
::
instance
()
->
param
();
if
(
!
in_array
(
$params
[
'source'
],
[
1
,
2
]))
{
return
Response
::
create
([
'code'
=>
101
,
'msg'
=>
'参数错误'
],
'json'
);
}
$id_array
=
explode
(
','
,
$params
[
'id'
]);
$update_data
[
'is_down'
]
=
$params
[
'source'
];
foreach
(
$id_array
as
$k
=>
$v
)
{
$update_data
[
'id'
]
=
$v
;
$this
->
m_down
->
updateData
(
$update_data
);
}
}
/**
* getDownVoiceParams -> downVoiceByParams -> updateDownVoiceId
* 获取下载参数->开始下载->更新数据库已下载
*
* @return Response|\think\response\Json|\think\response\Jsonp|\think\response\Redirect|\think\response\View|\think\response\Xml|void
*/
public
function
downVoiceByParams
()
{
$params
=
Request
::
instance
()
->
param
();
if
(
!
in_array
(
$params
[
'source'
],
[
1
,
2
]))
{
return
Response
::
create
([
'code'
=>
101
,
'msg'
=>
'参数错误'
],
'json'
);
}
$url
=
'http://www.tptl.com/task/getDownVoiceParams?source='
.
$params
[
'source'
];
$get_params
=
curl_get
(
$url
);
$data
=
json_decode
(
$get_params
,
true
);
if
(
$data
[
'code'
]
!=
200
)
{
return
Response
::
create
([
'code'
=>
101
,
'msg'
=>
'获取数据错误'
],
'json'
);
}
$save_path
=
''
;
$update_id
=
[];
foreach
(
$data
[
'data'
]
as
$k
=>
$v
)
{
$create_time
=
date
(
'Y-m-d'
,
strtotime
(
$v
[
'call_time'
]));
switch
(
$v
[
'type'
])
{
case
1
:
try
{
/*阿里云音频下载*/
$result_data
=
PlsDemo
::
queryRecordFileDownloadUrl
(
$v
[
'call_id'
],
$v
[
'call_time'
]);
}
catch
(
\Exception
$e
)
{
Log
::
write
(
$e
->
getMessage
(),
'voice_down_getVoiceUrl_error_id'
.
$v
[
'id'
]);
//记录日志
continue
;
}
if
(
isset
(
$result_data
->
Message
)
&&
$result_data
->
Message
==
'OK'
)
{
$down_url
=
isset
(
$result_data
->
DownloadUrl
)
?
explode
(
'?'
,
$result_data
->
DownloadUrl
)
:
$result_data
->
DownloadUrl
;
if
(
$v
[
'is_down'
]
==
0
)
{
$file_name
=
basename
(
$down_url
[
0
]);
}
else
{
$file_name
=
explode
(
'/'
,
$v
[
'voice_file'
]);
$file_name
=
$file_name
[
1
];
}
$save_path
=
down_file_name
(
$result_data
->
DownloadUrl
,
PHONE_VOICE
,
$file_name
,
$create_time
);
}
break
;
case
2
:
/*容联云音频下载*/
if
(
!
empty
(
$v
[
'mp3_url'
]))
{
if
(
$v
[
'is_down'
]
==
0
)
{
$file_name
=
basename
(
$v
[
'mp3_url'
]);
}
else
{
$file_name
=
explode
(
'/'
,
$v
[
'voice_file'
]);
$file_name
=
$file_name
[
1
];
}
$save_path
=
down_file_name
(
$v
[
'mp3_url'
],
PHONE_VOICE
,
$file_name
,
$create_time
);
}
break
;
}
if
(
file_exists
(
PHONE_VOICE
.
'/'
.
$save_path
))
{
$update_id
[]
=
$v
[
'id'
];
}
}
}
//更新下载
$id_string
=
implode
(
','
,
$update_id
);
$url
=
'http://www.tptl.com/task/updateDownVoiceId?id='
.
$id_string
.
'&source='
.
$params
[
'source'
];
curl_get
(
$url
);
return
;
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment