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
10b3b2db
Commit
10b3b2db
authored
Mar 08, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
隐私号码绑定逻辑修改
parent
818fa939
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
100 additions
and
39 deletions
+100
-39
CellPhone.php
application/api_broker/controller/CellPhone.php
+6
-12
AliYunPhone.php
application/model/AliYunPhone.php
+71
-15
BindingPhone.php
application/model/BindingPhone.php
+21
-9
SecretReport.php
application/model/SecretReport.php
+1
-1
PrivacyNumber.php
application/task/controller/PrivacyNumber.php
+1
-2
No files found.
application/api_broker/controller/CellPhone.php
View file @
10b3b2db
...
...
@@ -27,7 +27,9 @@ class CellPhone extends Basic
/**
* 绑定手机号
* 解绑之后有延迟
*
* @return \think\Response
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
...
...
@@ -54,7 +56,7 @@ class CellPhone extends Basic
if
(
$phone_x
)
{
$this
->
data
=
[
'phone'
=>
$phone_x
[
'phone_x'
]];
}
else
{
$phone_x
=
$aliYunPhone
->
getAliYunPhone
(
$phone_b
);
$phone_x
=
$aliYunPhone
->
getAliYunPhone
(
$phone_
a
,
$phone_
b
);
//是否还有未绑定的中间号码
if
(
$phone_x
)
{
...
...
@@ -63,19 +65,11 @@ 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);
}
$result
=
PlsDemo
::
bindAxb
(
$phone_a
,
$phone_b
,
$time
,
$record
,
$phone_x
[
'phone_x'
]);
if
(
$result
->
Message
==
'OK'
)
{
$aliYunPhone
->
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'
],
'expiry_date'
=>
$time
,
]);
$aliYunPhone
->
editStatus
(
$phone_x
,
$phone_a
,
$phone_b
,
$record
,
$time
,
$result
);
//记录绑定
$this
->
msg
=
'Binding success.'
;
$this
->
data
=
[
'phone'
=>
$phone_x
[
'phone_x'
]];
}
else
{
...
...
@@ -160,7 +154,7 @@ class CellPhone extends Basic
if
(
$subsId
)
{
$result
=
PlsDemo
::
unbindSubscription
(
$subsId
,
$phone_x
);
if
(
$result
->
Message
==
'OK'
)
{
$phone
->
UnBind
(
$phone_x
);
$phone
->
UnBind
(
$phone_x
,
$phone_a
,
$phone_b
);
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'remove binding error'
;
...
...
application/model/AliYunPhone.php
View file @
10b3b2db
...
...
@@ -18,31 +18,51 @@ class AliYunPhone extends BaseModel
/**
* 获取未绑定的手机号码
*
* @param string $phone
* @param $phone_a
* @param $phone_b
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getAliYunPhone
(
$phone
=
''
)
{
public
function
getAliYunPhone
(
$phone_a
,
$phone_b
)
{
/* //查找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();
$where
[
'status'
]
=
0
;
if
(
$phone
)
{
//查询之前一次绑定关系的号码
$phone_x
=
Db
::
table
(
'aliYun_binding_phone'
)
->
alias
(
'a'
)
->
join
(
'aliYun_phone b'
,
'a.aliYun_phone_id = b.id'
,
'left'
)
->
where
([
'phone_b'
=>
$phone
,
'a.status'
=>
0
,
'b.status'
=>
0
])
->
value
(
'phone_x'
);
//查找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();
if
(
$phone_x
)
{
$where
[
'phone_x'
]
=
$phone_x
;
$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
(
'phone_a='
.
$phone_a
.
' or phone_b='
.
$phone_b
)
->
select
();
foreach
(
$id_arr
as
$k
=>
$v
)
{
$id
[
$k
]
=
$v
[
'id'
];
//去除phone_a已经绑定的号码
}
$id
=
empty
(
$id
)
?
0
:
implode
(
','
,
$id
);
$where_phone
[
'status'
]
=
0
;
if
(
empty
(
$id
))
{
$result
=
Db
::
table
(
'aliYun_phone'
)
->
field
(
'id,phone_x'
)
->
where
(
$where_phone
)
->
find
();
}
else
{
$where_phone
[
'id'
]
=
[
'NOT IN'
,
$id
];
$result
=
Db
::
table
(
'aliYun_phone'
)
->
field
(
'id,phone_x'
)
->
where
(
$where_phone
)
->
find
();
}
$result
=
Db
::
table
(
'aliYun_phone'
)
->
field
(
'id,phone_x'
)
->
where
(
$where
)
->
find
();
return
$result
;
}
...
...
@@ -81,4 +101,39 @@ class AliYunPhone extends BaseModel
->
where
(
$where
)
->
count
();
}
/**
* 查询绑定数量
*
* @param $phone_x
* @return mixed
*/
public
function
checkNum
(
$phone_x
)
{
return
$this
->
where
(
'status'
,
0
)
->
where
(
'phone_x'
,
$phone_x
)
->
value
(
'bind_num'
);
}
/**
* 修改绑定后的数据
*
* @param $phone_x
* @param $phone_a
* @param $phone_b
* @param $record
* @param $time
* @param $result
* @throws \think\Exception
*/
public
function
editStatus
(
$phone_x
,
$phone_a
,
$phone_b
,
$record
,
$time
,
$result
)
{
$this
->
where
(
'phone_x'
,
$phone_x
[
'phone_x'
])
->
setInc
(
'bind_num'
);
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'
],
'expiry_date'
=>
$time
,
]);
return
;
}
}
\ No newline at end of file
application/model/BindingPhone.php
View file @
10b3b2db
...
...
@@ -44,21 +44,33 @@ class BindingPhone extends BaseModel
}
/**
* 释放绑定
*
* @param $phone_x
* @return bool|int
* @param string $phone_a
* @param string $phone_b
* @param string $request_id
* @return $this|bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
UnBind
(
$phone_x
)
{
public
function
UnBind
(
$phone_x
,
$phone_a
=
''
,
$phone_b
=
''
,
$request_id
=
''
)
{
if
(
$phone_x
)
{
$phone
=
new
AliYunPhone
();
$phone_data
=
$phone
->
get
([
'phone_x'
=>
$phone_x
]);
if
(
$phone_data
->
id
)
{
$phone_data
->
status
=
0
;
$phone_data
=
$phone
->
where
(
'phone_x'
,
$phone_x
)
->
find
();
if
(
$phone_data
[
'id'
])
{
$phone_data
[
'bind_num'
]
-=
1
;
$phone_data
->
save
();
$result
=
$this
->
where
([
'aliYun_phone_id'
=>
$phone_data
->
id
,
'status'
=>
1
])
->
setField
(
'status'
,
0
);
'aliYun_phone_id'
=>
$phone_data
[
'id'
],
'status'
=>
1
,
'phone_a'
=>
$phone_a
,
'phone_b'
=>
$phone_b
,
])
->
update
([
'status'
=>
0
,
'release_requestId'
=>
$request_id
]);
}
else
{
$result
=
false
;
}
...
...
@@ -81,7 +93,7 @@ class BindingPhone extends BaseModel
public
function
getPhoneX
(
$field
,
$where
)
{
return
$this
->
alias
(
'a'
)
->
field
(
$field
)
->
join
(
'aliYun_phone b'
,
'a.aliYun_phone_id=b.id'
)
->
join
(
'aliYun_phone b'
,
'a.aliYun_phone_id=b.id'
,
'left'
)
->
where
(
$where
)
->
find
();
}
...
...
application/model/SecretReport.php
View file @
10b3b2db
...
...
@@ -206,7 +206,7 @@ class SecretReport extends Model
if
(
$remainder
!=
0
)
{
$time
+=
1
;
}
$time
+=
floor
(
$v
->
time
/
60
);
$time
+=
ceil
(
$v
->
time
/
60
);
}
$price
+=
$time
*
0.06
+
$time
*
0.05
;
//通话 0.06元/分,录音 0.05元/分
}
...
...
application/task/controller/PrivacyNumber.php
View file @
10b3b2db
...
...
@@ -102,7 +102,7 @@ class PrivacyNumber
$subsId
=
$bind
->
getSubsId
(
$v
[
'phone_x'
],
$v
[
'phone_a'
],
$v
[
'phone_b'
],
1
);
$result
=
PlsDemo
::
unbindSubscription
(
$subsId
,
$v
[
'phone_x'
]);
if
(
$result
->
Message
==
'OK'
)
{
$bind
->
UnBind
(
$v
[
'phone_x'
],
$v
[
'phone_a'
],
$v
[
'phone_b'
]);
$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'
];
}
...
...
@@ -111,7 +111,6 @@ class PrivacyNumber
$id
[
'aliYun_binding_phone'
]
=
implode
(
','
,
$binding_phone_id
);
$id
[
'aliYun_phone'
]
=
implode
(
','
,
array_unique
(
$phone_id
));
Log
::
write
(
json_encode
(
$id
),
'AliYunReleaseNumber'
);
//记录日志
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