Commit 586e3740 authored by hujun's avatar hujun

跟进列表缓存

parent 41fe2700
......@@ -17,6 +17,7 @@ use app\model\ASite;
use app\model\AStore;
use app\model\AuthGroup;
use app\model\AuthRule;
use app\model\ULabels;
use app\model\Users;
class RedisCacheService
......@@ -27,6 +28,7 @@ class RedisCacheService
private $group_key = 'cache_group_';
private $rule_key = 'cache_rule_';
private $site_city_key = 'cache_site_city_';
private $label_call_key = 'cache_label_call';
private $time;
private $max_time;
......@@ -191,7 +193,7 @@ class RedisCacheService
$m_agent_phone = new AAgentsPhone();
$data['phone_list'] = $m_agent_phone->getAgentsByWhereColumn(['agents_id'=>$data['id'], 'status'=>0], 'phone');
$data['phone_list'][] = $data['phone'];
$this->setRedisCache($this->agent_key . $agent_id, $data, $this->agent_time);
$this->setRedisCache($this->agent_key . $agent_id, $data, $this->max_time);
}
return $data;
}
......@@ -221,17 +223,21 @@ class RedisCacheService
*
* @param $name
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function authCache($name)
{
$m_auth_rule = new AuthRule();
$field = 'id,name,title,pid,is_menu';
$data = $m_auth_rule->getRule($field, ['name'=>$name,'status'=>0]);
if (!empty($data)) {
$this->setRedisCache($this->rule_key . $name, $data[0]);
$data = $this->redis_ext->get($this->rule_key.$name);
if (empty($data)) {
try {
$m_auth_rule = new AuthRule();
$field = 'id,name,title,pid,is_menu';
$data = $m_auth_rule->getRule($field, ['name'=>$name,'status'=>0]);
$this->setRedisCache($this->rule_key . $name, $data[0]);
} catch (\Exception $e) {
$data = [];
}
} else {
$data = json_decode($data, true);
}
return $data;
}
......@@ -245,7 +251,7 @@ class RedisCacheService
public function siteCityCache($id)
{
$m_auth_rule = new ASite();
$name = $m_auth_rule->getSiteById('name', $id);
$name = $m_auth_rule->getSiteById('city', $id);
if (!empty($name)) {
$this->setRedisCache($this->site_city_key . $id, $name);
}
......@@ -253,7 +259,25 @@ class RedisCacheService
}
/**
* @param $type 1:客户 2:经纪人 3:角色组 4:权限规则 5:站点城市
* 缓存电话标签
*
* @return array
*/
public function userCallLabelCache()
{
$label_data = $this->redis_ext->get($this->label_call_key);
if (empty($label_data)) {
$m_label = new ULabels();
$label_data = $m_label->getColumn('id,name', ['type'=>1]); //获取标签
$this->setRedisCache($this->label_call_key, $label_data);
} else {
$label_data = json_decode($label_data, true);
}
return $label_data;
}
/**
* @param $type 1:客户 2:经纪人 3:角色组 4:站点城市
* @param $id
* @return array|bool|false|mixed|\PDOStatement|string|\think\Model
*/
......@@ -288,14 +312,6 @@ class RedisCacheService
}
break;
case 4 :
$result = $this->redis_ext->get($this->rule_key. $id);
if (empty($result)) {
$result = $this->authCache($id);
} else {
$result = json_decode($result, true);
}
break;
case 5 :
$result = $this->redis_ext->get($this->site_city_key.$id);
if (empty($result)) {
$result = $this->siteCityCache($id);
......
......@@ -58,7 +58,7 @@ class VipService
$rules = $group_data['rules'];
}
$rule_data = $this->redisCache->getRedisCache(4, $name);
$rule_data = $this->redisCache->authCache($name);
if (empty($auth_group_id)) {
$fields = 'id';
$auth_rule_id = $this->rulesModel->getAuthRuleByName($name, $fields);
......@@ -125,7 +125,7 @@ class VipService
$rules = $group_data['rules'];
}
$rule_data = $this->redisCache->getRedisCache(4, $name);
$rule_data = $this->redisCache->authCache($name);
if (empty($auth_group_id)) {
$auth_rule_id = $this->rulesModel->getAuthRuleByName($name, 'id');
} else {
......
......@@ -297,7 +297,7 @@ class Auth extends Basic
if ($data['status']) {
$redis_service->delRedisCache(4, $rule_data['name']);
} else {
$redis_service->getRedisCache(4, $rule_data['name']);
$redis_service->authCache($rule_data['name']);
}
return $this->response(200,'成功',$data);
}else{
......@@ -438,7 +438,7 @@ class Auth extends Basic
//prt($data)
if ($table->editData($data,$id)) {
$redis_service = new RedisCacheService();
$redis_service->getRedisCache(4, $data['name']);
$redis_service->authCache($data['name']);
return $this->response(200, '成功');
} else {
return $this->response(100, '无修改');
......
......@@ -49,9 +49,6 @@ class Remark extends Basic
}
}
$m_user = new Users();
$m_agent = new AAgents();
$code = 200;
$msg = '';
......@@ -88,6 +85,7 @@ class Remark extends Basic
if ($result_data['status'] != 'fail') {
$data['data']['list'] = $result_data['data'];
} else {
$code = 101;
$data['data']['list'] = [];
$msg = $result_data['msg'];
}
......
......@@ -45,7 +45,7 @@ class PhoneFollowUpService
$vrs = new VerifyRepetitionService();
$page_no = isset($params['page_no']) ? $params['page_no'] : 1;
$page_size = isset($params['page_size']) ? $params['page_size'] : 15;
$status = 'fail';
$is_check = $vrs->followUpClick($agent_id);
if($page_no == 1 && !$is_check){
$is_bool = $vrs->getCurrTimeSection();
......@@ -53,11 +53,11 @@ class PhoneFollowUpService
if($is_bool) {
$msg = "高峰期间每10秒钟只能搜索一次(6.30-8.30)";
}
return ['code'=>'101','data'=>$msg];
return ['status'=>$status,'msg'=>$msg];
}
$where = ' 1=1 ';
if (empty($start_time) || empty($end_time)) {
return ['code'=>'101','data'=>'时间不能为空'];
return ['status'=>$status,'data'=>'时间不能为空'];
} else {
$where .= ' AND create_time BETWEEN "'.$start_time.' 00:00:00" AND "'.$end_time. ' 23:59:59"';
}
......@@ -89,7 +89,7 @@ class PhoneFollowUpService
$agent_id = $m_agent->getAgentsByWhereColumn($agent_where, 'id');
if (empty($agent_id)) {
return ['code'=>'101','data'=>'暂无数据'];
return ['status'=>$status,'msg'=>'暂无数据'];
} else {
$agent_id_string = implode(',', $agent_id);
$where .= " AND agent_id in ({$agent_id_string})";
......@@ -103,12 +103,10 @@ class PhoneFollowUpService
$data = $this->phoneFollowUp->getFollowList($page_no, $page_size, $order_ = '', $field, $where);
}
$s_user_service = new UserService();
$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]); //获取标签
$redis_service = new RedisCacheService();
$redis_service = new RedisCacheService();
$label_data = $redis_service->userCallLabelCache(); //获取标签
foreach ($data as $k => $v) {
if (!empty($v['user_id'])) {
$user_data = $redis_service->getRedisCache(1, $v['user_id']);
......@@ -119,7 +117,6 @@ class PhoneFollowUpService
// $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_data['user_phone'], $agent_id);
$data[$k]['label_name'] = array_key_exists($v['labels_id'], $label_data) ? $label_data[$v['labels_id']] : '';
$data[$k]['user_name'] = $user_data['user_name'];
} else {
$data[$k]['user_name'] = '';
......@@ -134,10 +131,9 @@ class PhoneFollowUpService
}
$status = 'successful';
} catch (\Exception $e) {
$status = 'fail';
$msg = '内部错误'.$e->getMessage();
}
return ['status'=>$status, $msg, 'data'=>$data];
return ['status'=>$status, 'msg'=>$msg, 'data'=>$data];
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@
namespace app\task\controller;
use app\api_broker\service\RedisCacheService;
use app\extra\RedisExt;
use app\model\ASite;
use app\model\UPhoneFollowUp;
......@@ -35,7 +36,11 @@ class FollowUpTask
*/
public function isExistTable($time, $siteId)
{
$site_arr = $this->siteModel->findByOne('city', ["id" => $siteId]);
$redis_service = new RedisCacheService();
$site_arr = $redis_service->getRedisCache(4, $siteId);
if (empty($site_arr)) {
$site_arr = $this->siteModel->findByOne('city', ["id" => $siteId]);
}
if (count($site_arr) <= 0) {
return false;
}
......
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