Commit 78abe69f authored by zhuwei's avatar zhuwei

1

parent 73b6e1e3
......@@ -206,15 +206,13 @@ class UserAgentService
/**
* 查客方
* @param $site_id
* @param $user_id
* @return array|false|\PDOStatement|string|\think\Model
*/
public function getUserAgentId($site_id,$user_id)
public function getUserAgentId($user_id)
{
$params['site_id'] = $site_id;
$params['user_id'] = $user_id;
$field = 'agent_id';
$params['a.user_id'] = $user_id;
$field = 'a.agent_id,b.phone';
$user_agent_info = $this->m_user_agent->getUserAgentId($field,$params);
return $user_agent_info;
}
......
......@@ -116,9 +116,7 @@ class UserLogService
$data['site_ids_name_new'] = $s_user_site->getSiteNameList($user_id);
#拨打电话按钮是否显示 0:显示 1:不显示
$s_user_agent = new UserAgentService();
$user_agent_id = $s_user_agent->getUserAgentId($site_id,$user_id);
$data['is_phone_button_show'] = $this->isPhoneButtonShow($user_id,$user_arr['user_phone'],$user_agent_id['agent_id'],$agent_id,$user_arr['vip']);
$data['is_phone_button_show'] = $this->isPhoneButtonShow($user_id,$agent_id,$user_arr['vip']);
//客方
$s_user_agent = new UserAgentService();
......@@ -268,9 +266,7 @@ class UserLogService
$result["is_outstrip_twenty_four_hours"] = $user_service->isUserProtect($user_id);
#拨打电话按钮是否显示 0:显示 1:不显示
$s_user_agent = new UserAgentService();
$user_agent_id = $s_user_agent->getUserAgentId($site_id,$user_id);
$result['is_phone_button_show'] = $this->isPhoneButtonShow($user_id,$result['user_phone'],$user_agent_id["agent_id"],$agent_id,$result['vip']);
$result['is_phone_button_show'] = $this->isPhoneButtonShow($user_id, $agent_id,$result['vip']);
#编辑客户详情权限 0:有权限 1:无权限
......@@ -333,25 +329,38 @@ class UserLogService
/**
* 拨打电话按钮是否显示
* @param $user_id
* @param $result_user_phone
* @param $result_agent_id
* @param $agent_id
* @param $is_vip
* @return int
*/
public function isPhoneButtonShow($user_id,$result_user_phone,$result_agent_id,$agent_id,$is_vip)
public function isPhoneButtonShow($user_id,$agent_id,$is_vip)
{
$user_service = new UserService();
$vip_services = new VipService();
#查询当前经纪人是否是某个客方的总监 0:可查看 1:不可查看
$is_user_agent_boss = $user_service->isUserAgentDirector($result_agent_id, $agent_id);
$s_user_agent = new UserAgentService();
$user_agent_list = $s_user_agent->getUserAgentId($user_id);
$is_user_agent_boss = 1;
$called = 1;
$user_agent_list_arr=[];
if($user_agent_list){
foreach ($user_agent_list as $key => $value) {
$user_agent_list_arr[] = $value['agent_id'];
#查询当前经纪人是否是某个客方的总监 0:可查看 1:不可查看
$agent_boss_res = $user_service->isUserAgentDirector($value['agent_id'], $agent_id);
if($agent_boss_res == 0)
$is_user_agent_boss = 0;
#是否有绑定关系 0有 1无
$called_res = $this->userDetailIsOutpaceCallNumPhone($value['phone'], $agent_id);
if($called_res == 0)
$called = 0;
}
}
#判断当天被拨打是否超过5次 (0:拨打不超过5次 1:超过5次)
$is_outpace_call_num = $this->userDetailIsOutpaceCallNum5($user_id);
#是否有绑定关系 0有 1无
$called = $this->userDetailIsOutpaceCallNumPhone($result_user_phone, $agent_id);
#客户是否在保护期内(0:保护器内 1:超过保护期)
$is_outstrip_twenty_four_hours = $user_service->isUserProtect($user_id);
......@@ -367,13 +376,13 @@ class UserLogService
OR
($is_user_agent_boss == 0)//总监可以看
OR
($result_agent_id == $agent_id)//客方可以看
in_array($agent_id, $user_agent_list_arr)//客方可以看
OR
(($is_vip == 1) and ($examine_vip == 0))
OR
(($is_outpace_call_num == 0 ) and ($is_outstrip_twenty_four_hours == 0) and (($is_user_agent_boss == 0) or ($result_agent_id == $agent_id) or ($called == 0)))
(($is_outpace_call_num == 0 ) and ($is_outstrip_twenty_four_hours == 0) and (($is_user_agent_boss == 0) or (in_array($agent_id, $user_agent_list_arr)) or ($called == 0)))
OR
(($is_outpace_call_num == 1 ) and (($is_user_agent_boss == 0) or ($result_agent_id == $agent_id) or ($called == 0)))
(($is_outpace_call_num == 1 ) and (($is_user_agent_boss == 0) or (in_array($agent_id, $user_agent_list_arr)) or ($called == 0)))
OR
($is_report == 0)
){
......
......@@ -124,7 +124,7 @@ class UserService
$user_agent_res = $s_user_agent->findUserAgent($site_id,0,$id);
if (!$user_agent_res) {
$s_user_agent->addUserAgent($data['agents_id'],$id,$site_id);
//记录修改客方
//记录新增客方
$this->recordGuest($data['agents_id'], $agent_id_old, $id, $user_name, $type);
}else{
if (!empty($data['agents_id']) && ($data['agents_id'] != $agent_id_old)) {
......
......@@ -53,8 +53,10 @@ class UserAgentModel extends Model
$params["is_del"] = 0;
$result = $this->db_
->field($field)
->alias('a')
->join('a_agents b', 'a.agent_id = b.id', 'left')
->where($params)
->find();
->select();
//echo $this->getLastSql();
return $result;
}
......
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