Commit 467b2661 authored by hujun's avatar hujun

后台客户跟进查缓存

parent 99d36ae7
...@@ -10,13 +10,12 @@ namespace app\index\controller; ...@@ -10,13 +10,12 @@ namespace app\index\controller;
use app\api_broker\service\CallPhoneService; use app\api_broker\service\CallPhoneService;
use app\api_broker\service\ClientService; use app\api_broker\service\ClientService;
use app\extra\RedisExt; use app\api_broker\service\RedisCacheService;
use app\api_broker\service\VerifyRepetitionService;
use app\index\extend\Basic; use app\index\extend\Basic;
use app\index\service\PhoneFollowUpService; use app\index\service\PhoneFollowUpService;
use app\index\service\UserLogService;
use app\index\service\UserService; use app\index\service\UserService;
use app\model\AAgents; use app\model\AAgents;
use app\model\AAgentsPhone;
use app\model\ASite; use app\model\ASite;
use app\model\GOperatingRecords; use app\model\GOperatingRecords;
use app\model\Remarks; use app\model\Remarks;
...@@ -56,9 +55,6 @@ class Remark extends Basic ...@@ -56,9 +55,6 @@ class Remark extends Basic
} }
} }
$m_user = new Users();
$m_agent = new AAgents();
$code = 200; $code = 200;
$msg = ''; $msg = '';
...@@ -78,12 +74,6 @@ class Remark extends Basic ...@@ -78,12 +74,6 @@ class Remark extends Basic
if (!empty($this->params['content'])) { if (!empty($this->params['content'])) {
$where['content'] = $this->params['content']; $where['content'] = $this->params['content'];
} }
// if (!empty($this->params['remark_store_id'])) {
// $where['store_id'] = (int)$this->params['remark_store_id'];
// }
// if (!empty($this->params['remark_district_id'])) {
// $where['district_id'] = (int)$this->params['remark_district_id'];
// }
//有权限的人可以查看其它城市的跟进 //有权限的人可以查看其它城市的跟进
if (!empty($this->params['site_id'])) { if (!empty($this->params['site_id'])) {
...@@ -94,7 +84,7 @@ class Remark extends Basic ...@@ -94,7 +84,7 @@ class Remark extends Basic
if (date('Y-m-d') == $this->params['start_date'] && date('Y-m-d') == $this->params['end_date']) { if (date('Y-m-d') == $this->params['start_date'] && date('Y-m-d') == $this->params['end_date']) {
$is_today = false; $is_today = false;
} }
$result = [];
if ($site_id == "10001" && ($this->params['agent_id'] > 0 || !empty($this->params["content"])) && $is_today && empty($this->params['user_id'])) { if ($site_id == "10001" && ($this->params['agent_id'] > 0 || !empty($this->params["content"])) && $is_today && empty($this->params['user_id'])) {
$searchService = new SearchService(); $searchService = new SearchService();
$this->params['search_content'] = $this->params['content']; $this->params['search_content'] = $this->params['content'];
...@@ -106,32 +96,38 @@ class Remark extends Basic ...@@ -106,32 +96,38 @@ class Remark extends Basic
$if_search = true; $if_search = true;
} else { } else {
$follow_up_service = new PhoneFollowUpService($site_id); $follow_up_service = new PhoneFollowUpService($site_id);
$result_data = $follow_up_service->getPhoneFollowList($this->params['start_date'], $this->params['end_date'], $where, $this->userId); $result_list = $follow_up_service->getPhoneFollowList($this->params['start_date'], $this->params['end_date'], $where, $this->userId);
if ($result_data['code'] == 200) { if ($result_list['code'] == 200) {
$result = $result_data['data']; $result = $result_list['data'];
} else { } else {
$result = [];
$code = 101; $code = 101;
$msg = $result_data['data']; $msg = $result_list['msg'];
} }
} }
if ($result) { if ($result) {
$redis_service = new RedisCacheService();
$s_user_service = new UserService();
$s_user_Log_service = new UserLogService();
$call = new CallPhoneService();
$label_data = $redis_service->userCallLabelCache();
foreach ($result as $k => $v) { foreach ($result as $k => $v) {
$user_data = $agent_data = [];
if (!empty($v['user_id'])) { if (!empty($v['user_id'])) {
$user_data = $m_user->getUserById('user_name,user_phone,vip,agent_id,create_time', $v['user_id']); $user_data = $redis_service->getRedisCache(1, $v['user_id']);
$list[$k]['user_name'] = $user_data['user_name']; $list[$k]['user_name'] = $user_data['user_name'];
$list[$k]['user_phone'] = $user_data['user_phone']; } else {
$list[$k]['u_create_time'] = $user_data['create_time']; $list[$k]['user_name'] = '';
$list[$k]['vip'] = $user_data['vip']; }
$list[$k]['agent_id'] = $user_data['agent_id']; //客户客方
if (!empty($v['agent_id'])) {
$agent_data = $redis_service->getRedisCache(2, $v['agent_id']);
$list[$k]['admin'] = $agent_data['name'];
} else {
$list[$k]['admin'] = '';
} }
$list[$k]['user_phone'] = substr_replace($list[$k]['user_phone'], '****', 3, 4);
$list[$k]['admin'] = $m_agent->getAgentsById($v['agent_id'], 'name');
$list[$k]['label_name'] = $v['label_name'];
$list[$k]['is_outstrip_twenty_four_hours'] = $v['is_outstrip_twenty_four_hours'];
$list[$k]['is_outpace_call_num'] = $v['is_outpace_call_num'];
$list[$k]['user_id'] = $v['user_id']; $list[$k]['user_id'] = $v['user_id'];
$list[$k]['content'] = $v['content']; $list[$k]['content'] = $v['content'];
$list[$k]['user_status'] = $v['user_status']; $list[$k]['user_status'] = $v['user_status'];
...@@ -142,6 +138,20 @@ class Remark extends Basic ...@@ -142,6 +138,20 @@ class Remark extends Basic
} else { } else {
$list[$k]['create_time'] = $v['create_time']; $list[$k]['create_time'] = $v['create_time'];
} }
#客户是否在保护期内(0:保护器内 1:超过保护期)
$list[$k]['is_outstrip_twenty_four_hours'] = $s_user_service->isUserProtect($v['user_id']);
#判断当天被拨打是否超过5次,同时判断是否当前经纪人跟当前客户是否有电话绑定(0允许拨打 1不允许拨打)
$list[$k]['is_outpace_call_num'] = $s_user_Log_service->userDetailIsOutpaceCallNum($v['user_id'],$user_data['user_phone'], $this->userId);
if ($list[$k]['is_outpace_call_num']) {
$result = $call->checkBindRedis($this->userId, $agent_data['phone_list'], $v['user_phone']);
if($result != ''){
$list[$k]['is_outpace_call_num'] = 0;
}
}
$list[$k]['label_name'] = array_key_exists($v['labels_id'], $label_data) ? $label_data[$v['labels_id']] : '';
} }
} }
$data['data']['list'] = $list; $data['data']['list'] = $list;
......
...@@ -54,11 +54,11 @@ class PhoneFollowUpService ...@@ -54,11 +54,11 @@ class PhoneFollowUpService
if($is_bool) { if($is_bool) {
$msg = "高峰期间每10秒钟只能搜索一次(6.30-8.30)"; $msg = "高峰期间每10秒钟只能搜索一次(6.30-8.30)";
} }
return ['code'=>'101','data'=>$msg]; return ['code'=>'101','msg'=>$msg];
} }
$where = ' 1=1 '; $where = ' 1=1 ';
if (empty($start_time) || empty($end_time)) { if (empty($start_time) || empty($end_time)) {
return ['code'=>'101','data'=>'时间不能为空']; return ['code'=>'101','msg'=>'时间不能为空'];
} else { } else {
$where .= ' AND create_time BETWEEN "'.$start_time.' 00:00:00" AND "'.$end_time. ' 23:59:59"'; $where .= ' AND create_time BETWEEN "'.$start_time.' 00:00:00" AND "'.$end_time. ' 23:59:59"';
} }
...@@ -89,7 +89,7 @@ class PhoneFollowUpService ...@@ -89,7 +89,7 @@ class PhoneFollowUpService
$agent_id = $m_agent->getAgentsByWhereColumn($agent_where, 'id'); $agent_id = $m_agent->getAgentsByWhereColumn($agent_where, 'id');
if (empty($agent_id)) { if (empty($agent_id)) {
return ['code'=>'101','data'=>'暂无数据']; return ['code'=>'101','msg'=>'暂无数据'];
} else { } else {
$agent_id_string = implode(',', $agent_id); $agent_id_string = implode(',', $agent_id);
$where .= " AND agent_id in ({$agent_id_string})"; $where .= " AND agent_id in ({$agent_id_string})";
...@@ -103,20 +103,6 @@ class PhoneFollowUpService ...@@ -103,20 +103,6 @@ class PhoneFollowUpService
$data = $this->phoneFollowUp->getFollowList($page_no, $page_size, $order_ = '', $field, $where); $data = $this->phoneFollowUp->getFollowList($page_no, $page_size, $order_ = '', $field, $where);
} }
$s_user_service = new UserService();
$s_user_Log_service = new UserLogService();
$m_user = new Users();
$m_label = new ULabels();
$label_data = $m_label->getColumn('id,name', ['type'=>1]); //获取标签
foreach ($data as $k => $v) {
#客户是否在保护期内(0:保护器内 1:超过保护期)
$data[$k]['is_outstrip_twenty_four_hours'] = $s_user_service->isUserProtect($v['user_id']);
#判断当天被拨打是否超过5次,同时判断是否当前经纪人跟当前客户是否有电话绑定(0允许拨打 1不允许拨打)
$user_res = $m_user->getUserDetailStreamline($v['user_id'], 'user_name,user_phone');
$data[$k]['is_outpace_call_num'] = $s_user_Log_service->userDetailIsOutpaceCallNum($v['user_id'],$user_res['user_phone'], $agent_id);
$data[$k]['label_name'] = array_key_exists($v['labels_id'], $label_data) ? $label_data[$v['labels_id']] : '';
}
return ['code'=>'200','data'=>$data]; return ['code'=>'200','data'=>$data];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment