100 lines
3.3 KiB
PHP
100 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace service\modules\v1\controllers;
|
|
|
|
use common\core\BaseAppController;
|
|
use common\enums\UserRoleEnum;
|
|
use common\enums\UserStatusEnum;
|
|
use common\helpers\ArrayHelper;
|
|
use common\models\HospitalDepartment;
|
|
use common\models\oldDb\LeadInfo;
|
|
use common\models\oldDb\ServiceUser;
|
|
|
|
/**
|
|
* @doc-module 导医
|
|
*/
|
|
class LeaderController extends BaseAppController
|
|
{
|
|
/**
|
|
* @doc-name 医生列表
|
|
* @doc-param string keyword 关键词 / optional
|
|
* @doc-param int page 页码 1 optional
|
|
* @doc-param int page_size 每页条数 20 optional
|
|
* @doc-return mixed @List{ServiceUser{id,avator-string-医生头像,name-string-医生姓名,depart-string-医生科室,hospital-string-医院,yard-string-院区,title-string-职称,good_at-string-擅长,accept_percent-string-接诊率,good_comment_percent-string-好评率,inquiry_num-int-问诊量,avg_reply-string-平均回复,@Service{DoctorService{register_status,register_price}}}} 医生列表
|
|
* @doc-return mixed @Pagination{total_count-int-总数量,page_count-int-总页数,current_page-int-当前页,per_page-int-每页条数} 分页数据
|
|
*/
|
|
public function actionDoctorLists()
|
|
{
|
|
$post = \Yii::$app->request->post();
|
|
$keyword = $post['keyword'];
|
|
$query = ServiceUser::find()->alias('su')->where([
|
|
'su.role' => UserRoleEnum::DOCTOR,
|
|
'su.status' => UserStatusEnum::OK,
|
|
'su.is_delete' => 0
|
|
])->orderBy(['id'=>SORT_DESC]);
|
|
|
|
$depart_arr = json_decode(ArrayHelper::getValue($post, 'depart_id', "[]"), true);
|
|
|
|
$departs = HospitalDepartment::find()->select('id,name')->where(['<>', 'id', 0])->asArray()->all();
|
|
$id = 0;
|
|
foreach ($departs as $v) {
|
|
if (in_array($keyword, $v)) {
|
|
$id = $v['id'];
|
|
}
|
|
}
|
|
|
|
$query->joinWith(['docInfo' => function ($q) use ($id, $keyword, $depart_arr) {
|
|
$q->alias('i');
|
|
// 搜索框搜索姓名和科室
|
|
if (!empty($keyword)) {
|
|
$q->andWhere([
|
|
'or',
|
|
['like', 'i.name', $keyword],
|
|
['i.depart_id' => $id]
|
|
]);
|
|
}
|
|
// 科室搜索
|
|
if (!empty($depart_arr)) {
|
|
$q->andWhere([
|
|
'i.depart_id' => $depart_arr
|
|
]);
|
|
}
|
|
}]);
|
|
|
|
$this->field = [
|
|
ServiceUser::class => [
|
|
'id',
|
|
'avator' => 'docIdentity.work_avator',
|
|
'name' => 'docInfo.name',
|
|
'depart' => 'docInfo.depart.name',
|
|
'hospital' => 'docInfo.hospital.name',
|
|
'yard' => 'docInfo.yard.name',
|
|
'title' => 'docInfo.title.name',
|
|
'inquiry_num' => 'docInfo.inquiries',
|
|
],
|
|
];
|
|
return $this->create($query, $post);
|
|
}
|
|
|
|
/**
|
|
* @doc-name 切换在线状态
|
|
* @doc-param int online 0不在线1在线
|
|
*/
|
|
public function actionChangeOnline()
|
|
{
|
|
$online = \Yii::$app->request->post('online');
|
|
$user = \Yii::$app->user->identity;
|
|
$user->im_status = $online;
|
|
$user->save();
|
|
return ['切换成功'];
|
|
}
|
|
|
|
/**
|
|
* @doc-name 获取空闲导医
|
|
*/
|
|
public function actionGetFreeLeaders()
|
|
{
|
|
return LeadInfo::getLastLeadUserId();
|
|
}
|
|
}
|