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
c2b4a40a
Commit
c2b4a40a
authored
Jun 12, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
隐私号码修改,增加绑定关系检查。
parent
1a208c54
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
117 additions
and
74 deletions
+117
-74
CellPhone.php
application/api_broker/controller/CellPhone.php
+34
-40
PlsDemo.php
application/api_broker/untils/PlsDemo.php
+5
-5
CellPhone.php
application/index/controller/CellPhone.php
+1
-1
AliYunPhone.php
application/model/AliYunPhone.php
+11
-25
BindingPhone.php
application/model/BindingPhone.php
+36
-1
route.php
application/route.php
+1
-0
PrivacyNumber.php
application/task/controller/PrivacyNumber.php
+29
-2
No files found.
application/api_broker/controller/CellPhone.php
View file @
c2b4a40a
...
...
@@ -37,27 +37,34 @@ class CellPhone extends Basic
public
function
bindAXB
()
{
header
(
'Access-Control-Allow-Origin:*'
);
$params
=
$this
->
request
->
param
();
if
(
$params
[
'phone_a'
]
||
$params
[
'phone_b'
])
{
if
(
empty
(
$params
[
'phone_a'
])
||
empty
(
$params
[
'phone_b'
]))
{
$this
->
code
=
101
;
$this
->
msg
=
'phone_a or phone_b is null'
;
return
$this
->
response
(
101
,
'参数错误,请联系运营人员!'
);
}
$phone_a
=
$this
->
params
[
'phone_a'
];
//经纪人手机号
$phone_b
=
$this
->
params
[
'phone_b'
];
//客户手机号
$record
=
empty
(
$this
->
params
[
'record'
])
?
true
:
fals
e
;
//是否录音
$record
=
tru
e
;
//是否录音
$setting
=
Cache
::
get
(
'Setting'
);
//获取配置
//var_dump($setting);/*************测试****************/
//0不使用隐私号码 1阿里云 2容联云
if
(
$setting
[
'is_privacy'
]
!=
0
)
{
$aliYunPhone
=
new
AliYunPhone
();
$bind
=
new
BindingPhone
();
$field
=
'phone_x'
;
$where
[
'a.status'
]
=
1
;
$where
[
'a.phone_a'
]
=
$phone_a
;
$where
[
'a.phone_b'
]
=
$phone_b
;
$where
[
'a.type'
]
=
$setting
[
'is_privacy'
];
if
(
$setting
[
'is_privacy'
]
!=
0
)
{
$phone_x
=
$bind
->
getPhoneX
(
$field
,
$where
);
if
(
$phone_x
)
{
$phone_x
=
$bind
->
getPhoneX
(
'b.phone_x'
,
$where
);
//已经绑定的返回隐私号码
if
(
$phone_x
!=
NULL
)
{
$this
->
data
=
[
'phone'
=>
$phone_x
[
'phone_x'
]];
}
else
{
$phone_x
=
$aliYunPhone
->
getAliYunPhone
(
$phone_a
,
$phone_b
,
$setting
[
'is_privacy'
]);
$phone_x
=
$aliYunPhone
->
getAliYunPhone
(
$phone_a
,
$phone_b
,
$setting
[
'is_privacy'
]);
//是否还有未绑定的中间号码
if
(
$phone_x
)
{
...
...
@@ -66,15 +73,24 @@ class CellPhone extends Basic
}
else
{
$setting
[
'day_num'
]
+=
1
;
$time
=
date
(
'Y-m-d H:i:s'
,
strtotime
(
"+
{
$setting
[
'day_num'
]
}
day"
));
// $time = date('Y-m-d H:i:s',time()+300);
}
if
(
$setting
[
'is_privacy'
]
==
2
)
{
if
(
$setting
[
'is_privacy'
]
==
1
)
{
/*阿里云*/
$result
=
PlsDemo
::
bindAxb
(
$phone_a
,
$phone_b
,
$time
,
$record
,
$phone_x
[
'phone_x'
]);
if
(
$result
->
Message
==
'OK'
)
{
$aliYunPhone
->
editStatus
(
$phone_x
,
$phone_a
,
$phone_b
,
$record
,
$time
,
$result
,
''
,
$setting
[
'is_privacy'
]);
//记录绑定
$this
->
msg
=
'绑定成功。'
;
$this
->
data
=
[
'phone'
=>
$phone_x
[
'phone_x'
]];
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'号码绑定冲突,请联系运营人员!'
;
}
}
else
{
/*容联云*/
$Rong
=
new
RongDemo
();
$record2
=
empty
(
$this
->
params
[
'record'
])
?
'true'
:
'false'
;
/* 是否录音(容联云规定string类型)*/
// var_dump($phone_x);/*************测试****************/
/*计算有效期*/
if
(
empty
(
$setting
[
'day_num'
])){
$yx_time
=
$setting
[
'day_num'
]
*
60
*
60
*
24
;
...
...
@@ -83,7 +99,7 @@ class CellPhone extends Basic
}
$result
=
$Rong
->
setNumber
(
$phone_a
,
$phone_b
,
$phone_x
[
'phone_x'
],
$phone_x
[
'area'
],
$yx_time
,
$record2
);
/*绑定成功*/
// var_dump($result);/*************测试****************/
if
(
$result
[
'statusCode'
]
==
'000000'
){
$aliYunPhone
->
editStatus
(
$phone_x
,
$phone_a
,
$phone_b
,
$record
,
$time
,
0
,
$result
[
'data'
][
'mappingId'
],
$setting
[
'is_privacy'
]);
//记录绑定
$this
->
msg
=
'Binding Rong success'
;
...
...
@@ -92,19 +108,7 @@ class CellPhone extends Basic
$this
->
code
=
101
;
$this
->
msg
=
'操作频繁,请10秒后再操作。'
;
}
}
else
{
/*阿里云*/
$result
=
PlsDemo
::
bindAxb
(
$phone_a
,
$phone_b
,
$time
,
$record
,
$phone_x
[
'phone_x'
]);
if
(
$result
->
Message
==
'OK'
)
{
$aliYunPhone
->
editStatus
(
$phone_x
,
$phone_a
,
$phone_b
,
$record
,
$time
,
$result
,
''
,
$setting
[
'is_privacy'
]);
//记录绑定
$this
->
msg
=
'Binding success.'
;
$this
->
data
=
[
'phone'
=>
$phone_x
[
'phone_x'
]];
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'操作频繁,请10秒后再操作。'
;
}
}
Log
::
write
(
json_encode
(
$result
),
'AliYunBindAxb'
);
//记录日志
}
else
{
...
...
@@ -122,10 +126,6 @@ class CellPhone extends Basic
'record_down'
=>
3
,
]);
}
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'phone_a or phone_b is null'
;
}
return
$this
->
response
(
$this
->
code
,
$this
->
msg
,
$this
->
data
);
}
...
...
@@ -179,22 +179,20 @@ class CellPhone extends Basic
$setting
=
Cache
::
get
(
'Setting'
);
//获取配置
$phone
=
new
BindingPhone
();
if
(
$setting
[
'is_privacy'
]
==
1
)
{
/*阿里云*/
$subsId
=
$phone
->
getSubsId
(
$phone_x
,
$phone_a
,
$phone_b
,
1
,
'subsId'
);
if
(
$subsId
)
{
$result
=
PlsDemo
::
unbindSubscription
(
$subsId
,
$phone_x
);
/*解绑*/
if
(
$result
->
Message
==
'OK'
)
{
$phone
->
U
nBind
(
$phone_x
,
$phone_a
,
$phone_b
);
$phone
->
u
nBind
(
$phone_x
,
$phone_a
,
$phone_b
);
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'解
绑失败,请等一会再重试
!'
;
$this
->
msg
=
'解
除绑定关系失败,请联系运营
!'
;
}
}
else
{
$this
->
code
=
200
;
$this
->
msg
=
'
dont\'t have about phone_x info
'
;
$this
->
msg
=
'
没有号码绑定关系,请忽略!。
'
;
}
}
else
{
/*容联云*/
...
...
@@ -204,7 +202,7 @@ class CellPhone extends Basic
$result
=
$Rong
->
releaseNumber
(
$mappingId
);
/*解绑*/
//var_dump($result);/*************测试****************/
if
(
$result
[
'statusCode'
]
==
'000000'
)
{
$phone
->
U
nBind
(
$phone_x
,
$phone_a
,
$phone_b
);
$phone
->
u
nBind
(
$phone_x
,
$phone_a
,
$phone_b
);
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'remove binding error'
;
...
...
@@ -214,13 +212,9 @@ class CellPhone extends Basic
$this
->
msg
=
'dont\'t have about phone_x info'
;
}
}
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'
phone_x or phone_a or phone_b is null
'
;
$this
->
msg
=
'
解除关系参数错误,请联系运营人员!
'
;
}
$this
->
params
[
'phone_x'
];
return
$this
->
response
(
$this
->
code
,
$this
->
msg
);
...
...
application/api_broker/untils/PlsDemo.php
View file @
c2b4a40a
...
...
@@ -14,7 +14,7 @@ use Aliyun\Api\Dypls\Request\V20170525\UnbindSubscriptionRequest;
use
Aliyun\Api\Dypls\Request\V20170525\UpdateSubscriptionRequest
;
use
Aliyun\Api\Dypls\Request\V20170525\QueryRecordFileDownloadUrlRequest
;
use
Aliyun\Api\Dypls\Request\V20170525\QuerySubscriptionDetailRequest
;
use
Aliyun\Api\Dypls\Request\V20170525\BindAxnExtensionRequest
;
use
Symfony\Component\Yaml\Tests\DumperTest
;
use
Aliyun\Api\Dypls\Request\V20170525\BindAxnExtensionRequest
;
// 加载区域结点配置
Config
::
load
();
...
...
@@ -292,22 +292,22 @@ class PlsDemo
* @return stdClass
* @throws ClientException
*/
public
static
function
querySubscriptionDetail
()
{
public
static
function
querySubscriptionDetail
(
$subsId
,
$secretNo
)
{
//组装请求对象
$request
=
new
QuerySubscriptionDetailRequest
();
//必填:号池Key
$request
->
setPoolKey
(
"FC123456"
);
$request
->
setPoolKey
(
self
::
$pool_key
);
//必填: 产品类型,目前一共支持三款产品AXB_170,AXN_170,AXN_95
$request
->
setProductType
(
"AXB_170"
);
//必填: 绑定关系ID
$request
->
setSubsId
(
"123456"
);
$request
->
setSubsId
(
$subsId
);
//必填: 绑定关系对应的X号码
$request
->
setPhoneNoX
(
"170000000"
);
$request
->
setPhoneNoX
(
$secretNo
);
//hint 此处可能会抛出异常,注意catch
$response
=
static
::
getAcsClient
()
->
getAcsResponse
(
$request
);
...
...
application/index/controller/CellPhone.php
View file @
c2b4a40a
...
...
@@ -118,7 +118,7 @@ class CellPhone extends Basic
if
(
$subsId
)
{
$result
=
PlsDemo
::
unbindSubscription
(
$subsId
,
$phone_x
);
if
(
$result
->
Message
==
'OK'
)
{
$phone
->
U
nBind
(
$phone_x
);
$phone
->
u
nBind
(
$phone_x
);
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'remove binding error'
;
...
...
application/model/AliYunPhone.php
View file @
c2b4a40a
...
...
@@ -26,29 +26,15 @@ class AliYunPhone extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getAliYunPhone
(
$phone_a
,
$phone_b
,
$type
=
1
)
{
/* //查找phone_x 与 phone_a绑定的号码
$where_a['b.status'] = 1;
$where_a['phone_a'] = $phone_a;
$where_a['bind_num'] = ['<=',200];
$aliYun_phone_id1 = $this->field('a.id,phone_x')->alias('a')
->join('aliYun_binding_phone b','a.id = b.aliYun_phone_id','left')
->where($where_a)->select();
public
function
getAliYunPhone
(
$phone_a
,
$phone_b
,
$type
=
1
)
{
//找到phone_a和phone_b出现在两个字段中
$where_bind
[]
=
[
'EXP'
,
"(a.phone_a='
{
$phone_a
}
' or a.phone_b='
{
$phone_a
}
') or (a.phone_a='
{
$phone_b
}
' or a.phone_b='
{
$phone_b
}
')"
];
$where_bind
[
'a.status'
]
=
1
;
$where_bind
[
'b.bind_num'
]
=
[
'<='
,
200
];
$where_bind
[
'b.type'
]
=
$type
;
//查找phone_x 与 phone_b绑定的号码
$where_b['b.status'] = 1;
$where_b['phone_b'] = $phone_b;
$where_b['bind_num'] = ['<=',200];
$aliYun_phone_id2 = $this->field('a.id,phone_x')->alias('a')
->join('aliYun_binding_phone b','a.id = b.aliYun_phone_id','left')
->where($where_b)->select();
$id_arr = array_merge($aliYun_phone_id1,$aliYun_phone_id2); //合并phone_a和phone_b已经绑定的号码*/
$where_a
[
'b.status'
]
=
1
;
$where_a
[
'bind_num'
]
=
[
'<='
,
200
];
$id_arr
=
$this
->
field
(
'a.id,phone_x'
)
->
alias
(
'a'
)
->
join
(
'aliYun_binding_phone b'
,
'a.id = b.aliYun_phone_id'
,
'left'
)
->
where
(
$where_a
)
->
where
(
"(b.phone_a=
$phone_a
or b.phone_b=
$phone_b
) and a.type=
$type
"
)
->
select
();
$m_bind
=
new
BindingPhone
();
$id_arr
=
$m_bind
->
getBindingPhoneList
(
'b.id'
,
$where_bind
);
foreach
(
$id_arr
as
$k
=>
$v
)
{
$id
[
$k
]
=
$v
[
'id'
];
//去除phone_a已经绑定的号码
...
...
@@ -59,10 +45,10 @@ class AliYunPhone extends BaseModel
$where_phone
[
'type'
]
=
$type
;
if
(
empty
(
$id
))
{
$result
=
Db
::
table
(
'aliYun_phone'
)
->
field
(
'id,phone_x,area'
)
->
where
(
$where_phone
)
->
find
();
$result
=
$this
->
field
(
'id,phone_x,area'
)
->
where
(
$where_phone
)
->
find
();
}
else
{
$where_phone
[
'id'
]
=
[
'NOT IN'
,
$id
];
$result
=
Db
::
table
(
'aliYun_phone'
)
->
field
(
'id,phone_x,area'
)
->
where
(
$where_phone
)
->
find
();
$where_phone
[
'id'
]
=
[
'NOT IN'
,
$id
];
//排除已经绑定的号码
$result
=
$this
->
field
(
'id,phone_x,area'
)
->
where
(
$where_phone
)
->
find
();
}
return
$result
;
...
...
application/model/BindingPhone.php
View file @
c2b4a40a
...
...
@@ -56,7 +56,7 @@ class BindingPhone extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
U
nBind
(
$phone_x
,
$phone_a
=
''
,
$phone_b
=
''
,
$request_id
=
''
)
{
public
function
u
nBind
(
$phone_x
,
$phone_a
=
''
,
$phone_b
=
''
,
$request_id
=
''
)
{
if
(
$phone_x
)
{
$phone
=
new
AliYunPhone
();
$phone_data
=
$phone
->
where
(
'phone_x'
,
$phone_x
)
->
find
();
...
...
@@ -99,4 +99,38 @@ class BindingPhone extends BaseModel
->
find
();
}
/**
* @param $field
* @param $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getBindingPhoneList
(
$field
,
$where
)
{
return
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
'aliYun_phone b'
,
'a.aliYun_phone_id = b.id'
,
'left'
)
->
where
(
$where
)
->
select
();
}
/**
* 更新绑定号码与阿里云绑定不一致的问题
*
* @param $id
* @param $aliYun_phone_id
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
unBindTable
(
$id
,
$aliYun_phone_id
)
{
$phone
=
new
AliYunPhone
();
$phone_data
=
$phone
->
field
(
'id,bind_num'
)
->
where
(
'id'
,
$aliYun_phone_id
)
->
find
();
if
(
$phone_data
[
'id'
])
{
$phone_data
[
'bind_num'
]
-=
1
;
$phone_data
->
save
();
}
$this
->
update
([
'status'
=>
0
,
'id'
=>
$id
]);
return
;
}
}
\ No newline at end of file
application/route.php
View file @
c2b4a40a
...
...
@@ -341,6 +341,7 @@ Route::group('task', [
'addReport'
=>
[
'task/PrivacyNumber/addReport'
,
[
'method'
=>
'get|post'
]
],
//阿里大于隐私号码回调
'queryRecordFile'
=>
[
'task/PrivacyNumber/queryRecordFile'
,
[
'method'
=>
'get'
]
],
//下载录音
'releaseNumber'
=>
[
'task/PrivacyNumber/releaseNumber'
,
[
'method'
=>
'get'
]
],
//释放号码
'checkBindPhone'
=>
[
'task/PrivacyNumber/checkBindPhone'
,
[
'method'
=>
'get'
]
],
//检查绑定关系,去除表中不存在的绑定关系
'updateStatusByTime'
=>
[
'task/updateShopStatusTask/updateStatusByTime'
,
[
'method'
=>
'get'
]
],
//修改上下架
...
...
application/task/controller/PrivacyNumber.php
View file @
c2b4a40a
...
...
@@ -9,9 +9,9 @@
namespace
app\task\controller
;
use
app\api_broker\untils\PlsDemo
;
use
app\model\AliYunBindingPhone
;
use
app\model\BindingPhone
;
use
app\model\SecretReport
;
use
app\model\RongBilledInform
;
use
think\Db
;
use
think\Log
;
use
think\Request
;
...
...
@@ -129,7 +129,7 @@ class PrivacyNumber
$result
=
PlsDemo
::
unbindSubscription
(
$subsId
,
$v
[
'phone_x'
]);
if
(
$result
->
Message
==
'OK'
)
{
$bind
->
U
nBind
(
$v
[
'phone_x'
],
$v
[
'phone_a'
],
$v
[
'phone_b'
],
$result
->
RequestId
);
$bind
->
u
nBind
(
$v
[
'phone_x'
],
$v
[
'phone_a'
],
$v
[
'phone_b'
],
$result
->
RequestId
);
$binding_phone_id
[
$k
]
=
$v
[
'id'
];
$phone_id
[
$k
]
=
$v
[
'aliYun_phone_id'
];
}
...
...
@@ -203,4 +203,30 @@ class PrivacyNumber
}
/**
* 检查绑定关系,去除表中不存在的绑定关系
*
* @throws \Aliyun\Core\Exception\ClientException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
checkBindPhone
()
{
$m_bind
=
new
BindingPhone
();
$where
[
'a.status'
]
=
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
);
foreach
(
$select_data
as
$k
=>
$v
)
{
$query_status
=
PlsDemo
::
querySubscriptionDetail
(
$v
[
'subsId'
],
$v
[
'phone_x'
]);
$expiry_date
=
strtotime
(
$select_data
[
'expiry_date'
]);
if
((
$query_status
->
Code
!=
'OK'
)
&&
(
$expiry_date
<
time
()))
{
$m_bind
->
unBindTable
(
$v
[
'id'
],
$v
[
'aliYun_phone_id'
]);
}
}
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