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
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
83 additions
and
34 deletions
+83
-34
CellPhone.php
application/api_broker/controller/CellPhone.php
+0
-0
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
This diff is collapsed.
Click to expand it.
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