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
a3bdedd2
Commit
a3bdedd2
authored
Sep 14, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除房东跟进注释,代码调整
parent
7235d324
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
91 deletions
+70
-91
CallPhoneService.php
application/api_broker/service/CallPhoneService.php
+70
-91
No files found.
application/api_broker/service/CallPhoneService.php
View file @
a3bdedd2
<?php
/**
* Created by PhpStorm.
* User:
fuju
* User:
hu jun
* Date: 2018/7/9
* Time: 16:28
*/
...
...
@@ -14,7 +14,6 @@ use app\api_broker\untils\RongDemo;
use
app\extra\RedisExt
;
use
app\model\AliYunPhone
;
use
app\model\BindingPhone
;
use
app\model\GHousesFollowUp
;
use
app\model\SecretReport
;
use
app\model\UPhoneFollowPp
;
use
app\model\Users
;
...
...
@@ -35,17 +34,17 @@ class CallPhoneService
private
$request_id
=
''
;
private
$mapping_id
=
''
;
//容联云释放参数
private
$is_privacy
=
0
;
//0直接拨打号码1阿里云隐私号码2容联云隐私号码
private
$day_num
=
0
;
//号码绑定有效期
private
$day_num
=
0
;
//号码绑定有效期
private
$landlord_phone_day
=
0
;
//房东号码绑定有效期
private
$city
;
public
$redis
;
public
$redis
;
public
function
__construct
(
string
$city
=
'上海市'
)
{
$this
->
city
=
substr
(
$city
,
0
,
strpos
(
$city
,
'市'
));
//去市
$this
->
city
=
substr
(
$city
,
0
,
strpos
(
$city
,
'市'
));
//去市
$this
->
redis
=
RedisExt
::
getRedis
();
$this
->
is_privacy
=
$this
->
redis
->
get
(
's_is_privacy'
);
$this
->
day_num
=
$this
->
redis
->
get
(
's_day_num'
);
$this
->
day_num
=
$this
->
redis
->
get
(
's_day_num'
);
$this
->
landlord_phone_day
=
$this
->
redis
->
get
(
's_landlord_phone_day'
);
$this
->
is_privacy
=
empty
(
$this
->
is_privacy
)
?
0
:
$this
->
is_privacy
;
...
...
@@ -82,7 +81,7 @@ class CallPhoneService
$user_data
=
$this
->
getUserData
();
if
(
empty
(
$user_data
[
'user_phone'
]))
{
$result
[
'status'
]
=
'fail'
;
$result
[
'msg'
]
=
'没有用户信息'
;
$result
[
'msg'
]
=
'没有用户信息'
;
return
$result
;
}
...
...
@@ -104,10 +103,10 @@ class CallPhoneService
return
$result
;
}
$call_phone
=
[];
$call_phone
=
[];
$this
->
phone_a
=
$phone_a
;
//经纪人手机号
$this
->
phone_b
=
$phone_b
;
//客户手机号
$this
->
record
=
$record
;
//是否录音
$this
->
record
=
$record
;
//是否录音
$this
->
agent_id
=
$agent_id
;
$this
->
agent_name
=
$agent_name
;
try
{
...
...
@@ -119,23 +118,23 @@ class CallPhoneService
//0不使用隐私号码 1阿里云 2容联云
if
(
$this
->
is_privacy
==
0
)
{
$this
->
originalPhone
();
$result
[
'status'
]
=
'success'
;
$result
[
'phone'
]
=
$phone_b
;
$result
[
'status'
]
=
'success'
;
$result
[
'phone'
]
=
$phone_b
;
return
$result
;
}
$bind
=
new
BindingPhone
();
$where
[
'a.status'
]
=
1
;
$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
;
$where
[
'a.type'
]
=
$this
->
is_privacy
;
$phone_x
=
$bind
->
getPhoneX
(
'b.phone_x'
,
$where
);
//已经绑定的返回隐私号码
if
(
!
empty
(
$phone_x
[
'phone_x'
]))
{
$result
[
'status'
]
=
'success'
;
$result
[
'status'
]
=
'success'
;
$result
[
'phone'
]
=
$phone_x
[
'phone_x'
];
$result
[
'msg'
]
=
'已绑定,返回隐私号码。'
;
$result
[
'msg'
]
=
'已绑定,返回隐私号码。'
;
return
$result
;
//绑定过了,返回隐号
}
...
...
@@ -146,7 +145,7 @@ class CallPhoneService
if
(
$landlord
)
{
if
(
$this
->
day_num
==
0
)
{
$this
->
expiry_date
=
date
(
'Y-m-d H:i:s'
,
time
()
+
5
);
$this
->
release
=
0
;
$this
->
release
=
0
;
}
else
{
$this
->
expiry_date
=
date
(
'Y-m-d H:i:s'
,
strtotime
(
"+
{
$this
->
landlord_phone_day
}
day"
));
}
...
...
@@ -161,8 +160,8 @@ class CallPhoneService
if
(
$call_phone
[
'status'
]
==
'success'
)
{
$result
[
'status'
]
=
'success'
;
$result
[
'phone'
]
=
$call_phone
[
'phone'
];
$result
[
'msg'
]
=
$call_phone
[
'msg'
];
$result
[
'phone'
]
=
$call_phone
[
'phone'
];
$result
[
'msg'
]
=
$call_phone
[
'msg'
];
$type
=
'AliYunBindAxb'
;
}
else
{
$result
[
'msg'
]
=
$call_phone
[
'msg'
];
...
...
@@ -172,8 +171,8 @@ class CallPhoneService
if
(
$call_phone
[
'status'
]
==
'success'
)
{
$result
[
'status'
]
=
'success'
;
$result
[
'phone'
]
=
$call_phone
[
'phone'
];
$result
[
'msg'
]
=
$call_phone
[
'msg'
];
$result
[
'phone'
]
=
$call_phone
[
'phone'
];
$result
[
'msg'
]
=
$call_phone
[
'msg'
];
$type
=
'YunTongXunBindAxb'
;
}
else
{
$result
[
'msg'
]
=
$call_phone
[
'msg'
];
...
...
@@ -187,7 +186,7 @@ class CallPhoneService
Log
::
write
(
json_encode
(
$result
),
$type
);
//记录日志
}
catch
(
\Exception
$e
)
{
$data
[
'status'
]
=
'failed'
;
$data
[
'msg'
]
=
$e
->
getMessage
();
$data
[
'msg'
]
=
$e
->
getMessage
();
}
return
$result
;
...
...
@@ -205,16 +204,16 @@ class CallPhoneService
public
function
agentsUnBind
(
$phone_a
,
$phone_b
,
$phone_x
,
$user_id
)
{
$data
[
'status'
]
=
'success'
;
$data
[
'msg'
]
=
''
;
$data
[
'msg'
]
=
''
;
if
(
empty
(
$phone_x
))
{
$data
[
'status'
]
=
'failed'
;
$data
[
'msg'
]
=
'解除失败,请联系运营人员!'
;
$data
[
'msg'
]
=
'解除失败,请联系运营人员!'
;
return
$data
;
}
if
(
empty
(
$phone_a
))
{
$data
[
'status'
]
=
'failed'
;
$data
[
'msg'
]
=
'解除失败,请联系运营人员!'
;
$data
[
'msg'
]
=
'解除失败,请联系运营人员!'
;
return
$data
;
}
...
...
@@ -227,7 +226,7 @@ class CallPhoneService
$user_data
=
$this
->
getUserData
();
if
(
empty
(
$user_data
[
'user_phone'
]))
{
$data
[
'status'
]
=
'failed'
;
$data
[
'msg'
]
=
'没有客户信息,可以忽略。'
;
$data
[
'msg'
]
=
'没有客户信息,可以忽略。'
;
return
$data
;
}
...
...
@@ -239,7 +238,7 @@ class CallPhoneService
if
(
empty
(
$this
->
phone_b
))
{
$data
[
'status'
]
=
'failed'
;
$data
[
'msg'
]
=
'解除失败,请联系运营人员!'
;
$data
[
'msg'
]
=
'解除失败,请联系运营人员!'
;
return
$data
;
}
...
...
@@ -255,14 +254,14 @@ class CallPhoneService
$phone
->
unBind
(
$this
->
phone_x
,
$this
->
phone_a
,
$this
->
phone_b
);
}
else
{
$data
[
'status'
]
=
'failed'
;
$data
[
'msg'
]
=
'解除失败,如果需要继续与客户沟通,请联系运营!'
;
$data
[
'msg'
]
=
'解除失败,如果需要继续与客户沟通,请联系运营!'
;
}
}
else
{
$data
[
'msg'
]
=
'没有号码绑定关系,请忽略!'
;
}
}
elseif
(
$this
->
is_privacy
==
2
)
{
/*容联云*/
$mappingId
=
$phone
->
getSubsId
(
$this
->
phone_x
,
$this
->
phone_a
,
$this
->
phone_b
,
1
,
'mappingId'
);
$mappingId
=
$phone
->
getSubsId
(
$this
->
phone_x
,
$this
->
phone_a
,
$this
->
phone_b
,
1
,
'mappingId'
);
$yun_tong_xun
=
new
RongDemo
();
if
(
$mappingId
)
{
...
...
@@ -272,7 +271,7 @@ class CallPhoneService
$phone
->
unBind
(
$this
->
phone_x
,
$this
->
phone_a
,
$this
->
phone_b
);
}
else
{
$data
[
'status'
]
=
'failed'
;
$data
[
'msg'
]
=
'解除失败,如果需要继续与客户沟通,请联系运营!'
;
$data
[
'msg'
]
=
'解除失败,如果需要继续与客户沟通,请联系运营!'
;
}
}
else
{
$data
[
'msg'
]
=
'没有号码绑定关系,请忽略!。'
;
...
...
@@ -282,7 +281,7 @@ class CallPhoneService
}
}
catch
(
\Exception
$e
)
{
$data
[
'status'
]
=
'failed'
;
$data
[
'msg'
]
=
$e
->
getMessage
();
$data
[
'msg'
]
=
$e
->
getMessage
();
}
return
$data
;
...
...
@@ -299,10 +298,10 @@ class CallPhoneService
$result
=
PlsDemo
::
bindAxb
(
$this
->
phone_a
,
$this
->
phone_b
,
$this
->
expiry_date
,
$this
->
record
,
''
,
$this
->
city
);
if
(
$result
->
Code
==
'OK'
)
{
$data
[
'status'
]
=
'success'
;
$data
[
'msg'
]
=
'绑定成功。'
;
$data
[
'phone'
]
=
$result
->
SecretBindDTO
->
SecretNo
;
$this
->
subs_id
=
$result
->
SecretBindDTO
->
SubsId
;
$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'
]
=
'号码使用完,请联系运营人员。'
;
...
...
@@ -333,14 +332,14 @@ class CallPhoneService
}
$aliYunPhone
=
new
AliYunPhone
();
$phone_x
=
$aliYunPhone
->
getAliYunPhoneAll
(
$this
->
phone_a
,
$this
->
phone_b
,
$this
->
is_privacy
,
[],
$this
->
city
);
//获取未绑定隐号
$phone_x
=
$aliYunPhone
->
getAliYunPhoneAll
(
$this
->
phone_a
,
$this
->
phone_b
,
$this
->
is_privacy
,
[],
$this
->
city
);
//获取未绑定隐号
$result
=
$yun_tong_xun
->
setNumber
(
$this
->
phone_a
,
$this
->
phone_b
,
$phone_x
[
'data'
][
'phone_x'
],
$phone_x
[
'data'
][
'area'
],
$this
->
expiry_date
,
$record
);
/*绑定成功*/
if
(
$result
[
'statusCode'
]
==
'000000'
)
{
$data
[
'status'
]
=
'success'
;
$data
[
'msg'
]
=
'绑定成功。'
;
$data
[
'phone'
]
=
$phone_x
[
'data'
][
'phone_x'
];
$data
[
'status'
]
=
'success'
;
$data
[
'msg'
]
=
'绑定成功。'
;
$data
[
'phone'
]
=
$phone_x
[
'data'
][
'phone_x'
];
$this
->
mapping_id
=
$result
[
'data'
][
'mappingId'
];
}
else
{
...
...
@@ -348,13 +347,13 @@ class CallPhoneService
//尝试5次再绑定
for
(
$i
=
0
;
$i
<
5
;
$i
++
)
{
$phone_x
=
$aliYunPhone
->
getAliYunPhoneAll
(
$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
[
'data'
][
'phone_x'
],
$phone_x
[
'data'
][
'area'
],
$this
->
expiry_date
,
$record
);
$phone_x
=
$aliYunPhone
->
getAliYunPhoneAll
(
$this
->
phone_a
,
$this
->
phone_b
,
$this
->
is_privacy
,
$phone_x_arr
,
$this
->
city
);
//获取未绑定隐号
$result
=
$yun_tong_xun
->
setNumber
(
$this
->
phone_a
,
$this
->
phone_b
,
$phone_x
[
'data'
][
'phone_x'
],
$phone_x
[
'data'
][
'area'
],
$this
->
expiry_date
,
$record
);
if
(
$result
[
'statusCode'
]
==
'000000'
)
{
$data
[
'status'
]
=
'success'
;
$data
[
'msg'
]
=
'绑定成功。'
;
$data
[
'phone'
]
=
$phone_x
[
'data'
][
'phone_x'
];
$data
[
'status'
]
=
'success'
;
$data
[
'msg'
]
=
'绑定成功。'
;
$data
[
'phone'
]
=
$phone_x
[
'data'
][
'phone_x'
];
$this
->
mapping_id
=
$result
[
'data'
][
'mappingId'
];
break
;
}
else
{
...
...
@@ -365,7 +364,7 @@ class CallPhoneService
if
(
$data
[
'status'
]
!=
'success'
)
{
//绑定失败返回错误信息
$data
[
'status'
]
=
'failed'
;
$data
[
'msg'
]
=
$result
[
'code_msg'
];
$data
[
'msg'
]
=
$result
[
'code_msg'
];
}
}
...
...
@@ -379,11 +378,11 @@ class CallPhoneService
*/
private
function
originalPhone
()
{
$m_report
=
new
SecretReport
();
$report_data
[
'phone_no'
]
=
$this
->
phone_a
;
$report_data
[
'secret_no'
]
=
''
;
$report_data
[
'peer_no'
]
=
$this
->
phone_b
;
$report_data
[
'call_type'
]
=
1
;
$m_report
=
new
SecretReport
();
$report_data
[
'phone_no'
]
=
$this
->
phone_a
;
$report_data
[
'secret_no'
]
=
''
;
$report_data
[
'peer_no'
]
=
$this
->
phone_b
;
$report_data
[
'call_type'
]
=
1
;
$report_data
[
'record_down'
]
=
3
;
return
$m_report
->
editData
(
$report_data
);
//记录不使用隐号拨打记录
}
...
...
@@ -392,9 +391,10 @@ class CallPhoneService
* @param string $field
* @return array|false|\PDOStatement|string|\think\Model
*/
public
function
getUserData
(
$field
=
'user_phone'
)
{
public
function
getUserData
(
$field
=
'user_phone'
)
{
$m_user
=
new
Users
();
$data
=
$m_user
->
selectUser
(
$this
->
user_id
,
$field
);
$data
=
$m_user
->
selectUser
(
$this
->
user_id
,
$field
);
return
$data
;
}
...
...
@@ -406,7 +406,8 @@ class CallPhoneService
* @param $status
* @return int|string
*/
public
function
getBindNum
(
$phone_b
,
$phone_a
,
$status
=
1
)
{
public
function
getBindNum
(
$phone_b
,
$phone_a
,
$status
=
1
)
{
$m_bind
=
new
BindingPhone
();
return
$m_bind
->
getCallNumber
(
$phone_a
,
$phone_b
,
$status
);
}
...
...
@@ -414,33 +415,28 @@ class CallPhoneService
/**
* 默认跟进,供定时任务使用
*/
public
function
defaultFollowUp
()
{
$m_follow_up
=
new
UPhoneFollowPp
();
// $m_follow_house = new GHousesFollowUp();
public
function
defaultFollowUp
()
{
$m_follow_up
=
new
UPhoneFollowPp
();
$current_time
=
time
();
$time
=
$current_time
-
3600
;
$start_date
=
date
(
'Y-m-d'
,
$time
);
$end_date
=
date
(
'Y-m-d'
);
$user_key
=
'call_phone_user_'
.
$end_date
;
// $landlord_key = 'call_phone_landlord_'.$end_date;
$end_date
=
date
(
'Y-m-d'
);
$user_key
=
'call_phone_user_'
.
$end_date
;
$user_data
=
$this
->
redis
->
hKeys
(
$user_key
);
// $landlord_data = $this->redis->hKeys($landlord_key);
$content
=
'拨打电话,未打跟进。'
;
$follow_where
[
'create_time'
]
=
[
'between'
,
[
$start_date
,
$end_date
]];
//用户
if
(
!
empty
(
$user_data
))
{
foreach
(
$user_data
as
$k
=>
$v
)
{
foreach
(
$user_data
as
$k
=>
$v
)
{
$call_time
=
$this
->
redis
->
hGet
(
$user_key
,
$v
);
if
(
$current_time
-
$call_time
>
3600
)
{
$array
=
explode
(
'-'
,
$v
);
$follow_where
[
'agent_id'
]
=
$array
[
0
];
$follow_where
[
'user_id'
]
=
$array
[
1
];
$follow_where
[
'user_id'
]
=
$array
[
1
];
$num
=
$m_follow_up
->
getFollowTotal
(
$follow_where
);
if
(
empty
(
$num
)
&&
!
empty
(
$array
[
1
]))
{
...
...
@@ -451,26 +447,7 @@ class CallPhoneService
}
}
}
//房东
// if (!empty($landlord_data)) {
// foreach ($landlord_data as $k2=>$v2) {
// $call_time = $this->redis->hGet($landlord_key, $v2);
// if ($current_time - $call_time > 3600) {
// $array = explode('-', $v2);
// $follow_where['agent_id'] = $array[0];
// $follow_where['house_id'] = $array[1];
// $is = $m_follow_house->getFollowUpByHouseId($follow_where);
//
// if (!$is) {
// $m_follow_house->insertDefaultFollow($array[0], $array[1], $content, $array[3], $array[2]);
// $this->redis->hDel($landlord_key, $v2);
// }
// }
// }
// }
return
;
return
;
}
/**
...
...
@@ -482,21 +459,22 @@ class CallPhoneService
* @param $phone_b
* @param int $user_type
*/
public
function
recordCallRedis
(
$agent_id
,
$user_id
,
$phone_a
,
$phone_b
,
$user_type
=
1
)
{
public
function
recordCallRedis
(
$agent_id
,
$user_id
,
$phone_a
,
$phone_b
,
$user_type
=
1
)
{
$date
=
date
(
'Y-m-d'
);
if
(
$user_type
==
1
)
{
$key
=
'call_phone_user_'
.
$date
;
$key
=
'call_phone_user_'
.
$date
;
}
else
{
$key
=
'call_phone_landlord_'
.
$date
;
$key
=
'call_phone_landlord_'
.
$date
;
}
if
(
$user_type
==
1
)
{
$this
->
redis
->
hSet
(
$key
,
$agent_id
.
'-'
.
$user_id
,
time
());
$this
->
redis
->
hSet
(
$key
,
$agent_id
.
'-'
.
$user_id
,
time
());
}
else
{
$this
->
redis
->
hSet
(
$key
,
$agent_id
.
'-'
.
$user_id
.
'-'
.
$phone_a
.
'-'
.
$phone_b
,
time
());
$this
->
redis
->
hSet
(
$key
,
$agent_id
.
'-'
.
$user_id
.
'-'
.
$phone_a
.
'-'
.
$phone_b
,
time
());
}
return
;
return
;
}
}
\ 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