Commit 247f5dd7 authored by zhuwei's avatar zhuwei

1

parent 0bc65be9
......@@ -19,6 +19,7 @@ use app\model\UPhoneFollowPp;
use app\model\UPhoneFollowUp;
use app\model\UserAgentModel;
use app\model\Users;
use app\model\UserSiteModel;
use think\Log;
use think\Request;
......@@ -227,12 +228,236 @@ class User extends Basic
}
//客户站点
// if (isset($params['site_id']) ) {
// $site_ids = $params['site_id'];
// }else{
// $site_ids = $this->siteId;
// }
//
// $user_id_str = $this->getSiteUserList($site_ids);
// // big_log($user_id_str);
// if($user_id_str){
// $conditions['id'] = ['in', $user_id_str];
// }else{
// if (isset($params['site_id']) ) {
// $conditions['site_ids'] = [ 'LIKE', '%' . $params['site_id'] . '%' ];
// }else{
// $conditions['site_ids'] = [ 'LIKE', '%' . $this->siteId . '%' ];
// }
// }
if (isset($params['site_id']) ) {
$conditions['site_ids'] = [ 'LIKE', '%' . $params['site_id'] . '%' ];
}else{
$conditions['site_ids'] = [ 'LIKE', '%' . $this->siteId . '%' ];
}
//委托类型
if(isset($params['entrust_type']) && is_numeric($params['entrust_type'])){
$conditions['entrust_type'] =$params['entrust_type'];
}
}
// big_log($conditions);
$field = "id as user_id,sex,user_name,city,user_phone,user_status,agent_id,create_time,industry_type,
price_demand,area_demand,vip,user_label,source_intro,site_ids,entrust_type,concrete_industry";
$return_user_list = $this->userModel->selectUserList($field, $conditions, $pageNo, $pageSize, "id desc");
if (empty($return_user_list)) {
return $this->response("200", "此条件没有找到数据");
}
// 将经纪人所在城市的客户拍前面
if (($app_request_source_type == 0) && (!isset($params["agent_id"]))) {
$return_user_list = $this->userSequenceByCity($return_user_list,$params['site_id']);
}
$clientService = new ClientService();
$user_service = new UserService();
foreach ($return_user_list as $k => $v) {
/*判断是否纯房东 0:否 1:是 start*/
$is_single_homeowner = 0;
if ($v['user_label'] == 2) {
//source 41纯房东
$is_single_homeowner = 1;
}
$return_user_list[$k]['is_single_homeowner'] = $is_single_homeowner;
/*判断是否纯房东 end*/
$is_show = $clientService->dialTotal($v["user_id"]);
$return_user_list[$k]['sign_call'] = $is_show ? 0 : 1;
//查询客户是否在保护期内 0:保护期内 1:超过保护期
$is_outstrip_twenty_four_hours = $user_service->isUserProtect($v["user_id"]);
$return_user_list[$k]['is_outstrip_twenty_four_hours'] = $is_outstrip_twenty_four_hours;
$return_user_list[$k]['is_can_look'] = $user_service->isUserAgentDirector($v["agent_id"], $this->agentId);
$return_user_list[$k]['user_phone'] = substr_replace($return_user_list[$k]['user_phone'], '****', 3, 4);
$return_user_list[$k]['site_ids_name'] = $user_service->userSiteName($v["site_ids"]);
$return_user_list[$k]['user_name'] = $v['user_name'] && $v['entrust_type'] == 0 ?"{$v['concrete_industry']},{$v['user_name']}":$v['user_name'];
}
$vip_services = new VipService();
$data['examine_vip'] = $vip_services->vip($this->agentId);
$data['user_date'] = $return_user_list;
$data['total_page'] = count($return_user_list);
return $this->response("200", 'request success', $data);
}
public function searchUserV2()
{
$params = $this->params;
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
#接口调用类型 0:客户搜索 1:全部客户 2:我的客户
$app_request_source_type = isset($params["app_request_source_type"]) && is_numeric($params["app_request_source_type"])? $params["app_request_source_type"] : 1;
$conditions = [];
switch ($app_request_source_type) {
case 0:
$pageNo = 1;
$pageSize = 50;
if (isset($params['id'])) {
$conditions['id'] = $params['id'];
}
if (isset($params['user_name'])) {
if (strlen($params['user_name']) > 20) {
return $this->response(101, '输入内容长度超限');
}
$conditions['user_name'] = array( "like", "%" . trim($params['user_name']) . "%" );
}
if (isset($params['user_nick'])) {
if (strlen($params['user_nick']) > 20) {
return $this->response(101, '输入内容长度超限');
}
$conditions['user_nick'] = array( "like", "%" . trim($params['user_nick']) . "%" );
}
if (isset($params['user_phone'])) {
if (!is_numeric($params['user_phone'])) {
return $this->response(101, '请输入正确手机号');
}
if (strlen($params['user_phone']) > 20) {
return $this->response(101, '输入内容长度超限');
}
$conditions['user_phone'] = array( "like", "%" . trim($params['user_phone']) . "%" );
}
//具体业态搜索
if (isset($params['concrete_industry']) ) {
if (strlen($params['concrete_industry']) > 20) {
return $this->response(101, '输入内容长度超限');
}
$conditions['concrete_industry'] = [ 'LIKE', '%' . $params['concrete_industry'] . '%' ];
}
break;
case 2:
$user_id_str = $this->getUserIDList($params['agent_id']);
$conditions['id'] = ['in', $user_id_str];
if (isset($params['user_status'])) {
$conditions['user_status'] = $params['user_status'];
}
if(isset($params['entrust_type']) && is_numeric($params['entrust_type'])){
//委托类型
$conditions['entrust_type'] =$params['entrust_type'];
}
break;
default:
if (isset($params['user_status'])) {
$conditions['user_status'] = $params['user_status'];
}
if (isset($params['user_name'])) {
if (strlen($params['user_name']) > 20) {
return $this->response(101, '输入内容长度超限');
}
$conditions['user_name'] = array( "like", "%" . trim($params['user_name']) . "%" );
}
if (isset($params['user_nick'])) {
if (strlen($params['user_nick']) > 20) {
return $this->response(101, '输入内容长度超限');
}
$conditions['user_nick'] = array( "like", "%" . trim($params['user_nick']) . "%" );
}
if (isset($params['user_phone'])) {
if (!is_numeric($params['user_phone'])) {
return $this->response(101, '请输入正确手机号');
}
if (strlen($params['user_phone']) > 20) {
return $this->response(101, '输入内容长度超限');
}
$conditions['user_phone'] = array( "like", "%" . trim($params['user_phone']) . "%" );
}
if (isset($params['yetai'])) {
$conditions['industry_type'] = array( "like", "%" . trim($params['yetai']) . "%" );
}
$area_start = isset($params['area_start']) ? $params['area_start'] : -1;
$area_end = isset($params['area_end']) ? $params['area_end'] : -1;
if ($area_start >= 0 && $area_end >= 0) { //面积
$conditions['area_demand'] = array( 'between', array( $area_start, $area_end ) );
} else if ($area_start >= 0 && $area_end < 0) { //100米以上不用传结束面积
$conditions['area_demand'] = array( 'egt', $area_start );
}
$price_start = isset($params['money_start']) ? $params['money_start'] : -1;
$price_end = isset($params['money_end']) ? $params['money_end'] : -1;
if ($price_start >= 0 && $price_end >= 0) { //金额
$conditions['price_demand'] = array( 'between', array( $price_start, $price_end ) );
} else if ($price_start >= 0 && $price_end < 0) {
$conditions['price_demand'] = array( 'egt', $price_start );
}
if (isset($params['start_time']) && isset($params['end_time'])) {
$start_time = date('Y-m-d H:i:s', $params['start_time']);
$end_time = date('Y-m-d H:i:s', $params['end_time']);
$conditions['create_time'] = array( 'between', array( $start_time, $end_time ) );
}
if (isset($params['status'])) {
$conditions['status'] = $params['status'];
}
//是否vip客户 1是 0否
if (isset($params['is_vip']) ) {
$conditions['vip'] = $params['is_vip'];
}
//全部客户列表 排除排除纯房东客户
$conditions['user_label'] = array( "neq", 2 );
//根据时间搜索,要能搜到保护期客户
if(!isset($conditions['create_time'])){
//排除排除保护期内的客户 将截止日期大于当前时间的数据排除掉
$time_now = date('Y-m-d H:i:s');
$conditions['protect_time'] = array('lt',$time_now);
}
//客户站点
if (isset($params['site_id']) ) {
$conditions['site_ids'] = [ 'LIKE', '%' . $params['site_id'] . '%' ];
}else{
$conditions['site_ids'] = [ 'LIKE', '%' . $this->siteId . '%' ];
}
//委托类型
if(isset($params['entrust_type']) && is_numeric($params['entrust_type'])){
$conditions['entrust_type'] =$params['entrust_type'];
......@@ -904,6 +1129,27 @@ class User extends Basic
}
public function getSiteUserList($site_id)
{
//查询总监下面门店的所有经纪人
$params = [];
$params["site_id"] = $site_id;
$params["is_del"] = 0;
$m_user_site = new UserSiteModel();
$field = 'user_id';
$res = $m_user_site->selectUserSite($field,$params);
$user_id_str = "";
if (count($res) > 0) {
foreach ($res as $k => $v) {
$user_id_str .= $v["user_id"] . ",";
}
$user_id_str = rtrim($user_id_str, ",");
}
return $user_id_str;
}
/**
* 客方同步到新表
......
......@@ -814,7 +814,7 @@ class StatementService
public function selectStatementForDistrictWithDay($agent_level, $district_id)
{
$agent_res = $this->getAgentIDsByDistrictId($district_id, $agent_level, 0);
big_log($agent_res);
// big_log($agent_res);
$conditions['agent_id'] = array( "in", $agent_res['agent_ids'] );
......
......@@ -120,7 +120,7 @@ class OfficeFinance extends Basic
$select = 1;
}
big_log($where);
// big_log($where);
$field = 'a.id,b.id as bargain_id,f.income_time,a.practical_fee,b.scale_fee,s.address as internal_address,
b.agent_id,b.house_number,b.father_id,b.order_id,a.real_income_id,a.role,b.scale';
$m_Office_commission = new OfficeOPartialCommission();
......
......@@ -116,7 +116,8 @@ class UserLogService
$data['site_ids_name_new'] = $s_user_site->getSiteNameList($user_id);
#拨打电话按钮是否显示 0:显示 1:不显示
$data['is_phone_button_show'] = $this->isPhoneButtonShow($user_id,$agent_id,$user_arr['vip']);
$data['is_phone_button_show'] = $this->isPhoneButtonShow($user_id,$agent_id,$user_arr['vip'],$user_arr['user_phone'],$user_arr['agent_id']);
//客方
$s_user_agent = new UserAgentService();
......@@ -266,8 +267,7 @@ class UserLogService
$result["is_outstrip_twenty_four_hours"] = $user_service->isUserProtect($user_id);
#拨打电话按钮是否显示 0:显示 1:不显示
$result['is_phone_button_show'] = $this->isPhoneButtonShow($user_id, $agent_id,$result['vip']);
$result['is_phone_button_show'] = $this->isPhoneButtonShow($user_id, $agent_id,$result['vip'],$result['user_phone'],$result['agent_id']);
#编辑客户详情权限 0:有权限 1:无权限
$result['is_can_edit_user_info'] = $user_service->isCanEditUserInfo($result["agent_id"], $agent_id);
......@@ -331,33 +331,43 @@ class UserLogService
* @param $user_id
* @param $agent_id
* @param $is_vip
* @param $result_user_phone
* @param $result_agent_id
* @return int
*/
public function isPhoneButtonShow($user_id,$agent_id,$is_vip)
public function isPhoneButtonShow($user_id,$agent_id,$is_vip,$result_user_phone,$result_agent_id)
{
$user_service = new UserService();
$vip_services = new VipService();
$s_user_agent = new UserAgentService();
$user_agent_list = $s_user_agent->getUserAgentId($user_id);
if ($user_agent_list) {
$is_user_agent_boss = 1;
$called = 1;
$user_agent_list_arr=[];
if($user_agent_list){
$user_agent_list_arr = [];
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)
if ($agent_boss_res == 0)
$is_user_agent_boss = 0;
#是否有绑定关系 0有 1无
$called_res = $this->userDetailIsOutpaceCallNumPhone($value['phone'], $agent_id);
if($called_res == 0)
if ($called_res == 0)
$called = 0;
}
}
#查询当前经纪人是否是某个客方的总监 0:可查看 1:不可查看
$is_user_agent_boss_v2 = $user_service->isUserAgentDirector($result_agent_id, $agent_id);
if ($is_user_agent_boss_v2 == 0)
$is_user_agent_boss = 0;
#是否有绑定关系 0有 1无
$called_v2 = $this->userDetailIsOutpaceCallNumPhone($result_user_phone, $agent_id);
if ($called_v2 == 0)
$called = 0;
#判断当天被拨打是否超过5次 (0:拨打不超过5次 1:超过5次)
$is_outpace_call_num = $this->userDetailIsOutpaceCallNum5($user_id);
......@@ -378,6 +388,8 @@ class UserLogService
OR
in_array($agent_id, $user_agent_list_arr)//客方可以看
OR
($result_agent_id == $agent_id)//客方可以看
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 (in_array($agent_id, $user_agent_list_arr)) or ($called == 0)))
......
......@@ -83,7 +83,7 @@ class UserSiteService
for ($page = 1; $page <= $total_page; $page++) {
$res = $this->moveUserSiteSaveData($page,$limit);
big_log($res);
// big_log($res);
}
return '';
}
......
......@@ -42,7 +42,7 @@ class OPartialCommission extends BaseModel
->limit($pageSize)
->page($pageNo)
->select();
big_log($this->getLastSql());
// big_log($this->getLastSql());
$m_agent = new AAgents();
$fields_str = 'a.id,a.name,a.phone,b.store_name';
foreach ($data as $k => $v) {
......
......@@ -43,7 +43,7 @@ class OfficeOPartialCommission extends BaseModel
->limit($pageSize)
->page($pageNo)
->select();
big_log($this->getLastSql());
// big_log($this->getLastSql());
$m_agent = new AAgents();
$fields_str = 'a.id,a.name,a.phone,b.store_name';
foreach ($data as $k => $v) {
......
......@@ -50,6 +50,16 @@ class UserSiteModel extends Model
return $result;
}
public function selectUserSite($field,$params)
{
$result = $this->db_
->field($field)
->where($params)
->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