|
|
|
|
@ -74,14 +74,13 @@ class CourseSign extends SoftDeletesModel
|
|
|
|
|
return $this->hasMany(ThirdAppointmentLog::class, 'course_sign_id', 'id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 指定时间内的报名信息(未去重)
|
|
|
|
|
* 获取学员列表数据
|
|
|
|
|
*/
|
|
|
|
|
public static function courseSignsTotal($start_date, $end_date, $status = null, $course_ids = null, $area = null, $retList = false)
|
|
|
|
|
public static function getStudentList($start_date = null, $end_date = null, $status = null, $course_ids = null)
|
|
|
|
|
{
|
|
|
|
|
$total = CourseSign::where(function ($query) use ($status, $course_ids) {
|
|
|
|
|
if (isset($status)) {
|
|
|
|
|
$baseQuery = CourseSign::where(function ($query) use ($course_ids, $status) {
|
|
|
|
|
if ($status) {
|
|
|
|
|
$query->where('status', $status);
|
|
|
|
|
}
|
|
|
|
|
if (isset($course_ids)) {
|
|
|
|
|
@ -89,24 +88,27 @@ class CourseSign extends SoftDeletesModel
|
|
|
|
|
}
|
|
|
|
|
})->whereHas('course', function ($query) use ($start_date, $end_date) {
|
|
|
|
|
// 开始结束日期的筛选。or查询
|
|
|
|
|
$query->whereBetween('start_date', [$start_date, $end_date])
|
|
|
|
|
->orWhereBetween('end_date', [$start_date, $end_date]);
|
|
|
|
|
})->whereHas('user', function ($query) use ($area) {
|
|
|
|
|
// if (isset($area)) {
|
|
|
|
|
// if ($area == '苏州市外') {
|
|
|
|
|
// $allArea = ParameterDetail::where('parameter_id', 5)->get();
|
|
|
|
|
// $query->whereNotIn('company_area', $allArea->pluck('value'));
|
|
|
|
|
// } else {
|
|
|
|
|
// $query->where('company_area', $area);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
})->whereNotIn('status', [4, 5]);
|
|
|
|
|
if ($start_date && $end_date) {
|
|
|
|
|
$query->whereBetween('start_date', [$start_date, $end_date])
|
|
|
|
|
->orWhereBetween('end_date', [$start_date, $end_date]);
|
|
|
|
|
}
|
|
|
|
|
})->whereNotIn('status', [4, 5, 6]);
|
|
|
|
|
return $baseQuery;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 指定时间内的报名信息(未去重)
|
|
|
|
|
*/
|
|
|
|
|
public static function courseSignsTotal($start_date, $end_date, $status = null, $course_ids = null, $retList = false)
|
|
|
|
|
{
|
|
|
|
|
$totalQuery = self::getStudentList($start_date, $end_date, $status, $course_ids);
|
|
|
|
|
if ($retList) {
|
|
|
|
|
// 返回列表
|
|
|
|
|
return $total->get();
|
|
|
|
|
return $totalQuery->get();
|
|
|
|
|
} else {
|
|
|
|
|
// 基础数据
|
|
|
|
|
$baseTotal = $total->count();
|
|
|
|
|
$baseTotal = $totalQuery->count();
|
|
|
|
|
// 历史数据
|
|
|
|
|
$historyTotal = HistoryCourse::where(function ($query) use ($start_date, $end_date) {
|
|
|
|
|
// 开始结束日期的筛选。or查询
|
|
|
|
|
@ -121,30 +123,10 @@ class CourseSign extends SoftDeletesModel
|
|
|
|
|
/**
|
|
|
|
|
* 指定时间内的报名信息(去重)
|
|
|
|
|
*/
|
|
|
|
|
public static function courseSignsTotalByUnique($start_date, $end_date, $status = null, $course_ids = null, $area = null, $retList = false)
|
|
|
|
|
public static function courseSignsTotalByUnique($start_date, $end_date, $status = null, $course_ids = null, $retList = false)
|
|
|
|
|
{
|
|
|
|
|
$courseSignByType = CourseSign::whereHas('course', function ($query) use ($start_date, $end_date) {
|
|
|
|
|
// 开始结束日期的筛选。or查询
|
|
|
|
|
$query->whereBetween('start_date', [$start_date, $end_date])
|
|
|
|
|
->orWhereBetween('end_date', [$start_date, $end_date]);
|
|
|
|
|
})->whereHas('user', function ($query) use ($area) {
|
|
|
|
|
// if ($area) {
|
|
|
|
|
// if ($area == '苏州市外') {
|
|
|
|
|
// $allArea = ParameterDetail::where('parameter_id', 5)->get();
|
|
|
|
|
// $query->whereNotIn('company_area', $allArea->pluck('value'));
|
|
|
|
|
// } else {
|
|
|
|
|
// $query->where('company_area', $area);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
})->where(function ($query) use ($status, $course_ids) {
|
|
|
|
|
if (isset($status)) {
|
|
|
|
|
$query->where('status', $status);
|
|
|
|
|
}
|
|
|
|
|
if (isset($course_ids)) {
|
|
|
|
|
$query->whereIn('course_id', $course_ids);
|
|
|
|
|
}
|
|
|
|
|
})->whereNotIn('status', [4, 5])->get();
|
|
|
|
|
$user = User::whereIn('id', $courseSignByType->pluck('user_id'))->groupBy('mobile')->get();
|
|
|
|
|
$totalQuery = self::getStudentList($start_date, $end_date, $status, $course_ids);
|
|
|
|
|
$user = User::whereIn('id', $totalQuery->get()->pluck('user_id'))->groupBy('mobile')->get();
|
|
|
|
|
if ($retList) {
|
|
|
|
|
// 列表
|
|
|
|
|
return $user;
|
|
|
|
|
@ -164,15 +146,11 @@ class CourseSign extends SoftDeletesModel
|
|
|
|
|
/**
|
|
|
|
|
* 指定时间内的被投企业
|
|
|
|
|
*/
|
|
|
|
|
public static function yhInvested($start_date, $end_date, $retList = false)
|
|
|
|
|
public static function yhInvested($start_date = null, $end_date = null, $retList = false)
|
|
|
|
|
{
|
|
|
|
|
$courseSignByType = CourseSign::whereHas('course', function ($query) use ($start_date, $end_date) {
|
|
|
|
|
// 开始结束日期的筛选。or查询
|
|
|
|
|
$query->whereBetween('start_date', [$start_date, $end_date])
|
|
|
|
|
->orWhereBetween('end_date', [$start_date, $end_date]);
|
|
|
|
|
})->whereNotIn('status', [4, 5])->get();
|
|
|
|
|
$list = Company::whereHas('users', function ($query) use ($courseSignByType) {
|
|
|
|
|
$query->whereIn('id', $courseSignByType->pluck('user_id'));
|
|
|
|
|
$courseSignByTypeQuery = self::getStudentList($start_date, $end_date, null, null);
|
|
|
|
|
$list = Company::whereHas('users', function ($query) use ($courseSignByTypeQuery) {
|
|
|
|
|
$query->whereIn('id', $courseSignByTypeQuery->get()->pluck('user_id'));
|
|
|
|
|
})->where('is_yh_invested', 1)->get();
|
|
|
|
|
if ($retList) {
|
|
|
|
|
// 返回列表
|
|
|
|
|
@ -191,25 +169,17 @@ class CourseSign extends SoftDeletesModel
|
|
|
|
|
* @param bool $retList 是否返回列表,false返回数量,true返回列表
|
|
|
|
|
* @return int|\Illuminate\Database\Eloquent\Collection
|
|
|
|
|
*/
|
|
|
|
|
public static function ganbu($start_date, $end_date, $course_ids = null, $retList = false)
|
|
|
|
|
public static function genban($start_date, $end_date, $course_ids = null, $retList = false)
|
|
|
|
|
{
|
|
|
|
|
$courseSignsForGanbu = self::whereHas('course', function ($query) use ($start_date, $end_date) {
|
|
|
|
|
// 开始结束日期的筛选。or查询
|
|
|
|
|
$query->whereBetween('start_date', [$start_date, $end_date])
|
|
|
|
|
->orWhereBetween('end_date', [$start_date, $end_date]);
|
|
|
|
|
})->where(function ($query) use ($course_ids) {
|
|
|
|
|
if ($course_ids) {
|
|
|
|
|
$query->whereIn('course_id', $course_ids);
|
|
|
|
|
}
|
|
|
|
|
})->whereNotIn('status', [4, 5])
|
|
|
|
|
->whereHas('user', function ($query) {
|
|
|
|
|
$query->where('from', '跟班学员');
|
|
|
|
|
})->get();
|
|
|
|
|
$courseSignsQuery = self::getStudentList($start_date, $end_date, null, $course_ids);
|
|
|
|
|
$courseSigns = $courseSignsQuery->whereHas('user', function ($query) {
|
|
|
|
|
$query->where('from', '跟班学员');
|
|
|
|
|
})->get();
|
|
|
|
|
|
|
|
|
|
if ($retList) {
|
|
|
|
|
return User::with('company')->whereIn('id', $courseSignsForGanbu->pluck('user_id'))->get();
|
|
|
|
|
return User::with('company')->whereIn('id', $courseSigns->pluck('user_id'))->get();
|
|
|
|
|
} else {
|
|
|
|
|
return User::whereIn('id', $courseSignsForGanbu->pluck('user_id'))->count();
|
|
|
|
|
return User::whereIn('id', $courseSigns->pluck('user_id'))->count();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -223,18 +193,8 @@ class CourseSign extends SoftDeletesModel
|
|
|
|
|
*/
|
|
|
|
|
public static function companyMarketAfterEnrollment($start_date, $end_date, $course_ids = null, $retList = false)
|
|
|
|
|
{
|
|
|
|
|
$courseSignsForStock = self::whereHas('course', function ($query) use ($start_date, $end_date) {
|
|
|
|
|
// 开始结束日期的筛选。or查询
|
|
|
|
|
$query->whereBetween('start_date', [$start_date, $end_date])
|
|
|
|
|
->orWhereBetween('end_date', [$start_date, $end_date]);
|
|
|
|
|
})->where(function ($query) use ($course_ids) {
|
|
|
|
|
if ($course_ids) {
|
|
|
|
|
$query->whereIn('course_id', $course_ids);
|
|
|
|
|
}
|
|
|
|
|
})->whereNotIn('status', [4, 5])
|
|
|
|
|
->with('user.company')
|
|
|
|
|
->get();
|
|
|
|
|
|
|
|
|
|
$courseSignsQuery = self::getStudentList($start_date, $end_date, null, $course_ids);
|
|
|
|
|
$courseSignsForStock = $courseSignsQuery->with('user.company')->get();
|
|
|
|
|
$companiesAfterEnrollment = [];
|
|
|
|
|
foreach ($courseSignsForStock as $sign) {
|
|
|
|
|
if ($sign->user && $sign->user->company && $sign->user->company->company_market == 1) {
|
|
|
|
|
@ -272,19 +232,9 @@ class CourseSign extends SoftDeletesModel
|
|
|
|
|
*/
|
|
|
|
|
public static function area($start_date, $end_date, $status = null, $course_ids = null, $retList = false)
|
|
|
|
|
{
|
|
|
|
|
$courseSignsQuery = self::getStudentList($start_date, $end_date, $status, $course_ids);
|
|
|
|
|
// 获取所有学员id
|
|
|
|
|
$courseSignList = CourseSign::where(function ($query) use ($status, $course_ids) {
|
|
|
|
|
if (isset($status)) {
|
|
|
|
|
$query->where('status', $status);
|
|
|
|
|
}
|
|
|
|
|
if (isset($course_ids)) {
|
|
|
|
|
$query->whereIn('course_id', $course_ids);
|
|
|
|
|
}
|
|
|
|
|
})->whereHas('course', function ($query) use ($start_date, $end_date) {
|
|
|
|
|
// 开始结束日期的筛选。or查询
|
|
|
|
|
$query->whereBetween('start_date', [$start_date, $end_date])
|
|
|
|
|
->orWhereBetween('end_date', [$start_date, $end_date]);
|
|
|
|
|
})->whereHas('user')->whereNotIn('status', [4, 5]);
|
|
|
|
|
$courseSignList = $courseSignsQuery->whereHas('user');
|
|
|
|
|
// 地区
|
|
|
|
|
$suzhouArea = Company::where('company_city', '苏州市')->pluck('company_area')->unique();
|
|
|
|
|
$list = [];
|
|
|
|
|
@ -325,5 +275,117 @@ class CourseSign extends SoftDeletesModel
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 元和员工参与企业
|
|
|
|
|
*/
|
|
|
|
|
public static function companyJoin($start_date = null, $end_date = null, $course_ids = null, $retList = false)
|
|
|
|
|
{
|
|
|
|
|
$courseSignsQuery = self::getStudentList($start_date, $end_date, 1, $course_ids);
|
|
|
|
|
$courseSignByType = $courseSignsQuery->get();
|
|
|
|
|
|
|
|
|
|
// 检测关键词
|
|
|
|
|
$companyNameKeyword = [
|
|
|
|
|
'元禾控股', '元禾原点', '元禾厚望', '元禾重元',
|
|
|
|
|
'元禾璞华', '元禾谷风', '元禾绿柳', '元禾辰坤', '元禾沙湖',
|
|
|
|
|
'禾裕集团', '苏州科服', '信诚管理咨询',
|
|
|
|
|
'集成电路公司', '常州团队', '国企元禾'
|
|
|
|
|
];
|
|
|
|
|
$list = Company::whereHas('users', function ($query) use ($courseSignByType, $companyNameKeyword) {
|
|
|
|
|
$query->whereIn('id', $courseSignByType->pluck('user_id'));
|
|
|
|
|
})->where(function ($query) use ($companyNameKeyword) {
|
|
|
|
|
foreach ($companyNameKeyword as $item) {
|
|
|
|
|
$query->orWhere('company_name', 'like', '%' . $item . '%');
|
|
|
|
|
}
|
|
|
|
|
})->get();
|
|
|
|
|
if ($retList) {
|
|
|
|
|
// 返回列表
|
|
|
|
|
return $list;
|
|
|
|
|
} else {
|
|
|
|
|
// 返回统计数据
|
|
|
|
|
return $list->count();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 干部参与(统计或列表)
|
|
|
|
|
* @param string $start_date 开始日期
|
|
|
|
|
* @param string $end_date 结束日期
|
|
|
|
|
* @param array|null $course_ids 课程ID数组,不传则统计所有课程
|
|
|
|
|
* @param bool $retList 是否返回列表,false返回数量,true返回列表
|
|
|
|
|
* @return int|\Illuminate\Database\Eloquent\Collection
|
|
|
|
|
*/
|
|
|
|
|
public static function ganbu($start_date = null, $end_date = null, $course_ids = null, $retList = false)
|
|
|
|
|
{
|
|
|
|
|
$courseSignsQuery = self::getStudentList($start_date, $end_date, 1, $course_ids);
|
|
|
|
|
$courseSigns = $courseSignsQuery->whereHas('user', function ($query) {
|
|
|
|
|
$query->where('from', '跟班学员');
|
|
|
|
|
})->get();
|
|
|
|
|
if ($retList) {
|
|
|
|
|
return User::with('company')->whereIn('id', $courseSigns->pluck('user_id'))->get();
|
|
|
|
|
} else {
|
|
|
|
|
return User::whereIn('id', $courseSigns->pluck('user_id'))->count();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 头部企业(统计或列表)
|
|
|
|
|
* @param string $start_date 开始日期
|
|
|
|
|
* @param string $end_date 结束日期
|
|
|
|
|
* @param array|null $course_ids 课程ID数组,不传则统计所有课程
|
|
|
|
|
* @param bool $retList 是否返回列表,false返回数量,true返回列表
|
|
|
|
|
* @return int|\Illuminate\Database\Eloquent\Collection
|
|
|
|
|
*/
|
|
|
|
|
public static function toubuqiye($start_date = null, $end_date = null, $course_ids = null, $retList = false)
|
|
|
|
|
{
|
|
|
|
|
$courseSignsQuery = self::getStudentList($start_date, $end_date, 1, $course_ids);
|
|
|
|
|
$courseSignByType = $courseSignsQuery->get();
|
|
|
|
|
$list = Company::whereHas('users', function ($query) use ($courseSignByType) {
|
|
|
|
|
$query->whereIn('id', $courseSignByType->pluck('user_id'));
|
|
|
|
|
})->where('company_tag', 'like', '%' . '高新技术企业' . '%')->get();
|
|
|
|
|
if ($retList) {
|
|
|
|
|
// 返回列表
|
|
|
|
|
return $list;
|
|
|
|
|
} else {
|
|
|
|
|
// 返回统计数据
|
|
|
|
|
return $list->count();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 高层次人才
|
|
|
|
|
*/
|
|
|
|
|
public static function rencai($start_date = null, $end_date = null, $course_ids = null, $retList = false)
|
|
|
|
|
{
|
|
|
|
|
$courseSignsQuery = self::getStudentList($start_date, $end_date, 1, $course_ids);
|
|
|
|
|
$courseSigns = $courseSignsQuery->whereHas('course', function ($query) use ($start_date, $end_date) {
|
|
|
|
|
$query->where('typeDetail', function ($q) {
|
|
|
|
|
$q->where('name', '人才培训');
|
|
|
|
|
});
|
|
|
|
|
})->get();
|
|
|
|
|
if ($retList) {
|
|
|
|
|
return User::whereIn('id', $courseSigns->pluck('user_id'))->get();
|
|
|
|
|
} else {
|
|
|
|
|
return User::whereIn('id', $courseSigns->pluck('user_id'))->count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 重点上市公司
|
|
|
|
|
*/
|
|
|
|
|
public static function shangshi($start_date = null, $end_date = null, $course_ids = null, $retList = false)
|
|
|
|
|
{
|
|
|
|
|
$courseSignsQuery = self::getStudentList($start_date, $end_date, 1, $course_ids);
|
|
|
|
|
$list = Company::whereHas('users', function ($query) use ($courseSignsQuery) {
|
|
|
|
|
$query->whereIn('id', $courseSignsQuery->get()->pluck('user_id'));
|
|
|
|
|
})->where('company_market', 1)->get();
|
|
|
|
|
if ($retList) {
|
|
|
|
|
return $list->get();
|
|
|
|
|
} else {
|
|
|
|
|
return $list->count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|