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
5e8e396b
Commit
5e8e396b
authored
Sep 12, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
隐私号码优化
parent
fc5fcf4e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
11 deletions
+77
-11
AliYunPhone.php
application/model/AliYunPhone.php
+60
-1
BindingPhone.php
application/model/BindingPhone.php
+15
-8
PrivacyNumber.php
application/task/controller/PrivacyNumber.php
+2
-2
No files found.
application/model/AliYunPhone.php
View file @
5e8e396b
...
@@ -41,7 +41,7 @@ class AliYunPhone extends BaseModel
...
@@ -41,7 +41,7 @@ class AliYunPhone extends BaseModel
$m_bind
=
new
BindingPhone
();
$m_bind
=
new
BindingPhone
();
$id_arr
=
$m_bind
->
getBindingPhoneList
(
'b.id'
,
$where_bind
);
$id_arr
=
$m_bind
->
getBindingPhoneList
(
'b.id'
,
$where_bind
);
foreach
(
$id_arr
as
$k
=>
$v
)
{
foreach
(
$id_arr
[
'data'
]
as
$k
=>
$v
)
{
$id
[
$k
]
=
$v
[
'id'
];
//去除phone_a已经绑定的号码
$id
[
$k
]
=
$v
[
'id'
];
//去除phone_a已经绑定的号码
}
}
...
@@ -59,6 +59,65 @@ class AliYunPhone extends BaseModel
...
@@ -59,6 +59,65 @@ class AliYunPhone extends BaseModel
return
$result
;
return
$result
;
}
}
/**
* 获取未绑定的手机号码
*
* @param $phone_a
* @param $phone_b
* @param int $type
* @param array $phone_x
* @return mixed
*/
public
function
getAliYunPhoneAll
(
$phone_a
,
$phone_b
,
$type
=
1
,
$phone_x
=
[])
{
$result
[
'data'
]
=
[];
$m_bind
=
new
BindingPhone
();
//尝试多次绑定,去除已经绑定失败的号码
if
(
!
empty
(
$phone_x
))
{
$where_bind_a
[
'b.phone_x'
]
=
[
'NOT IN'
,
$phone_x
];
$where_bind_b
[
'b.phone_x'
]
=
[
'NOT IN'
,
$phone_x
];
}
//找到与phone_a绑定的隐私号码
$where_bind_a
[
'a.phone_a'
]
=
$phone_a
;
$where_bind_a
[
'a.status'
]
=
1
;
$where_bind_a
[
'b.type'
]
=
$type
;
$id_arr_a
=
$m_bind
->
getBindingPhoneList
(
'b.id'
,
$where_bind_a
);
//找到phone_b绑定的隐私号码
$where_bind_b
[
'a.phone_a'
]
=
$phone_b
;
$where_bind_b
[
'a.status'
]
=
1
;
$where_bind_b
[
'b.type'
]
=
$type
;
$id_arr_b
=
$m_bind
->
getBindingPhoneList
(
'b.id'
,
$where_bind_a
);
$id_merge
=
array_merge
(
$id_arr_a
[
'data'
],
$id_arr_b
[
'data'
]);
foreach
(
$id_merge
as
$k
=>
$v
)
{
$id
[
$k
]
=
$v
[
'id'
];
//去除phone_a已经绑定的号码
}
$id
=
empty
(
$id
)
?
0
:
$id
;
$where_phone
[
'status'
]
=
0
;
$where_phone
[
'type'
]
=
$type
;
try
{
if
(
empty
(
$id
))
{
$result
[
'data'
]
=
$this
->
field
(
'id,phone_x,area'
)
->
where
(
$where_phone
)
->
find
();
}
else
{
$where_phone
[
'id'
]
=
[
'NOT IN'
,
$id
];
//排除已经绑定的号码
$result
[
'data'
]
=
$this
->
field
(
'id,phone_x,area'
)
->
where
(
$where_phone
)
->
find
();
}
$result
[
'status'
]
=
'successful'
;
}
catch
(
\Exception
$e
)
{
$result
[
'status'
]
=
'fail'
;
$result
[
'msg'
]
=
$e
->
getMessage
();
}
return
$result
;
}
/**
/**
* 绑定手机号列表
* 绑定手机号列表
*
*
...
...
application/model/BindingPhone.php
View file @
5e8e396b
...
@@ -108,19 +108,26 @@ class BindingPhone extends BaseModel
...
@@ -108,19 +108,26 @@ class BindingPhone extends BaseModel
}
}
/**
/**
* 获取绑定信息
*
* @param $field
* @param $field
* @param $where
* @param $where
* @return false|\PDOStatement|string|\think\Collection
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
*/
public
function
getBindingPhoneList
(
$field
,
$where
)
public
function
getBindingPhoneList
(
$field
,
$where
)
{
{
return
$this
->
field
(
$field
)
->
alias
(
'a'
)
$data
[
'data'
]
=
[];
->
join
(
'aliYun_phone b'
,
'a.aliYun_phone_id = b.id'
,
'left'
)
try
{
->
where
(
$where
)
$data
[
'data'
]
=
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
select
();
->
join
(
'aliYun_phone b'
,
'a.aliYun_phone_id = b.id'
,
'left'
)
->
where
(
$where
)
->
select
();
$data
[
'status'
]
=
'successful'
;
}
catch
(
\Exception
$e
)
{
$data
[
'status'
]
=
'fail'
;
$data
[
'msg'
]
=
$e
->
getMessage
();
}
return
$data
;
}
}
/**
/**
...
...
application/task/controller/PrivacyNumber.php
View file @
5e8e396b
...
@@ -149,7 +149,7 @@ class PrivacyNumber
...
@@ -149,7 +149,7 @@ class PrivacyNumber
$binding_phone_id
=
[];
$binding_phone_id
=
[];
$phone_id
=
[];
$phone_id
=
[];
$bind
=
new
BindingPhone
();
$bind
=
new
BindingPhone
();
foreach
(
$bind_data
as
$k
=>
$v
)
{
foreach
(
$bind_data
[
'data'
]
as
$k
=>
$v
)
{
//解除绑定
//解除绑定
if
(
$v
[
'type'
]
==
1
&&
!
empty
(
$v
[
'subsId'
]))
{
if
(
$v
[
'type'
]
==
1
&&
!
empty
(
$v
[
'subsId'
]))
{
//释放阿里云隐私号码
//释放阿里云隐私号码
...
@@ -284,7 +284,7 @@ class PrivacyNumber
...
@@ -284,7 +284,7 @@ class PrivacyNumber
$where
[
'a.expiry_date'
]
=
[
'<'
,
date
(
'Y-m-d H:i:s'
)
];
$where
[
'a.expiry_date'
]
=
[
'<'
,
date
(
'Y-m-d H:i:s'
)
];
$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
[
'data'
]
as
$k
=>
$v
)
{
$query_status
=
PlsDemo
::
querySubscriptionDetail
(
$v
[
'subsId'
],
$v
[
'phone_x'
]);
$query_status
=
PlsDemo
::
querySubscriptionDetail
(
$v
[
'subsId'
],
$v
[
'phone_x'
]);
if
(
isset
(
$query_status
->
Code
)
&&
(
$query_status
->
Code
!=
'OK'
))
{
if
(
isset
(
$query_status
->
Code
)
&&
(
$query_status
->
Code
!=
'OK'
))
{
$m_bind
->
unBindTable
(
$v
[
'id'
],
$v
[
'aliYun_phone_id'
]);
$m_bind
->
unBindTable
(
$v
[
'id'
],
$v
[
'aliYun_phone_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