新增获取系统问诊配置接口

This commit is contained in:
2023-02-27 13:58:30 +08:00
parent 8a87298095
commit 9b137d16f5
10 changed files with 236 additions and 66 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ use Hyperf\Database\Model\Collection;
use Hyperf\Snowflake\Concern\Snowflake;
/**
* @property int $system_inquiry_config_id 主键id
* @property string $system_inquiry_config_id 主键id
* @property int $inquiry_type 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
* @property int $inquiry_mode 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
* @property int $max_work_num_day 每日最大接诊数量
+48 -50
View File
@@ -52,10 +52,10 @@ use Hyperf\Utils\Arr;
* @property string $brief_introduction 医生简介
* @property \Carbon\Carbon $created_at 创建时间
* @property \Carbon\Carbon $updated_at 修改时间
* @property-read \Hyperf\Database\Model\Collection|DoctorExpertise[] $DoctorExpertise
* @property-read \Hyperf\Database\Model\Collection|DoctorInquiryConfig[] $DoctorInquiryConfig
* @property-read Hospital $Hospital
* @property-read \Hyperf\Database\Model\Collection|OrderInquiry[] $OrderInquiry
* @property-read \Hyperf\Database\Model\Collection|DoctorExpertise[] $DoctorExpertise
* @property-read \Hyperf\Database\Model\Collection|DoctorInquiryConfig[] $DoctorInquiryConfig
* @property-read Hospital $Hospital
* @property-read \Hyperf\Database\Model\Collection|OrderInquiry[] $OrderInquiry
*/
class UserDoctor extends Model
{
@@ -185,16 +185,15 @@ class UserDoctor extends Model
->get($fields);
return $datas;
}
/**
* 获取问诊医生列表
* 专家问诊-公益问诊共用
* @param string $keyword
* @param array $hospital_params 医院搜索条件
* @param array $doctor_params 医生搜索条件
* @param array $doctor_or_params 医生搜索条件
* @param array $doctor_expertise_params
* @param string|int $sort_order
* @param array $fields
@@ -202,73 +201,72 @@ class UserDoctor extends Model
* @param int|null $per_page
* @return array
*/
public static function getInquiryDoctorPage(string $keyword = "",array $hospital_params = [],array $doctor_params = [],array $doctor_expertise_params = [],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 = [], string|int $sort_order = 1, array $fields = ["*"], int $page = null, ?int $per_page = 10): array
{
$result = self::with([
$query = self::with([
"Hospital:hospital_id,hospital_name,hospital_status,hospital_level_name,province_id,city_id",
"DoctorExpertise" => function($query) use($doctor_expertise_params){
"DoctorExpertise" => function ($query) use ($doctor_expertise_params) {
$query->where($doctor_expertise_params);
},
"DoctorExpertise.DiseaseClassExpertise:expertise_id,expertise_name",
"DoctorInquiryConfig" => function($query) use($sort_order){
"DoctorInquiryConfig" => function ($query) use ($sort_order) {
$params = array();
$params['inquiry_mode'] = 1;// 接诊方式:图文
$query->where($params)->whereIn('inquiry_type',[1,3]);
if ($sort_order == 1){
$query->where($params)->whereIn('inquiry_type', [1, 3]);
if ($sort_order == 1) {
// 综合
$query->orderBy('inquiry_price','asc');// 价格从低到高
}elseif ($sort_order == 3){
$query->orderBy('inquiry_price', 'asc');// 价格从低到高
} elseif ($sort_order == 3) {
// 价格从低到高
$query->orderBy('inquiry_price','asc');
}elseif ($sort_order == 4){
$query->orderBy('inquiry_price', 'asc');
} elseif ($sort_order == 4) {
// 价格从高到低
$query->orderBy('inquiry_price','desc');// 价格从高到低
$query->orderBy('inquiry_price', 'desc');// 价格从高到低
}
return $query;
},
'DoctorInquiryConfig.SystemInquiryConfig',
])
])
->where($doctor_params)
->when($keyword,function ($query, $keyword){
$query->where(function($query) use ($keyword){
$query->orwhere("user_name",'like','%' . $keyword . '%');
$query->orwhere("hospital_name",'like','%' . $keyword . '%');
$query->orwhere("department_custom_name",'like','%' . $keyword . '%');
->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 . '%');
$query->orwhere("department_custom_name", 'like', '%' . $keyword . '%');
$query->orWhereHas('Hospital', function ($query) use ($keyword) {
$query->where('hospital_name', 'like', '%' . $keyword . '%');
});
});
})
->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){
->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','desc');
$query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"),'asc');// 名称排名
}elseif ($sort_order == 3){
$query->orderBy('avg_response_time', 'desc');
$query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名
} elseif ($sort_order == 3) {
// 响应时间快
$query->orderBy('avg_response_time','desc');
$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 == 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('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');// 名称排名
$query->orderBy('served_patients_num', 'desc');
$query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名
}
return $query;
})
->whereExists(function ($query) use($hospital_params){
$query->select(Db::raw(1))
->from('hospital')
->whereColumn('hospital.hospital_id','user_doctor.hospital_id')
->where($hospital_params);
})
->paginate($per_page, $fields, "page", $page);
});
$result = $query->paginate($per_page, $fields, "page", $page);
$data = array();
$data['current_page'] = $result->currentPage();// 当前页码