235 lines
8.3 KiB
PHP
235 lines
8.3 KiB
PHP
<?php
|
||
|
||
namespace admin\controllers\doctor;
|
||
|
||
use admin\components\BaseAdminController;
|
||
use common\enums\UserRoleEnum;
|
||
use common\enums\UserStatusEnum;
|
||
use common\models\oldDb\Department;
|
||
use common\models\oldDb\PharmacistrInfo;
|
||
use common\models\oldDb\ServiceUser;
|
||
|
||
|
||
/**
|
||
* 药师
|
||
*/
|
||
class PharmacistController extends BaseAdminController
|
||
{
|
||
/**
|
||
* @doc-name 药师列表
|
||
* @doc-param int status 状态0待激活1待审核2已认证3拒绝(需要修改激活资料)4全部药师
|
||
* @doc-param string name 姓名 / optional
|
||
* @doc-param string mobile 电话 / optional
|
||
* @doc-param int depart_id 科室id / optional
|
||
* @doc-param int title_id 职称id / optional
|
||
* @doc-param int identity 身份1中医2西医 / optional
|
||
* @doc-return mixed @List{ServiceUser{id,reason-string-拒绝原因,status-int-状态0待激活1待审核2已认证3拒绝(需要修改激活资料),created_at-string-注册时间,updated_at-string-审核通过时间,identity-string-身份1中医2西医,avatar-string-药师头像,name-string-药师姓名,mobile-string-药师电话,depart-string-药师科室,title-string-职称,type-int-1初审2复审,@Identity{sign_type-string-签章类型1电子2手写,sign_image-string-签章图片},@DrugPracticing{qualification-string-资格证书}}}} 药师列表
|
||
* @doc-return mixed @Pagination{total-int-总数量,totalPage-int-总页数,pageSize-int-每页条数} 分页数据
|
||
*/
|
||
public function actionList()
|
||
{
|
||
$post = \Yii::$app->request->get();
|
||
$this->requestValidate($post,[
|
||
['status','required']
|
||
]);
|
||
$name=$post['name'];
|
||
$mobile=$post['mobile'];
|
||
$depart_id=$post['depart_id']?? 0;
|
||
$title_id=$post['title_id']?? 0;
|
||
$identity=$post['identity']?? 0;
|
||
|
||
switch ($post['status']){
|
||
case 0:
|
||
$query = ServiceUser::find()->alias('su')->where([
|
||
'su.role' => UserRoleEnum::DRUG,
|
||
'su.status' => UserStatusEnum::WAIT_JH,
|
||
'su.is_delete' => 0
|
||
]);
|
||
break;
|
||
case 1:
|
||
$query = ServiceUser::find()->alias('su')->where([
|
||
'su.role' => UserRoleEnum::DRUG,
|
||
'su.status' => UserStatusEnum::WAIT_SH,
|
||
'su.is_delete' => 0
|
||
]);
|
||
break;
|
||
case 2:
|
||
$query = ServiceUser::find()->alias('su')->where([
|
||
'su.role' => UserRoleEnum::DRUG,
|
||
'su.status' => UserStatusEnum::OK,
|
||
'su.is_delete' => 0
|
||
]);
|
||
break;
|
||
case 3:
|
||
$query = ServiceUser::find()->alias('su')->where([
|
||
'su.role' => UserRoleEnum::DRUG,
|
||
'su.status' => UserStatusEnum::REFUSED,
|
||
'su.is_delete' => 0
|
||
]);
|
||
break;
|
||
case 4:
|
||
$query = ServiceUser::find()->alias('su')->where([
|
||
'su.role' => UserRoleEnum::DRUG,
|
||
'su.status' =>[ UserStatusEnum::REFUSED,UserStatusEnum::OK, UserStatusEnum::WAIT_SH],
|
||
'su.is_delete' => 0
|
||
]);
|
||
break;
|
||
default:
|
||
throw new \yii\db\Exception('参数错误');
|
||
}
|
||
|
||
$departs = Department::find()->select('id,name')->where(['<>', 'id', 0])->asArray()->all();
|
||
|
||
$id = 0;
|
||
foreach ($departs as $v) {
|
||
if (in_array($depart_id, $v) == true) {
|
||
$id = $v['id'];
|
||
}
|
||
}
|
||
$query->joinWith(['drugInfo' => function ($q) use ($name,$id,$mobile, $depart_id, $title_id,$identity) {
|
||
$q->alias('d');
|
||
if (!empty($name)) {//搜索姓名
|
||
$q->andWhere(['like', 'd.name', $name]);
|
||
}
|
||
if (!empty($mobile)) {//手机号
|
||
$q->andWhere(['d.mobile'=>$mobile]);
|
||
}
|
||
if (!empty($depart_id)) {//科室
|
||
$q->andWhere(['d.depart_id'=>$depart_id]);
|
||
}
|
||
if (!empty($title_id)) {//职称搜索
|
||
$q->andWhere(['d.title_id' => $title_id]);
|
||
}
|
||
if (!empty($identity)) {//身份1中医2西医
|
||
$q->andWhere(['d.identity' => $identity]);
|
||
}
|
||
}]);
|
||
|
||
$this->field = [
|
||
ServiceUser::class => [
|
||
'id','reason','status','created_at','updated_at',
|
||
'identity'=>'drugInfo.identity',
|
||
'depart_id'=>'drugInfo.depart_id',
|
||
'avatar' => 'drugInfo.avatar',
|
||
'name' => 'drugInfo.name',
|
||
'mobile',
|
||
'depart' => 'drugInfo.depart.name',
|
||
'title1' => 'drugInfo.titles.name',
|
||
'drugIdentity' => 'drugIdentity',
|
||
'drugPracticing' => 'drugPracticing',
|
||
'type'=>'drugInfo.type',
|
||
'id_card'=>'drugInfo.idcard'
|
||
],
|
||
];
|
||
return $this->create($query, $post);
|
||
}
|
||
|
||
/**
|
||
* @doc-name 药师审核通过操作+拒绝操作(入驻)
|
||
* @doc-desc 当status为2时必填reason
|
||
* @doc-param int status 状态1审核通过2拒绝操作
|
||
* @doc-param string reason 拒绝的原因 / optional
|
||
* @doc-param int drug_id 药师id
|
||
*/
|
||
public function actionIntoCheck()
|
||
{
|
||
$post = \Yii::$app->request->get();
|
||
$this->requestValidate($post,[
|
||
[['status','drug_id'],'required']
|
||
]);
|
||
|
||
$is_exist = ServiceUser::find()->alias('su')->where([
|
||
'id'=>$post['drug_id'],
|
||
'su.role' => UserRoleEnum::DRUG,
|
||
'su.status' => UserStatusEnum::WAIT_SH,
|
||
'su.is_delete' => 0
|
||
])->one();
|
||
|
||
switch ($post['status']){
|
||
case 1:
|
||
if (!$is_exist){
|
||
throw new \Exception('药师不存在');
|
||
}
|
||
|
||
$is_exist->status=UserStatusEnum::OK;
|
||
$is_exist->updated_at=time();
|
||
if (!$is_exist->saveOrFail()){
|
||
throw new \Exception('error');
|
||
}
|
||
|
||
return ['药师审核通过'];
|
||
case 2:
|
||
if (!$is_exist){
|
||
throw new \Exception('药师不存在');
|
||
}
|
||
|
||
if (empty($post['reason'])){
|
||
throw new \Exception('拒绝原因不能为空');
|
||
}
|
||
|
||
$is_exist->status=UserStatusEnum::REFUSED;
|
||
$is_exist->updated_at=time();
|
||
$is_exist->reason=$post['reason'];
|
||
|
||
$is_exist->saveOrFail();
|
||
return ['药师审核拒绝'];
|
||
default:
|
||
throw new \yii\db\Exception('参数错误');
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @doc-name 药师详情
|
||
* @doc-param int drug_id 药师id
|
||
*/
|
||
public function actionInfo()
|
||
{
|
||
$post = \Yii::$app->request->post();
|
||
$this->requestValidate($post,[
|
||
['drug_id','required']
|
||
]);
|
||
$ServiceUser = ServiceUser::find()->alias('su')->where([
|
||
'id'=>$post['drug_id'],
|
||
'su.role' => UserRoleEnum::DRUG,
|
||
'su.is_delete' => 0
|
||
])->with(['drugInfo','drugIdentity','drugPracticing'])->asArray()->one();
|
||
if (!$ServiceUser){
|
||
throw new \Exception('药师不存在');
|
||
};
|
||
|
||
return $ServiceUser;
|
||
}
|
||
|
||
/**
|
||
* @doc-name 设置药师初审或复审
|
||
* @doc-param int drug_id 药师ID
|
||
* @doc-param int type 1初审2复审
|
||
*/
|
||
public function actionSetFirstAgain()
|
||
{
|
||
$get= \Yii::$app->request->get();
|
||
$this->requestValidate($get,[
|
||
[['drug_id','type'],'required']
|
||
]);
|
||
$ServiceUser = ServiceUser::find()->alias('su')->where([
|
||
'id'=>$get['drug_id'],
|
||
'su.role' => UserRoleEnum::DRUG,
|
||
'status'=>UserStatusEnum::OK,
|
||
'su.is_delete' => 0
|
||
])->one();
|
||
if (!$ServiceUser){
|
||
throw new \Exception('药师不存在');
|
||
}
|
||
|
||
$PharmacistrInfo=PharmacistrInfo::find()->where([
|
||
'su_id'=>$get['drug_id']
|
||
])->one();
|
||
if (!$PharmacistrInfo){
|
||
throw new \Exception('药师没完善信息');
|
||
}
|
||
$PharmacistrInfo->type=$get['type'];
|
||
$PharmacistrInfo->saveOrFail();
|
||
return ['设置成功'];
|
||
}
|
||
|
||
} |