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
90b541fa
Commit
90b541fa
authored
Jun 26, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
容联云隐私号码绑定和下载录音修改,
parent
87d356d1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
178 additions
and
287 deletions
+178
-287
CellPhone.php
application/api_broker/controller/CellPhone.php
+10
-12
config.php
application/config.php
+1
-0
CellPhone.php
application/index/controller/CellPhone.php
+0
-113
AliYunSecretReport.php
application/model/AliYunSecretReport.php
+24
-18
BindingPhone.php
application/model/BindingPhone.php
+41
-45
PrivacyNumber.php
application/task/controller/PrivacyNumber.php
+102
-99
No files found.
application/api_broker/controller/CellPhone.php
View file @
90b541fa
...
@@ -125,23 +125,19 @@ class CellPhone extends Basic
...
@@ -125,23 +125,19 @@ class CellPhone extends Basic
$Rong
=
new
RongDemo
();
$Rong
=
new
RongDemo
();
$record2
=
empty
(
$this
->
params
[
'record'
])
?
'true'
:
'false'
;
/* 是否录音(容联云规定string类型)*/
$record2
=
empty
(
$this
->
params
[
'record'
])
?
'true'
:
'false'
;
/* 是否录音(容联云规定string类型)*/
/*计算有效期*/
$aliYunPhone
=
new
AliYunPhone
();
if
(
empty
(
$day_num
))
{
$phone_x
=
$aliYunPhone
->
getAliYunPhone
(
$phone_a
,
$phone_b
,
$is_privacy
);
//获取未绑定隐号
$yx_time
=
$day_num
*
60
*
60
*
24
;
$result
=
$Rong
->
setNumber
(
$phone_a
,
$phone_b
,
$phone_x
[
'phone_x'
],
$phone_x
[
'area'
],
$day_num
,
$record2
);
}
else
{
$yx_time
=
604800
;
}
$result
=
$Rong
->
setNumber
(
$phone_a
,
$phone_b
,
$phone_x
[
'phone_x'
],
$phone_x
[
'area'
],
$yx_time
,
$record2
);
/*绑定成功*/
/*绑定成功*/
if
(
$result
[
'statusCode'
]
==
'000000'
)
{
if
(
$result
[
'statusCode'
]
==
'000000'
)
{
$aliYunPhone
=
new
AliYunPhone
();
$aliYunPhone
=
new
AliYunPhone
();
$aliYunPhone
->
editStatus
(
$phone_x
,
$phone_a
,
$phone_b
,
$record
,
$time
,
0
,
$result
[
'data'
][
'mappingId'
],
$is_privacy
);
//记录绑定
$aliYunPhone
->
editStatus
(
$phone_x
,
$phone_a
,
$phone_b
,
$record
,
$time
,
0
,
$result
[
'data'
][
'mappingId'
],
$is_privacy
);
//记录绑定
$this
->
msg
=
'
Binding Rong success
'
;
$this
->
msg
=
'
绑定成功
'
;
$this
->
data
=
[
'phone'
=>
$phone_x
[
'phone_x'
]
];
$this
->
data
=
[
'phone'
=>
$phone_x
[
'phone_x'
]
];
}
else
{
}
else
{
$this
->
code
=
101
;
$this
->
code
=
101
;
$this
->
msg
=
'
操作频繁,请10秒后再操作。
'
;
$this
->
msg
=
'
拨号失败,15秒再试,再无法拨号请联系请联系运营人员!
'
;
}
}
}
}
...
@@ -206,6 +202,7 @@ class CellPhone extends Basic
...
@@ -206,6 +202,7 @@ class CellPhone extends Basic
$redis
=
RedisExt
::
getRedis
();
$redis
=
RedisExt
::
getRedis
();
$is_privacy
=
$redis
->
get
(
's_is_privacy'
);
$is_privacy
=
$redis
->
get
(
's_is_privacy'
);
$is_privacy
=
$is_privacy
!=
'0'
?
$is_privacy
:
0
;
$is_privacy
=
$is_privacy
!=
'0'
?
$is_privacy
:
0
;
if
(
$is_privacy
==
1
)
{
if
(
$is_privacy
==
1
)
{
/*阿里云*/
/*阿里云*/
$subsId
=
$phone
->
getSubsId
(
$phone_x
,
$phone_a
,
$phone_b
,
1
,
'subsId'
);
$subsId
=
$phone
->
getSubsId
(
$phone_x
,
$phone_a
,
$phone_b
,
1
,
'subsId'
);
...
@@ -233,12 +230,13 @@ class CellPhone extends Basic
...
@@ -233,12 +230,13 @@ class CellPhone extends Basic
$phone
->
unBind
(
$phone_x
,
$phone_a
,
$phone_b
);
$phone
->
unBind
(
$phone_x
,
$phone_a
,
$phone_b
);
}
else
{
}
else
{
$this
->
code
=
101
;
$this
->
code
=
101
;
$this
->
msg
=
'
remove binding error
'
;
$this
->
msg
=
'
解除绑定关系失败,请联系运营!
'
;
}
}
}
else
{
}
else
{
$this
->
code
=
101
;
$this
->
code
=
200
;
$this
->
msg
=
'
dont\'t have about phone_x info
'
;
$this
->
msg
=
'
没有号码绑定关系,请忽略!。
'
;
}
}
}
else
{
}
else
{
$this
->
code
=
200
;
$this
->
code
=
200
;
$this
->
msg
=
'没有号码绑定关系,请忽略!。'
;
$this
->
msg
=
'没有号码绑定关系,请忽略!。'
;
...
...
application/config.php
View file @
90b541fa
...
@@ -22,6 +22,7 @@ define('CK_IMG_URL', CURRENT_URL . 'resource/lib/Attachments/'); //ck 资源文
...
@@ -22,6 +22,7 @@ define('CK_IMG_URL', CURRENT_URL . 'resource/lib/Attachments/'); //ck 资源文
define
(
'_POOLKEY'
,
'FC100000022056027'
);
//隐私号码
define
(
'_POOLKEY'
,
'FC100000022056027'
);
//隐私号码
define
(
'_TLSYPoolKey'
,
'FC100000022056027'
);
//隐私号码池
define
(
'_TLSYPoolKey'
,
'FC100000022056027'
);
//隐私号码池
define
(
'WEEK_WORK_IMG'
,
CURRENT_URL
.
'static'
.
DS
.
'week_work_img/'
);
//周报日报目录
define
(
'WEEK_WORK_IMG'
,
CURRENT_URL
.
'static'
.
DS
.
'week_work_img/'
);
//周报日报目录
define
(
'PHONE_VOICE'
,
ROOT_PATH
.
'public'
.
DS
.
'static'
.
DS
.
'voice'
);
//录音绝对路径
return
[
return
[
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
// | 应用设置
// | 应用设置
...
...
application/index/controller/CellPhone.php
View file @
90b541fa
...
@@ -22,119 +22,6 @@ class CellPhone extends Basic
...
@@ -22,119 +22,6 @@ class CellPhone extends Basic
protected
$data
=
[];
protected
$data
=
[];
protected
$msg
=
""
;
protected
$msg
=
""
;
/**
* 绑定手机号
* 解绑之后有延迟
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
bindAXB
()
{
$params
=
$this
->
request
->
param
();
if
(
$params
[
'phone_a'
]
||
$params
[
'phone_b'
])
{
$expiration
=
_EXPIRATION
;
//过期时间
$phone_a
=
$this
->
params
[
'phone_a'
];
//经纪人手机号
$phone_b
=
$this
->
params
[
'phone_b'
];
//客户手机号
$record
=
empty
(
$this
->
params
[
'record'
])
?
true
:
false
;
//是否录音
$bind
=
new
AliYunPhone
();
$phone_x
=
$bind
->
getAliYunPhone
(
$phone_b
);
//是否还有未绑定的中间号码
if
(
$phone_x
)
{
$result
=
PlsDemo
::
bindAxb
(
$phone_a
,
$phone_b
,
$expiration
,
$record
,
$phone_x
[
'phone_x'
]);
if
(
$result
->
Message
==
'OK'
)
{
$bind
->
where
(
'phone_x'
,
$phone_x
[
'phone_x'
])
->
setField
(
'status'
,
1
);
Db
::
table
(
'aliYun_binding_phone'
)
->
insert
([
'phone_a'
=>
$phone_a
,
'phone_b'
=>
$phone_b
,
'subsId'
=>
$result
->
SecretBindDTO
->
SubsId
,
'requestId'
=>
$result
->
RequestId
,
'record'
=>
$record
,
'aliYun_phone_id'
=>
$phone_x
[
'id'
]
]);
$this
->
msg
=
'Binding success.'
;
$this
->
data
=
[
'phone'
=>
$phone_x
[
'phone_x'
]];
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'Binding failure.'
;
}
}
else
{
$this
->
code
=
102
;
$this
->
msg
=
'Number pool run out.'
;
}
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'phone_a or phone_b is null'
;
}
return
$this
->
response
(
$this
->
code
,
$this
->
msg
,
$this
->
data
);
}
/**
* 更新绑定关系
*
* @return \think\Response
*/
public
function
updateBindAXB
()
{
$params
=
$this
->
request
->
param
();
if
(
$params
[
'phone_x'
]
&&
(
$params
[
'phone_a'
]
||
$params
[
'phone_b'
]))
{
$bind
=
new
BindingPhone
();
if
(
$params
[
'phone_a'
])
{
$subId
=
$bind
->
getSubsId
(
$params
[
'phone_x'
],
$params
[
'phone_a'
],
''
,
1
);
//跟换B号码
}
else
{
$subId
=
$bind
->
getSubsId
(
$params
[
'phone_x'
],
''
,
$params
[
'phone_b'
],
1
);
//更好A号码
}
$resutl
=
PlsDemo
::
updateSubscription
(
$params
[
'type'
],
$subId
,
$this
->
params
[
'phone_x'
],
$this
->
params
[
'phone_a'
],
$this
->
params
[
'phone_b'
],
$params
[
'date'
]);
if
(
$resutl
->
Message
==
'OK'
)
{
$this
->
msg
=
'ok'
;
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'update bind is error'
;
}
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'phone is null'
;
}
return
$this
->
response
(
$this
->
code
,
$this
->
msg
,
$this
->
data
);
}
/**
* 解除绑定关系
*
* @return \think\Response
* @throws \think\exception\DbException
*/
public
function
agentsUnBind
()
{
$phone_x
=
$this
->
params
[
'phone_x'
];
$phone_a
=
$this
->
params
[
'phone_a'
];
if
(
$phone_x
)
{
$phone
=
new
BindingPhone
();
$subsId
=
$phone
->
getSubsId
(
$phone_x
,
$phone_a
,
''
,
1
);
if
(
$subsId
)
{
$result
=
PlsDemo
::
unbindSubscription
(
$subsId
,
$phone_x
);
if
(
$result
->
Message
==
'OK'
)
{
$phone
->
unBind
(
$phone_x
);
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'remove binding error'
;
}
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'dont\'t have about phone_x info'
;
}
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'phone_x is null'
;
}
$this
->
params
[
'phone_x'
];
return
$this
->
response
(
$this
->
code
,
$this
->
msg
);
}
/**
/**
* 总记录列表、搜索
* 总记录列表、搜索
*
*
...
...
application/model/
RongBilledInform
.php
→
application/model/
AliYunSecretReport
.php
View file @
90b541fa
<?php
<?php
/**
/**
* Created by PhpStorm.
* Created by PhpStorm.
* User:
zfc
* User:
hu jun
* Date: 2018/
3/1
6
* Date: 2018/
6/2
6
* Time: 1
4:55
* Time: 1
1:30
*/
*/
namespace
app\model
;
namespace
app\model
;
class
RongBilledInform
extends
BaseModel
class
AliYunSecretReport
extends
BaseModel
{
{
/**
// 设置当前模型对应的完整数据表名称
* @param $where
protected
$table
=
'aliYun_secret_report'
;
* @param $v
* @return mixed
*/
public
function
getValue
(
$where
,
$v
)
{
$r
=
$this
->
where
(
$where
)
->
value
(
$v
);
return
$r
;
}
/**
/**
* @param $field
* 获取所有的通过回调记录
*
* @param $fields
* @param $where
* @param $where
* @return false|\PDOStatement|string|\think\Collection
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
getArr
(
$field
,
$where
){
public
function
secretReportAll
(
$fields
,
$where
)
$r
=
$this
->
field
(
$field
)
->
where
(
$where
)
->
select
();
{
return
$r
;
return
$this
->
field
(
$fields
)
->
where
(
$where
)
->
select
();
}
}
/**
* @param $id
* @param $data
* @return AliYunSecretReport
*/
public
function
updateDownStatus
(
$id
,
$data
)
{
return
$this
->
where
(
'id'
,
$id
)
->
update
(
$data
);
}
}
}
\ No newline at end of file
application/model/BindingPhone.php
View file @
90b541fa
...
@@ -23,7 +23,8 @@ class BindingPhone extends BaseModel
...
@@ -23,7 +23,8 @@ class BindingPhone extends BaseModel
* @param int $status
* @param int $status
* @return bool|mixed
* @return bool|mixed
*/
*/
public
function
getSubsId
(
$phone_x
,
$phone_a
,
$phone_b
=
''
,
$status
=
0
,
$phoneId
=
'subsId'
)
{
public
function
getSubsId
(
$phone_x
,
$phone_a
,
$phone_b
=
''
,
$status
=
0
,
$phoneId
=
'subsId'
)
{
if
(
$phone_x
&&
(
$phone_a
||
$phone_b
))
{
if
(
$phone_x
&&
(
$phone_a
||
$phone_b
))
{
$where
[
'a.status'
]
=
$status
;
$where
[
'a.status'
]
=
$status
;
...
@@ -31,7 +32,7 @@ class BindingPhone extends BaseModel
...
@@ -31,7 +32,7 @@ class BindingPhone extends BaseModel
$where
[
'a.phone_a'
]
=
$phone_a
;
$where
[
'a.phone_a'
]
=
$phone_a
;
}
}
if
(
$phone_b
){
if
(
$phone_b
)
{
$where
[
'a.phone_b'
]
=
$phone_b
;
$where
[
'a.phone_b'
]
=
$phone_b
;
}
}
...
@@ -40,7 +41,7 @@ class BindingPhone extends BaseModel
...
@@ -40,7 +41,7 @@ class BindingPhone extends BaseModel
}
}
$subsId
=
$this
->
alias
(
'a'
)
$subsId
=
$this
->
alias
(
'a'
)
->
join
(
'aliYun_phone b'
,
'a.aliYun_phone_id=b.id'
,
'left'
)
->
join
(
'aliYun_phone b'
,
'a.aliYun_phone_id=b.id'
,
'left'
)
->
where
(
$where
)
->
value
(
$phoneId
);
->
where
(
$where
)
->
value
(
$phoneId
);
}
else
{
}
else
{
$subsId
=
false
;
$subsId
=
false
;
...
@@ -60,21 +61,22 @@ class BindingPhone extends BaseModel
...
@@ -60,21 +61,22 @@ class BindingPhone extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
unBind
(
$phone_x
,
$phone_a
=
''
,
$phone_b
=
''
,
$request_id
=
''
)
{
public
function
unBind
(
$phone_x
,
$phone_a
=
''
,
$phone_b
=
''
,
$request_id
=
''
)
{
if
(
$phone_x
)
{
if
(
$phone_x
)
{
$phone
=
new
AliYunPhone
();
$phone
=
new
AliYunPhone
();
$phone_data
=
$phone
->
where
(
'phone_x'
,
$phone_x
)
->
find
();
$phone_data
=
$phone
->
where
(
'phone_x'
,
$phone_x
)
->
find
();
if
(
$phone_data
[
'id'
])
{
if
(
$phone_data
[
'id'
])
{
$phone_data
[
'bind_num'
]
-=
1
;
$phone_data
[
'bind_num'
]
-=
1
;
$phone_data
->
save
();
$phone_data
->
save
();
$result
=
$this
->
where
([
$result
=
$this
->
where
([
'aliYun_phone_id'
=>
$phone_data
[
'id'
],
'aliYun_phone_id'
=>
$phone_data
[
'id'
],
'status'
=>
1
,
'status'
=>
1
,
'phone_a'
=>
$phone_a
,
'phone_a'
=>
$phone_a
,
'phone_b'
=>
$phone_b
,
'phone_b'
=>
$phone_b
,
])
->
update
([
'status'
=>
0
,
'release_requestId'
=>
$request_id
]);
])
->
update
([
'status'
=>
0
,
'release_requestId'
=>
$request_id
]);
}
else
{
}
else
{
$result
=
false
;
$result
=
false
;
...
@@ -95,10 +97,11 @@ class BindingPhone extends BaseModel
...
@@ -95,10 +97,11 @@ class BindingPhone extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
getPhoneX
(
$field
=
''
,
$where
=
[])
{
public
function
getPhoneX
(
$field
=
''
,
$where
=
[])
{
return
$this
->
alias
(
'a'
)
return
$this
->
alias
(
'a'
)
->
field
(
$field
)
->
field
(
$field
)
->
join
(
'aliYun_phone b'
,
'a.aliYun_phone_id=b.id'
,
'left'
)
->
join
(
'aliYun_phone b'
,
'a.aliYun_phone_id=b.id'
,
'left'
)
->
where
(
$where
)
->
where
(
$where
)
->
order
(
'a.id desc'
)
->
order
(
'a.id desc'
)
->
find
();
->
find
();
...
@@ -112,9 +115,10 @@ class BindingPhone extends BaseModel
...
@@ -112,9 +115,10 @@ class BindingPhone extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
getBindingPhoneList
(
$field
,
$where
)
{
public
function
getBindingPhoneList
(
$field
,
$where
)
{
return
$this
->
field
(
$field
)
->
alias
(
'a'
)
return
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
'aliYun_phone b'
,
'a.aliYun_phone_id = b.id'
,
'left'
)
->
join
(
'aliYun_phone b'
,
'a.aliYun_phone_id = b.id'
,
'left'
)
->
where
(
$where
)
->
where
(
$where
)
->
select
();
->
select
();
}
}
...
@@ -128,28 +132,18 @@ class BindingPhone extends BaseModel
...
@@ -128,28 +132,18 @@ class BindingPhone extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
unBindTable
(
$id
,
$aliYun_phone_id
)
{
public
function
unBindTable
(
$id
,
$aliYun_phone_id
)
$phone
=
new
AliYunPhone
();
{
$phone_data
=
$phone
->
field
(
'id,bind_num'
)
->
where
(
'id'
,
$aliYun_phone_id
)
->
find
();
$phone
=
new
AliYunPhone
();
$phone_data
=
$phone
->
field
(
'id,bind_num'
)
->
where
(
'id'
,
$aliYun_phone_id
)
->
find
();
if
(
$phone_data
[
'id'
])
{
if
(
$phone_data
[
'id'
])
{
$phone_data
[
'bind_num'
]
-=
1
;
$phone_data
[
'bind_num'
]
-=
1
;
$phone_data
->
save
();
$phone_data
->
save
();
}
}
$this
->
update
([
'status'
=>
0
,
'id'
=>
$id
]);
$this
->
update
([
'status'
=>
0
,
'id'
=>
$id
]);
return
;
return
;
}
}
/**
* @param $phone_x
* @param $phone_a
* @param $phone_b
* @param $record
* @param $time
* @param $result
* @param string $mappingId
* @param int $type
* @return int|string
*/
/**
/**
* @param $phone_x
* @param $phone_x
* @param $phone_a
* @param $phone_a
...
@@ -164,22 +158,23 @@ class BindingPhone extends BaseModel
...
@@ -164,22 +158,23 @@ class BindingPhone extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
recordBindPhone
(
$phone_x
,
$phone_a
,
$phone_b
,
$record
,
$time
,
$result
,
$mappingId
=
''
,
$type
=
1
)
{
public
function
recordBindPhone
(
$phone_x
,
$phone_a
,
$phone_b
,
$record
,
$time
,
$result
,
$mappingId
=
''
,
$type
=
1
)
$m_ali_phone
=
new
AliYunPhone
();
{
$phone_id
=
$m_ali_phone
->
field
(
'id,bind_num'
)
->
where
(
'phone_x'
,
$phone_x
)
->
find
();
$m_ali_phone
=
new
AliYunPhone
();
$phone_id
=
$m_ali_phone
->
field
(
'id,bind_num'
)
->
where
(
'phone_x'
,
$phone_x
)
->
find
();
$phone_id
[
'bind_num'
]
+=
1
;
$phone_id
[
'bind_num'
]
+=
1
;
$m_ali_phone
->
where
(
'id'
,
$phone_id
[
'id'
])
->
update
([
'bind_num'
=>
$phone_id
[
'bind_num'
]
]);
$m_ali_phone
->
where
(
'id'
,
$phone_id
[
'id'
])
->
update
([
'bind_num'
=>
$phone_id
[
'bind_num'
]
]);
$insert_data
[
'phone_a'
]
=
$phone_a
;
$insert_data
[
'phone_a'
]
=
$phone_a
;
$insert_data
[
'phone_b'
]
=
$phone_b
;
$insert_data
[
'phone_b'
]
=
$phone_b
;
$insert_data
[
'subsId'
]
=
$result
->
SecretBindDTO
->
SubsId
;
$insert_data
[
'subsId'
]
=
$result
->
SecretBindDTO
->
SubsId
;
$insert_data
[
'requestId'
]
=
$result
->
RequestId
;
$insert_data
[
'requestId'
]
=
$result
->
RequestId
;
$insert_data
[
'mappingId'
]
=
$mappingId
;
$insert_data
[
'mappingId'
]
=
$mappingId
;
$insert_data
[
'record'
]
=
$record
;
$insert_data
[
'record'
]
=
$record
;
$insert_data
[
'aliYun_phone_id'
]
=
$phone_id
[
'id'
];
$insert_data
[
'aliYun_phone_id'
]
=
$phone_id
[
'id'
];
$insert_data
[
'expiry_date'
]
=
$time
;
$insert_data
[
'expiry_date'
]
=
$time
;
$insert_data
[
'type'
]
=
$type
;
$insert_data
[
'type'
]
=
$type
;
$insert_data
[
'status'
]
=
1
;
$insert_data
[
'status'
]
=
1
;
return
$this
->
insert
(
$insert_data
);
return
$this
->
insert
(
$insert_data
);
}
}
}
}
\ No newline at end of file
application/task/controller/PrivacyNumber.php
View file @
90b541fa
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
namespace
app\task\controller
;
namespace
app\task\controller
;
use
app\api_broker\untils\PlsDemo
;
use
app\api_broker\untils\PlsDemo
;
use
app\model\AliYun
BindingPhone
;
use
app\model\AliYun
SecretReport
;
use
app\model\BindingPhone
;
use
app\model\BindingPhone
;
use
app\model\SecretReport
;
use
app\model\SecretReport
;
use
think\Db
;
use
think\Db
;
...
@@ -23,75 +23,68 @@ class PrivacyNumber
...
@@ -23,75 +23,68 @@ class PrivacyNumber
*
*
* @return string
* @return string
*/
*/
public
function
addReport
()
{
public
function
addReport
()
$post_data
=
Request
::
instance
()
->
param
();
{
$post_data
=
Request
::
instance
()
->
param
();
$post_data
[
0
][
'report_id'
]
=
$post_data
[
0
][
'id'
];
$post_data
[
0
][
'report_id'
]
=
$post_data
[
0
][
'id'
];
unset
(
$post_data
[
0
][
'id'
]);
//阿里大于返回是的id改为report_id
unset
(
$post_data
[
0
][
'id'
]);
//阿里大于返回是的id改为report_id
if
(
$post_data
[
0
][
'phone_no'
])
{
if
(
$post_data
[
0
][
'phone_no'
])
{
$agents_id
=
Db
::
table
(
'a_agents'
)
->
where
(
"phone='
{
$post_data
[
0
][
'phone_no'
]
}
' AND password IS NOT NULL"
)
->
value
(
'id'
);
$agents_id
=
Db
::
table
(
'a_agents'
)
->
where
(
"phone='
{
$post_data
[
0
][
'phone_no'
]
}
' AND password IS NOT NULL"
)
->
value
(
'id'
);
if
(
empty
(
$agents_id
))
{
if
(
empty
(
$agents_id
))
{
$agents_id
=
Db
::
table
(
'a_agents_phone'
)
->
where
(
'phone'
,
$post_data
[
0
][
'phone_no'
])
->
value
(
'agents_id'
);
$agents_id
=
Db
::
table
(
'a_agents_phone'
)
->
where
(
'phone'
,
$post_data
[
0
][
'phone_no'
])
->
value
(
'agents_id'
);
}
}
$post_data
[
0
][
'agents_id'
]
=
$agents_id
;
$post_data
[
0
][
'agents_id'
]
=
$agents_id
;
$post_data
[
0
][
'users_id'
]
=
Db
::
table
(
'u_users'
)
->
where
(
'user_phone'
,
$post_data
[
0
][
'peer_no'
])
->
value
(
'id'
);
$post_data
[
0
][
'users_id'
]
=
Db
::
table
(
'u_users'
)
->
where
(
'user_phone'
,
$post_data
[
0
][
'peer_no'
])
->
value
(
'id'
);
}
}
$post_data
[
0
][
'time'
]
=
strtotime
(
$post_data
[
0
][
'release_time'
])
-
strtotime
(
$post_data
[
0
][
'start_time'
]);
$report
=
new
SecretReport
();
$post_data
[
0
][
'time'
]
=
strtotime
(
$post_data
[
0
][
'release_time'
])
-
strtotime
(
$post_data
[
0
][
'start_time'
]);
$report
=
new
SecretReport
();
$report
->
allowField
(
true
)
->
save
(
$post_data
[
0
]);
$report
->
allowField
(
true
)
->
save
(
$post_data
[
0
]);
Log
::
write
(
json_encode
(
$post_data
[
0
]),
'AliYunSecretReport'
);
//记录日志
Log
::
write
(
json_encode
(
$post_data
[
0
]),
'AliYunSecretReport'
);
//记录日志
return
json_encode
([
'code'
=>
0
,
'msg'
=>
'接收成功'
]);
return
json_encode
([
'code'
=>
0
,
'msg'
=>
'接收成功'
]);
}
}
/**
/**
* 高峰期 一般是早上9-11点 下午2-4点
*
下载录音
高峰期 一般是早上9-11点 下午2-4点
*
*
* @throws \Aliyun\Core\Exception\ClientException
* @throws \Aliyun\Core\Exception\ClientException
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
*/
public
function
queryRecordFile
()
{
public
function
queryRecordFile
()
$down_data
=
Db
::
table
(
'aliyun_secret_report'
)
->
field
(
'id,call_id,call_time'
)
{
->
where
(
'record_down'
,
0
)
set_time_limit
(
0
);
->
where
(
'time'
,
'<>'
,
0
)
$m_secret
=
new
AliYunSecretReport
();
->
whereTime
(
'call_time'
,
'<'
,
time
()
-
900
)
$fields
=
'id,call_id,call_time,voice_file,type'
;
->
select
();
$where
[
'record_down'
]
=
0
;
$where
[
'time'
]
=
[
'>'
,
0
];
$where
[
'type'
]
=
[
'>'
,
0
];
$down_data
=
$m_secret
->
secretReportAll
(
$fields
,
$where
);
$is_down
=
''
;
foreach
(
$down_data
as
$k
=>
$v
)
{
foreach
(
$down_data
as
$k
=>
$v
)
{
$result_data
=
PlsDemo
::
queryRecordFileDownloadUrl
(
$v
[
'call_id'
],
$v
[
'call_time'
]);
if
(
$v
[
'type'
]
==
1
)
{
if
(
$result_data
->
Message
==
'OK'
)
{
/*阿里云音频下载*/
$down_url
=
explode
(
'?'
,
$result_data
->
DownloadUrl
);
$result_data
=
PlsDemo
::
queryRecordFileDownloadUrl
(
$v
[
'call_id'
],
$v
[
'call_time'
]);
$is_down
=
down_file
(
$result_data
->
DownloadUrl
,
ROOT_PATH
.
'public'
.
DS
.
'static'
.
DS
.
'voice'
,
basename
(
$down_url
[
0
]));
if
(
isset
(
$result_data
->
Message
)
&&
$result_data
->
Message
==
'OK'
)
{
$down_url
=
isset
(
$result_data
->
DownloadUrl
)
?
explode
(
'?'
,
$result_data
->
DownloadUrl
)
:
$result_data
->
DownloadUrl
;
if
(
file_exists
(
$is_down
))
{
$is_down
=
down_file
(
$result_data
->
DownloadUrl
,
PHONE_VOICE
,
basename
(
$down_url
[
0
]));
$data
[
'id'
]
=
$v
[
'id'
];
$data
[
'record_down'
]
=
1
;
$data
[
'voice_file'
]
=
date
(
'Ymd'
)
.
'/'
.
basename
(
$is_down
);
Db
::
table
(
'aliYun_secret_report'
)
->
update
(
$data
);
}
}
}
elseif
(
$v
[
'type'
]
==
2
)
{
/*容联云音频下载*/
$is_down
=
down_file
(
$v
[
'voice_file'
],
PHONE_VOICE
);
}
}
}
/*容联云音频下载*/
if
(
file_exists
(
$is_down
))
{
/* $rongRecord = new RongBilledInform();
$data
[
'record_down'
]
=
1
;
$ids = [];
$data
[
'voice_file'
]
=
date
(
'Ymd'
)
.
'/'
.
basename
(
$is_down
);
$field = 'id,mp3_url';
$m_secret
->
updateDownStatus
(
$v
[
'id'
],
$data
);
$where = 'download=0';
$down_data2 = $rongRecord->getArr($field,$where);
if($down_data2) {
foreach ($down_data2 as $k => $v) {
$ids[] = $v['id'];
$down_url2 = explode('/', $v['mp3_url']);
down_file($v['mp3_url'], ROOT_PATH . 'public' . DS . 'static' . DS . 'voice', array_pop($down_url2));
}
}
}
}
$id_str = implode(',',$ids);
$update['download'] = 1;
$where = " id in($id_str)";
$rongRecord->save($update,$where);*/
return
;
return
;
}
}
...
@@ -103,21 +96,22 @@ class PrivacyNumber
...
@@ -103,21 +96,22 @@ class PrivacyNumber
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
releaseNumber
()
{
public
function
releaseNumber
()
$bind_data
=
Db
::
table
(
'aliYun_binding_phone'
)
{
->
alias
(
'a'
)
$m_bind
=
new
BindingPhone
();
->
join
(
'aliyun_phone b'
,
'a.aliYun_phone_id=b.id'
,
'left'
)
->
field
(
'a.id,aliYun_phone_id,expiry_date,phone_x,phone_a,phone_b,subsId'
)
$fields
=
'a.id,aliYun_phone_id,expiry_date,phone_x,phone_a,phone_b,subsId'
;
->
where
(
'a.status'
,
1
)
$where
[
'a.status'
]
=
1
;
->
where
(
'b.type'
,
1
)
$where
[
'b.type'
]
=
1
;
->
select
(
);
$bind_data
=
$m_bind
->
getBindingPhoneList
(
$fields
,
$where
);
$time
=
strtotime
(
date
(
'Y-m-d'
));
//今天0点
$time
=
strtotime
(
date
(
'Y-m-d'
));
//今天0点
$binding_phone_id
=
[];
$binding_phone_id
=
[];
$phone_id
=
[];
$phone_id
=
[];
$bind
=
new
BindingPhone
();
$bind
=
new
BindingPhone
();
foreach
(
$bind_data
as
$k
=>
$v
)
{
$date
=
strtotime
(
date
(
'Y-m-d'
,
strtotime
(
$v
[
'expiry_date'
])));
foreach
(
$bind_data
as
$k
=>
$v
)
{
$date
=
strtotime
(
date
(
'Y-m-d'
,
strtotime
(
$v
[
'expiry_date'
])));
//解除绑定
//解除绑定
if
(
$date
<=
$time
)
{
if
(
$date
<=
$time
)
{
...
@@ -131,27 +125,29 @@ class PrivacyNumber
...
@@ -131,27 +125,29 @@ class PrivacyNumber
if
(
$result
->
Message
==
'OK'
)
{
if
(
$result
->
Message
==
'OK'
)
{
$bind
->
unBind
(
$v
[
'phone_x'
],
$v
[
'phone_a'
],
$v
[
'phone_b'
],
$result
->
RequestId
);
$bind
->
unBind
(
$v
[
'phone_x'
],
$v
[
'phone_a'
],
$v
[
'phone_b'
],
$result
->
RequestId
);
$binding_phone_id
[
$k
]
=
$v
[
'id'
];
$binding_phone_id
[
$k
]
=
$v
[
'id'
];
$phone_id
[
$k
]
=
$v
[
'aliYun_phone_id'
];
$phone_id
[
$k
]
=
$v
[
'aliYun_phone_id'
];
}
}
}
}
}
}
$id
[
'aliYun_binding_phone'
]
=
implode
(
','
,
$binding_phone_id
);
$id
[
'aliYun_binding_phone'
]
=
implode
(
','
,
$binding_phone_id
);
$id
[
'aliYun_phone'
]
=
implode
(
','
,
array_unique
(
$phone_id
));
$id
[
'aliYun_phone'
]
=
implode
(
','
,
array_unique
(
$phone_id
));
Log
::
write
(
json_encode
(
$id
),
'AliYunReleaseNumber'
);
//记录日志
Log
::
write
(
json_encode
(
$id
),
'AliYunReleaseNumber'
);
//记录日志
return
;
return
;
}
}
/*******************************↓↓↓↓↓↓容联云↓↓↓↓↓***********************************************/
/*******************************↓↓↓↓↓↓容联云↓↓↓↓↓***********************************************/
/**话单通知
/**
* 话单通知
*
* @return string
* @return string
*/
*/
public
function
rongBilledInformUrl
()
{
public
function
rongBilledInformUrl
()
{
$params
=
Request
::
instance
()
->
param
();
$params
=
Request
::
instance
()
->
param
();
/*搜索A经纪人agent_id and B客户 user_id */
/*搜索A经纪人agent_id and B客户 user_id */
$date
=
[
$date
=
[
'call_id'
=>
$params
[
'callId'
],
'call_id'
=>
$params
[
'callId'
],
'phone_no'
=>
$params
[
'callerNum'
],
/*A*/
'phone_no'
=>
$params
[
'callerNum'
],
/*A*/
'secret_no'
=>
$params
[
'calleeNum'
],
/*X*/
'secret_no'
=>
$params
[
'calleeNum'
],
/*X*/
...
@@ -163,43 +159,51 @@ class PrivacyNumber
...
@@ -163,43 +159,51 @@ class PrivacyNumber
'time'
=>
$params
[
'duration'
],
/*本次通话时间*/
'time'
=>
$params
[
'duration'
],
/*本次通话时间*/
'release_dir'
=>
$params
[
'result'
],
/*本次通话的结果,0 成功2无应答 9呼叫失败 11*/
'release_dir'
=>
$params
[
'result'
],
/*本次通话的结果,0 成功2无应答 9呼叫失败 11*/
'mapping_id'
=>
$params
[
'mappingId'
],
/*绑定容联云id*/
'mapping_id'
=>
$params
[
'mappingId'
],
/*绑定容联云id*/
'type'
=>
2
,
'type'
=>
2
,
'call_display'
=>
$params
[
'calldisplay'
],
'call_display'
=>
$params
[
'calldisplay'
],
];
];
$phone_a
=
$params
[
'callerNum'
];
$phone_a
=
$params
[
'callerNum'
];
if
(
$phone_a
)
{
if
(
$phone_a
)
{
$agents_id
=
Db
::
table
(
'agents'
)
->
where
(
"phone='
{
$phone_a
}
' AND password IS NOT NULL"
)
->
value
(
'id'
);
$agents_id
=
Db
::
table
(
'a
_a
gents'
)
->
where
(
"phone='
{
$phone_a
}
' AND password IS NOT NULL"
)
->
value
(
'id'
);
if
(
empty
(
$agents_id
))
{
if
(
empty
(
$agents_id
))
{
$agents_id
=
Db
::
table
(
'a_agents_phone'
)
->
where
(
'phone'
,
$phone_a
)
->
value
(
'agents_id'
);
$agents_id
=
Db
::
table
(
'a_agents_phone'
)
->
where
(
'phone'
,
$phone_a
)
->
value
(
'agents_id'
);
}
}
$date
[
'agents_id'
]
=
$agents_id
;
$date
[
'agents_id'
]
=
$agents_id
;
$date
[
'users_id'
]
=
Db
::
table
(
'u_users'
)
->
where
(
'user_phone'
,
$phone_a
)
->
value
(
'id'
);
$date
[
'users_id'
]
=
Db
::
table
(
'u_users'
)
->
where
(
'user_phone'
,
$params
[
'servingNum'
]
)
->
value
(
'id'
);
}
}
$report
=
new
SecretReport
();
$report
=
new
SecretReport
();
$report
->
allowField
(
true
)
->
save
(
$date
);
$report
->
allowField
(
true
)
->
save
(
$date
);
$str
=
date
(
'Y-m-d h:i:s'
)
.
' 容联云话单'
.
var_export
(
$params
,
true
);
$str
=
date
(
'Y-m-d h:i:s'
)
.
' 容联云话单'
.
var_export
(
$params
,
true
);
Log
::
write
(
$str
,
'rongBilledInformUrl'
);
//记录日志
Log
::
write
(
$str
,
'rongBilledInformUrl'
);
//记录日志
return
json_encode
([
"statusCode"
=>
'000000'
,
'msg'
=>
'接收成功'
]);
return
json_encode
([
"statusCode"
=>
'000000'
,
'msg'
=>
'接收成功'
]);
}
}
//录音通知
/**
public
function
rongRecordingInformUrl
(){
* 录音通知
$params
=
Request
::
instance
()
->
param
();
*
$report
=
new
SecretReport
();
* @return string
$where
[
'call_id'
]
=
$params
[
'callId'
];
*/
$update
[
'voice_file'
]
=
$params
[
'recordUrl'
];
public
function
rongRecordingInformUrl
()
$report
->
save
(
$update
,
$where
);
{
$str
=
date
(
'Y-m-d h:i:s'
)
.
' 容联云录音'
.
var_export
(
$params
,
true
);
$params
=
Request
::
instance
()
->
param
();
Log
::
write
(
$str
,
'rongRecordingInformUrl'
);
//记录日志
$report
=
new
SecretReport
();
return
json_encode
([
"statusCode"
=>
'000000'
,
'msg'
=>
'接收成功'
]);
$where
[
'call_id'
]
=
$params
[
'callId'
];
$update
[
'voice_file'
]
=
$params
[
'recordUrl'
];
$report
->
save
(
$update
,
$where
);
$str
=
date
(
'Y-m-d h:i:s'
)
.
' 容联云录音'
.
var_export
(
$params
,
true
);
Log
::
write
(
$str
,
'rongRecordingInformUrl'
);
//记录日志
return
json_encode
([
"statusCode"
=>
'000000'
,
'msg'
=>
'接收成功'
]);
}
}
//状态通知
public
function
rongStatusInformUrl
(){
/**
* 状态通知
*/
public
function
rongStatusInformUrl
()
{
$params
=
Request
::
instance
()
->
param
();
$params
=
Request
::
instance
()
->
param
();
$str
=
date
(
'Y-m-d h:i:s'
)
.
' 容联云状态通知'
.
var_export
(
$params
,
true
);
$str
=
date
(
'Y-m-d h:i:s'
)
.
' 容联云状态通知'
.
var_export
(
$params
,
true
);
Log
::
write
(
json_encode
(
$str
),
'rongStatusInformUrl'
);
//记录日志
Log
::
write
(
json_encode
(
$str
),
'rongStatusInformUrl'
);
//记录日志
}
}
...
@@ -211,22 +215,22 @@ class PrivacyNumber
...
@@ -211,22 +215,22 @@ class PrivacyNumber
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
checkBindPhone
()
{
public
function
checkBindPhone
()
{
$m_bind
=
new
BindingPhone
();
$m_bind
=
new
BindingPhone
();
$where
[
'a.status'
]
=
1
;
$where
[
'a.status'
]
=
1
;
$where
[
'a.type'
]
=
1
;
$where
[
'a.type'
]
=
1
;
$select_data
=
$m_bind
->
getBindingPhoneList
(
'a.id,a.aliYun_phone_id,b.phone_x,a.subsId,a.expiry_date'
,
$where
);
$select_data
=
$m_bind
->
getBindingPhoneList
(
'a.id,a.aliYun_phone_id,b.phone_x,a.subsId,a.expiry_date'
,
$where
);
foreach
(
$select_data
as
$k
=>
$v
)
{
foreach
(
$select_data
as
$k
=>
$v
)
{
$query_status
=
PlsDemo
::
querySubscriptionDetail
(
$v
[
'subsId'
],
$v
[
'phone_x'
]);
$query_status
=
PlsDemo
::
querySubscriptionDetail
(
$v
[
'subsId'
],
$v
[
'phone_x'
]);
$expiry_date
=
strtotime
(
$select_data
[
'expiry_date'
]);
$expiry_date
=
strtotime
(
$select_data
[
'expiry_date'
]);
if
((
$query_status
->
Code
!=
'OK'
)
&&
(
$expiry_date
<
time
()))
{
if
(
isset
(
$query_status
->
code
)
&&
(
$query_status
->
Code
!=
'OK'
)
&&
(
$expiry_date
<
time
()))
{
$m_bind
->
unBindTable
(
$v
[
'id'
],
$v
[
'aliYun_phone_id'
]);
$m_bind
->
unBindTable
(
$v
[
'id'
],
$v
[
'aliYun_phone_id'
]);
}
}
}
}
return
;
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