医生列表备注版本
This commit is contained in:
+76
-46
@@ -219,24 +219,13 @@ class UserDoctor extends Model
|
||||
{
|
||||
$query = self::with([
|
||||
"Hospital:hospital_id,hospital_name,hospital_status,hospital_level_name,province_id,city_id",
|
||||
"DoctorExpertise",
|
||||
// "DoctorExpertise",
|
||||
"DoctorInquiryConfig" => function ($query) use ($sort_order) {
|
||||
if ($sort_order == 1) {
|
||||
// 综合-价格从低到高
|
||||
$query->orderBy('inquiry_price', 'asc');
|
||||
} elseif ($sort_order == 3) {
|
||||
// 价格从低到高
|
||||
$query->orderBy('inquiry_price', 'asc');
|
||||
} elseif ($sort_order == 4) {
|
||||
// 价格从高到低
|
||||
$query->orderBy('inquiry_price', 'desc');
|
||||
}
|
||||
$query->whereIn('inquiry_type', [1, 3])
|
||||
->where('inquiry_mode', 1);
|
||||
},
|
||||
])
|
||||
->where($doctor_params)
|
||||
->whereHas('Hospital', function ($query) use ($hospital_params) {
|
||||
$query->where($hospital_params);
|
||||
})
|
||||
->when($keyword, function ($query, $keyword) {
|
||||
$query->where(function ($query) use ($keyword) {
|
||||
$query->orwhere("user_name", 'like', '%' . $keyword . '%');
|
||||
@@ -246,44 +235,83 @@ class UserDoctor extends Model
|
||||
});
|
||||
});
|
||||
})
|
||||
->whereHas('DoctorExpertise', function ($query) use ($doctor_expertise_params) {
|
||||
$query->where($doctor_expertise_params);
|
||||
->whereHas('Hospital', function ($query) use ($hospital_params) {
|
||||
$query->where($hospital_params);
|
||||
})
|
||||
// ->whereHas('DoctorExpertise', function ($query) use ($doctor_expertise_params) {
|
||||
// $query->where($doctor_expertise_params);
|
||||
// })
|
||||
->whereHas('DoctorInquiryConfig', function ($query) {
|
||||
$params = array();
|
||||
$params['inquiry_mode'] = 1;// 接诊方式:图文
|
||||
$query->where($params)->whereIn('inquiry_type', [1, 3]);
|
||||
})
|
||||
->when($sort_order, function ($query, $sort_order) {
|
||||
if ($sort_order == 1) {
|
||||
$query->orderBy('is_recommend', 'desc');// 是否首页推荐(0:否 1:是)
|
||||
$query->orderBy('avg_response_time', 'desc');// 响应时间快
|
||||
$query->orderBy('served_patients_num', 'desc');// 服务数从多到少
|
||||
$query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
||||
} elseif ($sort_order == 2) {
|
||||
// 响应时间快
|
||||
$query->orderBy('avg_response_time', 'asc');
|
||||
$query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
||||
} elseif ($sort_order == 3) {
|
||||
// 价格从低到高
|
||||
$query->orderBy('avg_response_time', 'asc');
|
||||
$query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
||||
} elseif ($sort_order == 4) {
|
||||
// 价格从高到低
|
||||
$query->orderBy('avg_response_time', 'desc');
|
||||
$query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
||||
} elseif ($sort_order == 5) {
|
||||
// 服务数从多到少
|
||||
$query->orderBy('served_patients_num', 'desc');
|
||||
$query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
||||
}
|
||||
return $query;
|
||||
})
|
||||
// ->join('doctor_inquiry_config', 'user_doctor.doctor_id', '=', 'doctor_inquiry_config.doctor_id')
|
||||
// ->groupBy("user_doctor.doctor_id")
|
||||
// ->orderBy("doctor_inquiry_config.inquiry_price",'desc')
|
||||
->select("user_doctor.*");
|
||||
});
|
||||
// ->when($sort_order, function ($query, $sort_order) {
|
||||
// if ($sort_order == 1) {
|
||||
// $query->orderBy('is_recommend', 'desc');// 是否首页推荐(0:否 1:是)
|
||||
// $query->orderBy('avg_response_time', 'desc');// 响应时间快
|
||||
// $query->orderBy('served_patients_num', 'desc');// 服务数从多到少
|
||||
// $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
||||
// } elseif ($sort_order == 2) {
|
||||
// // 响应时间快
|
||||
// $query->orderBy('avg_response_time', 'asc');
|
||||
// $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
||||
// } elseif ($sort_order == 3) {
|
||||
// // 价格从低到高
|
||||
// $query->orderBy('avg_response_time', 'asc');
|
||||
// $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
||||
// } elseif ($sort_order == 4) {
|
||||
// // 价格从高到低
|
||||
// $query->orderBy('avg_response_time', 'desc');
|
||||
// $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
||||
// } elseif ($sort_order == 5) {
|
||||
// // 服务数从多到少
|
||||
// $query->orderBy('served_patients_num', 'desc');
|
||||
// $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
||||
// }
|
||||
// return $query;
|
||||
// });
|
||||
|
||||
if (!empty($sort_order)){
|
||||
if (in_array($sort_order,[1,3,4])){
|
||||
$query = $query->join('doctor_inquiry_config', function ($query) {
|
||||
$query->on('user_doctor.doctor_id', '=', 'doctor_inquiry_config.doctor_id')
|
||||
->whereIn('inquiry_type', [1, 3])
|
||||
->where('inquiry_mode', 1)
|
||||
->orderBy('inquiry_price', 'desc')
|
||||
->take(1);
|
||||
})
|
||||
->select("user_doctor.*")
|
||||
->groupBy("user_doctor.doctor_id");
|
||||
}
|
||||
|
||||
if ($sort_order == 1) {
|
||||
// 综合-价格从低到高
|
||||
$query->orderBy('is_recommend', 'desc');// 是否首页推荐(0:否 1:是)
|
||||
$query->orderBy('avg_response_time', 'asc');// 响应时间快
|
||||
$query->orderBy('served_patients_num', 'desc');// 服务数从多到少
|
||||
$query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
||||
$query->orderBy('doctor_inquiry_config.inquiry_price', 'asc');
|
||||
} elseif ($sort_order == 2) {
|
||||
// 响应时间快
|
||||
$query->orderBy('avg_response_time', 'asc');
|
||||
$query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
||||
} elseif ($sort_order == 3) {
|
||||
// 价格从低到高
|
||||
$query->orderBy('doctor_inquiry_config.inquiry_price', 'asc');
|
||||
$query->orderBy('avg_response_time', 'asc');
|
||||
$query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
||||
} elseif ($sort_order == 4) {
|
||||
// 价格从高到低
|
||||
$query->orderBy('doctor_inquiry_config.inquiry_price', 'desc');
|
||||
$query->orderBy('avg_response_time', 'asc');
|
||||
$query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
||||
} elseif ($sort_order == 5) {
|
||||
// 服务数从多到少
|
||||
$query->orderBy('served_patients_num', 'desc');
|
||||
$query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
||||
}
|
||||
}
|
||||
|
||||
$result = $query->paginate($per_page, $fields, "page", $page);
|
||||
|
||||
@@ -297,6 +325,8 @@ class UserDoctor extends Model
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取是否存在
|
||||
* @param array $params
|
||||
|
||||
Reference in New Issue
Block a user