master
cody 2 weeks ago
parent c79d2dd74a
commit 0567493434

@ -245,14 +245,14 @@ class OtherController extends CommonController
$list['course_day_total'] = (clone $calendar)->where('is_count_days', 1)->sum('days'); $list['course_day_total'] = (clone $calendar)->where('is_count_days', 1)->sum('days');
// 上市公司数(所有上市公司) // 上市公司数(所有上市公司)
$list['company_market_total'] = Company::companyMarket($start_date, $end_date); $list['company_market_total'] = CourseSign::shangshi($start_date, $end_date);
// 跟班学员数在指定时间范围内报名的学员中from为'跟班学员'的数量) // 跟班学员数在指定时间范围内报名的学员中from为'跟班学员'的数量)
$course_ids = $courses->pluck('id'); $course_ids = $courses->pluck('id');
$list['ganbu_total'] = CourseSign::genban($start_date, $end_date, $course_ids); $list['ganbu_total'] = CourseSign::genban($start_date, $end_date, $course_ids);
// 今年上市公司数量stock_date在今年 // 今年上市公司数量stock_date在今年
$list['company_market_year_total'] = Company::companyMarketYear($start_date, $end_date, $course_ids); $list['company_market_year_total'] = CourseSign::companyMarketYear($start_date, $end_date, $course_ids);
// 入学后上市公司数量(在指定时间范围内报名的学员所在公司中,在入学后上市的公司数量) // 入学后上市公司数量(在指定时间范围内报名的学员所在公司中,在入学后上市的公司数量)
$list['company_market_after_enrollment_total'] = CourseSign::companyMarketAfterEnrollment($start_date, $end_date, $course_ids); $list['company_market_after_enrollment_total'] = CourseSign::companyMarketAfterEnrollment($start_date, $end_date, $course_ids);
@ -657,7 +657,7 @@ class OtherController extends CommonController
case 'company_market_year_total': case 'company_market_year_total':
// 今年上市公司明细 - 使用模型方法 // 今年上市公司明细 - 使用模型方法
$companies = Company::companyMarketYear($start_date, $end_date, $course_ids, true); $companies = CourseSign::companyMarketYear($start_date, $end_date, $course_ids, true);
foreach ($companies as $company) { foreach ($companies as $company) {
$data[] = [ $data[] = [
'company_name' => $company->company_name, 'company_name' => $company->company_name,

@ -58,52 +58,4 @@ class Company extends SoftDeletesModel
} }
} }
/**
* 上市公司(统计或列表)
* @param bool $retList 是否返回列表false返回数量true返回列表
* @return int|\Illuminate\Database\Eloquent\Collection
*/
public static function companyMarket($start_date, $end_date, $retList = false)
{
$courseSignByType = CourseSign::whereDate('created_at', '>=', $start_date)
->whereDate('created_at', '<=', $end_date)
->whereNotIn('status', [4, 5])
->get();
$list = Company::whereHas('users', function ($query) use ($courseSignByType) {
$query->whereIn('id', $courseSignByType->pluck('user_id'));
})->where('company_market', 1)->get();
if ($retList) {
// 返回列表
return $list;
} else {
// 返回统计数据
return $list->count();
}
}
/**
* 今年上市公司(统计或列表)
* @param int|null $year 年份,不传则使用当前年份
* @param bool $retList 是否返回列表false返回数量true返回列表
* @return int|\Illuminate\Database\Eloquent\Collection
*/
public static function companyMarketYear($start_date, $end_date, $course_ids, $retList = false)
{
$year = date('Y');
$courseSignByType = CourseSign::whereDate('created_at', '>=', $start_date)
->whereDate('created_at', '<=', $end_date)
->whereNotIn('status', [4, 5])
->get();
$list = Company::whereHas('users', function ($query) use ($courseSignByType) {
$query->whereIn('id', $courseSignByType->pluck('user_id'));
})->where('company_market', 1)->whereYear('stock_date', $year)->get();
if ($retList) {
// 返回列表
return $list;
} else {
// 返回统计数据
return $list->count();
}
}
} }

@ -511,5 +511,27 @@ class CourseSign extends SoftDeletesModel
} }
/**
* 今年上市公司(统计或列表)
* @param int|null $year 年份,不传则使用当前年份
* @param bool $retList 是否返回列表false返回数量true返回列表
* @return int|\Illuminate\Database\Eloquent\Collection
*/
public static function companyMarketYear($start_date, $end_date, $course_ids, $retList = false)
{
$courseSignsQuery = self::getStudentList($start_date, $end_date, 1, $course_ids);
$year = date('Y');
$list = Company::whereHas('users', function ($query) use ($courseSignsQuery) {
$query->whereIn('id', $courseSignsQuery->get()->pluck('user_id'));
})->where('company_market', 1)->whereYear('stock_date', $year)->get();
if ($retList) {
// 返回列表
return $list;
} else {
// 返回统计数据
return $list->count();
}
}
} }

Loading…
Cancel
Save