Commit 857ec264 authored by hujun's avatar hujun

缓存角色站点

parent b55785a3
...@@ -16,6 +16,7 @@ use app\model\ADistrict; ...@@ -16,6 +16,7 @@ use app\model\ADistrict;
use app\model\ASite; use app\model\ASite;
use app\model\AStore; use app\model\AStore;
use app\model\AuthGroup; use app\model\AuthGroup;
use app\model\AuthGroupSite;
use app\model\AuthRule; use app\model\AuthRule;
use app\model\ULabels; use app\model\ULabels;
use app\model\Users; use app\model\Users;
...@@ -29,6 +30,7 @@ class RedisCacheService ...@@ -29,6 +30,7 @@ class RedisCacheService
private $rule_key = 'cache_rule_'; private $rule_key = 'cache_rule_';
private $site_city_key = 'cache_site_city_'; private $site_city_key = 'cache_site_city_';
private $label_call_key = 'cache_label_call'; private $label_call_key = 'cache_label_call';
private $group_site_key = 'cache_group_site_';
private $time; private $time;
private $max_time; private $max_time;
...@@ -277,7 +279,26 @@ class RedisCacheService ...@@ -277,7 +279,26 @@ class RedisCacheService
} }
/** /**
* @param $type 1:客户 2:经纪人 3:角色组 4:站点城市 * 缓存角色站点
*
* @param $id
* @return mixed
*/
public function groupSiteCache($id)
{
$group_site = new AuthGroupSite();
$site_id = $group_site->getGroupSiteField('site_id', ['status'=>0, 'group_id'=>$id]); //获取标签
if ($site_id) {
$this->setRedisCache($this->group_site_key.$id, $site_id);
} else {
$site_id = '';
}
return $site_id;
}
/**
* @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
*/ */
...@@ -315,8 +336,12 @@ class RedisCacheService ...@@ -315,8 +336,12 @@ class RedisCacheService
$result = $this->redis_ext->get($this->site_city_key.$id); $result = $this->redis_ext->get($this->site_city_key.$id);
if (empty($result)) { if (empty($result)) {
$result = $this->siteCityCache($id); $result = $this->siteCityCache($id);
} else { }
$result = json_decode($result, true); break;
case 5 :
$result = $this->redis_ext->get($this->group_site_key.$id);
if (empty($result)) {
$result = $this->groupSiteCache($id);
} }
break; break;
default : default :
......
...@@ -509,6 +509,8 @@ class Auth extends Basic ...@@ -509,6 +509,8 @@ class Auth extends Basic
$data['site_id'] = $this->params['site_id_string']; $data['site_id'] = $this->params['site_id_string'];
$num = $m_auth->editData($data, $this->params['id']); $num = $m_auth->editData($data, $this->params['id']);
if ($num > 0) { if ($num > 0) {
$redis = new RedisCacheService();
$redis->groupSiteCache($this->params['group_id']);
$msg = "操作成功"; $msg = "操作成功";
} else { } else {
$code = 101; $code = 101;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
namespace app\index\controller; namespace app\index\controller;
use app\api_broker\service\RedisCacheService;
use app\api_broker\service\VipService; use app\api_broker\service\VipService;
use app\index\service\BrokerService; use app\index\service\BrokerService;
use app\api_broker\service\CallPhoneService; use app\api_broker\service\CallPhoneService;
...@@ -95,27 +96,31 @@ class Broker extends Basic ...@@ -95,27 +96,31 @@ class Broker extends Basic
$where = []; $where = [];
} }
if ($this->params['phone']) { if (!empty($this->params['phone'])) {
$where['concat(phone,name)'] = ['LIKE', '%'.$this->params['phone'].'%']; $where['concat(phone,name)'] = ['LIKE', '%'.$this->params['phone'].'%'];
} }
if ($this->params['level']) { if (!empty($this->params['level'])) {
$where['level'] = ['IN', $this->params['level'] ]; $where['level'] = ['IN', $this->params['level'] ];
} }
if ($this->params['store_id']) { if (!empty($this->params['store_id'])) {
$where['store_id'] = $this->params['store_id']; $where['store_id'] = $this->params['store_id'];
} }
if ($this->params['district_id']) { if (!empty($this->params['district_id'])) {
$where['district_id'] = $this->params['district_id']; $where['district_id'] = $this->params['district_id'];
} }
if ($this->userId != 1) { if ($this->userId != 1) {
$group_site = new AuthGroupSite(); // $group_site = new AuthGroupSite();
$agent_model = new AAgents(); // $agent_model = new AAgents();
$auth_group_id = $agent_model->getAgentFieldById($this->userId, 'auth_group_id'); // $auth_group_id = $agent_model->getAgentFieldById($this->userId, 'auth_group_id');
$site_id = $group_site->getAgentField('site_id', ['group_id'=>$auth_group_id]); // $site_id = $group_site->getGroupSiteField('site_id', ['group_id'=>$auth_group_id]);
$redis_service = new RedisCacheService();
$agent_data = $redis_service->getRedisCache(2, $this->userId);
$site_id = $redis_service->getRedisCache(5, $agent_data['auth_group_id']);
if (empty($site_id)) { if (empty($site_id)) {
$where['site_id'] = $this->siteId; $where['site_id'] = $this->siteId;
} else { } else {
...@@ -123,14 +128,14 @@ class Broker extends Basic ...@@ -123,14 +128,14 @@ class Broker extends Basic
} }
} }
if ($this->params['position'] == -1) { if (isset($this->params['position']) && $this->params['position'] == -1) {
$where['position'] = 5; $where['position'] = 5;
} }
if ($where) { if ($where) {
$agent = new AAgents(); $agent = new AAgents();
$field = 'id,name,phone,status'; $field = 'id,name,phone,status';
$data['data'] = $agent->getList($pageNo, $pageSize, 'id DESC', $field, '', $where); $data['data'] = $agent->getListV2($pageNo, $pageSize, 'id DESC', $field, $where);
} else { } else {
$data['msg'] = '没有经纪人信息'; $data['msg'] = '没有经纪人信息';
} }
......
...@@ -87,6 +87,7 @@ class Basic extends Controller ...@@ -87,6 +87,7 @@ class Basic extends Controller
'index/getActivityCoupon', 'index/getActivityCoupon',
'index/ceshi', 'index/ceshi',
'index/baiduText', 'index/baiduText',
'index/getBroker_new',
); );
/** /**
......
...@@ -364,6 +364,27 @@ class AAgents extends BaseModel ...@@ -364,6 +364,27 @@ class AAgents extends BaseModel
return $data; return $data;
} }
/**
*
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getListV2($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
return $this->field($field)
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
}
/** /**
* 统计任务获取经纪人列表 * 统计任务获取经纪人列表
* *
......
...@@ -71,11 +71,11 @@ class AuthGroupSite extends BaseModel ...@@ -71,11 +71,11 @@ class AuthGroupSite extends BaseModel
} }
/** /**
* @param $id
* @param $fields * @param $fields
* @param $where
* @return mixed * @return mixed
*/ */
public function getAgentField($fields, $where) public function getGroupSiteField($fields, $where)
{ {
return $this->where($where)->value($fields); return $this->where($where)->value($fields);
} }
......
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