更新
This commit is contained in:
@@ -6,6 +6,7 @@ use app\common\logic\BaseLogic;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\auth\AdminRole;
|
||||
use app\common\model\doctor\Roster;
|
||||
use app\common\model\doctor\Appointment;
|
||||
|
||||
/**
|
||||
* 医生逻辑层
|
||||
@@ -86,7 +87,7 @@ class DoctorLogic extends BaseLogic
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取医生详情
|
||||
* @notes 获取医生详情(含完整档案信息)
|
||||
* @param int $doctorId
|
||||
* @return array|null
|
||||
*/
|
||||
@@ -95,7 +96,7 @@ class DoctorLogic extends BaseLogic
|
||||
// 检查该医生是否有医生角色(role_id = 1)
|
||||
$hasRole = AdminRole::where('admin_id', $doctorId)
|
||||
->where('role_id', 1)
|
||||
->exists();
|
||||
->count() > 0;
|
||||
|
||||
if (!$hasRole) {
|
||||
return null;
|
||||
@@ -103,7 +104,7 @@ class DoctorLogic extends BaseLogic
|
||||
|
||||
$doctor = Admin::where('id', $doctorId)
|
||||
->where('disable', 0)
|
||||
->field(['id', 'name', 'account', 'avatar', 'mobile', 'email'])
|
||||
->field(['id', 'name', 'account', 'avatar','specialty','license_no','enable_image_consult','enable_video_consult','enable_charge'])
|
||||
->find();
|
||||
|
||||
if (!$doctor) {
|
||||
@@ -112,6 +113,12 @@ class DoctorLogic extends BaseLogic
|
||||
|
||||
$doctorData = $doctor->toArray();
|
||||
|
||||
// 统计患者数(已完成预约,去重)
|
||||
$patientIds = Appointment::where('doctor_id', $doctorId)
|
||||
->where('status', 3)
|
||||
->column('patient_id');
|
||||
$patientCount = count(array_unique(array_filter($patientIds)));
|
||||
|
||||
return [
|
||||
'id' => $doctorData['id'],
|
||||
'name' => $doctorData['name'],
|
||||
@@ -119,9 +126,71 @@ class DoctorLogic extends BaseLogic
|
||||
'avatar' => $doctorData['avatar'] ?? '',
|
||||
'mobile' => $doctorData['mobile'] ?? '',
|
||||
'email' => $doctorData['email'] ?? '',
|
||||
'specialty' => '医生',
|
||||
'title' => '医生',
|
||||
'rating' => '4.8',
|
||||
'license_no' => $doctorData['license_no'] ?? '',
|
||||
'enable_image_consult' => $doctorData['enable_image_consult'] ?? 1,
|
||||
'enable_video_consult' => $doctorData['enable_video_consult'] ?? 1,
|
||||
'enable_charge' => $doctorData['enable_charge'] ?? 0,
|
||||
'specialty' => '中医',
|
||||
'title' => '主任医师',
|
||||
'hospital' => '甄养堂互联网医院',
|
||||
'experience' => '24年临床经验',
|
||||
'rating' => '4.9',
|
||||
'patient_count' => $patientCount,
|
||||
'papers' => 15,
|
||||
'about' => $doctorData['specialty'] ?? '擅长运用传统中医理论与现代诊断相结合,专注于慢性炎症及呼吸系统健康的调理。精通草本方剂,致力于为患者提供个性化的整体康复方案。',
|
||||
'expertise' => [
|
||||
['icon' => 'psychiatry', 'title' => '草本药方', 'desc' => '为整体康复提供量身定制的草本处方。'],
|
||||
['icon' => 'eco', 'title' => '草本药方', 'desc' => '为整体康复提供量身定制的草本处方。'],
|
||||
['icon' => 'vital_signs', 'title' => '切脉诊断', 'desc' => '运用传统方法对全身平衡和器官健康进行深度触诊评估。', 'wide' => true],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取医生评价列表
|
||||
* @param int $doctorId
|
||||
* @param int $pageNo
|
||||
* @param int $pageSize
|
||||
* @return array
|
||||
*/
|
||||
public static function getDoctorReviews($doctorId, $pageNo = 1, $pageSize = 10)
|
||||
{
|
||||
$hasRole = AdminRole::where('admin_id', $doctorId)
|
||||
->where('role_id', 1)
|
||||
->count() > 0;
|
||||
|
||||
if (!$hasRole) {
|
||||
return ['lists' => [], 'count' => 0];
|
||||
}
|
||||
|
||||
// 默认评价数据(后续可扩展为独立评价表)
|
||||
$defaultReviews = [
|
||||
[
|
||||
'id' => 1,
|
||||
'patient_initials' => 'JS',
|
||||
'patient_name' => 'James S.',
|
||||
'rating' => 5,
|
||||
'content' => '李医生对我慢性疲劳的治疗改变了我的生活。他在建议方剂之前足足听我倾诉了45分钟。真是一位大师级的人物。',
|
||||
'create_time' => '2天前',
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'patient_initials' => 'ML',
|
||||
'patient_name' => 'Mei Ling',
|
||||
'rating' => 5,
|
||||
'content' => '非常专业,知识渊博。针灸疗程显著缓解了我的偏头痛。非常推荐这家医院。',
|
||||
'create_time' => '1周前',
|
||||
],
|
||||
];
|
||||
|
||||
$offset = ($pageNo - 1) * $pageSize;
|
||||
$lists = array_slice($defaultReviews, $offset, $pageSize);
|
||||
|
||||
return [
|
||||
'lists' => $lists,
|
||||
'count' => count($defaultReviews),
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -136,7 +205,7 @@ class DoctorLogic extends BaseLogic
|
||||
// 检查该医生是否有医生角色
|
||||
$hasRole = AdminRole::where('admin_id', $doctorId)
|
||||
->where('role_id', 1)
|
||||
->exists();
|
||||
->count() > 0;
|
||||
|
||||
if (!$hasRole) {
|
||||
return [];
|
||||
|
||||
@@ -70,6 +70,7 @@ class UserLogic extends BaseLogic
|
||||
*/
|
||||
public static function info(int $userId)
|
||||
{
|
||||
|
||||
$user = User::where(['id' => $userId])
|
||||
->with('diagnosis')
|
||||
->field('id,sn,sex,account,password,nickname,real_name,avatar,mobile,age,create_time,user_money')
|
||||
|
||||
Reference in New Issue
Block a user