修改获取问诊医生列表
This commit is contained in:
parent
77af894a76
commit
a6a81268a9
@ -214,7 +214,8 @@ class UserDoctor extends Model
|
|||||||
* @param array $hospital_params 医院搜索条件
|
* @param array $hospital_params 医院搜索条件
|
||||||
* @param array $doctor_params 医生搜索条件
|
* @param array $doctor_params 医生搜索条件
|
||||||
* @param array $doctor_expertise_params
|
* @param array $doctor_expertise_params
|
||||||
* @param array $doctor_inquiry_config_params
|
* @param array $inquiry_type
|
||||||
|
* @param array $inquiry_mode
|
||||||
* @param string|int $is_first_online 是否优先在线(1:是)
|
* @param string|int $is_first_online 是否优先在线(1:是)
|
||||||
* @param string|int $sort_order
|
* @param string|int $sort_order
|
||||||
* @param array $fields
|
* @param array $fields
|
||||||
@ -222,7 +223,7 @@ class UserDoctor extends Model
|
|||||||
* @param int|null $per_page
|
* @param int|null $per_page
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getInquiryDoctorPage(string $keyword = "", array $hospital_params = [], array $doctor_params = [], array $doctor_expertise_params = [],array $doctor_inquiry_config_params = [],string|int $is_first_online = 0, string|int $sort_order = 1, array $fields = ["*"], int $page = null, ?int $per_page = 10): array
|
public static function getInquiryDoctorPage(string $keyword = "", array $hospital_params = [], array $doctor_params = [], array $doctor_expertise_params = [],array $inquiry_type = [],array $inquiry_mode = [],string|int $is_first_online = 0, string|int $sort_order = 1, array $fields = ["*"], int $page = null, ?int $per_page = 10): array
|
||||||
{
|
{
|
||||||
$query = self::with([
|
$query = self::with([
|
||||||
"Hospital:hospital_id,hospital_name,hospital_status,hospital_level_name,province_id,city_id",
|
"Hospital:hospital_id,hospital_name,hospital_status,hospital_level_name,province_id,city_id",
|
||||||
@ -245,23 +246,42 @@ class UserDoctor extends Model
|
|||||||
})
|
})
|
||||||
->whereHas('DoctorExpertise', function ($query) use ($doctor_expertise_params) {
|
->whereHas('DoctorExpertise', function ($query) use ($doctor_expertise_params) {
|
||||||
$query->where($doctor_expertise_params);
|
$query->where($doctor_expertise_params);
|
||||||
})
|
|
||||||
->whereHas('DoctorInquiryConfig', function ($query) use ($doctor_inquiry_config_params) {
|
|
||||||
$params = array();
|
|
||||||
$params['is_enable'] = 1;
|
|
||||||
|
|
||||||
if (!empty($doctor_inquiry_config_params)){
|
|
||||||
if (!empty($doctor_inquiry_config_params['inquiry_mode'])){
|
|
||||||
$params['inquiry_mode'] = $doctor_inquiry_config_params['inquiry_mode'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($doctor_inquiry_config_params['inquiry_type'])){
|
|
||||||
$params['inquiry_type'] = $doctor_inquiry_config_params['inquiry_type'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$query->where($params);
|
|
||||||
});
|
});
|
||||||
|
// ->whereHas('DoctorInquiryConfig', function ($query) use ($doctor_inquiry_config_params) {
|
||||||
|
// $params = array();
|
||||||
|
// $params['is_enable'] = 1;
|
||||||
|
//
|
||||||
|
// if (!empty($doctor_inquiry_config_params)){
|
||||||
|
// if (!empty($doctor_inquiry_config_params['inquiry_mode'])){
|
||||||
|
// $params['inquiry_mode'] = $doctor_inquiry_config_params['inquiry_mode'];
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (!empty($doctor_inquiry_config_params['inquiry_type'])){
|
||||||
|
// $params['inquiry_type'] = $doctor_inquiry_config_params['inquiry_type'];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// $query->where($params);
|
||||||
|
// });
|
||||||
|
// ->whereHas('DoctorInquiryConfig', function ($query) use ($doctor_inquiry_config_params) {
|
||||||
|
// $params = array();
|
||||||
|
// $params['is_enable'] = 1;
|
||||||
|
//
|
||||||
|
// if (!empty($doctor_inquiry_config_params)){
|
||||||
|
// if (!empty($doctor_inquiry_config_params['inquiry_mode'])){
|
||||||
|
// $inquiry_mode = explode(',',$doctor_inquiry_config_params['inquiry_mode']);
|
||||||
|
// $query->whereIn('inquiry_mode', $inquiry_mode);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (!empty($doctor_inquiry_config_params['inquiry_type'])){
|
||||||
|
// $inquiry_type = explode(',',$doctor_inquiry_config_params['inquiry_type']);
|
||||||
|
// $query->whereIn('inquiry_type', $inquiry_type);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// $query->where($params);
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
if ($is_first_online == 1){
|
if ($is_first_online == 1){
|
||||||
$query->join('user as u', function ($query) {
|
$query->join('user as u', function ($query) {
|
||||||
@ -272,16 +292,46 @@ class UserDoctor extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($sort_order)){
|
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])
|
||||||
|
// ->whereIn('inquiry_mode', [1,2,6,7])
|
||||||
|
// ->orderBy('inquiry_price', 'desc')
|
||||||
|
// ->take(1);
|
||||||
|
// })
|
||||||
|
// ->select("user_doctor.*")
|
||||||
|
// ->groupBy("user_doctor.doctor_id");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// select doctor_id, min(price) price_min from price group by doctor_id
|
||||||
if (in_array($sort_order,[1,3,4])){
|
if (in_array($sort_order,[1,3,4])){
|
||||||
$query = $query->join('doctor_inquiry_config', function ($query) {
|
$raw = "inquiry_price as min_inquiry_price";
|
||||||
$query->on('user_doctor.doctor_id', '=', 'doctor_inquiry_config.doctor_id')
|
if ($sort_order == 1){
|
||||||
->whereIn('inquiry_type', [1, 3])
|
// 综合-价格从低到高
|
||||||
->whereIn('inquiry_mode', [1,2,6,7])
|
$raw = "MIN(inquiry_price) as min_inquiry_price";
|
||||||
->orderBy('inquiry_price', 'desc')
|
} elseif ($sort_order == 3){
|
||||||
->take(1);
|
// 价格从低到高
|
||||||
})
|
$raw = "MIN(inquiry_price) as min_inquiry_price";
|
||||||
->select("user_doctor.*")
|
} elseif ($sort_order == 4){
|
||||||
->groupBy("user_doctor.doctor_id");
|
// 价格从高到低
|
||||||
|
$raw = "MAX(inquiry_price) as min_inquiry_price";
|
||||||
|
}
|
||||||
|
|
||||||
|
$latestPosts = Db::table('doctor_inquiry_config')
|
||||||
|
->select('doctor_inquiry_config.doctor_id', Db::raw($raw))
|
||||||
|
->where('is_enable', 1);
|
||||||
|
if (!empty($inquiry_type)){
|
||||||
|
$latestPosts = $latestPosts->whereIn('inquiry_type', $inquiry_type)
|
||||||
|
->whereIn('inquiry_mode',$inquiry_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
$latestPosts = $latestPosts->groupBy(["doctor_inquiry_config.doctor_id"]);
|
||||||
|
|
||||||
|
$query = $query
|
||||||
|
->joinSub($latestPosts, 'doctor_inquiry_config', function($join) {
|
||||||
|
$join->on('user_doctor.doctor_id', '=', 'doctor_inquiry_config.doctor_id');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sort_order == 1) {
|
if ($sort_order == 1) {
|
||||||
@ -291,7 +341,7 @@ class UserDoctor extends Model
|
|||||||
$query->orderBy('avg_response_time');
|
$query->orderBy('avg_response_time');
|
||||||
$query->orderBy('served_patients_num', 'desc');// 服务数从多到少
|
$query->orderBy('served_patients_num', 'desc');// 服务数从多到少
|
||||||
$query->orderBy(Db::raw("convert(substr(gdxz_user_doctor.user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
$query->orderBy(Db::raw("convert(substr(gdxz_user_doctor.user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
||||||
$query->orderBy('doctor_inquiry_config.inquiry_price', 'asc');
|
$query->orderBy('doctor_inquiry_config.min_inquiry_price', 'asc');
|
||||||
} elseif ($sort_order == 2) {
|
} elseif ($sort_order == 2) {
|
||||||
// 响应时间快
|
// 响应时间快
|
||||||
$query->orderByRaw('avg_response_time = 0 ASC');
|
$query->orderByRaw('avg_response_time = 0 ASC');
|
||||||
@ -305,7 +355,7 @@ class UserDoctor extends Model
|
|||||||
$query->orderBy(Db::raw("convert(substr(gdxz_user_doctor.user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
$query->orderBy(Db::raw("convert(substr(gdxz_user_doctor.user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
||||||
} elseif ($sort_order == 4) {
|
} elseif ($sort_order == 4) {
|
||||||
// 价格从高到低
|
// 价格从高到低
|
||||||
$query->orderBy('doctor_inquiry_config.inquiry_price', 'desc');
|
$query->orderBy('doctor_inquiry_config.min_inquiry_price', 'desc');
|
||||||
$query->orderByRaw('avg_response_time = 0 ASC');
|
$query->orderByRaw('avg_response_time = 0 ASC');
|
||||||
$query->orderBy('avg_response_time');
|
$query->orderBy('avg_response_time');
|
||||||
$query->orderBy(Db::raw("convert(substr(gdxz_user_doctor.user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
$query->orderBy(Db::raw("convert(substr(gdxz_user_doctor.user_name,1,1) using `GBK`)"), 'asc');// 名称排名
|
||||||
|
|||||||
@ -35,8 +35,8 @@ class PatientDoctorService extends BaseService
|
|||||||
$city_id = $this->request->input('city_id');
|
$city_id = $this->request->input('city_id');
|
||||||
$sort_order = $this->request->input('sort_order',1);
|
$sort_order = $this->request->input('sort_order',1);
|
||||||
$keyword = $this->request->input('keyword',"");
|
$keyword = $this->request->input('keyword',"");
|
||||||
$inquiry_type = $this->request->input('inquiry_type',0); // 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
$inquiry_type = $this->request->input('inquiry_type',[]); // 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||||
$inquiry_mode = $this->request->input('inquiry_mode',0); // 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊)
|
$inquiry_mode = $this->request->input('inquiry_mode',[]); // 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊)
|
||||||
$is_first_online = $this->request->input('is_first_online',0); // 是否优先在线(1:是)
|
$is_first_online = $this->request->input('is_first_online',0); // 是否优先在线(1:是)
|
||||||
$page = $this->request->input('page',1);
|
$page = $this->request->input('page',1);
|
||||||
$per_page = $this->request->input('per_page',10);
|
$per_page = $this->request->input('per_page',10);
|
||||||
@ -61,11 +61,9 @@ class PatientDoctorService extends BaseService
|
|||||||
$doctor_expertise_params['expertise_id'] = $expertise_id;
|
$doctor_expertise_params['expertise_id'] = $expertise_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 医生问诊条件
|
|
||||||
$doctor_inquiry_config_params = array();
|
|
||||||
if (!empty($inquiry_type)){
|
if (!empty($inquiry_type)){
|
||||||
$doctor_inquiry_config_params['inquiry_type'] = $inquiry_type;
|
$inquiry_type = explode(',',$inquiry_type);
|
||||||
$doctor_inquiry_config_params['inquiry_mode'] = $inquiry_mode;
|
$inquiry_mode = explode(',',$inquiry_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 固定医生查询条件
|
// 固定医生查询条件
|
||||||
@ -75,7 +73,7 @@ class PatientDoctorService extends BaseService
|
|||||||
$doctor_params["is_bind_bank"] = 1;// 是否已绑定结算银行卡(0:否 1:是)
|
$doctor_params["is_bind_bank"] = 1;// 是否已绑定结算银行卡(0:否 1:是)
|
||||||
|
|
||||||
$fields = [
|
$fields = [
|
||||||
"doctor_id",
|
"user_doctor.doctor_id",
|
||||||
"user_id",
|
"user_id",
|
||||||
"user_name",
|
"user_name",
|
||||||
"multi_point_status",
|
"multi_point_status",
|
||||||
@ -91,9 +89,10 @@ class PatientDoctorService extends BaseService
|
|||||||
"avg_response_time",
|
"avg_response_time",
|
||||||
"number_of_fans",
|
"number_of_fans",
|
||||||
"be_good_at",
|
"be_good_at",
|
||||||
|
"doctor_inquiry_config.min_inquiry_price",
|
||||||
];
|
];
|
||||||
|
|
||||||
$user_doctors = UserDoctor::getInquiryDoctorPage($keyword,$hospital_params, $doctor_params,$doctor_expertise_params,$doctor_inquiry_config_params,$is_first_online, $sort_order, $fields,$page,$per_page);
|
$user_doctors = UserDoctor::getInquiryDoctorPage($keyword,$hospital_params, $doctor_params,$doctor_expertise_params,$inquiry_type,$inquiry_mode,$is_first_online, $sort_order, $fields,$page,$per_page);
|
||||||
|
|
||||||
if (!empty($user_doctors['data'])) {
|
if (!empty($user_doctors['data'])) {
|
||||||
foreach ($user_doctors['data'] as &$user_doctor) {
|
foreach ($user_doctors['data'] as &$user_doctor) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user