Files
xk-api-yii/member/models/forms/PayForm.php

56 lines
1.3 KiB
PHP

<?php
namespace member\models\forms;
use common\core\BaseModel;
use common\models\oldDb\UserPatientRecord;
use yii\db\Exception;
//缴费
class PayForm extends BaseModel
{
public $up_id;
public $height;
public $weight;
public $region;
public $address;
public function rules()
{
return [
[['up_id', 'height', 'weight'], 'required'],
[['up_id'], 'integer'],
[['height', 'weight'], 'number'],
[['region', 'address'], 'string', 'max' => 255],
];
}
public function GoPutRecord()
{
if (!$this->validate()){
throw new Exception($this->getErrorMsg());
}
$is_record=UserPatientRecord::find()->where(['up_id'=>$this->up_id])->one();
if ($is_record){
throw new Exception('您已建过档');
}
$UserPatientRecord=new UserPatientRecord();
$UserPatientRecord->attributes=$this->attributes;
$UserPatientRecord->saveOrFail();
return ['建档成功,病案号为'.$UserPatientRecord->id];
}
public function attributeLabels()
{
return [
'up_id'=>'就诊人id',
'height' => 'Height',
'weight' => 'Weight',
'region' => 'Region',
'address' => 'Address',
];
}
}