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
2f7720df
Commit
2f7720df
authored
Oct 16, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
拨打电话记录redis
parent
f82db868
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
116 additions
and
18 deletions
+116
-18
CellPhone.php
application/api_broker/controller/CellPhone.php
+1
-1
CallPhoneService.php
application/api_broker/service/CallPhoneService.php
+103
-6
CellPhone.php
application/index/controller/CellPhone.php
+1
-1
BindingPhone.php
application/model/BindingPhone.php
+11
-10
No files found.
application/api_broker/controller/CellPhone.php
View file @
2f7720df
...
...
@@ -94,7 +94,7 @@ class CellPhone extends Basic
header
(
'Access-Control-Allow-Origin:*'
);
$call
=
new
CallPhoneService
();
$result
=
$call
->
agentsUnBind
(
$this
->
params
[
'phone_a'
],
$this
->
params
[
'phone_b'
],
$this
->
params
[
'phone_x'
],
$this
->
params
[
'user_id'
]
);
$result
=
$call
->
agentsUnBind
Redis
(
$this
->
params
[
'phone_a'
],
$this
->
params
[
'phone_b'
],
$this
->
params
[
'phone_x'
],
$this
->
params
[
'user_id'
],
$this
->
agentId
);
if
(
$result
[
'status'
]
==
'success'
)
{
$this
->
msg
=
$result
[
'msg'
];
...
...
application/api_broker/service/CallPhoneService.php
View file @
2f7720df
...
...
@@ -123,13 +123,18 @@ class CallPhoneService
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
=
$this
->
redis
->
get
(
'call_'
.
$agent_id
.
'_'
.
$this
->
phone_a
.
'_'
.
$this
->
phone_b
);
$phone_x
=
$bind
->
getPhoneX
(
'b.phone_x'
,
$where
);
//已经绑定的返回隐私号码
if
(
empty
(
$phone_x
))
{
$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_arr
=
$bind
->
getPhoneX
(
'b.phone_x'
,
$where
);
//已经绑定的返回隐私号码
$phone_x
=
$phone_x_arr
[
'phone_x'
];
}
if
(
!
empty
(
$phone_x
[
'phone_x'
]))
{
$result
[
'status'
]
=
'success'
;
...
...
@@ -287,6 +292,98 @@ class CallPhoneService
return
$data
;
}
/**
* 解除(redis)中绑定关系
*
* @param $phone_a
* @param $phone_b
* @param $phone_x
* @param $user_id
* @param $agent_id
* @return mixed
*/
public
function
agentsUnBindRedis
(
$phone_a
,
$phone_b
,
$phone_x
,
$user_id
,
$agent_id
)
{
$data
[
'status'
]
=
'success'
;
$data
[
'msg'
]
=
''
;
if
(
empty
(
$phone_x
))
{
$data
[
'status'
]
=
'failed'
;
$data
[
'msg'
]
=
'解除失败,请联系运营人员!'
;
return
$data
;
}
if
(
empty
(
$phone_a
))
{
$data
[
'status'
]
=
'failed'
;
$data
[
'msg'
]
=
'解除失败,请联系运营人员!'
;
return
$data
;
}
$this
->
phone_a
=
$phone_a
;
$this
->
phone_x
=
$phone_x
;
if
(
empty
(
$phone_b
))
{
if
(
!
empty
(
$user_id
))
{
$this
->
user_id
=
$user_id
;
$user_data
=
$this
->
getUserData
();
if
(
empty
(
$user_data
[
'user_phone'
]))
{
$data
[
'status'
]
=
'failed'
;
$data
[
'msg'
]
=
'没有客户信息,可以忽略。'
;
return
$data
;
}
$this
->
phone_b
=
$user_data
[
'user_phone'
];
}
}
else
{
$this
->
phone_b
=
$phone_b
;
}
if
(
empty
(
$this
->
phone_b
))
{
$data
[
'status'
]
=
'failed'
;
$data
[
'msg'
]
=
'解除失败,请联系运营人员!'
;
return
$data
;
}
$phone
=
new
BindingPhone
();
$call_key
=
'call_'
.
$agent_id
.
'_'
.
$this
->
phone_a
.
'_'
.
$this
->
phone_b
;
try
{
if
(
$this
->
is_privacy
==
1
)
{
/*阿里云*/
$subsId
=
$phone
->
getSubsId
(
$this
->
phone_x
,
$this
->
phone_a
,
$this
->
phone_b
,
1
,
'subsId'
);
if
(
$subsId
)
{
$result
=
PlsDemo
::
unbindSubscription
(
$subsId
,
$this
->
phone_x
);
/*解绑*/
if
(
$result
->
Message
==
'OK'
)
{
$this
->
redis
->
del
(
$call_key
);
}
else
{
$data
[
'status'
]
=
'failed'
;
$data
[
'msg'
]
=
'解除失败,如果需要继续与客户沟通,请联系运营!'
;
}
}
else
{
$data
[
'msg'
]
=
'没有号码绑定关系,请忽略!'
;
}
}
elseif
(
$this
->
is_privacy
==
2
)
{
/*容联云*/
$mappingId
=
$phone
->
getSubsId
(
$this
->
phone_x
,
$this
->
phone_a
,
$this
->
phone_b
,
1
,
'mappingId'
);
$yun_tong_xun
=
new
RongDemo
();
if
(
$mappingId
)
{
$result
=
$yun_tong_xun
->
releaseNumber
(
$mappingId
);
/*解绑*/
if
(
$result
[
'statusCode'
]
==
'000000'
)
{
$this
->
redis
->
del
(
$call_key
);
}
}
else
{
$data
[
'msg'
]
=
'没有号码绑定关系,请忽略!。'
;
}
}
else
{
$data
[
'msg'
]
=
'没有号码绑定关系,请忽略!。'
;
}
}
catch
(
\Exception
$e
)
{
$data
[
'status'
]
=
'failed'
;
$data
[
'msg'
]
=
$e
->
getMessage
();
}
return
$data
;
}
/**
* @return mixed|\SimpleXMLElement
*/
...
...
application/index/controller/CellPhone.php
View file @
2f7720df
...
...
@@ -199,7 +199,7 @@ class CellPhone extends Basic
}
$call_phone
=
new
CallPhoneService
();
$data
=
$call_phone
->
agentsUnBind
(
$this
->
params
[
'phone_a'
],
$phone_b
,
$this
->
params
[
'phone_x'
],
$user_i
d
);
$data
=
$call_phone
->
agentsUnBind
Redis
(
$this
->
params
[
'phone_a'
],
$phone_b
,
$this
->
params
[
'phone_x'
],
$user_id
,
$this
->
userI
d
);
$result
[
'msg'
]
=
''
;
if
(
$data
[
'status'
]
==
'success'
)
{
$result
[
'code'
]
=
200
;
...
...
application/model/BindingPhone.php
View file @
2f7720df
...
...
@@ -68,8 +68,8 @@ class BindingPhone extends BaseModel
$phone_data
=
$phone
->
where
(
'phone_x'
,
$phone_x
)
->
find
();
if
(
$phone_data
[
'id'
])
{
$phone_data
[
'bind_num'
]
-=
1
;
$phone_data
->
save
();
//
$phone_data['bind_num'] -= 1;
//
$phone_data->save();
$result
=
$this
->
where
([
'aliYun_phone_id'
=>
$phone_data
[
'id'
],
...
...
@@ -143,12 +143,13 @@ class BindingPhone extends BaseModel
*/
public
function
unBindTable
(
$id
,
$aliYun_phone_id
)
{
$phone
=
new
AliYunPhone
();
$phone_data
=
$phone
->
field
(
'id,bind_num'
)
->
where
(
'id'
,
$aliYun_phone_id
)
->
find
();
if
(
$phone_data
[
'id'
])
{
$phone_data
[
'bind_num'
]
-=
1
;
$phone_data
->
save
();
}
//由虚拟号码提供
// $phone = new AliYunPhone();
// $phone_data = $phone->field('id,bind_num')->where('id', $aliYun_phone_id)->find();
// if ($phone_data['id']) {
// $phone_data['bind_num'] -= 1;
// $phone_data->save();
// }
$this
->
update
([
'status'
=>
0
,
'id'
=>
$id
]);
return
;
}
...
...
@@ -173,8 +174,8 @@ class BindingPhone extends BaseModel
{
$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'
]
]);
//
$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
;
...
...
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