Commit 71c05233 authored by hujun's avatar hujun

客户详情缓存

parent d221d2f3
...@@ -13,6 +13,7 @@ use app\extra\RedisExt; ...@@ -13,6 +13,7 @@ use app\extra\RedisExt;
use app\model\AAgents; use app\model\AAgents;
use app\model\AAgentsPhone; use app\model\AAgentsPhone;
use app\model\ADistrict; use app\model\ADistrict;
use app\model\ASite;
use app\model\AStore; use app\model\AStore;
use app\model\AuthGroup; use app\model\AuthGroup;
use app\model\AuthRule; use app\model\AuthRule;
...@@ -25,12 +26,13 @@ class RedisCacheService ...@@ -25,12 +26,13 @@ class RedisCacheService
private $agent_key = 'cache_agent_'; private $agent_key = 'cache_agent_';
private $group_key = 'cache_group_'; private $group_key = 'cache_group_';
private $rule_key = 'cache_rule_'; private $rule_key = 'cache_rule_';
private $site_city_key = 'cache_site_city_';
private $time; private $time;
public function __construct() public function __construct()
{ {
$this->redis_ext = RedisExt::getRedis(); $this->redis_ext = RedisExt::getRedis();
$this->time = 172800; //2天 $this->time = 1800; //2天
} }
/** /**
...@@ -139,6 +141,16 @@ class RedisCacheService ...@@ -139,6 +141,16 @@ class RedisCacheService
$field .= ',source_intro'; $field .= ',source_intro';
$user_data = $m_user->findByOne($field, ['id'=>$user_id]); $user_data = $m_user->findByOne($field, ['id'=>$user_id]);
if (!empty($user_data)) { if (!empty($user_data)) {
if ($user_data['referrer_source'] == 10 && $user_data['referrer_id'] > 0) {
$referrer_data = $m_user->findByOne('user_phone,user_name', ['id'=>$user_data['referrer_id']]);
$user_data['referrer_user'] = $referrer_data['user_name'] . '-' . substr_replace($referrer_data['user_phone'], '****', 3, 4);
}
if ($user_data['referrer_source'] == 20 && $user_data['referrer_id'] > 0) {
$m_agent = new AAgents();
$agent_data = $m_agent->getAgentInfo('name,phone', $user_data['referrer_id']);
$user_data['referrer_user'] = $agent_data['name'] . '-' . $agent_data['phone'];
}
$this->setRedisCache($this->user_key.$user_id, $user_data); $this->setRedisCache($this->user_key.$user_id, $user_data);
} }
...@@ -223,7 +235,23 @@ class RedisCacheService ...@@ -223,7 +235,23 @@ class RedisCacheService
} }
/** /**
* @param $type 1:客户 2:经纪人 3:角色组 4:权限规则 * 缓存城市
*
* @param $id
* @return false|\PDOStatement|string|\think\Collection
*/
public function siteCityCache($id)
{
$m_auth_rule = new ASite();
$name = $m_auth_rule->getSiteById('name', $id);
if (!empty($name)) {
$this->setRedisCache($this->site_city_key . $id, $name);
}
return $name;
}
/**
* @param $type 1:客户 2:经纪人 3:角色组 4:权限规则 5:站点城市
* @param $id * @param $id
* @return array|bool|false|mixed|\PDOStatement|string|\think\Model * @return array|bool|false|mixed|\PDOStatement|string|\think\Model
*/ */
...@@ -265,6 +293,14 @@ class RedisCacheService ...@@ -265,6 +293,14 @@ class RedisCacheService
$result = json_decode($result, true); $result = json_decode($result, true);
} }
break; break;
case 5 :
$result = $this->redis_ext->get($this->site_city_key.$id);
if (empty($result)) {
$result = $this->siteCityCache($id);
} else {
$result = json_decode($result, true);
}
break;
default : default :
$result = false; $result = false;
} }
......
...@@ -5,6 +5,7 @@ namespace app\index\service; ...@@ -5,6 +5,7 @@ namespace app\index\service;
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\api_broker\service\OrderLogService; use app\api_broker\service\OrderLogService;
use app\api_broker\service\RedisCacheService;
use app\api_broker\service\VipService; use app\api_broker\service\VipService;
use app\extra\RedisExt; use app\extra\RedisExt;
use app\model\AAgents; use app\model\AAgents;
...@@ -52,36 +53,67 @@ class UserLogService ...@@ -52,36 +53,67 @@ class UserLogService
*/ */
public function userDetail($user_id, $agent_id) public function userDetail($user_id, $agent_id)
{ {
$redis_service = new RedisCacheService();
$user_arr = $redis_service->getRedisCache(1, $user_id);
if (empty($user_arr)) {
//查询客户详情 //查询客户详情
$user_arr = $this->userModel->useraction_search_user_res($user_id, 1); $user_arr = $this->userModel->useraction_search_user_res($user_id, 1);
if (count($user_arr) <= 0) { if (count($user_arr) <= 0) {
return ["code" => 101, "msg" => "没找到此条用户信息"]; return ["code" => 101, "msg" => "没找到此条用户信息"];
} }
}
$user_arr['user_pic'] = HEADERIMGURL . $user_arr['user_pic']; $user_arr['user_pic'] = HEADERIMGURL . $user_arr['user_pic'];
$user_arr['user_phone'] = substr_replace($user_arr['user_phone'], '****', 3, 4);
if ($user_arr['agent_id']) {
$agents_arr = $redis_service->getRedisCache(2, $user_arr['agent_id']);
if (empty($agents_arr)) {
$agents_arr = $this->agentModel->verifyUser('name,phone', '', ['id' => $user_arr['agent_id']]); $agents_arr = $this->agentModel->verifyUser('name,phone', '', ['id' => $user_arr['agent_id']]);
}
$user_arr['agent_info'] = $agents_arr ? $agents_arr['name'] . '-' . $agents_arr['phone'] : '未知'; $user_arr['agent_info'] = $agents_arr ? $agents_arr['name'] . '-' . $agents_arr['phone'] : '未知';
} else {
$user_arr['agent_info'] = '';
}
$data['agent_path'] = AGENTHEADERIMGURL; $data['agent_path'] = AGENTHEADERIMGURL;
/*查询站点名*/ /*查询站点名*/
$site_model = new ASite(); $site_model = new ASite();
foreach (explode(',', $user_arr['site_ids']) as $site_k => $site_v) { $user_arr['site_name'] = [];
if ($user_arr['site_ids']) {
$site_ids_arr = explode(',', $user_arr['site_ids']);
foreach ($site_ids_arr as $site_v) {
$site_name = $redis_service->getRedisCache(5, $site_v);
if (empty($site_name)) {
$site_field = 'city'; $site_field = 'city';
$site_params['id'] = $site_v; $site_params['id'] = $site_v;
$site_model = $site_model->findByOne($site_field, $site_params); $site_model = $site_model->findByOne($site_field, $site_params);
$user_arr['site_name'][] = $site_model["city"]; $site_name = $site_model["city"];
}
$user_arr['site_name'][] = $site_name;
} }
}
/*查询站点名*/ /*查询站点名*/
$call = new CallPhoneService();
$agent_data = $redis_service->getRedisCache(2, $agent_id);
$result = $call->checkBindRedis($this->userId, $agent_data['phone_list'], $user_arr['user_phone']);
if($result != ''){
$data['is_outpace_call_num'] = 0;
}
/*修改记录部分 start*/ /*修改记录部分 start*/
$records = new GOperatingRecords(); $records = new GOperatingRecords();
$param_['user_id'] = $user_id; $param_['user_id'] = $user_id;
$param_['type'] = 3; $param_['type'] = 3;
$records_result = $records->user_history($param_); $records_result = $records->user_history($param_);
$user_arr['user_phone'] = substr_replace($user_arr['user_phone'], '****', 3, 4);
$data['user_info'] = $user_arr; $data['user_info'] = $user_arr;
$data['user_history'] = $records_result; $data['user_history'] = $records_result;
$param_['type'] = 5; $param_['type'] = 5;
...@@ -121,13 +153,13 @@ class UserLogService ...@@ -121,13 +153,13 @@ class UserLogService
} }
$model = new AAgents(); // $model = new AAgents();
$result = $model->searchAgentsByKeyword("id,name,phone", ["id" => $agent_id]); // $result = $model->searchAgentsByKeyword("id,name,phone", ["id" => $agent_id]);
$call = new CallPhoneService(); // $call = new CallPhoneService();
$result = $call->getBindNum($user_arr['user_phone'], $result[0]['phone']); // $result = $call->getBindNum($user_arr['user_phone'], $result[0]['phone']);
if ($result != 0) { // if ($result != 0) {
$data['is_outpace_call_num'] = 0; // $data['is_outpace_call_num'] = 0;
} // }
//查询当前经纪人是否是某个客方的总监 0:可查看 1:不可查看 //查询当前经纪人是否是某个客方的总监 0:可查看 1:不可查看
$data['is_can_look'] = $user_service->isUserAgentDirector($user_arr["agent_id"], $agent_id); $data['is_can_look'] = $user_service->isUserAgentDirector($user_arr["agent_id"], $agent_id);
......
...@@ -66,12 +66,17 @@ class ASite extends BaseModel ...@@ -66,12 +66,17 @@ class ASite extends BaseModel
* 根据id获取单个字段值 * 根据id获取单个字段值
* *
* @param $id * @param $id
* @param $where
* @param $fields * @param $fields
* @return mixed * @return mixed
*/ */
public function getSiteById($id, $fields) public function getSiteById($fields, $id, $where = [])
{ {
$return = $this->where('id', $id)->value($fields); $where['is_del'] = 0;
if ($id) {
$where['id'] = $id;
}
$return = $this->where($where)->value($fields);
return $return; return $return;
} }
......
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