master
cody 4 months ago
parent 7677efd4eb
commit 7d79bfe8c1

@ -71,100 +71,103 @@ class CourseSignController extends BaseController
public function index() public function index()
{ {
$all = request()->all(); $all = request()->all();
$list = $this->model->with('course', 'user', 'thirdAppointmentLogs') $list = $this->model->with(['course', 'thirdAppointmentLogs', 'user' => function ($query) {
->whereHas('user', function ($query) use ($all) { $query->with(['courseSigns' => function ($q) {
if (isset($all['is_vip'])) { $q->where('status', 1)->with('course');
$query->where('is_vip', $all['is_vip']); }]);
} }])->whereHas('user', function ($query) use ($all) {
if (isset($all['company_name'])) { if (isset($all['is_vip'])) {
$query->where('company_name', 'like', '%' . $all['company_name'] . '%'); $query->where('is_vip', $all['is_vip']);
} }
if (isset($all['company_position'])) { if (isset($all['company_name'])) {
$query->where('company_position', $all['company_position']); $query->where('company_name', 'like', '%' . $all['company_name'] . '%');
} }
if (isset($all['company_area'])) { if (isset($all['company_position'])) {
$company_area = explode(',', $all['company_area']); $query->where('company_position', $all['company_position']);
$query->whereIn('company_area', $company_area); }
} if (isset($all['company_area'])) {
if (isset($all['company_type'])) { $company_area = explode(',', $all['company_area']);
$company_type = explode(',', $all['company_type']); $query->whereIn('company_area', $company_area);
$query->where(function ($q) use ($company_type) { }
foreach ($company_type as $v) { if (isset($all['company_type'])) {
$q->orWhereRaw('FIND_IN_SET(?, company_type)', [$v]); $company_type = explode(',', $all['company_type']);
} $query->where(function ($q) use ($company_type) {
}); foreach ($company_type as $v) {
} $q->orWhereRaw('FIND_IN_SET(?, company_type)', [$v]);
if (isset($all['company_industry'])) {
$company_industry = explode(',', $all['company_industry']);
$query->whereIn('company_industry', $company_industry);
}
if (isset($all['is_schoolmate'])) {
$query->where('is_schoolmate', $all['is_schoolmate']);
}
if (isset($all['mobile'])) {
$query->where('mobile', 'like', '%' . $all['mobile'] . '%');
}
if (isset($all['education'])) {
$education = explode(',', $all['education']);
$query->whereIn('education', $education);
}
if (isset($all['type'])) {
$type = explode(',', $all['type']);
$query->where(function ($q) use ($type) {
foreach ($type as $v) {
$q->orWhereRaw('FIND_IN_SET(?, type)', [$v]);
}
});
}
})->where(function ($query) use ($all) {
if (isset($all['filter_date']) && !empty($all['filter_date'])) {
foreach ($all['filter_date'] as $item) {
$query->whereJsonContains("data->{$item->name}", $item->value);
} }
});
}
if (isset($all['company_industry'])) {
$company_industry = explode(',', $all['company_industry']);
$query->whereIn('company_industry', $company_industry);
}
if (isset($all['is_schoolmate'])) {
$query->where('is_schoolmate', $all['is_schoolmate']);
}
if (isset($all['mobile'])) {
$query->where('mobile', 'like', '%' . $all['mobile'] . '%');
}
if (isset($all['education'])) {
$education = explode(',', $all['education']);
$query->whereIn('education', $education);
}
if (isset($all['type'])) {
$type = explode(',', $all['type']);
$query->where(function ($q) use ($type) {
foreach ($type as $v) {
$q->orWhereRaw('FIND_IN_SET(?, type)', [$v]);
}
});
}
})->where(function ($query) use ($all) {
if (isset($all['filter_date']) && !empty($all['filter_date'])) {
foreach ($all['filter_date'] as $item) {
$query->whereJsonContains("data->{$item->name}", $item->value);
} }
})->where(function ($query) use ($all) { }
if (isset($all['name'])) { })->where(function ($query) use ($all) {
$query->where(function ($q) use ($all) { if (isset($all['name'])) {
$q->whereHas('user', function ($q) use ($all) { $query->where(function ($q) use ($all) {
$q->where('name', 'like', '%' . $all['name'] . '%'); $q->whereHas('user', function ($q) use ($all) {
})->orWhere('change_data', 'like', '%' . $all['name'] . '%'); $q->where('name', 'like', '%' . $all['name'] . '%');
}); })->orWhere('change_data', 'like', '%' . $all['name'] . '%');
} });
if (isset($all['filter']) && !empty($all['filter'])) { }
foreach ($all['filter'] as $condition) { if (isset($all['filter']) && !empty($all['filter'])) {
$key = $condition['key'] ?? null; foreach ($all['filter'] as $condition) {
$op = $condition['op'] ?? null; $key = $condition['key'] ?? null;
$value = $condition['value'] ?? null; $op = $condition['op'] ?? null;
if (!isset($key) || !isset($op) || !isset($value)) { $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 == '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; continue;
} }
// 等于 $query->whereBetween($key, [$from, $to]);
if ($op == 'eq') {
$query->where($key, $value);
}
// 不等于
if ($op == 'neq') {
$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]);
}
} }
} }
})->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc') }
})->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc')
->orderBy('created_at', 'desc'); ->orderBy('created_at', 'desc');
if (isset($all['is_export']) && !empty($all['is_export'])) { if (isset($all['is_export']) && !empty($all['is_export'])) {
$list = $list->limit(5000)->get()->toArray(); $list = $list->limit(5000)->get()->toArray();

@ -645,6 +645,7 @@ class UserController extends BaseController
$validator = Validator::make($all, [ $validator = Validator::make($all, [
'ids' => 'required', 'ids' => 'required',
], $messages); ], $messages);
if ($validator->fails()) { if ($validator->fails()) {
return $this->fail([StarterResponseCode::START_ERROR_PARAMETER, implode(',', $validator->errors()->all())]); return $this->fail([StarterResponseCode::START_ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
} }

Loading…
Cancel
Save