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
1c396d89
Commit
1c396d89
authored
Nov 08, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
隐私号码优化
parent
5ac421ac
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
41 deletions
+78
-41
CallPhoneService.php
application/api_broker/service/CallPhoneService.php
+0
-0
BindingPhone.php
application/model/BindingPhone.php
+27
-0
PrivacyNumber.php
application/task/controller/PrivacyNumber.php
+51
-41
No files found.
application/api_broker/service/CallPhoneService.php
View file @
1c396d89
This diff is collapsed.
Click to expand it.
application/model/BindingPhone.php
View file @
1c396d89
...
@@ -132,6 +132,33 @@ class BindingPhone extends BaseModel
...
@@ -132,6 +132,33 @@ class BindingPhone extends BaseModel
return
$data
;
return
$data
;
}
}
/**
* 获取绑定信息
*
* @param $pageNo
* @param $pageSize
* @param $field
* @param $where
* @return mixed
*/
public
function
getBindingPhoneListLimit
(
$pageNo
,
$pageSize
,
$field
,
$where
)
{
$data
[
'data'
]
=
[];
try
{
$data
[
'data'
]
=
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
'aliYun_phone b'
,
'a.aliYun_phone_id = b.id'
,
'left'
)
->
where
(
$where
)
->
page
(
$pageNo
)
->
limit
(
$pageSize
)
->
select
();
$data
[
'status'
]
=
'successful'
;
}
catch
(
\Exception
$e
)
{
$data
[
'status'
]
=
'fail'
;
$data
[
'msg'
]
=
$e
->
getMessage
();
}
return
$data
;
}
/**
/**
* 更新绑定号码与阿里云绑定不一致的问题
* 更新绑定号码与阿里云绑定不一致的问题
*
*
...
...
application/task/controller/PrivacyNumber.php
View file @
1c396d89
...
@@ -147,57 +147,67 @@ class PrivacyNumber
...
@@ -147,57 +147,67 @@ class PrivacyNumber
$m_bind
=
new
BindingPhone
();
$m_bind
=
new
BindingPhone
();
$m_agent
=
new
AAgents
();
$m_agent
=
new
AAgents
();
$m_agent_phone
=
new
AAgentsPhone
();
$m_agent_phone
=
new
AAgentsPhone
();
$date
=
date
(
'Y-m-d'
)
.
' 23:59:59'
;
$fields
=
'a.id,aliYun_phone_id,expiry_date,phone_x,phone_a,phone_b,subsId,a.type,a.mappingId'
;
$fields
=
'a.id,aliYun_phone_id,expiry_date,phone_x,phone_a,phone_b,subsId,a.type,a.mappingId'
;
$where
[
'a.status'
]
=
1
;
$where
[
'a.status'
]
=
1
;
$where
[
'a.expiry_date'
]
=
[
'<='
,
date
(
'Y-m-d'
)
.
' 23:59:59'
];
$where
[
'a.expiry_date'
]
=
[
'<='
,
$date
];
$bind_data
=
$m_bind
->
getBindingPhoneList
(
$fields
,
$where
);
$where_count
[
'status'
]
=
1
;
$binding_phone_id
=
[];
$where_count
[
'expiry_date'
]
=
[
'<='
,
$date
];
$phone_id
=
[];
$total
=
$m_bind
->
getTotal
(
$where_count
);
$bind
=
new
BindingPhone
();
$redis
=
RedisExt
::
getRedis
();
$pageSize
=
5000
;
foreach
(
$bind_data
[
'data'
]
as
$k
=>
$v
)
{
$pageTotal
=
ceil
(
$total
/
$pageSize
);
for
(
$pageNo
=
1
;
$pageNo
<=
$pageTotal
;
$pageNo
++
)
{
$agent_id
=
$m_agent
->
getAgentsByWhere
([
'status'
=>
0
,
'phone'
=>
$v
[
'phone_a'
]],
'id'
);
$bind_data
=
$m_bind
->
getBindingPhoneListLimit
(
$pageNo
,
$pageSize
,
$fields
,
$where
);
if
(
empty
(
$agent_id
))
{
$agent_id
=
$m_agent_phone
->
getAgentsByWhere
([
'status'
=>
0
,
'phone'
=>
$v
[
'phone_a'
]],
'agents_id'
);
$binding_phone_id
=
[];
}
$phone_id
=
[];
$bind
=
new
BindingPhone
();
//解除绑定
$redis
=
RedisExt
::
getRedis
();
if
(
$v
[
'type'
]
==
1
&&
!
empty
(
$v
[
'subsId'
]))
{
foreach
(
$bind_data
[
'data'
]
as
$k
=>
$v
)
{
//释放阿里云隐私号码
$agent_id
=
$m_agent
->
getAgentsByWhere
([
'status'
=>
0
,
'phone'
=>
$v
[
'phone_a'
]],
'id'
);
$result
=
PlsDemo
::
unbindSubscription
(
$v
[
'subsId'
],
$v
[
'phone_x'
]);
if
(
empty
(
$agent_id
))
{
if
(
$result
->
Message
==
'OK'
)
{
$agent_id
=
$m_agent_phone
->
getAgentsByWhere
([
'status'
=>
0
,
'phone'
=>
$v
[
'phone_a'
]],
'agents_id'
);
$bind
->
unBind
(
$v
[
'phone_x'
],
$v
[
'phone_a'
],
$v
[
'phone_b'
],
$result
->
RequestId
);
$binding_phone_id
[
$k
]
=
$v
[
'id'
];
$phone_id
[
$k
]
=
$v
[
'aliYun_phone_id'
];
}
}
$call_key
=
'call_'
.
$agent_id
.
'_'
.
$v
[
'phone_a'
]
.
'_'
.
$v
[
'phone_b'
]
.
'_1'
;
//解除绑定
$redis
->
del
(
$call_key
);
if
(
$v
[
'type'
]
==
1
&&
!
empty
(
$v
[
'subsId'
]))
{
}
elseif
(
$v
[
'type'
]
==
2
&&
!
empty
(
$v
[
'mappingId'
]))
{
//释放阿里云隐私号码
//释放容联云隐私号码
$result
=
PlsDemo
::
unbindSubscription
(
$v
[
'subsId'
],
$v
[
'phone_x'
]);
$tong_xun
=
new
RongDemo
();
if
(
$result
->
Message
==
'OK'
)
{
$result
=
$tong_xun
->
releaseNumber
(
$v
[
'mappingId'
]);
/*解绑*/
$bind
->
unBind
(
$v
[
'phone_x'
],
$v
[
'phone_a'
],
$v
[
'phone_b'
],
$result
->
RequestId
);
if
(
$result
[
'statusCode'
]
==
'000000'
)
{
$binding_phone_id
[
$k
]
=
$v
[
'id'
];
$bind
->
unBind
(
$v
[
'phone_x'
],
$v
[
'phone_a'
],
$v
[
'phone_b'
]);
$phone_id
[
$k
]
=
$v
[
'aliYun_phone_id'
];
$binding_phone_id
[
$k
]
=
$v
[
'id'
];
}
$phone_id
[
$k
]
=
$v
[
'aliYun_phone_id'
];
}
else
{
$call_key
=
'call_'
.
$agent_id
.
'_'
.
$v
[
'phone_a'
]
.
'_'
.
$v
[
'phone_b'
]
.
'_1'
;
$yun_result
=
$tong_xun
->
getBindInfo
(
$v
[
'phone_a'
],
$v
[
'phone_b'
],
$v
[
'phone_x'
],
$v
[
'mappingId'
]);
$redis
->
del
(
$call_key
);
if
(
empty
(
$yun_result
[
'data'
][
'mappingId'
]))
{
}
elseif
(
$v
[
'type'
]
==
2
&&
!
empty
(
$v
[
'mappingId'
]))
{
//释放容联云隐私号码
$tong_xun
=
new
RongDemo
();
$result
=
$tong_xun
->
releaseNumber
(
$v
[
'mappingId'
]);
/*解绑*/
if
(
$result
[
'statusCode'
]
==
'000000'
)
{
$bind
->
unBind
(
$v
[
'phone_x'
],
$v
[
'phone_a'
],
$v
[
'phone_b'
]);
$bind
->
unBind
(
$v
[
'phone_x'
],
$v
[
'phone_a'
],
$v
[
'phone_b'
]);
$binding_phone_id
[
$k
]
=
$v
[
'id'
];
$phone_id
[
$k
]
=
$v
[
'aliYun_phone_id'
];
}
else
{
$yun_result
=
$tong_xun
->
getBindInfo
(
$v
[
'phone_a'
],
$v
[
'phone_b'
],
$v
[
'phone_x'
],
$v
[
'mappingId'
]);
if
(
empty
(
$yun_result
[
'data'
][
'mappingId'
]))
{
$bind
->
unBind
(
$v
[
'phone_x'
],
$v
[
'phone_a'
],
$v
[
'phone_b'
]);
}
}
}
}
$call_key
=
'call_'
.
$agent_id
.
'_'
.
$v
[
'phone_a'
]
.
'_'
.
$v
[
'phone_b'
]
.
'_2'
;
$call_key
=
'call_'
.
$agent_id
.
'_'
.
$v
[
'phone_a'
]
.
'_'
.
$v
[
'phone_b'
]
.
'_2'
;
$redis
->
del
(
$call_key
);
$redis
->
del
(
$call_key
);
}
}
}
$id
[
'aliYun_binding_phone'
]
=
implode
(
','
,
$binding_phone_id
);
$id
[
'aliYun_phone'
]
=
implode
(
','
,
array_unique
(
$phone_id
));
Log
::
write
(
json_encode
(
$id
),
'AliYunReleaseNumber'
);
//记录日志
}
}
$id
[
'aliYun_binding_phone'
]
=
implode
(
','
,
$binding_phone_id
);
$id
[
'aliYun_phone'
]
=
implode
(
','
,
array_unique
(
$phone_id
));
Log
::
write
(
json_encode
(
$id
),
'AliYunReleaseNumber'
);
//记录日志
return
;
return
;
}
}
...
...
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