|
|
|
|
@ -58,91 +58,107 @@ class CourseController extends BaseController
|
|
|
|
|
{
|
|
|
|
|
$all = request()->all();
|
|
|
|
|
$list = $this->model->with(underlineToHump($all['show_relation'] ?? []))
|
|
|
|
|
->withCount(['courseSigns' => function ($query) {
|
|
|
|
|
$query->whereNotIn('status', [4, 5]);
|
|
|
|
|
}])->withCount(['courseSigns as sign_pass_total' => function ($query) {
|
|
|
|
|
$query->where('status', 1)->whereHas('user');
|
|
|
|
|
}])->withCount(['courseSigns as sign_wait_total' => function ($query) {
|
|
|
|
|
$query->where('status', 0)->whereHas('user');
|
|
|
|
|
}])->withCount(['courseSigns as sign_fault_total' => function ($query) {
|
|
|
|
|
$query->where('status', 2)->whereHas('user');
|
|
|
|
|
}])->withCount(['courseSigns as sign_prepare_total' => function ($query) {
|
|
|
|
|
$query->where('status', 3)->whereHas('user');
|
|
|
|
|
}])->withCount(['courseSigns as sign_cancel_total' => function ($query) {
|
|
|
|
|
$query->where('status', 4)->whereHas('user');
|
|
|
|
|
}])->withCount(['courseSigns as sign_give_up_total' => function ($query) {
|
|
|
|
|
$query->where('status', 5)->whereHas('user');
|
|
|
|
|
}])->withCount(['courseSigns as sign_black_total' => function ($query) {
|
|
|
|
|
$query->where('status', 6)->whereHas('user');
|
|
|
|
|
}])->where(function ($query) use ($all) {
|
|
|
|
|
if (isset($all['has_course_forms']) && !empty($all['has_course_forms'])) {
|
|
|
|
|
$query->whereHas('courseForms');
|
|
|
|
|
->withCount([
|
|
|
|
|
'courseSigns' => function ($query) {
|
|
|
|
|
$query->whereNotIn('status', [4, 5]);
|
|
|
|
|
}
|
|
|
|
|
if (isset($all['start_date'])) {
|
|
|
|
|
$query->where('start_date', '>=', $all['start_date']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($all['end_date'])) {
|
|
|
|
|
$query->where('end_date', '<=', $all['end_date']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($all['course_type_id'])) {
|
|
|
|
|
$course_type_id = explode(',', $all['course_type_id']);
|
|
|
|
|
$query->whereIn('type', $course_type_id);
|
|
|
|
|
}
|
|
|
|
|
if (isset($all['filter']) && !empty($all['filter'])) {
|
|
|
|
|
foreach ($all['filter'] as $condition) {
|
|
|
|
|
$key = $condition['key'] ?? null;
|
|
|
|
|
$op = $condition['op'] ?? null;
|
|
|
|
|
$value = $condition['value'] ?? null;
|
|
|
|
|
if (!isset($key) || !isset($op) || !isset($value)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// 等于
|
|
|
|
|
if ($op == 'eq') {
|
|
|
|
|
$query->where($key, $value);
|
|
|
|
|
}
|
|
|
|
|
// 不等于
|
|
|
|
|
if ($op == 'neq') {
|
|
|
|
|
$query->where($key, '!=', $value);
|
|
|
|
|
}
|
|
|
|
|
// 大于
|
|
|
|
|
if ($op == 'gt') {
|
|
|
|
|
$query->where($key, '>', $value);
|
|
|
|
|
}
|
|
|
|
|
// 大于等于
|
|
|
|
|
if ($op == 'egt') {
|
|
|
|
|
$query->where($key, '>=', $value);
|
|
|
|
|
}
|
|
|
|
|
// 小于
|
|
|
|
|
if ($op == 'lt') {
|
|
|
|
|
$query->where($key, '<', $value);
|
|
|
|
|
}
|
|
|
|
|
// 小于等于
|
|
|
|
|
if ($op == 'elt') {
|
|
|
|
|
$query->where($key, '<=', $value);
|
|
|
|
|
}
|
|
|
|
|
// 模糊搜索
|
|
|
|
|
if ($op == 'like') {
|
|
|
|
|
$query->where($key, 'like', '%' . $value . '%');
|
|
|
|
|
}
|
|
|
|
|
// 否定模糊搜索
|
|
|
|
|
if ($op == 'notlike') {
|
|
|
|
|
$query->where($key, 'not like', '%' . $value . '%');
|
|
|
|
|
}
|
|
|
|
|
// 范围搜索
|
|
|
|
|
if ($op == 'range') {
|
|
|
|
|
list($from, $to) = explode(',', $value);
|
|
|
|
|
if (empty($from) || empty($to)) {
|
|
|
|
|
])->withCount([
|
|
|
|
|
'courseSigns as sign_pass_total' => function ($query) {
|
|
|
|
|
$query->where('status', 1)->whereHas('user');
|
|
|
|
|
}
|
|
|
|
|
])->withCount([
|
|
|
|
|
'courseSigns as sign_wait_total' => function ($query) {
|
|
|
|
|
$query->where('status', 0)->whereHas('user');
|
|
|
|
|
}
|
|
|
|
|
])->withCount([
|
|
|
|
|
'courseSigns as sign_fault_total' => function ($query) {
|
|
|
|
|
$query->where('status', 2)->whereHas('user');
|
|
|
|
|
}
|
|
|
|
|
])->withCount([
|
|
|
|
|
'courseSigns as sign_prepare_total' => function ($query) {
|
|
|
|
|
$query->where('status', 3)->whereHas('user');
|
|
|
|
|
}
|
|
|
|
|
])->withCount([
|
|
|
|
|
'courseSigns as sign_cancel_total' => function ($query) {
|
|
|
|
|
$query->where('status', 4)->whereHas('user');
|
|
|
|
|
}
|
|
|
|
|
])->withCount([
|
|
|
|
|
'courseSigns as sign_give_up_total' => function ($query) {
|
|
|
|
|
$query->where('status', 5)->whereHas('user');
|
|
|
|
|
}
|
|
|
|
|
])->withCount([
|
|
|
|
|
'courseSigns as sign_black_total' => function ($query) {
|
|
|
|
|
$query->where('status', 6)->whereHas('user');
|
|
|
|
|
}
|
|
|
|
|
])->where(function ($query) use ($all) {
|
|
|
|
|
if (isset($all['has_course_forms']) && !empty($all['has_course_forms'])) {
|
|
|
|
|
$query->whereHas('courseForms');
|
|
|
|
|
}
|
|
|
|
|
if (isset($all['start_date'])) {
|
|
|
|
|
$query->where('start_date', '>=', $all['start_date']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($all['end_date'])) {
|
|
|
|
|
$query->where('end_date', '<=', $all['end_date']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($all['course_type_id'])) {
|
|
|
|
|
$course_type_id = explode(',', $all['course_type_id']);
|
|
|
|
|
$query->whereIn('type', $course_type_id);
|
|
|
|
|
}
|
|
|
|
|
if (isset($all['filter']) && !empty($all['filter'])) {
|
|
|
|
|
foreach ($all['filter'] as $condition) {
|
|
|
|
|
$key = $condition['key'] ?? null;
|
|
|
|
|
$op = $condition['op'] ?? null;
|
|
|
|
|
$value = $condition['value'] ?? null;
|
|
|
|
|
if (!isset($key) || !isset($op) || !isset($value)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$query->whereBetween($key, [$from, $to]);
|
|
|
|
|
}
|
|
|
|
|
if ($op == 'in') {
|
|
|
|
|
$array = explode(',', $value);
|
|
|
|
|
$query->whereIn($key, $array);
|
|
|
|
|
// 等于
|
|
|
|
|
if ($op == 'eq') {
|
|
|
|
|
$query->where($key, $value);
|
|
|
|
|
}
|
|
|
|
|
// 不等于
|
|
|
|
|
if ($op == 'neq') {
|
|
|
|
|
$query->where($key, '!=', $value);
|
|
|
|
|
}
|
|
|
|
|
// 大于
|
|
|
|
|
if ($op == 'gt') {
|
|
|
|
|
$query->where($key, '>', $value);
|
|
|
|
|
}
|
|
|
|
|
// 大于等于
|
|
|
|
|
if ($op == 'egt') {
|
|
|
|
|
$query->where($key, '>=', $value);
|
|
|
|
|
}
|
|
|
|
|
// 小于
|
|
|
|
|
if ($op == 'lt') {
|
|
|
|
|
$query->where($key, '<', $value);
|
|
|
|
|
}
|
|
|
|
|
// 小于等于
|
|
|
|
|
if ($op == 'elt') {
|
|
|
|
|
$query->where($key, '<=', $value);
|
|
|
|
|
}
|
|
|
|
|
// 模糊搜索
|
|
|
|
|
if ($op == 'like') {
|
|
|
|
|
$query->where($key, 'like', '%' . $value . '%');
|
|
|
|
|
}
|
|
|
|
|
// 否定模糊搜索
|
|
|
|
|
if ($op == 'notlike') {
|
|
|
|
|
$query->where($key, 'not like', '%' . $value . '%');
|
|
|
|
|
}
|
|
|
|
|
// 范围搜索
|
|
|
|
|
if ($op == 'range') {
|
|
|
|
|
list($from, $to) = explode(',', $value);
|
|
|
|
|
if (empty($from) || empty($to)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$query->whereBetween($key, [$from, $to]);
|
|
|
|
|
}
|
|
|
|
|
if ($op == 'in') {
|
|
|
|
|
$array = explode(',', $value);
|
|
|
|
|
$query->whereIn($key, $array);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
$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();
|
|
|
|
|
@ -219,6 +235,8 @@ class CourseController extends BaseController
|
|
|
|
|
* @OA\Parameter(name="latitude", in="query", @OA\Schema(type="string"), description="纬度"),
|
|
|
|
|
* @OA\Parameter(name="address_detail", in="query", @OA\Schema(type="string"), description="详细地址"),
|
|
|
|
|
* @OA\Parameter(name="url_title", in="query", @OA\Schema(type="string"), description="链接地址"),
|
|
|
|
|
* @OA\Parameter(name="is_ganbu", in="query", @OA\Schema(type="integer"), description="是否干部课程-0否1是"),
|
|
|
|
|
* @OA\Parameter(name="is_chart", in="query", @OA\Schema(type="integer"), description="是否参与统计-0否1是,默认1"),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response=200,
|
|
|
|
|
* description="操作成功"
|
|
|
|
|
|