383 lines
14 KiB
PHP
383 lines
14 KiB
PHP
<?php
|
||
|
||
namespace App\Services;
|
||
|
||
use App\Constants\DoctorTitleCode;
|
||
use App\Constants\HttpEnumCode;
|
||
use App\Model\Banner as BannerModel;
|
||
use App\Model\DoctorInquiryConfig as DoctorInquiryConfigModel;
|
||
use App\Model\Module as ModuleModel;
|
||
use App\Model\PatientHistoryInquiry as PatientHistoryInquiryModel;
|
||
use App\Model\PharmacistAuditStatistic;
|
||
use App\Model\User;
|
||
use App\Model\UserDoctor as UserDoctorModel;
|
||
use App\Model\UserPharmacist;
|
||
use Hyperf\Utils\Parallel;
|
||
use Hyperf\Utils\WaitGroup;
|
||
|
||
/**
|
||
* 首页模块
|
||
*/
|
||
class IndexService extends BaseService
|
||
{
|
||
// /**
|
||
// * 医生端-首页
|
||
// * @return array
|
||
// */
|
||
// public function getDoctorIndex(): array
|
||
// {
|
||
// $user_info = $this->request->getAttribute("userInfo") ?? [];
|
||
//
|
||
// // 获取医生数据
|
||
// $params = array();
|
||
// $params['doctor_id'] = $user_info['client_user_id'];
|
||
//
|
||
// $fields = [
|
||
// "doctor_id",
|
||
// "user_id",
|
||
// "user_name",
|
||
// "open_id",
|
||
// "status",
|
||
// "idcard_status",
|
||
// "iden_auth_status",
|
||
// "iden_auth_fail_reason",
|
||
// "multi_point_status",
|
||
// "is_bind_bank",
|
||
// "praise_rate",
|
||
// "avg_response_time",
|
||
// "number_of_fans",
|
||
// "avatar",
|
||
// "is_online",
|
||
// "is_img_expert_reception",
|
||
// "is_img_welfare_reception",
|
||
// "is_img_quick_reception",
|
||
// ];
|
||
//
|
||
// $doctor = UserDoctorModel::getOne($params, $fields);
|
||
// if (empty($doctor)) {
|
||
// return fail(HttpEnumCode::USER_STATUS_ERROR);
|
||
// }
|
||
//
|
||
// if ($doctor['status'] == 0){
|
||
// return fail(HttpEnumCode::USER_STATUS_DISABLE);
|
||
// }
|
||
//
|
||
// if ($doctor['status'] != 1){
|
||
// return fail(HttpEnumCode::USER_STATUS_ERROR);
|
||
// }
|
||
//
|
||
// $InquiryService = new InquiryService();
|
||
// $OrderPrescriptionService = new OrderPrescriptionService();
|
||
//
|
||
// // 获取未接诊患者个数
|
||
// $not_accepted_inquiry_num = $InquiryService->getDoctorNotAcceptedInquiryNum($doctor['doctor_id']);
|
||
//
|
||
// // 获取接诊中患者个数
|
||
// $accepting_inquiry_num = $InquiryService->getDoctorAcceptingInquiryNum($doctor['doctor_id']);
|
||
//
|
||
// // 获取被驳回处方数据
|
||
// $reject_prescription_number = $OrderPrescriptionService->getDoctorExistsAuditFail($doctor['doctor_id']);
|
||
//
|
||
// // 获取医生问诊价格
|
||
// $params = array();
|
||
// $params['doctor_id'] = $doctor['doctor_id'];
|
||
// $params['inquiry_type'] = 1;// 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊)
|
||
// $params['inquiry_mode'] = 1;// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
|
||
// $doctor_inquiry_config = DoctorInquiryConfigModel::getOne($params);
|
||
//
|
||
// // 获取banner
|
||
// $params = array();
|
||
// $params["app_type"] = 1;
|
||
// $params["client_type"] = 2;
|
||
// $params["banner_place"] = 1;
|
||
// $params["banner_status"] = 1;
|
||
// $banner = BannerModel::getList($params);
|
||
// if (!empty($banner)){
|
||
// foreach ($banner as &$item){
|
||
// $item['banner_path'] = addAliyunOssWebsite($item['banner_path']);
|
||
// }
|
||
// }
|
||
//
|
||
// // 处理返回数据
|
||
// $info = array();
|
||
// $info['doctor_id'] = $doctor['doctor_id'];
|
||
// $info['user_name'] = $doctor['user_name'];
|
||
// $info['status'] = $doctor['status'];
|
||
// $info['idcard_status'] = $doctor['idcard_status'];// 实名认证状态(0:未认证 1:认证通过 2:认证失败)
|
||
// $info['iden_auth_status'] = $doctor['iden_auth_status'];// 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||
// $info['multi_point_status'] = $doctor['multi_point_status'];// 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||
// $info['is_bind_bank'] = $doctor['is_bind_bank'];// 是否已绑定结算银行卡(0:否 1:是)
|
||
// $info['avatar'] = addAliyunOssWebsite($doctor['avatar']);
|
||
// $info['is_img_expert_reception'] = $doctor['is_img_expert_reception'];// 是否参加专家图文接诊(0:否 1:是)
|
||
// $info['is_img_welfare_reception'] = $doctor['is_img_welfare_reception'];// 是否参加公益图文问诊(0:否 1:是)
|
||
// $info['is_img_quick_reception'] = $doctor['is_img_quick_reception'];// 是否参加快速图文接诊(0:否 1:是)
|
||
// $info['praise_rate'] = $doctor['praise_rate'];// 好评率(百分制。回复质量占4、服务态度占3、回复速度占3。每周计算一次)
|
||
// $info['avg_response_time'] = (float)ceil($doctor['avg_response_time']);;// 平均响应时间(分钟制)
|
||
// $info['number_of_fans'] = $doctor['number_of_fans'];// 被关注数量
|
||
// $info['inquiry_price'] = $doctor_inquiry_config['inquiry_price'] ?? "";// 在线问诊价格
|
||
// $info['not_accepted_inquiry_num'] = $not_accepted_inquiry_num ?? 0;// 获取未接诊患者个数
|
||
// $info['accepting_inquiry_num'] = $accepting_inquiry_num ?? 0;// 获取接诊中患者个数
|
||
// $info['reject_prescription_number'] = $reject_prescription_number ?? 0;// 获取被驳回处方数据
|
||
//
|
||
// $data = array();
|
||
// $data['banner'] = $banner ?? [];// banner
|
||
// $data['info'] = $info;// 医生数据
|
||
//
|
||
// return success($data);
|
||
// }
|
||
|
||
/**
|
||
* 医生端-首页
|
||
* @return array
|
||
*/
|
||
public function getDoctorIndex(): array
|
||
{
|
||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||
|
||
// 获取医生数据
|
||
$params = array();
|
||
$params['doctor_id'] = $user_info['client_user_id'];
|
||
|
||
$fields = [
|
||
"doctor_id",
|
||
"user_id",
|
||
"user_name",
|
||
"open_id",
|
||
"status",
|
||
"idcard_status",
|
||
"iden_auth_status",
|
||
"iden_auth_fail_reason",
|
||
"multi_point_status",
|
||
"introduction_status",
|
||
"is_bind_bank",
|
||
"praise_rate",
|
||
"avg_response_time",
|
||
"number_of_fans",
|
||
"avatar",
|
||
"is_welfare_cooperation",
|
||
];
|
||
|
||
$doctor = UserDoctorModel::getOne($params, $fields);
|
||
if (empty($doctor)) {
|
||
return fail(HttpEnumCode::USER_STATUS_ERROR);
|
||
}
|
||
|
||
if ($doctor['status'] == 0){
|
||
return fail(HttpEnumCode::USER_STATUS_DISABLE);
|
||
}
|
||
|
||
if ($doctor['status'] != 1){
|
||
return fail(HttpEnumCode::USER_STATUS_ERROR);
|
||
}
|
||
|
||
$InquiryService = new InquiryService();
|
||
$OrderPrescriptionService = new OrderPrescriptionService();
|
||
|
||
// 获取未接诊患者个数
|
||
$not_accepted_inquiry_num = $InquiryService->getDoctorNotAcceptedInquiryNum($doctor['doctor_id']);
|
||
|
||
// 获取接诊中患者个数
|
||
$accepting_inquiry_num = $InquiryService->getDoctorAcceptingInquiryNum($doctor['doctor_id']);
|
||
|
||
// 获取被驳回处方数据
|
||
$reject_prescription_number = $OrderPrescriptionService->getDoctorExistsAuditFail($doctor['doctor_id']);
|
||
|
||
// 在线问诊价格
|
||
$inquiry_price = "";
|
||
|
||
// 获取医生问诊配置
|
||
$params = array();
|
||
$params['doctor_id'] = $doctor['doctor_id'];
|
||
$doctor_inquiry_config = DoctorInquiryConfigModel::getInquiryConfigList($params);
|
||
foreach ($doctor_inquiry_config as $value){
|
||
// 获取在线问诊设置的价格
|
||
if ($value['inquiry_type'] == 1 && $value['inquiry_mode'] == 1){
|
||
$inquiry_price = $value['inquiry_price'];
|
||
}
|
||
}
|
||
|
||
// 获取banner
|
||
$params = array();
|
||
$params["app_type"] = 1;
|
||
$params["client_type"] = 2;
|
||
$params["banner_place"] = 1;
|
||
$params["banner_status"] = 1;
|
||
$banner = BannerModel::getList($params);
|
||
if (!empty($banner)){
|
||
foreach ($banner as &$item){
|
||
$item['banner_path'] = addAliyunOssWebsite($item['banner_path']);
|
||
}
|
||
}
|
||
|
||
// 处理返回数据
|
||
$info = array();
|
||
$info['doctor_id'] = $doctor['doctor_id'];
|
||
$info['user_name'] = $doctor['user_name'];
|
||
$info['status'] = $doctor['status'];
|
||
$info['idcard_status'] = $doctor['idcard_status'];// 实名认证状态(0:未认证 1:认证通过 2:认证失败)
|
||
$info['iden_auth_status'] = $doctor['iden_auth_status'];// 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||
$info['multi_point_status'] = $doctor['multi_point_status'];// 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||
$info['is_bind_bank'] = $doctor['is_bind_bank'];// 是否已绑定结算银行卡(0:否 1:是)
|
||
$info['avatar'] = addAliyunOssWebsite($doctor['avatar']);
|
||
$info['praise_rate'] = $doctor['praise_rate'];// 好评率(百分制。回复质量占4、服务态度占3、回复速度占3。每周计算一次)
|
||
$info['avg_response_time'] = (float)ceil($doctor['avg_response_time']);;// 平均响应时间(分钟制)
|
||
$info['number_of_fans'] = $doctor['number_of_fans'];// 被关注数量
|
||
$info['inquiry_price'] = $inquiry_price;// 在线问诊价格
|
||
$info['not_accepted_inquiry_num'] = $not_accepted_inquiry_num ?? 0;// 获取未接诊患者个数
|
||
$info['accepting_inquiry_num'] = $accepting_inquiry_num ?? 0;// 获取接诊中患者个数
|
||
$info['reject_prescription_number'] = $reject_prescription_number ?? 0;// 获取被驳回处方数据
|
||
$info['introduction_status'] = $doctor['introduction_status'];// 个人简介审核状态(0:未审核 1:审核通过 2:审核中 3:审核失败)
|
||
$info['is_welfare_cooperation'] = $doctor['is_welfare_cooperation'];// 是否公益问诊合作医生(可把公益问诊设为0元)
|
||
|
||
$data = array();
|
||
$data['banner'] = $banner ?? [];// banner
|
||
$data['info'] = $info;// 医生数据
|
||
$data['doctor_inquiry_config'] = $doctor_inquiry_config;// 医生问诊配置
|
||
|
||
return success($data);
|
||
}
|
||
|
||
/**
|
||
* 患者端-首页
|
||
* @return array
|
||
*/
|
||
public function getPatientIndex(): array
|
||
{
|
||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||
|
||
$wg = new WaitGroup();
|
||
$wg->add(4);
|
||
|
||
// 获取banner
|
||
$banner = [];
|
||
co(function () use ($wg, &$banner) {
|
||
defer(function() use ($wg) {
|
||
$wg->done();
|
||
});
|
||
$params = array();
|
||
$params["app_type"] = 1;
|
||
$params["client_type"] = 1;
|
||
$params["banner_place"] = 1;
|
||
$params["banner_status"] = 1;
|
||
$banner = BannerModel::getList($params);
|
||
if (!empty($banner)){
|
||
foreach ($banner as &$item){
|
||
$item['banner_path'] = addAliyunOssWebsite($item['banner_path']);
|
||
}
|
||
}
|
||
});
|
||
|
||
// 获取模块
|
||
$module = [];
|
||
co(function () use ($wg, &$module) {
|
||
defer(function() use ($wg) {
|
||
$wg->done();
|
||
});
|
||
|
||
$params = array();
|
||
$params["app_type"] = 1;
|
||
$params["client_type"] = 1;
|
||
$params["module_place"] = 1;
|
||
$params["module_status"] = 1;
|
||
$module = ModuleModel::getList($params);
|
||
});
|
||
|
||
|
||
// 我的医生
|
||
$my_doctor = [];
|
||
co(function () use ($wg, &$my_doctor,$user_info) {
|
||
defer(function() use ($wg) {
|
||
$wg->done();
|
||
});
|
||
$PatientDoctorService = new PatientDoctorService();
|
||
|
||
if (!empty($user_info)) {
|
||
$my_doctor = $PatientDoctorService->getIndexPatientDoctorLimit($user_info['client_user_id']);
|
||
}
|
||
});
|
||
|
||
// 推荐医生
|
||
$recommend_doctor = [];
|
||
co(function () use ($wg, &$recommend_doctor) {
|
||
defer(function() use ($wg) {
|
||
$wg->done();
|
||
});
|
||
|
||
$PatientDoctorService = new PatientDoctorService();
|
||
|
||
$recommend_doctor = $PatientDoctorService->getIndexRecommendDoctorLimit();
|
||
});
|
||
|
||
$wg->wait();
|
||
|
||
$result = array();
|
||
$result["banner"] = $banner ?? [];// banner
|
||
$result["recommend_doctor"] = $recommend_doctor['data'] ?? []; // 推荐医生
|
||
$result["my_doctor"] = $my_doctor ?? []; // 我的医生
|
||
$result["module"] = $module ?? []; // 首页模块
|
||
return success($result);
|
||
}
|
||
|
||
/**
|
||
* 药师端-首页
|
||
* @return array
|
||
*/
|
||
public function getPharmacistIndex(): array
|
||
{
|
||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||
|
||
// 获取药师数据
|
||
$params = array();
|
||
$params['pharmacist_id'] = $user_info['client_user_id'];
|
||
|
||
$fields = [
|
||
"pharmacist_id",
|
||
"user_id",
|
||
"user_name",
|
||
"status",
|
||
"avatar",
|
||
];
|
||
|
||
$user_pharmacist = UserPharmacist::getOne($params,$fields);
|
||
if (empty($user_pharmacist)) {
|
||
return fail(HttpEnumCode::USER_STATUS_ERROR);
|
||
}
|
||
|
||
if ($user_pharmacist['status'] == 0){
|
||
return fail(HttpEnumCode::USER_STATUS_DISABLE);
|
||
}
|
||
|
||
if ($user_pharmacist['status'] != 1){
|
||
return fail(HttpEnumCode::USER_STATUS_ERROR);
|
||
}
|
||
|
||
$user_pharmacist['avatar'] = addAliyunOssWebsite($user_pharmacist['avatar']);
|
||
|
||
// 获取用户数据
|
||
$params = array();
|
||
$params['user_id'] = $user_pharmacist['user_id'];
|
||
$user = User::getOne($params);
|
||
if (empty($user)){
|
||
return fail();
|
||
}
|
||
|
||
$user_pharmacist['is_online'] = $user['is_online'];
|
||
|
||
// 获取药师审方数量
|
||
$params = array();
|
||
$params['pharmacist_id'] = $user_pharmacist['pharmacist_id'];
|
||
$params['statistics_date'] = date('Y-m-d',time());
|
||
$audit_number = PharmacistAuditStatistic::getCount($params);
|
||
if (empty($audit_number)){
|
||
$audit_number = 0;
|
||
}
|
||
|
||
// 组合返回数据
|
||
$data = array();
|
||
$data['pharmacist'] = $user_pharmacist;
|
||
$data['audit_number'] = $audit_number;
|
||
|
||
return success($data);
|
||
}
|
||
|
||
} |