205 lines
6.8 KiB
PHP
205 lines
6.8 KiB
PHP
<?php
|
|
|
|
namespace member\modules\v1\controllers;
|
|
|
|
use common\core\BaseAppController;
|
|
use common\forms\RegisterRefundForm;
|
|
use common\models\oldDb\Register;
|
|
use member\models\forms\RegisterForm;
|
|
use member\models\forms\RegisterSubmitForm;
|
|
use yii\db\Exception;
|
|
|
|
/**
|
|
* @doc-module 挂号
|
|
*/
|
|
class RegisterController extends BaseAppController
|
|
{
|
|
/**
|
|
* @doc-name 挂号
|
|
* @doc-param int user_id 用户id
|
|
* @doc-param int user_patient_id 就诊人id
|
|
* @doc-param int store_id 诊所id
|
|
* @doc-param int service_user_id 医生id
|
|
* @doc-return int register_id 挂号id
|
|
*/
|
|
public function actionRegister()
|
|
{
|
|
$post=\Yii::$app->request->post();
|
|
if (!isset($post['register_type'])) {
|
|
$post['register_type'] = '0';
|
|
}
|
|
$RegisterForm=new RegisterForm();
|
|
$RegisterForm->attributes=$post;
|
|
return $RegisterForm->save();
|
|
}
|
|
|
|
/**
|
|
* @doc-name 挂号信息
|
|
* @doc-param int service_user_id 医生id
|
|
* @doc-return string time 日期
|
|
* @doc-return float register_price 金额
|
|
* @doc-return int left_num 剩余号
|
|
* @doc-return int register_num 总号数
|
|
*/
|
|
public function actionDocRegisterInfo()
|
|
{
|
|
$post=\Yii::$app->request->post();
|
|
$this->requestValidate($post,[
|
|
['service_user_id','required']
|
|
]);
|
|
$RegisterForm=new RegisterForm();
|
|
$RegisterForm->attributes=$post;
|
|
|
|
return $RegisterForm->info();
|
|
}
|
|
|
|
|
|
/**
|
|
* @doc-name 支付挂号
|
|
* @doc-param int register_id 挂号id
|
|
* @doc-return int is_paid 1已支付0未支付
|
|
* @doc-return int register_id 挂号id
|
|
* @doc-return array config 支付配置参数,在is_paid=0时返回
|
|
*/
|
|
public function actionPay()
|
|
{
|
|
$post=\Yii::$app->request->post();
|
|
$this->requestValidate($post,[
|
|
['register_id','required']
|
|
]);
|
|
$RegisterSubmitForm=new RegisterSubmitForm();
|
|
$RegisterSubmitForm->attributes=$post;
|
|
|
|
return $RegisterSubmitForm->getPayData($post['register_id']);
|
|
}
|
|
|
|
/**
|
|
* @doc-name 挂号退款
|
|
* @doc-param int register_id 挂号id
|
|
*/
|
|
public function actionRefund()
|
|
{
|
|
$post=\Yii::$app->request->post();
|
|
$this->requestValidate($post,[
|
|
['register_id','required']
|
|
]);
|
|
|
|
$RegisterRefundForm=new RegisterRefundForm();
|
|
$RegisterRefundForm->attributes=$post;
|
|
|
|
return $RegisterRefundForm->refund($post['register_id']);
|
|
}
|
|
|
|
/**
|
|
* @doc-name 挂号详情
|
|
* @doc-param int register_id 挂号id
|
|
* @doc-return string store 门店
|
|
* @doc-return string depart 科室
|
|
* @doc-return string doctor 医生
|
|
* @doc-return int order_number 预约序号
|
|
* @doc-return float price 挂号金额
|
|
* @doc-return string patient 就诊人
|
|
* @doc-return string idcard 身份证
|
|
* @doc-return string mobile 手机号
|
|
* @doc-return int is_pay 是否支付0否1是
|
|
* @doc-return int status 状态1待接诊2接诊中3已结束4已取消5待评价6已评价7已拒诊
|
|
* @doc-return int is_cancel 是否取消0否1是
|
|
* @doc-return int cancel_time 取消时间
|
|
* @doc-return string refuse_reason 拒诊原因
|
|
*/
|
|
public function actionRegisterDetail()
|
|
{
|
|
$post=\Yii::$app->request->post();
|
|
$this->requestValidate($post,[
|
|
['register_id','required']
|
|
]);
|
|
$Register = Register::find()->where([
|
|
'id'=>$post['register_id'],
|
|
'user_id' => \Yii::$app->user->id,
|
|
'is_delete' => 0,
|
|
])->one();
|
|
if (!$Register) throw new Exception('该挂号不存在');
|
|
|
|
$query = Register::find()->where([
|
|
'id'=>$post['register_id'],
|
|
'user_id' => \Yii::$app->user->id,
|
|
'is_delete' => 0,
|
|
])->with(['store','depart','doctor','patient']);
|
|
|
|
$this->field=[
|
|
Register::class=>[
|
|
'store'=>'store.name',
|
|
'depart'=>'doctor.depart.name',
|
|
'doctor'=>'doctor.name',
|
|
'order_number','price',
|
|
'patient'=>'patient.name',
|
|
'idcard'=>'patient.id_card',
|
|
'register_type'=>'type',
|
|
'mobile'=>'patient.mobile',
|
|
'status','is_pay','created_at','is_cancel',
|
|
'cancel_time'=>function($m){
|
|
return date('Y-m-d H:i:s',$m->cancel_time);
|
|
},
|
|
'refuse_reason'
|
|
]
|
|
];
|
|
return $this->create($query,$post);
|
|
}
|
|
|
|
/**
|
|
* @doc-name 取消挂号
|
|
* @doc-return string msg 信息
|
|
*/
|
|
public function actionCancel()
|
|
{
|
|
$post=\Yii::$app->request->post();
|
|
$this->requestValidate($post,[
|
|
['register_id','required']
|
|
]);
|
|
$RegisterForm=new RegisterForm();
|
|
$RegisterForm->attributes=$post;
|
|
|
|
return $RegisterForm->cancel();
|
|
}
|
|
|
|
/**
|
|
* @doc-name 挂号列表
|
|
* @doc-param int patient_id 患者id / optional
|
|
* @doc-return mixed @List{id-int-挂号id,user_id-int-用户id,order_no-string-订单号,service_user_id-int-医生id,store-string-门店,user_patient_id-int-患者id,depart-string-科室,doctor-string-医生,order_number-int-挂号序号,price-float-挂号金额,patient-string-患者,idcard-string-身份证,mobile-string-手机号,status-int-状态1待接诊2接诊中3已结束4已取消5待评价6已评价7已拒诊,is_pay-int-是否支付0否1是,created_at-string-挂号时间,is_cancel-int0是否取消0否1是} 挂号信息
|
|
* @doc-return mixed @Pagination{total-int-总数据,totalPage-int-总页数,pageSize-int-每页多少条} 分页信息
|
|
*/
|
|
public function actionList()
|
|
{
|
|
$post=\Yii::$app->request->post();
|
|
$Register = Register::find()->where([
|
|
'user_id' => \Yii::$app->user->id,
|
|
'is_delete' => 0,
|
|
'is_cancel'=>0,
|
|
])->all();
|
|
if (!$Register) throw new Exception('暂无挂号记录');
|
|
|
|
$query = Register::find()->where([
|
|
'user_id' => \Yii::$app->user->id,
|
|
'is_delete' => 0,
|
|
])->with(['store','depart','patient','doctor'])->orderBy(['id'=>SORT_DESC]);
|
|
|
|
if (!empty($post['patient_id'])) $query->andWhere(['user_patient_id'=>$post['patient_id']]);
|
|
|
|
|
|
$this->field=[
|
|
Register::class=>[
|
|
'id','user_id','order_no','service_user_id',
|
|
'store'=>'store.name',
|
|
'user_patient_id',
|
|
'depart'=>'depart.name',
|
|
'doctor'=>'doctor.name',
|
|
'order_number','price',
|
|
'patient'=>'patient.name',
|
|
'idcard'=>'patient.id_card',
|
|
'mobile'=>'patient.mobile',
|
|
'status','is_pay','created_at','is_cancel'
|
|
]
|
|
];
|
|
return $this->create($query,$post);
|
|
}
|
|
} |