Commit 528540b2 authored by hujun's avatar hujun

客户列表与商品列表站点控制

parent fefc3ab1
...@@ -792,4 +792,21 @@ class Broker extends Basic ...@@ -792,4 +792,21 @@ class Broker extends Basic
$data['status'] = 200; $data['status'] = 200;
return $this->response($data['status'], $data['msg'], $data['data']); return $this->response($data['status'], $data['msg'], $data['data']);
} }
/**
* 获得经纪人站点城市
*
* @return \think\Response
*/
public function getAgentGroupSite() {
$service_broker = new \app\index\service\BrokerService();
$site_data = $service_broker->checkSite($this->agentId);
if ($site_data) {
$data['data'] = $site_data;
} else {
$data['data'] = [];
}
return $this->response(200, '', $data['data']);
}
} }
\ No newline at end of file
...@@ -688,4 +688,21 @@ class Broker extends Basic ...@@ -688,4 +688,21 @@ class Broker extends Basic
return $this->response(100, '失败'); return $this->response(100, '失败');
} }
} }
/**
* 获得经纪人站点城市
*
* @return \think\Response
*/
public function getAgentGroupSite() {
$service_broker = new BrokerService();
$site_data = $service_broker->checkSite($this->userId);
if ($site_data) {
$data['data'] = $site_data;
} else {
$data['data'] = [];
}
return $this->response(200, '', $data['data']);
}
} }
\ No newline at end of file
...@@ -412,15 +412,14 @@ class Houses extends Basic ...@@ -412,15 +412,14 @@ class Houses extends Basic
$where['is_lock'] = $this->params['is_lock']; $where['is_lock'] = $this->params['is_lock'];
} }
$service_broker = new BrokerService(); if (!empty($this->params['site_id'])) {
$check_data = $service_broker->checkSite($this->userId); $service_broker = new BrokerService();
if ($check_data) { $check_data = $service_broker->checkSite($this->userId, $this->params['site_id']);
if ($check_data['city'] != 'all') { if (!$check_data) {
$where['city'] = ['in', $check_data['city']]; $where['city'] = $this->city;
} }
} else {
$where['city'] = $this->city;
} }
$list = $this->house->getHouseListDish($pageNo, $pageSize, 'id DESC', $fields, $where, $this->userId); $list = $this->house->getHouseListDish($pageNo, $pageSize, 'id DESC', $fields, $where, $this->userId);
$data['data']['total'] = $this->house->getHouseListTotal($where); $data['data']['total'] = $this->house->getHouseListTotal($where);
......
...@@ -294,20 +294,12 @@ class Member extends Basic{ ...@@ -294,20 +294,12 @@ class Member extends Basic{
#if_search_user 存在精确搜索客户姓名,电话,编号 则变成 false #if_search_user 存在精确搜索客户姓名,电话,编号 则变成 false
// $where['a.site_ids'] = [ 'LIKE', '%' . $this->siteId . '%' ];//默认显示经纪人所在站点的客户 // $where['a.site_ids'] = [ 'LIKE', '%' . $this->siteId . '%' ];//默认显示经纪人所在站点的客户
$service_broker = new BrokerService(); if (!empty($this->params['site_id'])) {
$check_data = $service_broker->checkSite($this->userId); $service_broker = new BrokerService();
if ($check_data) { $check_data = $service_broker->checkSite($this->userId, $this->params['site_id']);
if ($check_data['site_id'] != 'all') { if (!$check_data) {
if (!empty($check_data['site_id'])) { $where['city'] = $this->city;
$site_id = explode(',', $check_data['site_id']);
foreach ($site_id as $k=>$v) {
$site_id[$k] = intval($v); //转为整型
}
$where['a.site_ids'] = [ 'in', $site_id];
}
} }
} else {
$where['a.site_ids'] = [ 'LIKE', '%' . $this->siteId . '%' ];
} }
} }
......
...@@ -266,9 +266,10 @@ class BrokerService ...@@ -266,9 +266,10 @@ class BrokerService
* 检查角色是否属于某个站点 * 检查角色是否属于某个站点
* *
* @param $agent_id * @param $agent_id
* @return bool * @param int $site_id
* @return array|bool|mixed
*/ */
public function checkSite($agent_id) { public function checkSite($agent_id, $site_id = 0) {
$city = []; $city = [];
$m_group_site = new AuthGroupSite(); $m_group_site = new AuthGroupSite();
$m_site = new ASite(); $m_site = new ASite();
...@@ -279,23 +280,19 @@ class BrokerService ...@@ -279,23 +280,19 @@ class BrokerService
if ($auth_group_id) { if ($auth_group_id) {
$where['group_id'] = $auth_group_id; $where['group_id'] = $auth_group_id;
$where['status'] = 0; $where['status'] = 0;
if ($site_id) {
$where[] = ['EXP', 'find_in_set('.$site_id.', site_id)'];
}
$site_id = $m_group_site->getGroupSite('site_id', $where); $site_id = $m_group_site->getGroupSite('site_id', $where);
if ($site_id['status'] != 'fail' && !empty($site_id['data']['site_id'])) { if ($site_id['status'] != 'fail' && !empty($site_id['data']['site_id'])) {
$city = $m_site->getSiteByIdColumn($site_id['data']['site_id'], 'city'); $city = $m_site->getSiteByIdColumn($site_id['data']['site_id'], 'id,city');
} }
if (empty($city)) { if (empty($city)) {
$result = false; $result = false;
} else { } else {
$num = $m_site->getTotal(['is_del'=>0]); $result = $city;
if (count($city) == $num) {
$result['city'] = 'all';
$result['site_id'] = 'all';
} else {
$result['city'] = implode(',', $city);
$result['site_id'] = $site_id['data']['site_id'];
}
} }
} else { } else {
$result = false; $result = false;
......
...@@ -110,6 +110,7 @@ Route::group('index', [ ...@@ -110,6 +110,7 @@ Route::group('index', [
'getAgentDistrictStore' => [ 'index/broker/getAgentDistrictStore', [ 'method' => 'GET' ] ], //获取经纪人id获取部门门店名称 'getAgentDistrictStore' => [ 'index/broker/getAgentDistrictStore', [ 'method' => 'GET' ] ], //获取经纪人id获取部门门店名称
'getCurrentCity' => [ 'index/broker/getCurrentCity', [ 'method' => 'GET' ] ], //获取所属城市 'getCurrentCity' => [ 'index/broker/getCurrentCity', [ 'method' => 'GET' ] ], //获取所属城市
'settingCity' => [ 'index/broker/settingCity', [ 'method' => 'POST' ] ], //设置所属城市 'settingCity' => [ 'index/broker/settingCity', [ 'method' => 'POST' ] ], //设置所属城市
'getAgentGroupSite' => [ 'index/broker/getAgentGroupSite', [ 'method' => 'GET' ] ], //获得经纪人站点
'batchChangDish' => [ 'index/houses/batchChangDish', [ 'method' => 'post' ] ],//批量修改盘方 'batchChangDish' => [ 'index/houses/batchChangDish', [ 'method' => 'post' ] ],//批量修改盘方
'transformLandlord' => [ 'index/houses/transformLandlord', [ 'method' => 'post' ] ],//转换房东手机号 'transformLandlord' => [ 'index/houses/transformLandlord', [ 'method' => 'post' ] ],//转换房东手机号
'lockHouse' => [ 'index/houses/lockHouse', [ 'method' => 'post' ] ],//锁盘 'lockHouse' => [ 'index/houses/lockHouse', [ 'method' => 'post' ] ],//锁盘
...@@ -365,6 +366,7 @@ Route::group('api', [ ...@@ -365,6 +366,7 @@ Route::group('api', [
'appraiser' => [ 'api/broker/appraiser', [ 'method' => 'post' ] ], //评价经纪人 'appraiser' => [ 'api/broker/appraiser', [ 'method' => 'post' ] ], //评价经纪人
'recordCallNum' => [ 'api/broker/recordCallNum', [ 'method' => 'post' ] ], //记录拨打经纪人号码 'recordCallNum' => [ 'api/broker/recordCallNum', [ 'method' => 'post' ] ], //记录拨打经纪人号码
'recordCallNumShare' => [ 'api/broker/recordCallNumShare', [ 'method' => 'post' ] ], //记录拨打经纪人号码 'recordCallNumShare' => [ 'api/broker/recordCallNumShare', [ 'method' => 'post' ] ], //记录拨打经纪人号码
'getAgentGroupSite' => [ 'api/broker/getAgentGroupSite', [ 'method' => 'GET' ] ], //获得经纪人站点城市
//get member //get member
'logout' => [ 'api/member/logout', [ 'method' => 'get' ] ], 'logout' => [ 'api/member/logout', [ 'method' => 'get' ] ],
......
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