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
d5a3f1ff
Commit
d5a3f1ff
authored
Jul 03, 2019
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
录音回调处理
parent
1e2bc39a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
146 additions
and
3 deletions
+146
-3
route.php
application/route.php
+3
-2
PrivacyNumber.php
application/task/controller/PrivacyNumber.php
+143
-1
No files found.
application/route.php
View file @
d5a3f1ff
...
...
@@ -669,10 +669,11 @@ Route::group('task', [
'rongRecordingInformUrl'
=>
[
'task/PrivacyNumber/rongRecordingInformUrl'
,
[
'method'
=>
'post | get'
]],
//隐私号码回调[录音通知]
'rongStatusInformUrl'
=>
[
'task/PrivacyNumber/rongStatusInformUrl'
,
[
'method'
=>
'post | get'
]],
//隐私号码回调[状态通知]
'defaultFollowUp'
=>
[
'task/PrivacyNumber/defaultFollowUp'
,
[
'method'
=>
'post | get'
]],
//默认跟进
'callBackDownVoice'
=>
[
'task/PrivacyNumber/callBackDownVoice'
,
[
'method'
=>
'post | get'
]],
//回调录音
'callBackDownVoice'
=>
[
'task/PrivacyNumber/callBackDownVoice
V2
'
,
[
'method'
=>
'post | get'
]],
//回调录音
'getDownVoiceParams'
=>
[
'task/PrivacyNumber/getDownVoiceParams'
,
[
'method'
=>
'post | get'
]],
//获取下载参数
'downVoiceByParams'
=>
[
'task/PrivacyNumber/downVoiceByParams'
,
[
'method'
=>
'post | get'
]],
//下载录音
'updateDownVoiceId'
=>
[
'task/PrivacyNumber/updateDownVoiceId'
,
[
'method'
=>
'post | get'
]],
//更新下载数据库
'updateDownVoiceId'
=>
[
'task/PrivacyNumber/updateDownVoiceIdV2'
,
[
'method'
=>
'post | get'
]],
//更新下载数据库
'getVoiceByCallId'
=>
[
'task/PrivacyNumber/getVoiceByCallId'
,
[
'method'
=>
'post | get'
]],
//更新下载数据库
'updateShopTask'
=>
[
'task/JobTask/updateShopTask'
,
[
'method'
=>
'post | get'
]],
//默认跟进
'updateShopImageIdTask'
=>
[
'task/JobTask/updateShopImageIdTask'
,
[
'method'
=>
'post | get'
]],
//默认图片
'image'
=>
[
'task/JobTask/image'
,
[
'method'
=>
'post | get'
]],
//压缩图片
...
...
application/task/controller/PrivacyNumber.php
View file @
d5a3f1ff
...
...
@@ -705,6 +705,71 @@ class PrivacyNumber
return
$return
;
}
/**
* 阿里云回调下载录音
*/
public
function
callBackDownVoiceV2
()
{
/**
* pool_key String 对应的号池Key
* subs_id Number 对应的三元组的绑定关系ID
* call_id String 对应的呼叫记录的call_id
* call_time Date 呼叫时间
*/
$post_data
=
Request
::
instance
()
->
param
();
$base_url
=
'https://api.tonglianjituan.com/task/'
;
if
(
isset
(
$post_data
[
0
][
'call_id'
]))
{
$result
=
$post_data
;
}
else
{
$result
=
[
$post_data
];
}
if
(
empty
(
$post_data
[
'record_down'
]))
{
return
json_encode
([
'code'
=>
1
,
'msg'
=>
'处理回调失败'
]);
}
foreach
(
$result
as
$k
=>
$v
)
{
if
(
empty
(
$v
[
'call_id'
])){
continue
;
}
if
(
empty
(
$v
[
'call_time'
]))
{
continue
;
}
$call_time
=
date
(
'Y-m-d H:i:s'
,
$v
[
'call_time'
]
/
1000
);
try
{
$result_data
=
PlsDemo
::
queryRecordFileDownloadUrl
(
$v
[
'call_id'
],
$call_time
);
}
catch
(
\Exception
$e
)
{
Log
::
write
(
$e
->
getMessage
(),
'voice_down_callBack_error'
);
//记录日志
return
json_encode
([
'code'
=>
1
,
'msg'
=>
'处理回调失败'
]);
}
if
(
isset
(
$result_data
->
Message
)
&&
$result_data
->
Message
==
'OK'
)
{
$down_url
=
isset
(
$result_data
->
DownloadUrl
)
?
explode
(
'?'
,
$result_data
->
DownloadUrl
)
:
$result_data
->
DownloadUrl
;
$file_name
=
basename
(
$down_url
[
0
]);
$is_down
=
down_file
(
$result_data
->
DownloadUrl
,
PHONE_VOICE
,
$file_name
,
date
(
'Y-m-d'
,
strtotime
(
$call_time
)));
if
(
file_exists
(
$is_down
))
{
$update_data
[]
=
[
'call_id'
=>
$v
[
'call_id'
],
'call_time'
=>
$call_time
,
'voice_file'
=>
date
(
'Ymd'
)
.
'/'
.
basename
(
$is_down
)
];
}
}
}
$return
=
json_encode
([
'code'
=>
0
,
'msg'
=>
'接收成功'
]);
if
(
isset
(
$update_data
))
{
$update_data
=
json_encode
(
$update_data
);
//更新下载
$url
=
$base_url
.
'updateDownVoiceId'
;
curl_post
(
$url
,
[
'params'
=>
$update_data
,
'source'
=>
1
],
10
);
}
return
$return
;
}
/**
* 为录音服务器和备份服务器下载提供参数
*
...
...
@@ -726,6 +791,7 @@ class PrivacyNumber
$where
[
'is_down'
]
=
1
;
}
$where
[
'is_del'
]
=
0
;
$where
[
'call_time'
]
=
[
'<'
,
date
(
'Y-m-d H:i:s'
,
time
()
-
900
)];
$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'
);
...
...
@@ -788,6 +854,76 @@ class PrivacyNumber
return
$num
;
}
/**
* 更新已下载
*
* @return int|Response|\think\response\Json|\think\response\Jsonp|\think\response\Redirect|\think\response\View|\think\response\Xml
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public
function
updateDownVoiceIdV2
()
{
$params
=
Request
::
instance
()
->
param
();
if
(
!
in_array
(
$params
[
'source'
],
[
1
,
2
]))
{
return
Response
::
create
([
'code'
=>
101
,
'msg'
=>
'参数错误'
],
'json'
);
}
if
(
empty
(
$params
[
'params'
]))
{
return
Response
::
create
([
'code'
=>
101
,
'msg'
=>
'参数错误'
],
'json'
);
}
$data_array
=
json_decode
(
$params
[
'params'
],
true
);
$num
=
count
(
$data_array
);
if
(
$num
<=
0
)
{
return
Response
::
create
([
'code'
=>
101
,
'msg'
=>
'数据错误'
],
'json'
);
}
$limit_num
=
round
(
$num
/
10
);
$count
=
0
;
$update_data
[
'is_down'
]
=
$save_data
[
'record_down'
]
=
$params
[
'source'
];
for
(
$i
=
0
;
$i
<
$num
;
$i
++
)
{
if
(
isset
(
$data_array
[
$i
][
'id'
]))
{
$voice_file
[]
=
[
'id'
=>
$data_array
[
$i
][
'id'
],
'voice_file'
=>
$data_array
[
$i
][
'voice_file'
],
'call_id'
=>
$data_array
[
$i
][
'call_id'
],
'call_time'
=>
$data_array
[
$i
][
'call_time'
],
];
}
else
{
$voice_file
[]
=
[
'voice_file'
=>
$data_array
[
$i
][
'voice_file'
],
'call_id'
=>
$data_array
[
$i
][
'call_id'
],
'call_time'
=>
$data_array
[
$i
][
'call_time'
],
];
}
if
(
$count
==
$limit_num
)
{
foreach
(
$voice_file
as
$k
=>
$v
)
{
$where
[
'call_id'
]
=
$v
[
'call_id'
];
$where
[
'call_time'
]
=
$v
[
'call_time'
];
//阿里云录音
if
(
$params
[
'source'
]
==
1
)
{
//通过id或call_id取文件路径
$save_data
[
'voice_file'
]
=
$update_data
[
'voice_file'
]
=
$v
[
'voice_file'
];
}
$this
->
m_secret_report
->
updateData
(
$save_data
,
$where
);
if
(
isset
(
$v
[
'id'
]))
{
$this
->
m_down
->
updateData
(
$update_data
,
[
'id'
=>
$v
[
'id'
]]);
//更新下载状态
}
else
{
$this
->
m_down
->
updateData
(
$update_data
,
$where
);
//更新下载状态
}
}
$count
=
0
;
}
$count
++
;
}
return
$num
;
}
/**
* getDownVoiceParams -> downVoiceByParams -> updateDownVoiceId
* 获取下载参数->开始下载->更新数据库已下载
...
...
@@ -813,6 +949,10 @@ class PrivacyNumber
$save_path
=
''
;
$update_data
=
[];
foreach
(
$data
[
'data'
]
as
$k
=>
$v
)
{
if
(
file_exists
(
PHONE_VOICE
.
'/'
.
$v
[
'voice_file'
])
&&
!
empty
(
$v
[
'voice_file'
]))
{
continue
;
}
$create_time
=
date
(
'Y-m-d'
,
strtotime
(
$v
[
'call_time'
]));
switch
(
$v
[
'type'
])
{
case
1
:
...
...
@@ -852,7 +992,9 @@ class PrivacyNumber
if
(
file_exists
(
PHONE_VOICE
.
'/'
.
$save_path
))
{
$update_data
[]
=
[
'id'
=>
$v
[
'id'
],
'voice_file'
=>
$save_path
'voice_file'
=>
$save_path
,
'call_time'
=>
$v
[
'call_time'
],
'call_id'
=>
$v
[
'call_id'
]
];
}
}
...
...
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