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
8439c732
Commit
8439c732
authored
Feb 23, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解除绑定关系
parent
0c7fcc15
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
131 additions
and
36 deletions
+131
-36
config.php
application/api_broker/config.php
+2
-3
CellPhone.php
application/api_broker/controller/CellPhone.php
+57
-19
PlsDemo.php
application/api_broker/untils/PlsDemo.php
+7
-6
AliYunPhone.php
application/model/AliYunPhone.php
+14
-7
BindingPhone.php
application/model/BindingPhone.php
+49
-0
route.php
application/route.php
+2
-1
No files found.
application/api_broker/config.php
View file @
8439c732
...
...
@@ -4,10 +4,10 @@ error_reporting(E_ERROR | E_PARSE);
define
(
'_MESSAGE_TYPE'
,
'SecretReport'
);
define
(
'_QUEUE_NAME'
,
'Alicom-Queue-1186048444498461-SecretReport'
);
define
(
'_EXPIRATION'
,
date
(
'Y-m-d H:i:s'
,
time
()
+
518400
));
//手机号码保留七天
define
(
'_POOLKEY'
,
'FC100000022056027'
);
define
(
'_TLSYPoolKey'
,
'FC100000022056027'
);
return
[
'jwt_key'
=>
'tonglian+123'
,
// 应用模式状态
'app_status'
=>
'dev-config'
,
'_DefaultPoolKey'
=>
'FC100000022056027'
,
'tonglianshangyePoolKey'
=>
'FC100000027622039'
];
\ No newline at end of file
application/api_broker/controller/CellPhone.php
View file @
8439c732
...
...
@@ -11,8 +11,8 @@ namespace app\api_broker\controller;
use
app\api_broker\extend\Basic
;
use
app\api_broker\untils\PlsDemo
;
use
app\model\Ali
y
unPhone
;
use
think\Config
;
use
app\model\Ali
Y
unPhone
;
use
app\model\BindingPhone
;
use
think\Db
;
class
CellPhone
extends
Basic
...
...
@@ -25,7 +25,9 @@ class CellPhone extends Basic
* 绑定手机号
*
* @return \think\Response
* @throws \Aliyun\Core\Exception\ClientException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
bindAXB
()
{
$params
=
$this
->
request
->
param
();
...
...
@@ -35,22 +37,29 @@ class CellPhone extends Basic
$phone_b
=
$this
->
params
[
'phone_b'
];
//客户手机号
$record
=
empty
(
$this
->
params
[
'record'
])
?
false
:
true
;
//是否录音
$bind
=
new
Ali
y
unPhone
();
$bind
=
new
Ali
Y
unPhone
();
$phone_x
=
$bind
->
getAliYunPhone
(
$phone_b
);
$result
=
PlsDemo
::
bindAxb
(
$phone_a
,
$phone_b
,
$expiration
,
$record
,
Config
::
get
(
'_DefaultPoolKey'
),
$phone_x
);
if
(
$result
->
Message
==
'OK'
)
{
Db
::
table
(
'aliyun_binding_phone'
)
->
save
([
'phone_a'
=>
$phone_a
,
'phone_b'
=>
$phone_b
,
'SubsId'
=>
$result
->
SecretBindDTO
->
SubsId
,
'RequestId'
=>
$result
->
RequestId
,
'record'
=>
$record
]);
$this
->
msg
=
'Binding success'
;
//是否还有未绑定的中间号码
if
(
$phone_x
)
{
$result
=
PlsDemo
::
bindAxb
(
$phone_a
,
$phone_b
,
$expiration
,
$record
,
$phone_x
[
'phone_x'
]);
if
(
$result
->
Message
==
'OK'
)
{
$bind
->
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'
]
]);
$this
->
msg
=
'Binding success.'
;
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'Binding failure.'
;
}
}
else
{
$this
->
code
=
10
1
;
$this
->
msg
=
'
Binding failure
'
;
$this
->
code
=
10
2
;
$this
->
msg
=
'
Number pool run out.
'
;
}
}
else
{
$this
->
code
=
101
;
...
...
@@ -67,8 +76,36 @@ class CellPhone extends Basic
return $this->response($this->code, $this->msg,$this->data);*/
}
/**
* 解除绑定关系
*
* @return \think\Response
* @throws \think\exception\DbException
*/
public
function
agentsUnBind
()
{
PlsDemo
::
unbindSubscription
()
;
}
$phone_x
=
$this
->
params
[
'phone_x'
]
;
$phone_a
=
$this
->
params
[
'phone_a'
];
if
(
$phone_x
)
{
$phone
=
new
BindingPhone
();
$subsId
=
$phone
->
getSubsId
(
$phone_x
,
$phone_a
,
1
);
if
(
$subsId
)
{
$result
=
PlsDemo
::
unbindSubscription
(
$subsId
,
$phone_x
);
if
(
$result
->
Message
==
'OK'
)
{
$phone
->
UnBind
(
$phone_x
);
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'remove binding error'
;
}
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'dont\'t have about phone_x info'
;
}
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'phone_x is null'
;
}
$this
->
params
[
'phone_x'
];
return
$this
->
response
(
$this
->
code
,
$this
->
msg
);
}
}
\ No newline at end of file
application/api_broker/untils/PlsDemo.php
View file @
8439c732
...
...
@@ -29,7 +29,7 @@ class PlsDemo
{
static
$acsClient
=
null
;
static
$pool_key
=
_POOLKEY
;
/**
* 取得AcsClient
*
...
...
@@ -80,13 +80,13 @@ class PlsDemo
* @param string $phoneNoX 中间号码
* @return mixed|\SimpleXMLElement
*/
public
static
function
bindAxb
(
$phoneA
,
$phoneB
,
$time
,
$isRecordingEnabled
=
false
,
$p
oolKey
=
'FC100000022056027'
,
$p
honeNoX
=
'17091955105'
)
{
public
static
function
bindAxb
(
$phoneA
,
$phoneB
,
$time
,
$isRecordingEnabled
=
false
,
$phoneNoX
=
'17091955105'
)
{
//组装请求对象-具体描述见控制台-文档部分内容
$request
=
new
BindAxbRequest
();
//必填:号池Key
$request
->
setPoolKey
(
$poolK
ey
);
$request
->
setPoolKey
(
self
::
$pool_k
ey
);
//必填:AXB关系中的A号码
$request
->
setPhoneNoA
(
$phoneA
);
...
...
@@ -162,8 +162,9 @@ class PlsDemo
/**
* 解绑接口
*
* @return stdClass
* @throws ClientException
* @param $subsId
* @param $secretNo
* @return mixed|\SimpleXMLElement
*/
public
static
function
unbindSubscription
(
$subsId
,
$secretNo
)
{
...
...
@@ -171,7 +172,7 @@ class PlsDemo
$request
=
new
UnbindSubscriptionRequest
();
//必填:号池Key
$request
->
setPoolKey
(
"FC123456"
);
$request
->
setPoolKey
(
self
::
$pool_key
);
//必填:对应的产品类型
$request
->
setProductType
(
"AXB_170"
);
...
...
application/model/Ali
y
unPhone.php
→
application/model/Ali
Y
unPhone.php
View file @
8439c732
<?php
/**
* Created by PhpStorm.
* User:
fuju
* User:
hu jun
* Date: 2018/1/20
* Time: 17:52
*/
...
...
@@ -10,8 +10,11 @@ namespace app\model;
use
think\Db
;
class
Ali
y
unPhone
extends
BaseModel
class
Ali
Y
unPhone
extends
BaseModel
{
// 设置当前模型对应的完整数据表名称
protected
$table
=
'aliYun_phone'
;
/**
* 获取未绑定的手机号码
*
...
...
@@ -22,19 +25,22 @@ class AliyunPhone extends BaseModel
* @throws \think\exception\DbException
*/
public
function
getAliYunPhone
(
$phone
=
''
)
{
$where
[
'status'
]
=
1
;
$where
[
'status'
]
=
0
;
if
(
$phone
)
{
//查询之前一次绑定关系的号码
$phone_x
=
Db
::
table
(
'ali
y
un_binding_phone'
)
->
field
(
'phone_x'
)
->
alias
(
'a'
)
->
join
(
'ali
yun_phone b'
,
'a.aliy
un_phone_id = b.id'
,
'left'
)
$phone_x
=
Db
::
table
(
'ali
Y
un_binding_phone'
)
->
field
(
'phone_x'
)
->
alias
(
'a'
)
->
join
(
'ali
Yun_phone b'
,
'a.aliY
un_phone_id = b.id'
,
'left'
)
->
where
([
'phone_b'
=>
$phone
,
'a.status'
=>
1
])
->
value
(
'phone_x'
);
$where
[
'phone_x'
]
=
$phone_x
;
if
(
$phone_x
)
{
$where
[
'phone_x'
]
=
$phone_x
;
}
}
$result
=
Db
::
table
(
'ali
yun_phone'
)
->
field
(
'
phone_x'
)
->
whereOr
(
$where
)
->
find
();
$result
=
Db
::
table
(
'ali
Yun_phone'
)
->
field
(
'id,
phone_x'
)
->
whereOr
(
$where
)
->
find
();
return
$result
;
}
}
\ No newline at end of file
application/model/BindingPhone.php
View file @
8439c732
...
...
@@ -12,4 +12,52 @@ class BindingPhone extends BaseModel
{
// 设置当前模型对应的完整数据表名称
protected
$table
=
'aliyun_binding_phone'
;
/**
* 通过阿里号码获取subsId
*
* @param $phone_x
* @param $phone_a
* @param int $status
* @return bool|mixed
*/
public
function
getSubsId
(
$phone_x
,
$phone_a
,
$status
=
0
)
{
if
(
$phone_x
&&
$phone_a
)
{
$subsId
=
$this
->
alias
(
'a'
)
->
join
(
'aliYun_phone b'
,
'a.aliYun_phone_id=b.id'
,
'left'
)
->
where
([
'a.status'
=>
$status
,
'phone_x'
=>
$phone_x
,
'phone_a'
=>
$phone_a
])
->
value
(
'subsId'
);
}
else
{
$subsId
=
false
;
}
return
$subsId
;
}
/**
* @param $phone_x
* @return bool|int
* @throws \think\exception\DbException
*/
public
function
UnBind
(
$phone_x
)
{
if
(
$phone_x
)
{
$phone
=
new
AliYunPhone
();
$phone_data
=
$phone
->
get
([
'phone_x'
=>
$phone_x
]);
if
(
$phone_data
->
id
)
{
$phone_data
->
status
=
0
;
$phone_data
->
save
();
$result
=
$this
->
where
([
'aliYun_phone_id'
=>
$phone_data
->
id
,
'status'
=>
1
])
->
setField
(
'status'
,
0
);
}
else
{
$result
=
false
;
}
}
else
{
$result
=
false
;
}
return
$result
;
}
}
\ No newline at end of file
application/route.php
View file @
8439c732
...
...
@@ -228,7 +228,8 @@ Route::group('broker', [
'add_phone_follow_up'
=>
[
'api_broker/broker/add_phone_follow_up'
,[
'method'
=>
'get|post'
]],
//新增-客户电话跟进
'user_search'
=>
[
'api_broker/broker/user_search'
,[
'method'
=>
'get|post'
]],
//客户搜索
'agentUserTb'
=>
[
'api_broker/Client/agentUserTb'
,
[
'method'
=>
'get'
]
],
//客户列表
'bindAXB'
=>
[
'api_broker/CellPhone/bindAXB'
,
[
'method'
=>
'post'
]
],
//客户列表
'bindAXB'
=>
[
'api_broker/CellPhone/bindAXB'
,
[
'method'
=>
'post'
]
],
//隐私号码
'agentsUnBind'
=>
[
'api_broker/CellPhone/agentsUnBind'
,
[
'method'
=>
'post'
]
],
//解除绑定关系
]);
...
...
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