diff --git a/app/Http/Controllers/Admin/OtherController.php b/app/Http/Controllers/Admin/OtherController.php index b9e5cdc..2c7e97e 100755 --- a/app/Http/Controllers/Admin/OtherController.php +++ b/app/Http/Controllers/Admin/OtherController.php @@ -377,22 +377,11 @@ class OtherController extends CommonController ]; } } - // 附加历史课程数据(与 home-v2 yearConfigs 口径一致:仅统计 typeDetail.name 能匹配某个 is_chart=1 且 is_history=0 的 CourseType 的 HistoryCourse) - $chartHistoryTypeNames = CourseType::where('is_chart', 1)->where('is_history', 0)->pluck('name')->toArray(); + // 附加历史课程数据(与 course_signs_pass 口径一致:与 needHistory 的 HistoryCourse 条件一致,calendar+日期+type in course_type_id) $courseTypesHistory = CourseType::where('is_history', 1)->whereIn('id', $course_type_id)->get(); foreach ($courseTypesHistory as $historyCourse) { $courses3 = HistoryCourse::whereHas('calendar', function ($query) { $query->where('is_count_people', 1); - })->whereHas('typeDetail', function ($query) use ($chartHistoryTypeNames) { - if (empty($chartHistoryTypeNames)) { - $query->whereRaw('1=0'); - return; - } - $query->where(function ($q) use ($chartHistoryTypeNames) { - foreach ($chartHistoryTypeNames as $n) { - $q->orWhere('name', 'like', '%' . $n . '%'); - } - }); })->where(function ($query) use ($start_date, $end_date) { // 开始结束日期的筛选。or查询 $query->whereBetween('start_time', [$start_date, $end_date]) @@ -874,22 +863,11 @@ class OtherController extends CommonController ]; } } - // 附加历史课程数据(与 home-v2 yearConfigs 口径一致:仅统计 typeDetail.name 能匹配某个 is_chart=1 且 is_history=0 的 CourseType 的 HistoryCourse) - $chartHistoryTypeNames = CourseType::where('is_chart', 1)->where('is_history', 0)->pluck('name')->toArray(); + // 附加历史课程数据(与 course_signs_pass 口径一致:与 needHistory 的 HistoryCourse 条件一致,calendar+日期+type in course_type_id) $courseTypesHistory = CourseType::where('is_history', 1)->whereIn('id', $course_type_id)->get(); foreach ($courseTypesHistory as $historyCourse) { $courses3 = HistoryCourse::whereHas('calendar', function ($query) { $query->where('is_count_people', 1); - })->whereHas('typeDetail', function ($query) use ($chartHistoryTypeNames) { - if (empty($chartHistoryTypeNames)) { - $query->whereRaw('1=0'); - return; - } - $query->where(function ($q) use ($chartHistoryTypeNames) { - foreach ($chartHistoryTypeNames as $n) { - $q->orWhere('name', 'like', '%' . $n . '%'); - } - }); })->where(function ($query) use ($start_date, $end_date) { // 开始结束日期的筛选。or查询 $query->whereBetween('start_time', [$start_date, $end_date])