|
|
|
|
@ -135,34 +135,28 @@ class OtherController extends CommonController
|
|
|
|
|
$courseType->course_signs_total = CourseSign::courseSignsTotalByUnique($start_date, $end_date, 1, $courses->pluck('id'), null, $userIds);
|
|
|
|
|
}
|
|
|
|
|
// 苏州区域数据
|
|
|
|
|
$suzhou = DB::table('companies')
|
|
|
|
|
->where('company_city', '苏州市')
|
|
|
|
|
->whereNotNull('company_area')
|
|
|
|
|
->whereNull('companies.deleted_at')
|
|
|
|
|
->leftJoin('users', function ($join) {
|
|
|
|
|
$join->on('companies.id', '=', 'users.company_id')
|
|
|
|
|
->whereNull('users.deleted_at');
|
|
|
|
|
})->select(
|
|
|
|
|
'companies.company_area',
|
|
|
|
|
DB::raw('count(distinct companies.id) as company_total'),
|
|
|
|
|
DB::raw('count(distinct users.id) as user_total')
|
|
|
|
|
)->groupBy('companies.company_area')
|
|
|
|
|
->get();
|
|
|
|
|
$suzhouArea = Company::where('company_city', '苏州市')->groupBy('company_area')->get(['company_area']);
|
|
|
|
|
$suzhou = [];
|
|
|
|
|
foreach ($suzhouArea as $item) {
|
|
|
|
|
$suzhou[] = [
|
|
|
|
|
'company_area' => $item->company_area,
|
|
|
|
|
'company_total' => User::whereHas('company', function ($query) use ($item) {
|
|
|
|
|
$query->where('company_area', $item->company_area);
|
|
|
|
|
})->where('is_schoolmate', 1)->count()
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 全国数据
|
|
|
|
|
$country = DB::table('companies')
|
|
|
|
|
->whereNotNull('company_city')
|
|
|
|
|
->whereNull('companies.deleted_at')
|
|
|
|
|
->leftJoin('users', function ($join) {
|
|
|
|
|
$join->on('companies.id', '=', 'users.company_id')
|
|
|
|
|
->whereNull('users.deleted_at');
|
|
|
|
|
})
|
|
|
|
|
->select(
|
|
|
|
|
'companies.company_city',
|
|
|
|
|
DB::raw('count(distinct companies.id) as company_total'),
|
|
|
|
|
DB::raw('count(distinct users.id) as user_total')
|
|
|
|
|
)
|
|
|
|
|
->groupBy('companies.company_city')
|
|
|
|
|
->get();
|
|
|
|
|
$countryArea = Company::groupBy('company_city')->get(['company_area']);
|
|
|
|
|
$country = [];
|
|
|
|
|
foreach ($countryArea as $item) {
|
|
|
|
|
$country[] = [
|
|
|
|
|
'company_city' => $item->company_city,
|
|
|
|
|
'company_total' => User::whereHas('company', function ($query) use ($item) {
|
|
|
|
|
$query->where('company_city', $item->company_city);
|
|
|
|
|
})->where('is_schoolmate', 1)->count()
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
return $this->success(compact('courseTypes', 'schoolmate', 'suzhou', 'country'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|