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
90996260
Commit
90996260
authored
Jul 10, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
拨打电话service
parent
ac468a92
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
247 additions
and
9 deletions
+247
-9
CellPhone.php
application/api_broker/controller/CellPhone.php
+2
-2
CallPhoneService.php
application/api_broker/service/CallPhoneService.php
+237
-0
BindingPhone.php
application/model/BindingPhone.php
+8
-7
No files found.
application/api_broker/controller/CellPhone.php
View file @
90996260
...
...
@@ -110,7 +110,7 @@ class CellPhone extends Basic
if
(
$result
->
Code
==
'OK'
)
{
//记录绑定
$bind
->
recordBindPhone
(
$result
->
SecretBindDTO
->
SecretNo
,
$phone_a
,
$phone_b
,
$record
,
$time
,
$result
,
''
,
$is_privacy
,
$release
);
$bind
->
recordBindPhone
(
$result
->
SecretBindDTO
->
SecretNo
,
$phone_a
,
$phone_b
,
$record
,
$time
,
$result
->
SecretBindDTO
->
SubsId
,
$result
->
RequestId
,
''
,
$is_privacy
,
$release
);
$this
->
msg
=
'绑定成功。'
;
$this
->
data
=
[
'phone'
=>
$result
->
SecretBindDTO
->
SecretNo
];
...
...
@@ -150,7 +150,7 @@ class CellPhone extends Basic
$result
=
$Rong
->
setNumber
(
$phone_a
,
$phone_b
,
$phone_x
[
'phone_x'
],
$phone_x
[
'area'
],
$time
,
$record2
);
if
(
$result
[
'statusCode'
]
==
'000000'
)
{
$bind
->
recordBindPhone
(
$phone_x
[
'phone_x'
],
$phone_a
,
$phone_b
,
$record
,
$time
,
0
,
$result
[
'data'
][
'mappingId'
],
$is_privacy
,
$release
);
//记录绑定
$bind
->
recordBindPhone
(
$phone_x
[
'phone_x'
],
$phone_a
,
$phone_b
,
$record
,
$time
,
''
,
''
,
$result
[
'data'
][
'mappingId'
],
$is_privacy
,
$release
);
//记录绑定
$this
->
msg
=
'绑定成功'
;
$this
->
data
=
[
'phone'
=>
$phone_x
[
'phone_x'
]
];
return
$this
->
response
(
$this
->
code
,
$this
->
msg
,
$this
->
data
);
...
...
application/api_broker/service/CallPhoneService.php
0 → 100644
View file @
90996260
<?php
/**
* Created by PhpStorm.
* User: fuju
* Date: 2018/7/9
* Time: 16:28
*/
namespace
app\api_broker\service
;
use
app\api_broker\untils\PlsDemo
;
use
app\api_broker\untils\RongDemo
;
use
app\extra\RedisExt
;
use
app\model\AliYunPhone
;
use
app\model\BindingPhone
;
use
app\model\SecretReport
;
class
CallPhoneService
{
private
$phone_a
=
''
;
private
$phone_b
=
''
;
private
$expiry_date
=
''
;
private
$record
=
true
;
private
$release
=
1
;
private
$subs_id
=
''
;
private
$request_id
=
''
;
private
$mapping_id
=
''
;
private
$is_privacy
=
0
;
//0直接拨打号码1阿里云隐私号码2容联云隐私号码
/**
* 绑定AXB手机号
*
* @param $phone_a
* @param $phone_b
* @param bool $record
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
bindAXB
(
$phone_a
,
$phone_b
,
$record
=
true
)
{
$result
[
'status'
]
=
'failed'
;
if
(
empty
(
$phone_a
)
||
empty
(
$phone_b
))
{
$result
[
'msg'
]
=
'参数错误,请联系运营人员!'
;
return
$result
;
}
if
((
strlen
(
$phone_a
)
!=
11
)
||
(
strlen
(
$phone_b
)
!=
11
))
{
$result
[
'msg'
]
=
'号码格式错误,请联系运营人员!'
;
return
$result
;
}
$call_phone
=
[];
$this
->
phone_a
=
$phone_a
;
//经纪人手机号
$this
->
phone_b
=
$phone_b
;
//客户手机号
$this
->
record
=
$record
;
//是否录音
$redis
=
RedisExt
::
getRedis
();
$this
->
is_privacy
=
$redis
->
get
(
's_is_privacy'
);
//0不使用隐私号码 1阿里云 2容联云
if
(
$this
->
is_privacy
==
0
)
{
$this
->
originalPhone
();
$result
[
'status'
]
=
'success'
;
$result
[
'phone'
]
=
$phone_b
;
return
$result
;
}
$bind
=
new
BindingPhone
();
$where
[
'a.status'
]
=
1
;
$where
[
'a.phone_a'
]
=
$phone_a
;
$where
[
'a.phone_b'
]
=
$phone_b
;
$where
[
'a.type'
]
=
$this
->
is_privacy
;
$phone_x
=
$bind
->
getPhoneX
(
'b.phone_x'
,
$where
);
//已经绑定的返回隐私号码
if
(
!
empty
(
$phone_x
[
'phone_x'
]))
{
$result
[
'status'
]
=
'success'
;
$result
[
'data'
][
'phone'
]
=
$phone_x
[
'phone_x'
];
$result
[
'msg'
]
=
'已绑定,返回隐私号码。'
;
return
$result
;
//绑定过了,返回隐号
}
$day_num
=
$redis
->
get
(
's_day_num'
);
$this
->
release
=
1
;
//是否释放
if
(
empty
(
$day_num
))
{
$this
->
expiry_date
=
_EXPIRATION
;
}
else
{
if
(
empty
(
$this
->
params
[
'landlord'
]))
{
$this
->
expiry_date
=
date
(
'Y-m-d H:i:s'
,
strtotime
(
"+
{
$day_num
}
day"
));
}
else
{
$day_num
=
$redis
->
get
(
's_landlord_phone_day'
);
if
(
$day_num
==
0
)
{
$this
->
expiry_date
=
date
(
'Y-m-d H:i:s'
,
time
()
+
5
);
$this
->
release
=
0
;
}
else
{
$this
->
expiry_date
=
date
(
'Y-m-d H:i:s'
,
strtotime
(
"+
{
$day_num
}
day"
));
}
}
}
if
(
$this
->
is_privacy
==
1
)
{
/*阿里云*/
$call_phone
=
$this
->
aliYunBind
();
if
(
$call_phone
[
'status'
]
==
'success'
)
{
$result
[
'status'
]
=
'success'
;
$result
[
'phone'
]
=
$call_phone
[
'phone'
];
$result
[
'msg'
]
=
$call_phone
[
'msg'
];
}
else
{
$result
[
'msg'
]
=
$call_phone
[
'msg'
];
}
}
elseif
(
$this
->
is_privacy
==
2
)
{
$call_phone
=
$this
->
yunTongXun
();
if
(
$call_phone
[
'status'
]
==
'success'
)
{
$result
[
'status'
]
=
'success'
;
$result
[
'phone'
]
=
$call_phone
[
'phone'
];
$result
[
'msg'
]
=
$call_phone
[
'msg'
];
}
else
{
$result
[
'msg'
]
=
$call_phone
[
'msg'
];
}
}
if
(
$result
[
'status'
]
==
'success'
)
$bind
->
recordBindPhone
(
$call_phone
[
'phone'
],
$phone_a
,
$phone_b
,
$record
,
$this
->
expiry_date
,
$this
->
subs_id
,
$this
->
request_id
,
$this
->
mapping_id
,
$this
->
is_privacy
,
$this
->
release
);
return
$result
;
}
/**
* @return mixed|\SimpleXMLElement
*/
public
function
aliYunBind
()
{
$data
[
'status'
]
=
'failed'
;
try
{
$result
=
PlsDemo
::
bindAxb
(
$this
->
phone_a
,
$this
->
phone_b
,
$this
->
expiry_date
,
$this
->
record
);
if
(
$result
->
Code
==
'OK'
)
{
$data
[
'status'
]
=
'success'
;
$data
[
'msg'
]
=
'绑定成功。'
;
$data
[
'phone'
]
=
$result
->
SecretBindDTO
->
SecretNo
;
$this
->
subs_id
=
$result
->
SecretBindDTO
->
SubsId
;
$this
->
request_id
=
$result
->
RequestId
;
}
elseif
(
$result
->
Code
==
'isv.NO_AVAILABLE_NUMBER'
)
{
$data
[
'msg'
]
=
'号码使用完,请联系运营人员。'
;
}
else
{
$data
[
'msg'
]
=
'拨号失败,15秒再试,再无法拨号请联系请联系运营人员!'
;
}
}
catch
(
\Exception
$e
)
{
$data
[
'msg'
]
=
'参数异常,无法呼叫,请联系运营人员!'
;
}
return
$data
;
}
/**
* 容联云
*
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
yunTongXun
()
{
$yun_tong_xun
=
new
RongDemo
();
if
(
$this
->
record
)
{
$record
=
'true'
;
}
else
{
$record
=
'false'
;
}
$aliYunPhone
=
new
AliYunPhone
();
$phone_x
=
$aliYunPhone
->
getAliYunPhone
(
$this
->
phone_a
,
$this
->
phone_b
,
$this
->
is_privacy
);
//获取未绑定隐号
$result
=
$yun_tong_xun
->
setNumber
(
$this
->
phone_a
,
$this
->
phone_b
,
$phone_x
[
'phone_x'
],
$phone_x
[
'area'
],
$this
->
expiry_date
,
$record
);
/*绑定成功*/
if
(
$result
[
'statusCode'
]
==
'000000'
)
{
$data
[
'status'
]
=
'success'
;
$data
[
'msg'
]
=
'绑定成功。'
;
$data
[
'phone'
]
=
$phone_x
[
'phone_x'
];
$this
->
mapping_id
=
$result
[
'data'
][
'mappingId'
];
}
else
{
$phone_x_arr
[]
=
$phone_x
[
'phone_x'
];
//剔除绑定失败的中间号
//尝试5次再绑定
for
(
$i
=
0
;
$i
<
5
;
$i
++
)
{
$phone_x
=
$aliYunPhone
->
getAliYunPhone
(
$this
->
phone_a
,
$this
->
phone_b
,
$this
->
is_privacy
,
$phone_x_arr
);
//获取未绑定隐号
$result
=
$yun_tong_xun
->
setNumber
(
$this
->
phone_a
,
$this
->
phone_b
,
$phone_x
[
'phone_x'
],
$phone_x
[
'area'
],
$this
->
expiry_date
,
$record
);
if
(
$result
[
'statusCode'
]
==
'000000'
)
{
$data
[
'status'
]
=
'success'
;
$data
[
'msg'
]
=
'绑定成功。'
;
$data
[
'phone'
]
=
$phone_x
[
'phone_x'
];
$this
->
mapping_id
=
$result
[
'data'
][
'mappingId'
];
break
;
}
else
{
$phone_x_arr
[]
=
$phone_x
[
'phone_x'
];
//剔除绑定失败的中间号
}
}
//绑定失败返回错误信息
$data
[
'status'
]
=
'failed'
;
$data
[
'msg'
]
=
'拨号失败,15秒再试,再无法拨号请联系请联系运营人员!'
;
}
return
$data
;
}
/**
* 直接拨打号码记录
*
* @return false|int
*/
private
function
originalPhone
()
{
$m_report
=
new
SecretReport
();
$report_data
[
'phone_no'
]
=
$this
->
phone_a
;
$report_data
[
'secret_no'
]
=
$this
->
phone_b
;
$report_data
[
'peer_no'
]
=
$this
->
phone_b
;
$report_data
[
'call_type'
]
=
1
;
$report_data
[
'record_down'
]
=
3
;
return
$m_report
->
editData
(
$report_data
);
//记录不使用隐号拨打记录
}
}
\ No newline at end of file
application/model/BindingPhone.php
View file @
90996260
...
...
@@ -150,16 +150,17 @@ class BindingPhone extends BaseModel
* @param $phone_b
* @param $record
* @param $time
* @param $result
* @param string $mappingId
* @param $subs_id
* @param $request_id
* @param string $mapping_id
* @param int $type
* @param int $status
绑定状态
* @param int $status
* @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
,
$mappingI
d
=
''
,
$type
=
1
,
$status
=
1
)
public
function
recordBindPhone
(
$phone_x
,
$phone_a
,
$phone_b
,
$record
,
$time
,
$
subs_id
,
$request_id
,
$mapping_i
d
=
''
,
$type
=
1
,
$status
=
1
)
{
$m_ali_phone
=
new
AliYunPhone
();
$phone_id
=
$m_ali_phone
->
field
(
'id,bind_num'
)
->
where
(
'phone_x'
,
$phone_x
)
->
find
();
...
...
@@ -168,9 +169,9 @@ class BindingPhone extends BaseModel
$insert_data
[
'phone_a'
]
=
$phone_a
;
$insert_data
[
'phone_b'
]
=
$phone_b
;
$insert_data
[
'subsId'
]
=
$
result
->
SecretBindDTO
->
SubsI
d
;
$insert_data
[
'requestId'
]
=
$re
sult
->
RequestI
d
;
$insert_data
[
'mappingId'
]
=
$mapping
I
d
;
$insert_data
[
'subsId'
]
=
$
subs_i
d
;
$insert_data
[
'requestId'
]
=
$re
quest_i
d
;
$insert_data
[
'mappingId'
]
=
$mapping
_i
d
;
$insert_data
[
'record'
]
=
$record
;
$insert_data
[
'aliYun_phone_id'
]
=
$phone_id
[
'id'
];
$insert_data
[
'expiry_date'
]
=
$time
;
...
...
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