作者 何书鹏
1 个管道 的构建 通过 耗费 14 秒

地区代理商

... ... @@ -51,13 +51,27 @@ class House extends Backend
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
// 城市或区县代理
$group_id_arr = array_column($this->auth->getGroups(), 'group_id');
$where1 = [];
if(!in_array(1,$group_id_arr) && array_intersect([6,7],$group_id_arr)){
$area_arr = \app\admin\model\AdminArea::where('admin_id',$this->auth->id)->column('area');
foreach ($area_arr as $v) {
$where1[] = "area like '%{$v}%'";
}
$where1 = $where1 ? implode(' or ',$where1) : 'id = 0';
}
$total = $this->model
->where($where)
->where($where1)
->order($sort, $order)
->count();
$list = $this->model
->where($where)
->where($where1)
->order($sort, $order)
->limit($offset, $limit)
->select();
... ...
... ... @@ -44,6 +44,7 @@ class Store extends Backend
*/
public function index()
{
$group_id_arr = array_column($this->auth->getGroups(), 'group_id');
//当前是否为关联查询
$this->relationSearch = true;
//设置过滤方法
... ... @@ -56,15 +57,40 @@ class Store extends Backend
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
// 城市或区县代理
$where1 = [];
if(!in_array(1,$group_id_arr) && array_intersect([6,7],$group_id_arr)){
$area_arr = \app\admin\model\AdminArea::where('admin_id',$this->auth->id)->column('area');
// 城市管理员
if(in_array(6,$group_id_arr)){
foreach ($area_arr as $v) {
$area = explode('/', $v);
$province = strpos($area[0], '省') === false && strpos($area[0], '市') === false ? $area[0].'市' : $area[0];
$where1[] = "(province = '{$province}' and city = '{$area[1]}')";
}
}else{
// 区县级管理员
foreach ($area_arr as $v) {
$area = explode('/', $v);
$province = strpos($area[0], '') === false && strpos($area[0], '') === false ? $area[0].'' : $area[0];
$where1[] = "(province = '{$province}' and city = '{$area[1]}' and region = '{$area[2]}')";
}
}
$where1 = $where1 ? implode(' or ',$where1) : 'id = 0';
}
$total = $this->model
->with(['admin','user'])
->where($where)
->where($where1)
->order($sort, $order)
->count();
$list = $this->model
->with(['admin','user'])
->where($where)
->where($where1)
->order($sort, $order)
->limit($offset, $limit)
->select();
... ... @@ -84,7 +110,6 @@ class Store extends Backend
}
// 城市或区县代理
$have_store_num = 0;
$group_id_arr = array_column($this->auth->getGroups(), 'group_id');
if(!in_array(1,$group_id_arr) && array_intersect([6,7],$group_id_arr)){
$have_store_num = 1;
}
... ...