Commit 528540b2 authored by hujun's avatar hujun

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

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