Commit 857ec264 authored by hujun's avatar hujun

缓存角色站点

parent b55785a3
......@@ -16,6 +16,7 @@ use app\model\ADistrict;
use app\model\ASite;
use app\model\AStore;
use app\model\AuthGroup;
use app\model\AuthGroupSite;
use app\model\AuthRule;
use app\model\ULabels;
use app\model\Users;
......@@ -29,6 +30,7 @@ class RedisCacheService
private $rule_key = 'cache_rule_';
private $site_city_key = 'cache_site_city_';
private $label_call_key = 'cache_label_call';
private $group_site_key = 'cache_group_site_';
private $time;
private $max_time;
......@@ -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
* @return array|bool|false|mixed|\PDOStatement|string|\think\Model
*/
......@@ -315,8 +336,12 @@ class RedisCacheService
$result = $this->redis_ext->get($this->site_city_key.$id);
if (empty($result)) {
$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;
default :
......
......@@ -509,6 +509,8 @@ class Auth extends Basic
$data['site_id'] = $this->params['site_id_string'];
$num = $m_auth->editData($data, $this->params['id']);
if ($num > 0) {
$redis = new RedisCacheService();
$redis->groupSiteCache($this->params['group_id']);
$msg = "操作成功";
} else {
$code = 101;
......
......@@ -9,6 +9,7 @@
namespace app\index\controller;
use app\api_broker\service\RedisCacheService;
use app\api_broker\service\VipService;
use app\index\service\BrokerService;
use app\api_broker\service\CallPhoneService;
......@@ -95,27 +96,31 @@ class Broker extends Basic
$where = [];
}
if ($this->params['phone']) {
if (!empty($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'] ];
}
if ($this->params['store_id']) {
if (!empty($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'];
}
if ($this->userId != 1) {
$group_site = new AuthGroupSite();
$agent_model = new AAgents();
$auth_group_id = $agent_model->getAgentFieldById($this->userId, 'auth_group_id');
$site_id = $group_site->getAgentField('site_id', ['group_id'=>$auth_group_id]);
// $group_site = new AuthGroupSite();
// $agent_model = new AAgents();
// $auth_group_id = $agent_model->getAgentFieldById($this->userId, '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)) {
$where['site_id'] = $this->siteId;
} else {
......@@ -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;
}
if ($where) {
$agent = new AAgents();
$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 {
$data['msg'] = '没有经纪人信息';
}
......
......@@ -87,6 +87,7 @@ class Basic extends Controller
'index/getActivityCoupon',
'index/ceshi',
'index/baiduText',
'index/getBroker_new',
);
/**
......
......@@ -364,6 +364,27 @@ class AAgents extends BaseModel
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
}
/**
* @param $id
* @param $fields
* @param $where
* @return mixed
*/
public function getAgentField($fields, $where)
public function getGroupSiteField($fields, $where)
{
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