update
This commit is contained in:
parent
5eea9476db
commit
e8e389c78e
@ -272,4 +272,59 @@
|
||||
->toArray();
|
||||
return $this->success('请求成功',$data);
|
||||
}
|
||||
|
||||
public function responsibleArea(): Json
|
||||
{
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$params = $this->request->post(['key','value','company_type']);
|
||||
if (empty($params['key']) || empty($params['value']) || empty($params['company_type'])) {
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
if ($params['key'] == 'city') {
|
||||
$where[] = ['area', '=', 0];
|
||||
}
|
||||
if ($params['value'] == '') {
|
||||
return $this->fail('参数不能为空');
|
||||
}
|
||||
$where[] = [$params['key'], '=', $params['value']];
|
||||
$where[] = ['company_type', '=', $params['company_type']];
|
||||
switch ($params['key']) {
|
||||
case 'city':
|
||||
// $geo_area=Db::name('geo_area')->where('city_code', '=', $parmas['value'])->column('area_code');
|
||||
// $where[] = ['area', 'in', $geo_area];
|
||||
break;
|
||||
case 'area':
|
||||
$street_code = Db::name('geo_street')->where('area_code', '=', $params['value'])->column('street_code');
|
||||
$where[] = ['street', 'in', $street_code];
|
||||
$where[] = ['village', '=', 0];
|
||||
break;
|
||||
case 'street':
|
||||
$street_code = Db::name('geo_village')->where('street_code', '=', $params['value'])->column('village_code');
|
||||
$where[] = ['village', 'in', $street_code];
|
||||
$where[] = ['brigade', '=', 0];
|
||||
break;
|
||||
case 'village':
|
||||
// $street_code = Db::name('geo_brigade')->where('street_code', '=', $parmas['value'])->column('village_code');
|
||||
$where[] = ['village', '=', $params['value']];
|
||||
// $where[] = ['brigade', '=', 0];
|
||||
break;
|
||||
}
|
||||
|
||||
$res = Company::where($where)->column('responsible_area');
|
||||
|
||||
foreach ($res as $k => $v) {
|
||||
$res[$k] = explode(',', $v);
|
||||
}
|
||||
$data = [];
|
||||
foreach ($res as $k => $v) {
|
||||
foreach ($v as $kk => $vv) {
|
||||
if ($vv != '') {
|
||||
$data[] = $vv;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->success('success', array_unique($data));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user