|
|
|
@ -9,6 +9,7 @@ use App\Models\AppointmentType;
|
|
|
|
use App\Models\Book;
|
|
|
|
use App\Models\Book;
|
|
|
|
use App\Models\Calendar;
|
|
|
|
use App\Models\Calendar;
|
|
|
|
use App\Models\Company;
|
|
|
|
use App\Models\Company;
|
|
|
|
|
|
|
|
use App\Models\Course;
|
|
|
|
use App\Models\CourseContentEvaluationAsk;
|
|
|
|
use App\Models\CourseContentEvaluationAsk;
|
|
|
|
use App\Models\CourseContentEvaluationForm;
|
|
|
|
use App\Models\CourseContentEvaluationForm;
|
|
|
|
use App\Models\CourseSign;
|
|
|
|
use App\Models\CourseSign;
|
|
|
|
@ -117,6 +118,7 @@ class CompanyController extends BaseController
|
|
|
|
* @OA\Parameter(name="is_schoolmate", in="query", @OA\Schema(type="string"), required=false, description="是否校友0否1是"),
|
|
|
|
* @OA\Parameter(name="is_schoolmate", in="query", @OA\Schema(type="string"), required=false, description="是否校友0否1是"),
|
|
|
|
* @OA\Parameter(name="course_start_date", in="query", @OA\Schema(type="string"), required=false, description="课程开始日期(筛选课程起止时间在范围内的企业)"),
|
|
|
|
* @OA\Parameter(name="course_start_date", in="query", @OA\Schema(type="string"), required=false, description="课程开始日期(筛选课程起止时间在范围内的企业)"),
|
|
|
|
* @OA\Parameter(name="course_end_date", in="query", @OA\Schema(type="string"), required=false, description="课程结束日期(筛选课程起止时间在范围内的企业)"),
|
|
|
|
* @OA\Parameter(name="course_end_date", in="query", @OA\Schema(type="string"), required=false, description="课程结束日期(筛选课程起止时间在范围内的企业)"),
|
|
|
|
|
|
|
|
* @OA\Parameter(name="is_chart", in="query", @OA\Schema(type="string"), required=false, description="课程是否参与统计0否1是(按公司下用户关联的课程筛选)"),
|
|
|
|
* @OA\Response(
|
|
|
|
* @OA\Response(
|
|
|
|
* response="200",
|
|
|
|
* response="200",
|
|
|
|
* description="暂无"
|
|
|
|
* description="暂无"
|
|
|
|
@ -136,35 +138,44 @@ class CompanyController extends BaseController
|
|
|
|
})->with('courseSigns.course');
|
|
|
|
})->with('courseSigns.course');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
])->whereHas('users', function ($query) use ($all) {
|
|
|
|
])->whereHas('users', function ($query) use ($all) {
|
|
|
|
if (isset($all['course_type_id']) && !empty($all['course_type_id'])) {
|
|
|
|
// 课程筛选:与 courses-home / getStudentList 口径一致,仅 status=1 的报名,且由同一条 courseSign 满足 type/name/日期/is_chart
|
|
|
|
$query->whereHas('courses', function ($q) use ($all) {
|
|
|
|
$hasCourseFilter = (isset($all['course_type_id']) && $all['course_type_id'] !== '') ||
|
|
|
|
$q->where('type', $all['course_type_id']);
|
|
|
|
(isset($all['course_name']) && $all['course_name'] !== '') ||
|
|
|
|
});
|
|
|
|
(isset($all['course_start_date']) && $all['course_start_date'] !== '') ||
|
|
|
|
|
|
|
|
(isset($all['course_end_date']) && $all['course_end_date'] !== '') ||
|
|
|
|
|
|
|
|
(isset($all['is_chart']) && $all['is_chart'] !== '');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($hasCourseFilter) {
|
|
|
|
|
|
|
|
$query->whereHas('courseSigns', function ($q) use ($all) {
|
|
|
|
|
|
|
|
$q->where('status', 1);
|
|
|
|
|
|
|
|
$q->whereHas('course', function ($c) use ($all) {
|
|
|
|
|
|
|
|
if (isset($all['course_type_id']) && $all['course_type_id'] !== '') {
|
|
|
|
|
|
|
|
$c->where('type', $all['course_type_id']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($all['course_name']) && !empty($all['course_name'])) {
|
|
|
|
if (isset($all['course_name']) && $all['course_name'] !== '') {
|
|
|
|
$query->whereHas('courses', function ($q) use ($all) {
|
|
|
|
$c->where('name', 'like', '%' . $all['course_name'] . '%');
|
|
|
|
$q->where('name', 'like', '%' . $all['course_name'] . '%');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 课程起止时间筛选
|
|
|
|
if (
|
|
|
|
if ((isset($all['course_start_date']) && !empty($all['course_start_date'])) ||
|
|
|
|
(isset($all['course_start_date']) && $all['course_start_date'] !== '') ||
|
|
|
|
(isset($all['course_end_date']) && !empty($all['course_end_date']))) {
|
|
|
|
(isset($all['course_end_date']) && $all['course_end_date'] !== '')
|
|
|
|
$query->whereHas('courses', function ($q) use ($all) {
|
|
|
|
) {
|
|
|
|
$course_start_date = $all['course_start_date'] ?? null;
|
|
|
|
$course_start_date = $all['course_start_date'] ?? null;
|
|
|
|
$course_end_date = $all['course_end_date'] ?? null;
|
|
|
|
$course_end_date = $all['course_end_date'] ?? null;
|
|
|
|
if ($course_start_date && $course_end_date) {
|
|
|
|
if ($course_start_date && $course_end_date) {
|
|
|
|
// 课程开始时间或结束时间在指定时间范围内
|
|
|
|
$c->where(function ($sub) use ($course_start_date, $course_end_date) {
|
|
|
|
$q->where(function ($subQuery) use ($course_start_date, $course_end_date) {
|
|
|
|
$sub->whereBetween('start_date', [$course_start_date, $course_end_date])
|
|
|
|
$subQuery->whereBetween('start_date', [$course_start_date, $course_end_date])
|
|
|
|
|
|
|
|
->orWhereBetween('end_date', [$course_start_date, $course_end_date]);
|
|
|
|
->orWhereBetween('end_date', [$course_start_date, $course_end_date]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} elseif ($course_start_date) {
|
|
|
|
} elseif ($course_start_date) {
|
|
|
|
// 只指定开始日期,筛选课程结束时间 >= 开始日期
|
|
|
|
$c->where('end_date', '>=', $course_start_date);
|
|
|
|
$q->where('end_date', '>=', $course_start_date);
|
|
|
|
|
|
|
|
} elseif ($course_end_date) {
|
|
|
|
} elseif ($course_end_date) {
|
|
|
|
// 只指定结束日期,筛选课程开始时间 <= 结束日期
|
|
|
|
$c->where('start_date', '<=', $course_end_date);
|
|
|
|
$q->where('start_date', '<=', $course_end_date);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($all['is_chart']) && $all['is_chart'] !== '') {
|
|
|
|
|
|
|
|
$c->where('is_chart', $all['is_chart']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($all['user_name']) && !empty($all['user_name'])) {
|
|
|
|
if (isset($all['user_name']) && !empty($all['user_name'])) {
|
|
|
|
@ -273,8 +284,14 @@ class CompanyController extends BaseController
|
|
|
|
$start_date = $start_year ? $start_year . '-01-01' : date('Y-01-01');
|
|
|
|
$start_date = $start_year ? $start_year . '-01-01' : date('Y-01-01');
|
|
|
|
$end_date = $end_year ? $end_year . '-12-31' : date('Y-m-d');
|
|
|
|
$end_date = $end_year ? $end_year . '-12-31' : date('Y-m-d');
|
|
|
|
if ($start_date && $end_date) {
|
|
|
|
if ($start_date && $end_date) {
|
|
|
|
// 累计被投企业数(从起始日期到结束日期)
|
|
|
|
// 累计被投企业数(与 CourseSign::yhInvestedTotal / courses-home 口径一致:getStudentList 学员 + 被投企业)
|
|
|
|
$investedCompanies = Company::yhInvestedTotal($end_date, true);
|
|
|
|
$course_ids = null;
|
|
|
|
|
|
|
|
if (!empty($all['course_type_id'])) {
|
|
|
|
|
|
|
|
$tid = is_array($all['course_type_id']) ? $all['course_type_id'] : explode(',', (string) $all['course_type_id']);
|
|
|
|
|
|
|
|
$tid = array_filter(array_map('trim', $tid));
|
|
|
|
|
|
|
|
$course_ids = $tid ? Course::whereIn('type', $tid)->pluck('id')->toArray() : null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$investedCompanies = CourseSign::yhInvestedTotal(CourseType::START_DATE, $end_date, $course_ids, true);
|
|
|
|
if ($investedCompanies) {
|
|
|
|
if ($investedCompanies) {
|
|
|
|
$investedCompaniesCollection = collect($investedCompanies);
|
|
|
|
$investedCompaniesCollection = collect($investedCompanies);
|
|
|
|
$statistics['course_signs_invested'] = $investedCompaniesCollection->count();
|
|
|
|
$statistics['course_signs_invested'] = $investedCompaniesCollection->count();
|
|
|
|
|