|
|
|
|
@ -169,8 +169,9 @@ class CourseController extends BaseController
|
|
|
|
|
});
|
|
|
|
|
$list = $list->orderBy($all['sort_name'] ?? 'sign_status', $all['sort_type'] ?? 'asc');
|
|
|
|
|
if (isset($all['is_export']) && !empty($all['is_export'])) {
|
|
|
|
|
$list = $list->limit(5000)->get()->toArray();
|
|
|
|
|
return Excel::download(new CommonExport($list, $all['export_fields'] ?? ''), $all['file_name'] ?? '' . date('YmdHis') . '.xlsx');
|
|
|
|
|
$exportList = $list->limit(5000)->get();
|
|
|
|
|
$this->withoutCourseQrcodeAppend($exportList);
|
|
|
|
|
return Excel::download(new CommonExport($exportList->toArray(), $all['export_fields'] ?? ''), $all['file_name'] ?? '' . date('YmdHis') . '.xlsx');
|
|
|
|
|
} else {
|
|
|
|
|
// 在分页之前,克隆查询构建器用于计算总和
|
|
|
|
|
$totalStatsQuery = clone $list;
|
|
|
|
|
@ -206,6 +207,9 @@ class CourseController extends BaseController
|
|
|
|
|
$totalStats['sign_black_total'] += $course->sign_black_total ?? 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 列表不现场生成小程序码,避免微信缓存失败导致整页 500
|
|
|
|
|
$this->withoutCourseQrcodeAppend($list->getCollection());
|
|
|
|
|
|
|
|
|
|
// 将分页数据转换为数组,并在最外层追加统计总和
|
|
|
|
|
$result = $list->toArray();
|
|
|
|
|
$result['statistics_total'] = $totalStats;
|
|
|
|
|
@ -214,6 +218,19 @@ class CourseController extends BaseController
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 列表/导出时移除 qrcode append,避免触发微信 access_token
|
|
|
|
|
*/
|
|
|
|
|
protected function withoutCourseQrcodeAppend($courses)
|
|
|
|
|
{
|
|
|
|
|
foreach ($courses as $course) {
|
|
|
|
|
if (method_exists($course, 'setAppends')) {
|
|
|
|
|
$course->setAppends(array_values(array_diff($course->getAppends(), ['qrcode'])));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $courses;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\Get(
|
|
|
|
|
* path="/api/admin/courses/show",
|
|
|
|
|
@ -242,6 +259,9 @@ class CourseController extends BaseController
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
|
|
|
|
|
}
|
|
|
|
|
$detail = $this->model->withCount('courseSigns')->with(underlineToHump($all['show_relation'] ?? []))->find($all['id']);
|
|
|
|
|
if ($detail) {
|
|
|
|
|
$detail->setAppends(array_values(array_diff($detail->getAppends(), ['qrcode'])));
|
|
|
|
|
}
|
|
|
|
|
return $this->success($detail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|