From 329ab42f05ce9ffce1cdeed955fd6eecd0f1f31f Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Sun, 4 Feb 2024 16:33:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BB=E7=94=9F=E7=AE=80=E4=BB=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/DoctorIntroductionRecord.php | 31 ++++++++++++++++++++++++-- app/Services/DoctorAuthService.php | 17 +++++++++----- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/app/Model/DoctorIntroductionRecord.php b/app/Model/DoctorIntroductionRecord.php index 3f40c50..3889ef1 100644 --- a/app/Model/DoctorIntroductionRecord.php +++ b/app/Model/DoctorIntroductionRecord.php @@ -11,7 +11,7 @@ use Hyperf\Snowflake\Concern\Snowflake; /** * @property int $record_id 主键id * @property int $doctor_id 医生id - * @property int $is_verified 是否已审核(0:否 1:是) + * @property int $introduction_status 个人简介审核状态(0:未审核 1:审核通过 2:审核中 3:审核失败) * @property string $avatar 头像 * @property string $be_good_at 擅长 * @property string $brief_introduction 医生简介 @@ -31,7 +31,7 @@ class DoctorIntroductionRecord extends Model /** * The attributes that are mass assignable. */ - protected array $fillable = ['record_id', 'doctor_id', 'is_verified', 'avatar', 'be_good_at', 'brief_introduction', 'expertise_ids', 'created_at', 'updated_at']; + protected array $fillable = ['record_id', 'doctor_id', 'introduction_status', 'avatar', 'be_good_at', 'brief_introduction', 'expertise_ids', 'created_at', 'updated_at']; protected string $primaryKey = "record_id"; @@ -66,4 +66,31 @@ class DoctorIntroductionRecord extends Model { return self::create($data); } + + /** + * 获取信息-单条 + * @param array $params + * @param array $fields + * @return object|null + */ + public static function getLastOne(array $params, array $fields = ['*']): object|null + { + return self::where($params)->latest()->first($fields); + } + + /** + * 获取某种状态的最后一条数据 + * @param array $params + * @param array $introduction_status + * @param array $fields + * @return object|null + */ + public static function getStatusLastOne(array $params, array $introduction_status,array $fields = ["*"]): object|null + { + return self::where($params) + ->whereIn("introduction_status", $introduction_status) + ->latest() + ->first($fields); + } + } diff --git a/app/Services/DoctorAuthService.php b/app/Services/DoctorAuthService.php index a9acd2a..1fb0905 100644 --- a/app/Services/DoctorAuthService.php +++ b/app/Services/DoctorAuthService.php @@ -917,16 +917,21 @@ class DoctorAuthService extends BaseService $UserDoctorService = new UserDoctorService(); $result['doctor_expertise'] = $UserDoctorService->getDoctorSelectedExpertise($doctor['doctor_id']); - if ($doctor['introduction_status'] == 2 || $doctor['introduction_status'] == 3){ + if ($doctor['introduction_status'] == 2){ // 获取修改数据 $params = array(); $params['doctor_id'] = $doctor['doctor_id']; - $params['is_verified'] = 0; - $doctor_introduction_record = DoctorIntroductionRecord::getOne($params); - if (empty($doctor_introduction_record)){ - return fail(); - } + $params['introduction_status'] = 2; + $doctor_introduction_record = DoctorIntroductionRecord::getLastOne($params); + } elseif ($doctor['introduction_status'] == 3){ + // 获取修改数据 + $params = array(); + $params['doctor_id'] = $doctor['doctor_id']; + $params['introduction_status'] = 3; + $doctor_introduction_record = DoctorIntroductionRecord::getLastOne($params); + } + if (!empty($doctor_introduction_record)){ if (!empty($doctor_introduction_record['avatar'])){ $result['avatar'] = PcreMatch::pregRemoveOssWebsite($doctor_introduction_record['avatar']); }