master
cody 3 months ago
parent ce7dc9eecf
commit f248e9b163

@ -174,21 +174,21 @@ class OtherController extends CommonController
]; ];
} }
// 全国数据 // 全国数据(与 study 的 address 口径一致company_address 或 company_city 的 like 匹配,含「市」的取前部如 上海市→上海 以同时匹配 上海/上海市)
$countryArea = Company::approvedStudents()->groupBy('company_city')->whereNotNull('company_city')->get(['company_city']); $countryArea = Company::approvedStudents()->groupBy('company_city')->whereNotNull('company_city')->get(['company_city']);
$country = []; $country = [];
foreach ($countryArea as $item) { foreach ($countryArea as $item) {
$total = User::whereHas('company', function ($query) use ($item) { $term = preg_replace('/市$/', '', $item->company_city) ?: $item->company_city;
$query->where('company_city', $item->company_city); $total = User::whereHas('company', function ($query) use ($term) {
$query->where('company_address', 'like', '%' . $term . '%')
->orWhere('company_city', 'like', '%' . $term . '%');
})->where('is_schoolmate', 1)->count(); })->where('is_schoolmate', 1)->count();
if (empty($total)) { if (empty($total)) {
continue; continue;
} }
$country[] = [ $country[] = [
'area' => $item->company_city, 'area' => $item->company_city,
'total' => User::whereHas('company', function ($query) use ($item) { 'total' => $total,
$query->where('company_city', $item->company_city);
})->where('is_schoolmate', 1)->count()
]; ];
} }

Loading…
Cancel
Save