个人简介相关接口
This commit is contained in:
@@ -4,8 +4,10 @@ namespace App\Services;
|
||||
|
||||
use App\Constants\DoctorTitleCode;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Model\DiseaseClassExpertise;
|
||||
use App\Model\DoctorExpertise;
|
||||
use App\Model\DoctorIdenFail;
|
||||
use App\Model\DoctorIntroductionRecord;
|
||||
use App\Model\Hospital;
|
||||
use App\Model\HospitalDepartmentCustom;
|
||||
use App\Model\User;
|
||||
@@ -233,14 +235,13 @@ class DoctorAuthService extends BaseService
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$source = $this->request->input('source'); // 来源(1:身份认证 2:简介)
|
||||
|
||||
// 获取医生数据
|
||||
$fields = [
|
||||
'doctor_id',
|
||||
'user_id',
|
||||
'idcard_status',
|
||||
'iden_auth_status',
|
||||
'introduction_status',
|
||||
'avatar',
|
||||
'hospital_id',
|
||||
'department_custom_id',
|
||||
@@ -273,42 +274,40 @@ class DoctorAuthService extends BaseService
|
||||
// 职称转换
|
||||
$result['doctor_title_name'] = empty($doctor['doctor_title']) ? "" : DoctorTitleCode::getMessage($doctor['doctor_title']);
|
||||
|
||||
if ($source == 1){
|
||||
// 获取医生详情数据
|
||||
$result['license_cert'] = [];
|
||||
$result['qualification_cert'] = [];
|
||||
$result['work_cert'] = [];
|
||||
// 获取医生详情数据
|
||||
$result['license_cert'] = [];
|
||||
$result['qualification_cert'] = [];
|
||||
$result['work_cert'] = [];
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$user_doctor_info = UserDoctorInfo::getOne($params);
|
||||
if (!empty($user_doctor_info)) {
|
||||
// 医师执业证
|
||||
if (!empty($user_doctor_info['license_cert'])) {
|
||||
$license_cert = explode(',', $user_doctor_info['license_cert']);
|
||||
foreach ($license_cert as &$item) {
|
||||
$item = addAliyunOssWebsite($item);
|
||||
}
|
||||
$result['license_cert'] = $license_cert;
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$user_doctor_info = UserDoctorInfo::getOne($params);
|
||||
if (!empty($user_doctor_info)) {
|
||||
// 医师执业证
|
||||
if (!empty($user_doctor_info['license_cert'])) {
|
||||
$license_cert = explode(',', $user_doctor_info['license_cert']);
|
||||
foreach ($license_cert as &$item) {
|
||||
$item = addAliyunOssWebsite($item);
|
||||
}
|
||||
$result['license_cert'] = $license_cert;
|
||||
}
|
||||
|
||||
// 医师职称证
|
||||
if (!empty($user_doctor_info['qualification_cert'])) {
|
||||
$qualification_cert = explode(',', $user_doctor_info['qualification_cert']);
|
||||
foreach ($qualification_cert as &$item) {
|
||||
$item = addAliyunOssWebsite($item);
|
||||
}
|
||||
$result['qualification_cert'] = $qualification_cert;
|
||||
// 医师职称证
|
||||
if (!empty($user_doctor_info['qualification_cert'])) {
|
||||
$qualification_cert = explode(',', $user_doctor_info['qualification_cert']);
|
||||
foreach ($qualification_cert as &$item) {
|
||||
$item = addAliyunOssWebsite($item);
|
||||
}
|
||||
$result['qualification_cert'] = $qualification_cert;
|
||||
}
|
||||
|
||||
// 医师资格证
|
||||
if (!empty($user_doctor_info['work_cert'])) {
|
||||
$work_cert = explode(',', $user_doctor_info['work_cert']);
|
||||
foreach ($work_cert as &$item) {
|
||||
$item = addAliyunOssWebsite($item);
|
||||
}
|
||||
$result['work_cert'] = $work_cert;
|
||||
// 医师资格证
|
||||
if (!empty($user_doctor_info['work_cert'])) {
|
||||
$work_cert = explode(',', $user_doctor_info['work_cert']);
|
||||
foreach ($work_cert as &$item) {
|
||||
$item = addAliyunOssWebsite($item);
|
||||
}
|
||||
$result['work_cert'] = $work_cert;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -778,7 +777,7 @@ class DoctorAuthService extends BaseService
|
||||
return success(null);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$result = null;
|
||||
foreach ($doctor_iden_fails as $doctor_iden_fail) {
|
||||
$result[$doctor_iden_fail['field_name']] = $doctor_iden_fail['fail_reason'];
|
||||
}
|
||||
@@ -824,23 +823,304 @@ class DoctorAuthService extends BaseService
|
||||
return success(null);
|
||||
}
|
||||
|
||||
$result = null;
|
||||
foreach ($doctor_iden_fails as $doctor_iden_fail) {
|
||||
// 头像
|
||||
if ($doctor_iden_fail['field_name'] == "avatar") {
|
||||
$result['avatar_reason'] = $doctor_iden_fail['fail_reason'];
|
||||
$result[$doctor_iden_fail['field_name']] = $doctor_iden_fail['fail_reason'];
|
||||
}
|
||||
|
||||
// 医生简介
|
||||
if ($doctor_iden_fail['field_name'] == "brief_introduction") {
|
||||
$result['brief_introduction_reason'] = $doctor_iden_fail['fail_reason'];
|
||||
$result[$doctor_iden_fail['field_name']] = $doctor_iden_fail['fail_reason'];
|
||||
}
|
||||
|
||||
// 擅长
|
||||
if ($doctor_iden_fail['field_name'] == "be_good_at") {
|
||||
$result['be_good_at_reason'] = $doctor_iden_fail['fail_reason'];
|
||||
$result[$doctor_iden_fail['field_name']] = $doctor_iden_fail['fail_reason'];
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
return success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取个人简介
|
||||
* @return array
|
||||
*/
|
||||
public function getDoctorIntroduction(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
// 获取医生数据
|
||||
$fields = [
|
||||
'doctor_id',
|
||||
'user_id',
|
||||
'idcard_status',
|
||||
'iden_auth_status',
|
||||
'introduction_status',
|
||||
'avatar',
|
||||
'hospital_id',
|
||||
'department_custom_id',
|
||||
'department_custom_name',
|
||||
'department_custom_mobile',
|
||||
'doctor_title',
|
||||
'brief_introduction',
|
||||
'be_good_at',
|
||||
];
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor = UserDoctor::getOne($params, $fields);
|
||||
if (empty($doctor)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未知医生");
|
||||
}
|
||||
|
||||
// 实名认证状态(0:未认证 1:认证通过 2:认证失败)
|
||||
if ($doctor['idcard_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先实名认证");
|
||||
}
|
||||
|
||||
$result = $doctor->toArray();
|
||||
|
||||
// 头像
|
||||
if (!empty($doctor['avatar'])) {
|
||||
$result['avatar'] = addAliyunOssWebsite($doctor['avatar']);
|
||||
}
|
||||
|
||||
// 职称转换
|
||||
$result['doctor_title_name'] = empty($doctor['doctor_title']) ? "" : DoctorTitleCode::getMessage($doctor['doctor_title']);
|
||||
|
||||
// 获取医生医院
|
||||
$result['hospital'] = [];
|
||||
|
||||
$fields = [
|
||||
'hospital_id',
|
||||
'hospital_name',
|
||||
'hospital_level_name',
|
||||
'province_id',
|
||||
'province',
|
||||
'city_id',
|
||||
'city',
|
||||
'county_id',
|
||||
'county',
|
||||
];
|
||||
|
||||
$params = array();
|
||||
$params['hospital_id'] = $doctor['hospital_id'];
|
||||
$hospital = Hospital::getOne($params, $fields);
|
||||
if (!empty($hospital)) {
|
||||
$result['hospital'] = $hospital;
|
||||
}
|
||||
|
||||
// 获取医生已选择专长
|
||||
$UserDoctorService = new UserDoctorService();
|
||||
$result['doctor_expertise'] = $UserDoctorService->getDoctorSelectedExpertise($doctor['doctor_id']);
|
||||
|
||||
if ($doctor['introduction_status'] == 2 || $doctor['introduction_status'] == 3){
|
||||
// 获取修改数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor['doctor_id'];
|
||||
$params['is_verified'] = 0;
|
||||
$doctor_introduction_record = DoctorIntroductionRecord::getOne($params);
|
||||
if (empty($doctor_introduction_record)){
|
||||
return fail();
|
||||
}
|
||||
|
||||
if (!empty($doctor_introduction_record['avatar'])){
|
||||
$result['avatar'] = PcreMatch::pregRemoveOssWebsite($doctor_introduction_record['avatar']);
|
||||
}
|
||||
|
||||
if (!empty($doctor_introduction_record['be_good_at'])){
|
||||
$result['be_good_at'] = $doctor_introduction_record['be_good_at'];
|
||||
}
|
||||
|
||||
if (!empty($doctor_introduction_record['brief_introduction'])){
|
||||
$result['brief_introduction'] = $doctor_introduction_record['brief_introduction'];
|
||||
}
|
||||
|
||||
// 处理专长
|
||||
if (!empty($doctor_introduction_record['expertise_ids'])){
|
||||
$result['doctor_expertise'] = array();
|
||||
|
||||
$expertise_ids = explode(',',$doctor_introduction_record['expertise_ids']);
|
||||
foreach ($expertise_ids as $expertise_id){
|
||||
$params = array();
|
||||
$params['expertise_id'] = $expertise_id;
|
||||
$disease_class_expertise = DiseaseClassExpertise::getOne($params);
|
||||
if (empty($disease_class_expertise)){
|
||||
return fail();
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data['expertise_id'] = $expertise_id;
|
||||
$data['expertise_name'] = $disease_class_expertise['expertise_name'];
|
||||
$result['doctor_expertise'][] = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改个人简介
|
||||
* @return array
|
||||
*/
|
||||
public function putDoctorIntroduction(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$request_params = $this->request->all();
|
||||
|
||||
// 获取医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor = UserDoctor::getOne($params);
|
||||
if (empty($doctor)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未知医生");
|
||||
}
|
||||
|
||||
// 实名认证状态(0:未认证 1:认证通过 2:认证失败)
|
||||
if ($doctor['idcard_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先实名认证");
|
||||
}
|
||||
|
||||
// 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||||
if ($doctor['iden_auth_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先完成身份认证");
|
||||
}
|
||||
|
||||
// 个人简介审核状态(0:未审核 1:审核通过 2:审核中 3:审核失败)
|
||||
if ($doctor['introduction_status'] == 0){
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未审核,暂不允许修改");
|
||||
}
|
||||
|
||||
if ($doctor['introduction_status'] == 2){
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "审核中,暂不允许修改");
|
||||
}
|
||||
|
||||
// 组合存储数据
|
||||
$doctor_introduction_record_data = array();
|
||||
|
||||
// 头像
|
||||
$request_params['avatar'] = PcreMatch::pregRemoveOssWebsite($request_params['avatar']);
|
||||
if ($doctor['avatar'] != $request_params['avatar']) {
|
||||
$doctor_introduction_record_data['avatar'] = $request_params['avatar'];
|
||||
}
|
||||
|
||||
// 医生简介
|
||||
if ($doctor['brief_introduction'] != $request_params['brief_introduction']) {
|
||||
$doctor_introduction_record_data['brief_introduction'] = $request_params['brief_introduction'];
|
||||
}
|
||||
|
||||
// 擅长领域
|
||||
if ($doctor['be_good_at'] != $request_params['be_good_at']) {
|
||||
$doctor_introduction_record_data['be_good_at'] = $request_params['be_good_at'];
|
||||
}
|
||||
|
||||
//已选择专长列表
|
||||
$expertise_ids = [];
|
||||
|
||||
// 获取医生专长
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor_expertise = DoctorExpertise::getList($params);
|
||||
if (!empty($doctor_expertise)) {
|
||||
$expertise_ids = array_column($doctor_expertise->toArray(), 'expertise_id');
|
||||
}
|
||||
|
||||
// 对比已选择专长
|
||||
// 对比专长是否删除
|
||||
$is_delete_expertise = array_diff($request_params['doctor_expertise'], $expertise_ids);
|
||||
|
||||
// 对比专长是否新增
|
||||
if (empty($is_delete_expertise)) {
|
||||
$is_add_expertise = array_diff($expertise_ids, $request_params['doctor_expertise']);
|
||||
}
|
||||
|
||||
// 专长是否改动:false(未改动) true(已改动)
|
||||
$expertise_is_change = false;
|
||||
if (!empty($is_delete_expertise) || !empty($is_add_expertise)) {
|
||||
$doctor_introduction_record_data['expertise_ids'] = implode(',',$request_params['doctor_expertise']);
|
||||
|
||||
$expertise_is_change = true;
|
||||
}
|
||||
|
||||
if (empty($doctor_introduction_record_data)){
|
||||
// 未修改
|
||||
return success();
|
||||
}
|
||||
|
||||
// 审核失败,重新提交,判断被审核错误字段数据是否更改
|
||||
if ($doctor['introduction_status'] == 3){
|
||||
// 获取认证失败字段
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor_iden_fails = DoctorIdenFail::getList($params);
|
||||
if (!empty($doctor_iden_fails)){
|
||||
foreach ($doctor_iden_fails as $doctor_iden_fail){
|
||||
// 头像
|
||||
if ($doctor_iden_fail['field_name'] == "avatar") {
|
||||
if ($doctor['avatar'] == $request_params['avatar']){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"医生头像" . $doctor_iden_fail['fail_reason']);
|
||||
}
|
||||
}
|
||||
|
||||
// 医生简介
|
||||
if ($doctor_iden_fail['field_name'] == "brief_introduction") {
|
||||
if ($doctor['brief_introduction'] == $request_params['brief_introduction']){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"医生简介" . $doctor_iden_fail['fail_reason']);
|
||||
}
|
||||
}
|
||||
|
||||
// 擅长领域
|
||||
if ($doctor_iden_fail['field_name'] == "be_good_at") {
|
||||
if ($doctor['be_good_at'] == $request_params['be_good_at']){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"擅长领域" . $doctor_iden_fail['fail_reason']);
|
||||
}
|
||||
}
|
||||
|
||||
// 专长
|
||||
if ($doctor_iden_fail['field_name'] == "expertise_ids") {
|
||||
if (!$expertise_is_change){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"专长" . $doctor_iden_fail['fail_reason']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 新增医生简介修改记录表
|
||||
$doctor_introduction_record_data['doctor_id'] = $doctor['doctor_id'];
|
||||
$doctor_introduction_record_data['is_verified'] = 0;
|
||||
$doctor_introduction_record = DoctorIntroductionRecord::addDoctorIntroductionRecord($doctor_introduction_record_data);
|
||||
if (empty($doctor_introduction_record)){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
// 修改医生表个人简介审核状态
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
|
||||
$data = array();
|
||||
$data['introduction_status'] = 2;
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', time());
|
||||
$res = UserDoctor::editUserDoctor($params, $data);
|
||||
if (!$res) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage());
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
}
|
||||
@@ -148,6 +148,7 @@ class IndexService extends BaseService
|
||||
"iden_auth_status",
|
||||
"iden_auth_fail_reason",
|
||||
"multi_point_status",
|
||||
"introduction_status",
|
||||
"is_bind_bank",
|
||||
"praise_rate",
|
||||
"avg_response_time",
|
||||
|
||||
Reference in New Issue
Block a user