82 lines
2.4 KiB
PHP
82 lines
2.4 KiB
PHP
<?php
|
|
namespace service\models\forms;
|
|
|
|
use common\core\BaseModel;
|
|
use common\enums\UserStatusEnum;
|
|
use common\models\oldDb\DoctorService;
|
|
use common\models\oldDb\ServiceUser;
|
|
use yii\base\Exception;
|
|
|
|
//医生完善信息第四步
|
|
class DoctorCompleteFour extends BaseModel
|
|
{
|
|
public $register_status;
|
|
public $register_price;
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['register_status','register_price'],'default','value'=>0],
|
|
['register_price','match', 'pattern' => '/^\d+(\.\d{1,2})?$/i','message'=>'挂号价格最多两位小数']
|
|
];
|
|
}
|
|
public function attributeLabels()
|
|
{
|
|
return [
|
|
'register_status' => '是否开启挂号服务0否1是',
|
|
'register_price' => '挂号价格',
|
|
];
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
if(!$this->validate()){
|
|
throw new Exception($this->getErrorMsg());
|
|
}
|
|
|
|
$serviceUser = ServiceUser::find()->where([
|
|
'id' => \Yii::$app->user->identity->id,
|
|
'is_delete' => 0
|
|
])->with('docInfo','docIdentity','docPracticing')->one();
|
|
if(!$serviceUser){
|
|
throw new Exception('用户不存在');
|
|
}
|
|
if(!$serviceUser->docInfo || !$serviceUser->docIdentity || !$serviceUser->docPracticing){
|
|
throw new Exception('请先完善前几步信息');
|
|
}
|
|
$su_id=\Yii::$app->user->identity->id;
|
|
|
|
$t = \Yii::$app->db->beginTransaction();
|
|
try {
|
|
$model = DoctorService::find()->where([
|
|
'su_id' => \Yii::$app->user->identity->id,
|
|
])->one();
|
|
if(!$model){
|
|
$model = new DoctorService();
|
|
$model->su_id =$su_id;
|
|
}
|
|
$model->attributes = $this->attributes;
|
|
|
|
$model->saveOrFail();
|
|
|
|
//第四步完成后需要修改账户的激活状态未待审核 - 后台审核 - 已认证
|
|
//后台拒绝 - 前台修改资料 - 提交 - 重新待审核
|
|
|
|
$user = \Yii::$app->user->identity;
|
|
$user->status = UserStatusEnum::WAIT_SH;
|
|
$user->reason =null;
|
|
$user->saveOrFail();
|
|
|
|
|
|
$t->commit();
|
|
}catch (Exception $exception){
|
|
$t->rollBack();
|
|
file_put_contents('error.log',$exception->getMessage().PHP_EOL,FILE_APPEND);
|
|
throw $exception;
|
|
}
|
|
return ['已完善服务信息'];
|
|
}
|
|
|
|
|
|
}
|