苏州市外查询

master
lion 2 weeks ago
parent ff3c30d1af
commit edf8bfaf07

@ -71,10 +71,32 @@ class Company extends SoftDeletesModel
$hasSuzhouOut = in_array('苏州市外', $company_area); $hasSuzhouOut = in_array('苏州市外', $company_area);
if ($hasSuzhouOut) { if ($hasSuzhouOut) {
// 如果包含"苏州市外",查询所有不等于"苏州"的记录 // 苏州市外:排除 company_area 参数接口返回的苏州市内选项,以及虎丘区
return $query->where('company_area', '!=', '苏州') $excludeAreas = Parameter::where('number', 'company_area')
->whereNotNull('company_area') ->with(['detail' => fn ($q) => $q->orderBy('sort', 'asc')])
->where('company_area', '!=', ''); ->first();
$excludeList = [];
if ($excludeAreas && $excludeAreas->detail) {
foreach ($excludeAreas->detail as $d) {
$v = trim((string) ($d->value ?? ''));
if ($v !== '' && $v !== '苏州市外') {
$excludeList[] = $v;
// 高新区映射为虎丘(数据库可能存虎丘)
if ($v === '高新区') {
$excludeList[] = '虎丘';
}
}
}
}
$excludeList = array_unique(array_merge($excludeList, ['虎丘区']));
$query->whereNotNull('company_area')->where('company_area', '!=', '');
if (!empty($excludeList)) {
foreach ($excludeList as $v) {
$query->where('company_area', 'not like', '%' . $v . '%');
}
}
return $query;
} else { } else {
// 将搜索参数转换为数据库值 // 将搜索参数转换为数据库值
$company_area = array_map(function ($v) use ($areaMapping) { $company_area = array_map(function ($v) use ($areaMapping) {

Loading…
Cancel
Save