102 lines
2.9 KiB
PHP
102 lines
2.9 KiB
PHP
<?php
|
|
namespace service\models\forms;
|
|
|
|
use common\core\BaseModel;
|
|
use common\enums\UserStatusEnum;
|
|
use common\models\DoctorInfo;
|
|
use common\models\LeadInfo;
|
|
use common\models\PharmacistrInfo;
|
|
use common\models\ServInfo;
|
|
use common\validators\MobileValidator;
|
|
use GuzzleHttp\Client;
|
|
use yii\base\Exception;
|
|
|
|
//客服完善信息第一步
|
|
class ServiceCompleteOne extends BaseModel
|
|
{
|
|
public $name;
|
|
public $avatar;
|
|
public $mobile;
|
|
public $idcard;
|
|
public $hospital_id;
|
|
public $yard_id;
|
|
public $depart_id;
|
|
public $card_up;
|
|
public $card_down;
|
|
public $id_card;
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['name','avatar','mobile','idcard','hospital_id','yard_id','depart_id','card_up','card_down'],'required'],
|
|
['mobile',MobileValidator::class],
|
|
['id_card', 'match', 'pattern' => '/^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/i'],
|
|
['id_card', 'checkCard'],
|
|
];
|
|
}
|
|
|
|
public function checkCard($attribute, $params)
|
|
{
|
|
$response = (new Client(['http_errors' => false]))->post("https://eid.shumaidata.com/eid/check", [
|
|
'headers' => ['Authorization' =>"APPCODE f98bba3251714c759f5bd29d00e1c46e"],
|
|
'query' => [
|
|
'idcard' => $this->idcard,
|
|
'name' => $this->name
|
|
],
|
|
]);
|
|
$result = json_decode($response->getBody(),true);
|
|
if(!($result['code']==0 && $result['result']['res']==1)){
|
|
$this->addError($attribute, '身份证名字不匹配');
|
|
}
|
|
}
|
|
|
|
public function attributeLabels()
|
|
{
|
|
return [
|
|
'name' => '姓名',
|
|
'avatar' => '头像',
|
|
'mobile' => '手机号',
|
|
'idcard' => '身份证号',
|
|
'hospital_id' => '医院id',
|
|
'yard_id' => '院区',
|
|
'depart_id' => '科室',
|
|
'title_id' => '职称',
|
|
'card_up' => '身份证正面',
|
|
'card_down' => '身份证反面'
|
|
];
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
if(!$this->validate()){
|
|
throw new Exception($this->getErrorMsg());
|
|
}
|
|
|
|
$t = \Yii::$app->db->beginTransaction();
|
|
try {
|
|
$model = ServInfo::find()->where([
|
|
'su_id' => \Yii::$app->user->identity->id,
|
|
])->one();
|
|
if(!$model){
|
|
$model = new ServInfo();
|
|
$model->su_id = \Yii::$app->user->identity->id;
|
|
}
|
|
$model->attributes = $this->attributes;
|
|
$model->saveOrFail();
|
|
|
|
//修改状态
|
|
$user = \Yii::$app->user->identity;
|
|
$user->status = UserStatusEnum::WAIT_SH;
|
|
$user->saveOrFail();
|
|
|
|
$t->commit();
|
|
}catch (Exception $exception){
|
|
$t->rollBack();
|
|
throw $exception;
|
|
}
|
|
|
|
return [];
|
|
}
|
|
|
|
|
|
} |