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
8c23baae
Commit
8c23baae
authored
Jun 21, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
绑定手机号修改
parent
c124d813
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
107 additions
and
72 deletions
+107
-72
CellPhone.php
application/api_broker/controller/CellPhone.php
+57
-68
PlsDemo.php
application/api_broker/untils/PlsDemo.php
+1
-1
BindingPhone.php
application/model/BindingPhone.php
+49
-3
No files found.
application/api_broker/controller/CellPhone.php
View file @
8c23baae
...
@@ -26,7 +26,7 @@ class CellPhone extends Basic
...
@@ -26,7 +26,7 @@ class CellPhone extends Basic
/**
/**
* 绑定手机号
* 绑定手机号
* 解绑之后有延迟
* 解绑之后有延迟
(15s)
*
*
* @return \think\Response
* @return \think\Response
* @throws \think\Exception
* @throws \think\Exception
...
@@ -37,58 +37,49 @@ class CellPhone extends Basic
...
@@ -37,58 +37,49 @@ class CellPhone extends Basic
public
function
bindAXB
()
public
function
bindAXB
()
{
{
header
(
'Access-Control-Allow-Origin:*'
);
header
(
'Access-Control-Allow-Origin:*'
);
$params
=
$this
->
request
->
param
();
if
(
empty
(
$
params
[
'phone_a'
])
||
empty
(
$
params
[
'phone_b'
]))
{
if
(
empty
(
$
this
->
params
[
'phone_a'
])
||
empty
(
$this
->
params
[
'phone_b'
]))
{
$this
->
code
=
101
;
$this
->
code
=
101
;
$this
->
msg
=
'phone_a or phone_b is null'
;
$this
->
msg
=
'phone_a or phone_b is null'
;
return
$this
->
response
(
101
,
'参数错误,请联系运营人员!'
);
return
$this
->
response
(
101
,
'参数错误,请联系运营人员!'
);
}
}
$phone_a
=
$this
->
params
[
'phone_a'
];
//经纪人手机号
$phone_a
=
$this
->
params
[
'phone_a'
];
//经纪人手机号
$phone_b
=
$this
->
params
[
'phone_b'
];
//客户手机号
$phone_b
=
$this
->
params
[
'phone_b'
];
//客户手机号
$record
=
true
;
//是否录音
$record
=
true
;
//是否录音
$redis
=
RedisExt
::
getRedis
();
$redis
=
RedisExt
::
getRedis
();
$is_privacy
=
$redis
->
get
(
's_is_privacy'
);
$is_privacy
=
$redis
->
get
(
's_is_privacy'
);
//0不使用隐私号码 1阿里云 2容联云
//0不使用隐私号码 1阿里云 2容联云
if
(
$is_privacy
==
0
)
{
if
(
$is_privacy
==
0
)
{
$this
->
data
=
[
'phone'
=>
$phone_b
];
$this
->
data
=
[
'phone'
=>
$phone_b
];
$m_report
=
new
SecretReport
();
$m_report
=
new
SecretReport
();
$report_data
[
'phone_no'
]
=
$phone_a
;
$report_data
[
'phone_no'
]
=
$phone_a
;
$report_data
[
'secret_no'
]
=
$phone_b
;
$report_data
[
'secret_no'
]
=
$phone_b
;
$report_data
[
'peer_no'
]
=
$phone_b
;
$report_data
[
'peer_no'
]
=
$phone_b
;
$report_data
[
'call_type'
]
=
1
;
$report_data
[
'call_type'
]
=
1
;
$report_data
[
'record_down'
]
=
3
;
$report_data
[
'record_down'
]
=
3
;
$m_report
->
editData
(
$report_data
);
//记录不使用隐号拨打记录
$m_report
->
editData
(
$report_data
);
//记录不使用隐号拨打记录
return
$this
->
response
(
$this
->
code
,
$this
->
msg
,
$this
->
data
);
return
$this
->
response
(
$this
->
code
,
$this
->
msg
,
$this
->
data
);
}
}
$aliYunPhone
=
new
AliYunPhone
();
$bind
=
new
BindingPhone
();
$bind
=
new
BindingPhone
();
$where
[
'a.status'
]
=
1
;
$where
[
'a.status'
]
=
1
;
$where
[
'a.phone_a'
]
=
$phone_a
;
$where
[
'a.phone_a'
]
=
$phone_a
;
$where
[
'a.phone_b'
]
=
$phone_b
;
$where
[
'a.phone_b'
]
=
$phone_b
;
$where
[
'a.type'
]
=
$is_privacy
;
$where
[
'a.type'
]
=
$is_privacy
;
$phone_x
=
$bind
->
getPhoneX
(
'b.phone_x'
,
$where
);
//已经绑定的返回隐私号码
$phone_x
=
$bind
->
getPhoneX
(
'b.phone_x'
,
$where
);
//已经绑定的返回隐私号码
if
(
!
empty
(
$phone_x
[
'phone_x'
]))
{
if
(
!
empty
(
$phone_x
[
'phone_x'
]))
{
$this
->
data
=
[
'phone'
=>
$phone_x
[
'phone_x'
]];
$this
->
data
=
[
'phone'
=>
$phone_x
[
'phone_x'
]
];
$this
->
msg
=
'已绑定,返回隐私号码。'
;
return
$this
->
response
(
$this
->
code
,
$this
->
msg
,
$this
->
data
);
//绑定过了,返回隐号
return
$this
->
response
(
$this
->
code
,
$this
->
msg
,
$this
->
data
);
//绑定过了,返回隐号
}
}
$phone_x
=
$aliYunPhone
->
getAliYunPhone
(
$phone_a
,
$phone_b
,
$is_privacy
);
//获取未绑定隐号
if
(
empty
(
$phone_x
))
{
$this
->
code
=
102
;
$this
->
msg
=
'号码使用完,请联系运营人员。'
;
return
$this
->
response
(
$this
->
code
,
$this
->
msg
,
$this
->
data
);
}
$day_num
=
$redis
->
get
(
's_day_num'
);
$day_num
=
$redis
->
get
(
's_day_num'
);
if
(
empty
(
$day_num
))
{
if
(
empty
(
$day_num
))
{
...
@@ -98,43 +89,37 @@ class CellPhone extends Basic
...
@@ -98,43 +89,37 @@ class CellPhone extends Basic
$day_num
+=
1
;
$day_num
+=
1
;
}
else
{
}
else
{
$landlord_phone_day
=
$redis
->
get
(
'landlord_phone_day'
);
$landlord_phone_day
=
$redis
->
get
(
'landlord_phone_day'
);
$day_num
=
$landlord_phone_day
+
1
;
$day_num
=
$landlord_phone_day
+
1
;
}
}
$time
=
date
(
'Y-m-d H:i:s'
,
strtotime
(
"+
{
$day_num
}
day"
));
$time
=
date
(
'Y-m-d H:i:s'
,
strtotime
(
"+
{
$day_num
}
day"
));
}
}
if
(
$is_privacy
==
1
)
{
if
(
$is_privacy
==
1
)
{
/*阿里云*/
/*阿里云*/
$result
=
PlsDemo
::
bindAxb
(
$phone_a
,
$phone_b
,
$time
,
$record
,
$phone_x
[
'phone_x'
]);
if
(
$result
->
Message
==
'OK'
)
{
$aliYunPhone
->
editStatus
(
$phone_x
,
$phone_a
,
$phone_b
,
$record
,
$time
,
$result
,
''
,
$is_privacy
);
//记录绑定
$this
->
msg
=
'绑定成功。'
;
$this
->
data
=
[
'phone'
=>
$phone_x
[
'phone_x'
]];
}
else
{
$phone_x_array
[]
=
$phone_x
[
'phone_x'
];
try
{
//尝试5次绑定
$result
=
PlsDemo
::
bindAxb
(
$phone_a
,
$phone_b
,
$time
,
$record
);
for
(
$i
=
1
;
$i
<
5
;
$i
++
)
{
}
catch
(
\Exception
$e
)
{
$phone_x
=
$aliYunPhone
->
getAliYunPhone
(
$phone_a
,
$phone_b
,
$is_privacy
,
$phone_x_array
);
return
$this
->
response
(
101
,
'参数异常,无法呼叫,请联系运营人员!'
);
$result
=
PlsDemo
::
bindAxb
(
$phone_a
,
$phone_b
,
$time
,
$record
,
$phone_x
);
//再尝试一下
}
if
(
$result
->
Message
==
'OK'
)
{
$aliYunPhone
->
editStatus
(
$phone_x
,
$phone_a
,
$phone_b
,
$record
,
$time
,
$result
,
''
,
$is_privacy
);
//记录绑定
$this
->
msg
=
'绑定成功。'
;
$this
->
data
=
[
'phone'
=>
$phone_x
[
'phone_x'
]];
break
;
}
else
{
$phone_x_array
[]
=
$phone_x
;
//记录绑定冲突号码,重新分配
}
}
if
(
$result
->
Message
!=
'OK'
)
{
if
(
$result
->
Code
==
'OK'
)
{
$this
->
code
=
101
;
//记录绑定
$this
->
msg
=
'拨号失败,10秒再试,再无法拨号请联系请联系运营人员!'
;
$bind
->
recordBindPhone
(
$result
->
SecretBindDTO
->
SecretNo
,
$phone_a
,
$phone_b
,
$record
,
$time
,
$result
,
''
,
$is_privacy
);
}
$this
->
msg
=
'绑定成功。'
;
$this
->
data
=
[
'phone'
=>
$result
->
SecretBindDTO
->
SecretNo
];
}
elseif
(
$result
->
Code
==
'isv.NO_AVAILABLE_NUMBER'
)
{
$this
->
code
=
101
;
$this
->
msg
=
'号码使用完,请联系运营人员。'
;
}
else
{
$this
->
code
=
101
;
$this
->
msg
=
'拨号失败,15秒再试,再无法拨号请联系请联系运营人员!'
;
}
}
}
else
{
}
else
{
/*容联云*/
/*容联云*/
$Rong
=
new
RongDemo
();
$Rong
=
new
RongDemo
();
$record2
=
empty
(
$this
->
params
[
'record'
])
?
'true'
:
'false'
;
/* 是否录音(容联云规定string类型)*/
$record2
=
empty
(
$this
->
params
[
'record'
])
?
'true'
:
'false'
;
/* 是否录音(容联云规定string类型)*/
/*计算有效期*/
/*计算有效期*/
...
@@ -147,12 +132,13 @@ class CellPhone extends Basic
...
@@ -147,12 +132,13 @@ class CellPhone extends Basic
/*绑定成功*/
/*绑定成功*/
if
(
$result
[
'statusCode'
]
==
'000000'
)
{
if
(
$result
[
'statusCode'
]
==
'000000'
)
{
$aliYunPhone
=
new
AliYunPhone
();
$aliYunPhone
->
editStatus
(
$phone_x
,
$phone_a
,
$phone_b
,
$record
,
$time
,
0
,
$result
[
'data'
][
'mappingId'
],
$is_privacy
);
//记录绑定
$aliYunPhone
->
editStatus
(
$phone_x
,
$phone_a
,
$phone_b
,
$record
,
$time
,
0
,
$result
[
'data'
][
'mappingId'
],
$is_privacy
);
//记录绑定
$this
->
msg
=
'Binding Rong success'
;
$this
->
msg
=
'Binding Rong success'
;
$this
->
data
=
[
'phone'
=>
$phone_x
[
'phone_x'
]
];
$this
->
data
=
[
'phone'
=>
$phone_x
[
'phone_x'
]
];
}
else
{
}
else
{
$this
->
code
=
101
;
$this
->
code
=
101
;
$this
->
msg
=
'操作频繁,请10秒后再操作。'
;
$this
->
msg
=
'操作频繁,请10秒后再操作。'
;
}
}
}
}
...
@@ -184,12 +170,12 @@ class CellPhone extends Basic
...
@@ -184,12 +170,12 @@ class CellPhone extends Basic
$this
->
msg
=
'ok'
;
$this
->
msg
=
'ok'
;
}
else
{
}
else
{
$this
->
code
=
101
;
$this
->
code
=
101
;
$this
->
msg
=
'update bind is error'
;
$this
->
msg
=
'update bind is error'
;
}
}
}
else
{
}
else
{
$this
->
code
=
101
;
$this
->
code
=
101
;
$this
->
msg
=
'phone is null'
;
$this
->
msg
=
'phone is null'
;
}
}
return
$this
->
response
(
$this
->
code
,
$this
->
msg
,
$this
->
data
);
return
$this
->
response
(
$this
->
code
,
$this
->
msg
,
$this
->
data
);
}
}
...
@@ -209,14 +195,14 @@ class CellPhone extends Basic
...
@@ -209,14 +195,14 @@ class CellPhone extends Basic
if
(
empty
(
$phone_x
)
||
empty
(
$phone_a
)
||
empty
(
$phone_b
))
{
if
(
empty
(
$phone_x
)
||
empty
(
$phone_a
)
||
empty
(
$phone_b
))
{
$this
->
code
=
101
;
$this
->
code
=
101
;
$this
->
msg
=
'解除关系参数错误,请联系运营人员!'
;
$this
->
msg
=
'解除关系参数错误,请联系运营人员!'
;
return
$this
->
response
(
$this
->
code
,
$this
->
msg
);
return
$this
->
response
(
$this
->
code
,
$this
->
msg
);
}
}
$phone
=
new
BindingPhone
();
$phone
=
new
BindingPhone
();
$redis
=
RedisExt
::
getRedis
();
$redis
=
RedisExt
::
getRedis
();
$is_privacy
=
$redis
->
get
(
's_is_privacy'
);
$is_privacy
=
$redis
->
get
(
's_is_privacy'
);
$is_privacy
=
$is_privacy
!=
'0'
?
$is_privacy
:
0
;
if
(
$is_privacy
==
1
)
{
if
(
$is_privacy
==
1
)
{
/*阿里云*/
/*阿里云*/
$subsId
=
$phone
->
getSubsId
(
$phone_x
,
$phone_a
,
$phone_b
,
1
,
'subsId'
);
$subsId
=
$phone
->
getSubsId
(
$phone_x
,
$phone_a
,
$phone_b
,
1
,
'subsId'
);
...
@@ -226,16 +212,16 @@ class CellPhone extends Basic
...
@@ -226,16 +212,16 @@ class CellPhone extends Basic
$phone
->
unBind
(
$phone_x
,
$phone_a
,
$phone_b
);
$phone
->
unBind
(
$phone_x
,
$phone_a
,
$phone_b
);
}
else
{
}
else
{
$this
->
code
=
101
;
$this
->
code
=
101
;
$this
->
msg
=
'解除绑定关系失败,请联系运营!'
;
$this
->
msg
=
'解除绑定关系失败,请联系运营!'
;
}
}
}
else
{
}
else
{
$this
->
code
=
200
;
$this
->
code
=
200
;
$this
->
msg
=
'没有号码绑定关系,请忽略!。'
;
$this
->
msg
=
'没有号码绑定关系,请忽略!。'
;
}
}
}
else
{
}
else
if
(
$is_privacy
==
2
)
{
/*容联云*/
/*容联云*/
$mappingId
=
$phone
->
getSubsId
(
$phone_x
,
$phone_a
,
$phone_b
,
1
,
'mappingId'
);
$mappingId
=
$phone
->
getSubsId
(
$phone_x
,
$phone_a
,
$phone_b
,
1
,
'mappingId'
);
$Rong
=
new
RongDemo
();
$Rong
=
new
RongDemo
();
if
(
$mappingId
)
{
if
(
$mappingId
)
{
$result
=
$Rong
->
releaseNumber
(
$mappingId
);
/*解绑*/
$result
=
$Rong
->
releaseNumber
(
$mappingId
);
/*解绑*/
...
@@ -244,14 +230,17 @@ class CellPhone extends Basic
...
@@ -244,14 +230,17 @@ class CellPhone extends Basic
$phone
->
unBind
(
$phone_x
,
$phone_a
,
$phone_b
);
$phone
->
unBind
(
$phone_x
,
$phone_a
,
$phone_b
);
}
else
{
}
else
{
$this
->
code
=
101
;
$this
->
code
=
101
;
$this
->
msg
=
'remove binding error'
;
$this
->
msg
=
'remove binding error'
;
}
}
}
else
{
}
else
{
$this
->
code
=
101
;
$this
->
code
=
101
;
$this
->
msg
=
'dont\'t have about phone_x info'
;
$this
->
msg
=
'dont\'t have about phone_x info'
;
}
}
}
else
{
$this
->
code
=
200
;
$this
->
msg
=
'没有号码绑定关系,请忽略!。'
;
}
}
$this
->
params
[
'phone_x'
];
return
$this
->
response
(
$this
->
code
,
$this
->
msg
);
return
$this
->
response
(
$this
->
code
,
$this
->
msg
);
}
}
...
@@ -276,8 +265,8 @@ class CellPhone extends Basic
...
@@ -276,8 +265,8 @@ class CellPhone extends Basic
if
(
$this
->
request
->
isGet
())
{
if
(
$this
->
request
->
isGet
())
{
$where
[
'agents_id'
]
=
$this
->
params
[
'agents_id'
];
$where
[
'agents_id'
]
=
$this
->
params
[
'agents_id'
];
$where
[
'status'
]
=
0
;
$where
[
'status'
]
=
0
;
$this
->
data
=
$agents_phone
->
getList
(
1
,
3
,
'id asc'
,
'id,phone'
,
$where
);
$this
->
data
=
$agents_phone
->
getList
(
1
,
3
,
'id asc'
,
'id,phone'
,
$where
);
}
else
{
}
else
{
if
(
$this
->
params
[
'type'
]
==
'delete'
)
{
if
(
$this
->
params
[
'type'
]
==
'delete'
)
{
$this
->
data
=
$agents_phone
->
delPhone
(
$this
->
params
[
'agents_id'
],
$this
->
params
[
'phone'
]);
$this
->
data
=
$agents_phone
->
delPhone
(
$this
->
params
[
'agents_id'
],
$this
->
params
[
'phone'
]);
...
...
application/api_broker/untils/PlsDemo.php
View file @
8c23baae
...
@@ -80,7 +80,7 @@ class PlsDemo
...
@@ -80,7 +80,7 @@ class PlsDemo
* @param string $phoneNoX 中间号码
* @param string $phoneNoX 中间号码
* @return mixed|\SimpleXMLElement
* @return mixed|\SimpleXMLElement
*/
*/
public
static
function
bindAxb
(
$phoneA
,
$phoneB
,
$time
,
$isRecordingEnabled
=
false
,
$phoneNoX
=
'
17091955105
'
)
{
public
static
function
bindAxb
(
$phoneA
,
$phoneB
,
$time
,
$isRecordingEnabled
=
false
,
$phoneNoX
=
''
)
{
//组装请求对象-具体描述见控制台-文档部分内容
//组装请求对象-具体描述见控制台-文档部分内容
$request
=
new
BindAxbRequest
();
$request
=
new
BindAxbRequest
();
...
...
application/model/BindingPhone.php
View file @
8c23baae
...
@@ -88,18 +88,19 @@ class BindingPhone extends BaseModel
...
@@ -88,18 +88,19 @@ class BindingPhone extends BaseModel
/**
/**
* 获取phone_x
* 获取phone_x
*
*
* @param $field
* @param
string
$field
* @param $where
* @param
array
$where
* @return array|false|\PDOStatement|string|\think\Model
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
getPhoneX
(
$field
,
$where
)
{
public
function
getPhoneX
(
$field
=
''
,
$where
=
[]
)
{
return
$this
->
alias
(
'a'
)
return
$this
->
alias
(
'a'
)
->
field
(
$field
)
->
field
(
$field
)
->
join
(
'aliYun_phone b'
,
'a.aliYun_phone_id=b.id'
,
'left'
)
->
join
(
'aliYun_phone b'
,
'a.aliYun_phone_id=b.id'
,
'left'
)
->
where
(
$where
)
->
where
(
$where
)
->
order
(
'a.id desc'
)
->
find
();
->
find
();
}
}
...
@@ -137,4 +138,48 @@ class BindingPhone extends BaseModel
...
@@ -137,4 +138,48 @@ class BindingPhone extends BaseModel
$this
->
update
([
'status'
=>
0
,
'id'
=>
$id
]);
$this
->
update
([
'status'
=>
0
,
'id'
=>
$id
]);
return
;
return
;
}
}
/**
* @param $phone_x
* @param $phone_a
* @param $phone_b
* @param $record
* @param $time
* @param $result
* @param string $mappingId
* @param int $type
* @return int|string
*/
/**
* @param $phone_x
* @param $phone_a
* @param $phone_b
* @param $record
* @param $time
* @param $result
* @param string $mappingId
* @param int $type
* @return int|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
recordBindPhone
(
$phone_x
,
$phone_a
,
$phone_b
,
$record
,
$time
,
$result
,
$mappingId
=
''
,
$type
=
1
)
{
$m_ali_phone
=
new
AliYunPhone
();
$phone_id
=
$m_ali_phone
->
field
(
'id,bind_num'
)
->
where
(
'phone_x'
,
$phone_x
)
->
find
();
$phone_id
[
'bind_num'
]
+=
1
;
$m_ali_phone
->
where
(
'id'
,
$phone_id
[
'id'
])
->
update
([
'bind_num'
=>
$phone_id
[
'bind_num'
]]);
$insert_data
[
'phone_a'
]
=
$phone_a
;
$insert_data
[
'phone_b'
]
=
$phone_b
;
$insert_data
[
'subsId'
]
=
$result
->
SecretBindDTO
->
SubsId
;
$insert_data
[
'requestId'
]
=
$result
->
RequestId
;
$insert_data
[
'mappingId'
]
=
$mappingId
;
$insert_data
[
'record'
]
=
$record
;
$insert_data
[
'aliYun_phone_id'
]
=
$phone_id
[
'id'
];
$insert_data
[
'expiry_date'
]
=
$time
;
$insert_data
[
'type'
]
=
$type
;
$insert_data
[
'status'
]
=
1
;
return
$this
->
insert
(
$insert_data
);
}
}
}
\ 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