初始化仓库
This commit is contained in:
83
service/models/forms/DoctorCompleteFour.php
Normal file
83
service/models/forms/DoctorCompleteFour.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
namespace service\models\forms;
|
||||
|
||||
use common\core\BaseModel;
|
||||
use common\enums\UserStatusEnum;
|
||||
use common\models\DoctorService;
|
||||
use common\models\ServiceUser;
|
||||
use yii\base\Exception;
|
||||
use GuzzleHttp\Client;
|
||||
use common\models\StoreDoctor;
|
||||
|
||||
//医生完善信息第四步
|
||||
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 ['已完善服务信息'];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user