validate()) { throw new Exception($this->getErrorMsg()); } $today = strtotime(date('Y-m-d', time())); $end = $today + 60 * 60 * 24; $UserPatientCase = UserPatientCase::find()->where([ 'user_patient_id' => $this->user_patient_id, 'register_id' => $this->register_id, 'store_id' => \Yii::$app->store, 'service_user_id' => \Yii::$app->user->id, 'is_delete' => 0 ])->andWhere(['between', 'created_at', $today, $end])->one(); try { if (!$UserPatientCase) { $UserPatientCase = new UserPatientCase(); } $UserPatientCase->store_id = \Yii::$app->store; $UserPatientCase->service_user_id = \Yii::$app->user->id; $UserPatientCase->created_at =time(); $UserPatientCase->updated_at =time(); $UserPatientCase->attributes = $this->attributes; $UserPatientCase->saveOrFail(); } catch (\Exception $e) { throw new Exception($e->getMessage()); } } public function update() { } public function info() { if (!$this->validate()) { throw new Exception($this->getErrorMsg()); } $UserPatientCase = UserPatientCase::find()->where([ 'register_id' => $this->register_id, 'user_patient_id' => $this->user_patient_id, 'is_delete' => 0, 'service_user_id' => \Yii::$app->user->id, 'store_id' => \Yii::$app->store, ])->with(['userPatient'])->asArray()->all(); if (!$UserPatientCase) throw new Exception('病历不存在'); return $UserPatientCase; } }