Commit 41fd455b authored by hujun's avatar hujun

跟进搜索时间判断

parent d75484a1
......@@ -40,156 +40,9 @@ class Remark extends Basic
if (!$this->request->isAjax()) {
return view('remark_follow_index');
}
$vrs = new VerifyRepetitionService();
$is_check = $vrs->followUpClick($this->userId);
if($this->params['pageNo'] == 1 && !$is_check){
$is_bool = $vrs->getCurrTimeSection();
$msg = "请勿频繁请求";
if($is_bool) {
$msg = "高峰期间每10秒钟只能搜索一次(6.30-8.30)";
}
return $this->response("101", $msg);
}
$u_phone_follow = new UPhoneFollowUp($this->siteId);
$user_service = new UserService();
$clientService = new ClientService();
$m_agent_phone = new AAgentsPhone();
$m_user = new Users();
$m_label = new ULabels();
$m_agent = new AAgents();
$redis = RedisExt::getRedis();
$data['status'] = 200;
$data['msg'] = '';
$agent_where = $where = [];
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
if (!empty($this->params['start_date']) && empty($this->params['end_date'])) {
$where['create_time'] = ['> time', $this->params['start_date'] . ' 00:00:00'];
}
if (!empty($this->params['end_date']) && empty($this->params['start_date'])) {
$where['create_time'] = ['< time', $this->params['end_date'] . ' 23:59:59'];;
}
if (!empty($this->params['end_date']) && !empty($this->params['start_date'])) {
$where['create_time'] = ['between', [$this->params['start_date'] . ' 00:00:00', $this->params['end_date'] . ' 23:59:59']];
}
if (!empty($this->params['content'])) {
$content = trim($this->params['content']);
$where['content'] = ['LIKE', "%{$content}%"];
}
//跟进人id
if (!empty($this->params['agent_id'])) {
$agent_where['id'] = $this->params['agent_id'];
}
//跟进人门店
if (!empty($this->params['remark_store_id'])) {
$agent_where['store_id'] = $this->params['remark_store_id'];
}
//跟进人部门
if (!empty($this->params['remark_district_id'])) {
$agent_where['district_id'] = $this->params['remark_district_id'];
}
if (!empty($this->params['disc'])) {
$where['disc'] = $this->params['disc'];
}
if (!empty($this->params['user_id'])) {
$where['user_id'] = $this->params['user_id'];
}
if (!empty($agent_where)) {
$agent_id = $m_agent->getAgentsByWhereColumn($agent_where, 'id');
if (empty($agent_id)) {
$data['data']['list'] = [];
return $this->response(200, '', $data); //处理经纪人空数据
} else {
$where['agent_id'] = ['in', $agent_id];
}
}
$field = 'id,user_id,create_time,content,user_status,labels_id,agent_id';
$list = $u_phone_follow->getFollowList($pageNo, $pageSize, $order_ = 'id desc', $field, $where);
$label_data = $m_label->getColumn('id,name', ['type'=>1]); //获取标签
$redis_service = new RedisCacheService();
$call = new CallPhoneService();
foreach ($list as $k => $v) {
if (!empty($v['user_id'])) {
$user_data = $m_user->getUserById('user_name,user_phone,vip,agent_id,create_time', $v['user_id']);
$list[$k]['user_name'] = $user_data['user_name'];
$list[$k]['user_phone'] = $user_data['user_phone'];
$list[$k]['u_create_time'] = $user_data['create_time'];
$list[$k]['vip'] = $user_data['vip'];
$list[$k]['agent_id'] = $user_data['agent_id']; //客户客方
}
//查询客户是否在保护期内
//判断客户是否超过24小时保护期间 0:保护器内 1:超过保护期
$is_outstrip_twenty_four_hours = $user_service->isUserProtect($v["user_id"]);
$list[$k]['is_outstrip_twenty_four_hours'] = $is_outstrip_twenty_four_hours;
/* 判断当天被拨打是否超过5次,同时判断是否当前经纪人跟当前客户是否有电话绑定 start*/
//0允许拨打 1不允许拨打
$is_outpace_call_num = 0;
if (!$clientService->dialTotal($v["user_id"])) {
$is_outpace_call_num = 1;
}
$agent_data = $redis_service->getRedisCache(2, $this->userId);
if (empty($agent_data)) {
$phone['phone_list'] = $m_agent->getAgentsById($this->userId, 'phone');
} else {
$phone = $agent_data['phone_list'];
}
if ($is_outpace_call_num == 1 ) {
// $is_privacy = $redis->get('s_is_privacy');//判断是否当前经纪人跟当前客户是否有电话绑定 从redis查询
// if (empty($phone)) {
// $phone = $m_agent_phone->getAgentsByWhere(['agent_id'=>$this->userId], 'phone');
// }
// $call_key = 'call_'.$this->userId.'_'.$phone.'_'.$v['user_phone'].'_'.$is_privacy;
// $redis_res = $redis->get($call_key);
$redis_res = $call->checkBindRedis($this->userId, $agent_data['phone_list'], $v['user_phone']);
if(empty($redis_res)){
$is_outpace_call_num = 1;
}
}
$list[$k]['is_outpace_call_num'] = $is_outpace_call_num;
/* 判断当天被拨打是否超过5次,同时判断是否当前经纪人跟当前客户是否有电话绑定 end*/
$list[$k]['user_phone'] = substr_replace($list[$k]['user_phone'], '****', 3, 4);
$list[$k]['admin'] = $m_agent->getAgentsById($v['agent_id'], 'name');
$data[$k]['label_name'] = array_key_exists($v['labels_id'], $label_data) ? $label_data[$v['labels_id']] : '';
}
$data['data']['list'] = $list;
$data['data']['total'] = 40000;
return $this->response(200, '成功', $data);
}
/**
* 跟进列表
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function followUpListV2()
{
if (!$this->request->isAjax()) {
return view('remark_follow_index');
if (!strtotime($this->params['start_date']) || !strtotime($this->params['end_date'])) {
return $this->response(101, '时间格式错误', []);
}
if (!empty($this->params['start_date']) || !empty($this->params['end_date'])) {
......@@ -233,6 +86,10 @@ class Remark extends Basic
$site_id = $this->params['site_id'];
}
if (empty($where)) {
return $this->response(101, '请输入查询条件', []);
}
$follow_up_service = new PhoneFollowUpService($site_id);
$result_data = $follow_up_service->getPhoneFollowList($this->params['start_date'], $this->params['end_date'], $where, $this->userId);
if ($result_data['code'] == 200) {
......
......@@ -62,7 +62,6 @@ class PhoneFollowUpService
} else {
$where .= ' AND create_time BETWEEN "'.$start_time.' 00:00:00" AND "'.$end_time. ' 23:59:59"';
}
$data = [];
if (isset($params['user_id'])) {
$where .= " AND user_id= {$params['user_id']}";
......@@ -98,16 +97,11 @@ class PhoneFollowUpService
}
$date = date("Y-m-d", time());
// if ($end_time < $date && $end_time < $date . " 23:59:59" ) {
if ($end_time == $date && $start_time == $date) {
$data = $this->phoneFollowUpTemporary->getFollowList($page_no, $page_size, $order_ = 'id desc', $field, $where);
} else {
$data = $this->phoneFollowUp->getFollowList($page_no, $page_size, $order_ = '', $field, $where);
}
// else {
// $data = $this->phoneFollowUpTemporary->getFollowListV3($this->siteId,$page_no, $page_size, $where, $field);
// }
$s_user_service = new UserService();
$s_user_Log_service = new UserLogService();
......
......@@ -204,7 +204,7 @@ Route::group('index', [
'lable' => ['index/label/index', ['method' => 'get']], //标签列表
'getDistrict' => ['index/District/getList', ['method' => 'get']], //获取部门列表
//数据统计
'RemarkFollowList' => ['index/remark/followUpListV2', ['method' => 'get']],//跟进列表
'RemarkFollowList' => ['index/remark/followUpList', ['method' => 'get']],//跟进列表
'phone_list' => ['index/Phone/index', ['method' => 'get']],//隐私号码列表
'bindPhoneList' => ['index/Phone/bindPhoneList', ['method' => 'get']],//绑定的隐私号码列表
'edit_aliYunPhone' => ['index/Phone/edit_aliYunPhone', ['method' => 'get|post']],//新增或编辑中间号
......
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