master
cody 4 months ago
parent 7677efd4eb
commit 7d79bfe8c1

@ -71,100 +71,103 @@ class CourseSignController extends BaseController
public function index()
{
$all = request()->all();
$list = $this->model->with('course', 'user', 'thirdAppointmentLogs')
->whereHas('user', function ($query) use ($all) {
if (isset($all['is_vip'])) {
$query->where('is_vip', $all['is_vip']);
}
if (isset($all['company_name'])) {
$query->where('company_name', 'like', '%' . $all['company_name'] . '%');
}
if (isset($all['company_position'])) {
$query->where('company_position', $all['company_position']);
}
if (isset($all['company_area'])) {
$company_area = explode(',', $all['company_area']);
$query->whereIn('company_area', $company_area);
}
if (isset($all['company_type'])) {
$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);
$list = $this->model->with(['course', 'thirdAppointmentLogs', 'user' => function ($query) {
$query->with(['courseSigns' => function ($q) {
$q->where('status', 1)->with('course');
}]);
}])->whereHas('user', function ($query) use ($all) {
if (isset($all['is_vip'])) {
$query->where('is_vip', $all['is_vip']);
}
if (isset($all['company_name'])) {
$query->where('company_name', 'like', '%' . $all['company_name'] . '%');
}
if (isset($all['company_position'])) {
$query->where('company_position', $all['company_position']);
}
if (isset($all['company_area'])) {
$company_area = explode(',', $all['company_area']);
$query->whereIn('company_area', $company_area);
}
if (isset($all['company_type'])) {
$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);
}
})->where(function ($query) use ($all) {
if (isset($all['name'])) {
$query->where(function ($q) use ($all) {
$q->whereHas('user', function ($q) use ($all) {
$q->where('name', 'like', '%' . $all['name'] . '%');
})->orWhere('change_data', 'like', '%' . $all['name'] . '%');
});
}
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)) {
}
})->where(function ($query) use ($all) {
if (isset($all['name'])) {
$query->where(function ($q) use ($all) {
$q->whereHas('user', function ($q) use ($all) {
$q->where('name', 'like', '%' . $all['name'] . '%');
})->orWhere('change_data', 'like', '%' . $all['name'] . '%');
});
}
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 == '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;
}
// 等于
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]);
}
$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');
if (isset($all['is_export']) && !empty($all['is_export'])) {
$list = $list->limit(5000)->get()->toArray();

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

Loading…
Cancel
Save