2024-09-19 11:32:39 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace service\modules\v1\controllers;
|
|
|
|
|
|
|
|
|
|
use common\core\BaseServiceController;
|
|
|
|
|
use common\enums\UserStatusEnum;
|
|
|
|
|
use common\helpers\ArrayHelper;
|
2024-12-19 19:20:27 +08:00
|
|
|
use common\models\oldDb\DoctorIdentity;
|
|
|
|
|
use common\models\oldDb\DoctorInfo;
|
|
|
|
|
use common\models\oldDb\DoctorPracticing;
|
|
|
|
|
use common\models\oldDb\PharmacistIdentity;
|
|
|
|
|
use common\models\oldDb\PharmacistPracticing;
|
|
|
|
|
use common\models\oldDb\ServiceUser;
|
|
|
|
|
use common\models\oldDb\StoreDoctor;
|
2024-09-19 11:32:39 +08:00
|
|
|
use service\models\forms\DoctorCompleteFour;
|
|
|
|
|
use service\models\forms\DoctorCompleteOne;
|
|
|
|
|
use service\models\forms\DoctorServiceForm;
|
|
|
|
|
use service\models\forms\DrugCompleteOne;
|
|
|
|
|
use service\models\forms\LeadCompleteOne;
|
|
|
|
|
use service\models\forms\ServiceCompleteOne;
|
|
|
|
|
use yii\base\Exception;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @doc-module 完善信息
|
|
|
|
|
*/
|
|
|
|
|
class CompleteController extends BaseServiceController
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @doc-name 医生-完善信息详情
|
|
|
|
|
* @doc-return mixed ServiceUser{id,status,@Info{DoctorInfo{*}},@Identity{DoctorIdentity{*}},@Practicing{DoctorPracticing{*}},@Service{DoctorService{*}}}
|
|
|
|
|
*/
|
|
|
|
|
public function actionDoctorInfo()
|
|
|
|
|
{
|
|
|
|
|
$id = \Yii::$app->user->identity->getId();
|
|
|
|
|
$store_id = StoreDoctor::find()->where([
|
|
|
|
|
'su_id' => $id,
|
|
|
|
|
'store_id' => \Yii::$app->store,
|
|
|
|
|
'is_delete' => 0
|
|
|
|
|
])->one();
|
|
|
|
|
if (!$store_id) throw new \yii\db\Exception('您不在该门店,无法查看基本信息');
|
|
|
|
|
$user = ServiceUser::find()->where([
|
|
|
|
|
'id' => $id
|
|
|
|
|
])->with('docInfo', 'docIdentity', 'docPracticing', 'docService')->one();
|
|
|
|
|
|
|
|
|
|
return ArrayHelper::toArray($user, [
|
|
|
|
|
ServiceUser::class => [
|
|
|
|
|
'id', 'status', 'reason',
|
|
|
|
|
'info' => 'docInfo',
|
|
|
|
|
'identity' => 'docIdentity',
|
|
|
|
|
'practicing' => 'docPracticing',
|
|
|
|
|
'service' => 'docService',
|
|
|
|
|
]
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @doc-name 中西医
|
|
|
|
|
* @doc-return array aa bb
|
|
|
|
|
*/
|
|
|
|
|
public function actionIdentity()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
['key' => 1, 'value' => '中医'],
|
|
|
|
|
['key' => 2, 'value' => '西医'],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @doc-name 中西药
|
|
|
|
|
* @doc-return array aa bb
|
|
|
|
|
*/
|
|
|
|
|
public function actionDrugIdentity()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
['key' => 0, 'value' => '中药'],
|
|
|
|
|
['key' => 1, 'value' => '西药'],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @doc-name 医生-完善基本信息
|
|
|
|
|
* @doc-param string name 姓名
|
|
|
|
|
* @doc-param string avatar 头像
|
|
|
|
|
* @doc-param string mobile 手机号
|
|
|
|
|
* @doc-param string idcard 身份证
|
|
|
|
|
* @doc-param json store_id 门店id["1","2"]
|
|
|
|
|
* @doc-param int depart_id 科室id
|
|
|
|
|
* @doc-param int identity 身份1中医2西医
|
|
|
|
|
* @doc-param int title_id 职称id
|
|
|
|
|
* @doc-param string good_at 擅长
|
|
|
|
|
* @doc-param string intro 简介
|
|
|
|
|
*/
|
|
|
|
|
public function actionDoctorStepOne()
|
|
|
|
|
{
|
|
|
|
|
//医院院区科室职称有删除的怎么办-先不管
|
2024-12-12 14:23:53 +08:00
|
|
|
try {
|
|
|
|
|
$form = new DoctorCompleteOne();
|
|
|
|
|
$form->attributes = \Yii::$app->request->post();
|
|
|
|
|
return $form->save();
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
ds([
|
|
|
|
|
'code' => 500,
|
|
|
|
|
'msg' => $e->getMessage(),
|
|
|
|
|
'data' => [
|
|
|
|
|
$e->getLine(),
|
|
|
|
|
$e->getFile(),
|
|
|
|
|
]
|
|
|
|
|
]);
|
|
|
|
|
throw new Exception($e->getMessage());
|
|
|
|
|
}
|
2024-09-19 11:32:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @doc-name 医生-完善认证信息
|
|
|
|
|
* @doc-param string card_up 身份证正面
|
|
|
|
|
* @doc-param string card_down 身份证反面
|
|
|
|
|
* @doc-param string work_avator 工作照
|
|
|
|
|
* @doc-param int sign_type 签章类型1电子2手写
|
|
|
|
|
* @doc-param string sign_image 签章图片
|
|
|
|
|
*/
|
|
|
|
|
public function actionDoctorStepTwo()
|
|
|
|
|
{
|
|
|
|
|
$post = \Yii::$app->request->post();
|
|
|
|
|
$this->requestValidate($post, [
|
|
|
|
|
['card_up', 'required', 'message' => '身份证正面照不能为空'],
|
|
|
|
|
['card_down', 'required', 'message' => '身份证反面照不能为空'],
|
|
|
|
|
['work_avator', 'required', 'message' => '工作照不能为空'],
|
|
|
|
|
]);
|
|
|
|
|
$su_id = \Yii::$app->user->identity->id;
|
|
|
|
|
$model = DoctorIdentity::find()->where([
|
|
|
|
|
'su_id' => $su_id,
|
|
|
|
|
])->one();
|
|
|
|
|
$t = \Yii::$app->db->beginTransaction();
|
|
|
|
|
try {
|
|
|
|
|
if (!$model) {
|
|
|
|
|
$model = new DoctorIdentity();
|
|
|
|
|
$model->su_id = $su_id;
|
|
|
|
|
}
|
|
|
|
|
$model->sign_type = 2;//手写
|
|
|
|
|
$model->attributes = $post;
|
|
|
|
|
$model->saveOrFail();
|
|
|
|
|
|
|
|
|
|
$t->commit();
|
|
|
|
|
return ['已完善认证信息'];
|
|
|
|
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
$t->rollBack();
|
|
|
|
|
throw new Exception($e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @doc-name 医生-完善执业信息
|
|
|
|
|
* @doc-param json qualification 资格证书["图片1","图片2"]
|
|
|
|
|
* @doc-param json practicing 执业证书["图片1","图片2"]
|
|
|
|
|
* @doc-param json title 职称证书["图片1","图片2"]
|
|
|
|
|
*/
|
|
|
|
|
public function actionDoctorStepThree()
|
|
|
|
|
{
|
|
|
|
|
$post = \Yii::$app->request->post();
|
|
|
|
|
$this->requestValidate($post, [
|
|
|
|
|
['qualification', 'required', 'message' => '资格证书不能为空'],
|
|
|
|
|
['practicing', 'required', 'message' => '执业证书不能为空'],
|
|
|
|
|
// ['title','required','message'=>'职称证书不能为空'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$qualification = json_decode($post['qualification'], true);
|
|
|
|
|
$practicing = json_decode($post['practicing'], true);
|
|
|
|
|
$title = json_decode($post['title'], true);
|
|
|
|
|
if (empty($qualification)) {
|
|
|
|
|
throw new Exception("资格证书不能为空");
|
|
|
|
|
}
|
|
|
|
|
if (empty($practicing)) {
|
|
|
|
|
throw new Exception("执业证书不能为空");
|
|
|
|
|
}
|
|
|
|
|
// if(empty($title)){
|
|
|
|
|
// throw new Exception("职称证书不能为空");
|
|
|
|
|
// }
|
|
|
|
|
$su_id = \Yii::$app->user->identity->id;
|
|
|
|
|
$t = \Yii::$app->db->beginTransaction();
|
|
|
|
|
try {
|
|
|
|
|
$model = DoctorPracticing::find()->where([
|
|
|
|
|
'su_id' => $su_id,
|
|
|
|
|
])->one();
|
|
|
|
|
if (!$model) {
|
|
|
|
|
$model = new DoctorPracticing();
|
|
|
|
|
$model->su_id = $su_id;
|
|
|
|
|
}
|
|
|
|
|
$model->attributes = $post;
|
|
|
|
|
$model->saveOrFail();
|
|
|
|
|
|
|
|
|
|
$t->commit();
|
|
|
|
|
return ['已完善执业信息'];
|
|
|
|
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
$t->rollBack();
|
|
|
|
|
throw new Exception($e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @doc-name 医生-完善服务信息
|
|
|
|
|
* @doc-param int register_status 是否开启挂号服务0否1是 0 optional
|
|
|
|
|
* @doc-param double register_price 挂号价格 0 optional
|
|
|
|
|
*/
|
|
|
|
|
public function actionDoctorStepFour()
|
|
|
|
|
{
|
|
|
|
|
$form = new DoctorCompleteFour();
|
|
|
|
|
$form->attributes = \Yii::$app->request->post();
|
|
|
|
|
return $form->save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 医生同步互医
|
|
|
|
|
* @return string[]
|
|
|
|
|
* @throws Exception
|
|
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
|
|
*/
|
|
|
|
|
public function actionSyncDoctor()
|
|
|
|
|
{
|
|
|
|
|
$serviceUser = ServiceUser::find()->where([
|
|
|
|
|
'id' => \Yii::$app->user->identity->id
|
|
|
|
|
])->with('docInfo', 'docIdentity', 'docPracticing')->one();
|
|
|
|
|
if (empty($serviceUser) || empty($serviceUser->docInfo) || empty($serviceUser->docIdentity) || empty($serviceUser->docPracticing)) {
|
|
|
|
|
throw new Exception('医生信息错误');
|
|
|
|
|
}
|
|
|
|
|
if($serviceUser->docInfo->is_sync == 1){
|
|
|
|
|
throw new Exception('该医生同步至互医已是审核中状态');
|
|
|
|
|
}
|
|
|
|
|
DoctorInfo::updateAll(['is_sync' => 1], ['su_id' => \Yii::$app->user->identity->id]);
|
|
|
|
|
return ['同步互医审核中'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @doc-name 药师-完善信息详情
|
|
|
|
|
* @doc-return mixed ServiceUser{id,status,@Info{PharmacistrInfo{*}},@Identity{PharmacistIdentity{*}},@Practicing{PharmacistPracticing{*}}}
|
|
|
|
|
*/
|
|
|
|
|
public function actionDrugInfo()
|
|
|
|
|
{
|
|
|
|
|
$user = ServiceUser::find()->where([
|
|
|
|
|
'id' => \Yii::$app->user->identity->id
|
|
|
|
|
])->with('drugInfo', 'drugIdentity', 'drugPracticing')->one();
|
|
|
|
|
|
|
|
|
|
return ArrayHelper::toArray($user, [
|
|
|
|
|
ServiceUser::class => [
|
|
|
|
|
'id', 'status', 'reason',
|
|
|
|
|
'info' => 'drugInfo',
|
|
|
|
|
'identity' => 'drugIdentity',
|
|
|
|
|
'practicing' => 'drugPracticing'
|
|
|
|
|
]
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @doc-name 药师-完善基础信息
|
|
|
|
|
* @doc-param string name 姓名
|
|
|
|
|
* @doc-param string avatar 头像
|
|
|
|
|
* @doc-param string mobile 手机号
|
|
|
|
|
* @doc-param string idcard 身份证
|
|
|
|
|
* @doc-param string store_id 门店id
|
|
|
|
|
* @doc-param int title_id 职称id
|
|
|
|
|
* @doc-param int type 身份类型1中医药师 2西医药师
|
|
|
|
|
*/
|
|
|
|
|
public function actionDrugStepOne()
|
|
|
|
|
{
|
|
|
|
|
$form = new DrugCompleteOne();
|
|
|
|
|
$form->attributes = \Yii::$app->request->post();
|
|
|
|
|
return $form->save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @doc-name 药师-完善认证信息
|
|
|
|
|
* @doc-param string card_up 身份证正面
|
|
|
|
|
* @doc-param string card_down 身份证反面
|
|
|
|
|
* @doc-param int sign_type 签章类型1电子2手写
|
|
|
|
|
* @doc-param string sign_image 签章图片
|
|
|
|
|
*/
|
|
|
|
|
public function actionDrugStepTwo()
|
|
|
|
|
{
|
|
|
|
|
$post = \Yii::$app->request->post();
|
|
|
|
|
$this->requestValidate($post, [
|
|
|
|
|
['card_up', 'required', 'message' => '身份证正面照不能为空'],
|
|
|
|
|
['card_down', 'required', 'message' => '身份证反面照不能为空'],
|
|
|
|
|
]);
|
|
|
|
|
$model = PharmacistIdentity::find()->where([
|
|
|
|
|
'su_id' => \Yii::$app->user->identity->id,
|
|
|
|
|
])->one();
|
|
|
|
|
if (!$model) {
|
|
|
|
|
$model = new PharmacistIdentity();
|
|
|
|
|
$model->su_id = \Yii::$app->user->identity->id;
|
|
|
|
|
}
|
|
|
|
|
$model->sign_type = 2;//手写
|
|
|
|
|
$model->attributes = $post;
|
|
|
|
|
$model->saveOrFail();
|
|
|
|
|
return ['已完善认证信息'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @doc-name 药师-完善执业信息
|
|
|
|
|
* @doc-param json qualification 资格证书["图片1","图片2"]
|
|
|
|
|
* @doc-param json practicing 执业证书["图片1","图片2"]
|
|
|
|
|
* @doc-param json title 职称证书["图片1","图片2"]
|
|
|
|
|
*/
|
|
|
|
|
public function actionDrugStepThree()
|
|
|
|
|
{
|
|
|
|
|
$post = \Yii::$app->request->post();
|
|
|
|
|
$this->requestValidate($post, [
|
|
|
|
|
['qualification', 'required', 'message' => '资格证书不能为空'],
|
|
|
|
|
// ['practicing', 'required', 'message' => '执业证书不能为空'],
|
|
|
|
|
// ['title', 'required', 'message' => '职称证书不能为空'],
|
|
|
|
|
]);
|
|
|
|
|
$qualification = json_decode($post['qualification'], true);
|
2024-12-12 16:49:13 +08:00
|
|
|
// $practicing = json_decode($post['practicing'], true);
|
|
|
|
|
// $title = json_decode($post['title'], true);
|
2024-09-19 11:32:39 +08:00
|
|
|
if (empty($qualification)) {
|
|
|
|
|
throw new Exception("资格证书不能为空");
|
|
|
|
|
}
|
|
|
|
|
// if (empty($practicing)) {
|
|
|
|
|
// throw new Exception("执业证书不能为空");
|
|
|
|
|
// }
|
|
|
|
|
// if (empty($title)) {
|
|
|
|
|
// throw new Exception("职称证书不能为空");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$serviceUser = ServiceUser::find()->where([
|
|
|
|
|
'id' => \Yii::$app->user->identity->id,
|
|
|
|
|
'is_delete' => 0
|
|
|
|
|
])->with('drugInfo', 'drugIdentity')->one();
|
|
|
|
|
|
|
|
|
|
if (!$serviceUser) {
|
|
|
|
|
throw new Exception('用户不存在');
|
|
|
|
|
}
|
|
|
|
|
if (!$serviceUser->drugInfo || !$serviceUser->drugIdentity) {
|
|
|
|
|
throw new Exception('请先完善前几步信息');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$t = \Yii::$app->db->beginTransaction();
|
|
|
|
|
try {
|
|
|
|
|
$model = PharmacistPracticing::find()->where([
|
|
|
|
|
'su_id' => \Yii::$app->user->identity->id,
|
|
|
|
|
])->one();
|
|
|
|
|
if (!$model) {
|
|
|
|
|
$model = new PharmacistPracticing();
|
|
|
|
|
$model->su_id = \Yii::$app->user->identity->id;
|
|
|
|
|
}
|
|
|
|
|
$model->attributes = $post;
|
|
|
|
|
|
|
|
|
|
$model->saveOrFail();
|
|
|
|
|
|
|
|
|
|
//第三步完成后需要修改账户的激活状态未待审核 - 后台审核 - 已认证
|
|
|
|
|
//后台拒绝 - 前台修改资料 - 提交 - 重新待审核
|
|
|
|
|
$user = \Yii::$app->user->identity;
|
|
|
|
|
$user->status = UserStatusEnum::WAIT_SH;
|
|
|
|
|
$user->reason = null;
|
|
|
|
|
$user->saveOrFail();
|
|
|
|
|
|
|
|
|
|
$t->commit();
|
|
|
|
|
} catch (Exception $exception) {
|
|
|
|
|
$t->rollBack();
|
|
|
|
|
throw $exception;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @doc-name 导医-完善信息详情
|
|
|
|
|
* @doc-return mixed ServiceUser{id,status,@Info{LeadInfo{*}}}
|
|
|
|
|
*/
|
|
|
|
|
public function actionLeadInfo()
|
|
|
|
|
{
|
|
|
|
|
$user = ServiceUser::find()->where([
|
|
|
|
|
'id' => \Yii::$app->user->identity->id
|
|
|
|
|
])->with('leadInfo')->one();
|
|
|
|
|
|
|
|
|
|
return ArrayHelper::toArray($user, [
|
|
|
|
|
ServiceUser::class => [
|
|
|
|
|
'id', 'status', 'info' => 'leadInfo'
|
|
|
|
|
]
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @doc-name 导医-完善信息
|
|
|
|
|
* @doc-param string name 姓名
|
|
|
|
|
* @doc-param string avatar 头像
|
|
|
|
|
* @doc-param string mobile 手机号
|
|
|
|
|
* @doc-param string idcard 身份证
|
|
|
|
|
* @doc-param int hospital_id 医院id
|
|
|
|
|
* @doc-param int yard_id 院区id
|
|
|
|
|
* @doc-param int depart_id 科室id
|
|
|
|
|
* @doc-param string card_up 身份证正面
|
|
|
|
|
* @doc-param string card_down 身份证反面
|
|
|
|
|
*/
|
|
|
|
|
public function actionLeader()
|
|
|
|
|
{
|
|
|
|
|
$form = new LeadCompleteOne();
|
|
|
|
|
$form->attributes = \Yii::$app->request->post();
|
|
|
|
|
return $form->save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @doc-name 导医-完善信息详情
|
|
|
|
|
* @doc-return mixed ServiceUser{id,status,@Info{LeadInfo{*}}}
|
|
|
|
|
*/
|
|
|
|
|
public function actionServInfo()
|
|
|
|
|
{
|
|
|
|
|
$user = ServiceUser::find()->where([
|
|
|
|
|
'id' => \Yii::$app->user->identity->id
|
|
|
|
|
])->with('servInfo')->one();
|
|
|
|
|
|
|
|
|
|
return ArrayHelper::toArray($user, [
|
|
|
|
|
ServiceUser::class => [
|
|
|
|
|
'id', 'status', 'info' => 'servInfo'
|
|
|
|
|
]
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @doc-name 客服完善信息
|
|
|
|
|
* @doc-param string name 姓名
|
|
|
|
|
* @doc-param string avatar 头像
|
|
|
|
|
* @doc-param string mobile 手机号
|
|
|
|
|
* @doc-param string idcard 身份证
|
|
|
|
|
* @doc-param int hospital_id 医院id
|
|
|
|
|
* @doc-param int yard_id 院区id
|
|
|
|
|
* @doc-param int depart_id 科室id
|
|
|
|
|
* @doc-param string card_up 身份证正面
|
|
|
|
|
* @doc-param string card_down 身份证反面
|
|
|
|
|
*/
|
|
|
|
|
public function actionService()
|
|
|
|
|
{
|
|
|
|
|
$form = new ServiceCompleteOne();
|
|
|
|
|
$form->attributes = \Yii::$app->request->post();
|
|
|
|
|
return $form->save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @doc-name 医生-服务设置
|
|
|
|
|
* @doc-param int register_status 是否开通挂号 0 optioanl
|
|
|
|
|
* @doc-param double register_price 挂号价格 0 optional
|
|
|
|
|
*/
|
|
|
|
|
public function actionDoctorService()
|
|
|
|
|
{
|
|
|
|
|
$form = new DoctorServiceForm();
|
|
|
|
|
$form->attributes = \Yii::$app->request->post();
|
|
|
|
|
return $form->save();
|
|
|
|
|
}
|
|
|
|
|
}
|