From 9c2150c785e5c53d2883d3d02f5f3cc664bb5658 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Wed, 3 Apr 2024 17:11:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=90=AF=E6=9C=8D=E5=8A=A1=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=A4=84=E7=90=86=E5=8C=BB=E7=94=9F=E5=81=A5=E5=BA=B7?= =?UTF-8?q?=E5=8C=85=E3=80=82=E8=8E=B7=E5=8F=96=E5=8C=BB=E7=94=9F=E9=97=AE?= =?UTF-8?q?=E8=AF=8A=E9=85=8D=E7=BD=AE-=E5=81=A5=E5=BA=B7=E5=8C=85?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DoctorInquiryConfigController.php | 13 ++- app/Model/ConfigHealthPackage.php | 80 +++++++++++++ app/Services/DoctorInquiryService.php | 108 ++++++++++++++++-- config/routes.php | 6 + 4 files changed, 195 insertions(+), 12 deletions(-) create mode 100644 app/Model/ConfigHealthPackage.php diff --git a/app/Controller/DoctorInquiryConfigController.php b/app/Controller/DoctorInquiryConfigController.php index 41ba786..4df29af 100644 --- a/app/Controller/DoctorInquiryConfigController.php +++ b/app/Controller/DoctorInquiryConfigController.php @@ -127,8 +127,6 @@ class DoctorInquiryConfigController extends AbstractController /** * 获取医生问诊配置-随访包 * @return ResponseInterface - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface */ public function getDoctorInquiryFollowConfig(): ResponseInterface { @@ -180,4 +178,15 @@ class DoctorInquiryConfigController extends AbstractController return $this->response->json($data); } + /** + * 获取医生问诊配置-健康包 + * @return ResponseInterface + */ + public function getDoctorInquiryHealthConfig(): ResponseInterface + { + $DoctorInquiryService = new DoctorInquiryService(); + $data = $DoctorInquiryService->getDoctorInquiryHealthConfig(); + return $this->response->json($data); + } + } \ No newline at end of file diff --git a/app/Model/ConfigHealthPackage.php b/app/Model/ConfigHealthPackage.php new file mode 100644 index 0000000..84adc24 --- /dev/null +++ b/app/Model/ConfigHealthPackage.php @@ -0,0 +1,80 @@ +first($fields); + } + + /** + * 多条 + * @param array $params + * @param array $fields + * @return Collection|array + */ + public static function getList(array $params, array $fields = ['*']): Collection|array + { + return self::where($params)->get($fields); + } + + /** + * 新增 + * @param array $data + * @return ConfigHealthPackage|\Hyperf\Database\Model\Model + */ + public static function addConfigHealthPackage(array $data): \Hyperf\Database\Model\Model|ConfigHealthPackage + { + return self::create($data); + } + + /** + * 修改 + * @param array $params + * @param array $data + * @return int + */ + public static function edit(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } +} diff --git a/app/Services/DoctorInquiryService.php b/app/Services/DoctorInquiryService.php index d1887e2..ea00efc 100644 --- a/app/Services/DoctorInquiryService.php +++ b/app/Services/DoctorInquiryService.php @@ -4,6 +4,7 @@ namespace App\Services; use App\Constants\HttpEnumCode; use App\Exception\BusinessException; +use App\Model\ConfigHealthPackage; use App\Model\DoctorConfigDifficultConsultation; use App\Model\DoctorConfigFollowPackage; use App\Model\DoctorConfigFollowPackageItem; @@ -316,16 +317,6 @@ class DoctorInquiryService extends BaseService } } - // 健康包 - if ($inquiry_type == 1 && $inquiry_mode == 8) { - $params = array(); - $params['doctor_id'] = $user_info['client_user_id']; - $doctor_config_health_package = DoctorConfigHealthPackage::getOne($params); - if (empty($doctor_config_health_package)){ - return fail(HttpEnumCode::HTTP_ERROR, "请设置服务价格后开启"); - } - } - Db::beginTransaction(); try { @@ -336,6 +327,13 @@ class DoctorInquiryService extends BaseService $params['inquiry_mode'] = $inquiry_mode; $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); if (empty($doctor_inquiry_config)) { + if ($inquiry_type == 1 || $inquiry_type == 3){ + if ($inquiry_mode != 8 && $inquiry_mode != 9){ + Db::rollBack(); + return fail(HttpEnumCode::SERVER_ERROR); + } + } + // 此处两个参数都默认设置为0,随访包以及健康包使用不到 $work_num_day = 0; // 每日接诊数量 $inquiry_price = null; // 接诊价格(专家问诊-公益问诊) @@ -371,6 +369,39 @@ class DoctorInquiryService extends BaseService Db::rollBack(); return fail(HttpEnumCode::SERVER_ERROR); } + + // 处理医生健康包 + if ($inquiry_type == 1 || $inquiry_mode == 8){ + // 获取健康包配置 + $params = array(); + $config_health_package = ConfigHealthPackage::getOne($params); + if (empty($config_health_package)){ + Db::rollBack(); + return fail(HttpEnumCode::SERVER_ERROR); + } + + // 获取专家图文问诊价格 + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + $params['inquiry_type'] = 1; + $params['inquiry_mode'] = 1; + $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); + if (empty($doctor_inquiry_config)){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, "本服务需设置图文问诊的价格,才可开启"); + } + + // 创建医生健康包 + $data = array(); + $data['doctor_id'] = $user_info['client_user_id']; + $data['config_health_package_id'] = $config_health_package['config_health_package_id']; + $data['service_price'] = $doctor_inquiry_config['inquiry_price'] * $config_health_package['service_rate'] / 100 * 6; + $doctor_config_health_package = DoctorConfigHealthPackage::addDoctorConfigHealthPackage($data); + if (empty($doctor_config_health_package)){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, "开启失败"); + } + } } else { // 已存在问诊配置,进行修改 $params = array(); @@ -1057,4 +1088,61 @@ class DoctorInquiryService extends BaseService return success(); } + + /** + * 获取医生问诊配置-健康包 + * @return array + */ + public function getDoctorInquiryHealthConfig(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + // 获取医生信息 + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + $doctor = UserDoctor::getOne($params); + if (empty($doctor)) { + return fail(HttpEnumCode::HTTP_ERROR, "未知医生"); + } + + if ($doctor['idcard_status'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先进行实名认证"); + } + + if ($doctor['iden_auth_status'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先进行身份认证"); + } + + if ($doctor['is_bind_bank'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "请先进行绑定结算银行卡"); + } + + if ($doctor['multi_point_status'] != 1) { + return fail(HttpEnumCode::HTTP_ERROR, "本服务需开处方,您还未做多点执业认证,是否前往?"); + } + + // 获取专家图文问诊价格 + $params = array(); + $params['doctor_id'] = $user_info['client_user_id']; + $params['inquiry_type'] = 1; + $params['inquiry_mode'] = 1; + $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); + if (empty($doctor_inquiry_config)){ + return fail(HttpEnumCode::HTTP_ERROR, "本服务需设置图文问诊的价格,才可开通"); + } + + // 获取健康包配置 + $params = array(); + $config_health_package = ConfigHealthPackage::getOne($params); + if (empty($config_health_package)){ + return fail(HttpEnumCode::SERVER_ERROR); + } + + $result = array(); + $result['service_count'] = $config_health_package['service_count']; // 总服务次数 + $result['service_rate'] = $config_health_package['service_rate']; // 服务费率。100为满值,表示1,正常费率。 + $result['inquiry_price'] = $doctor_inquiry_config['inquiry_price']; // 专家问诊-图文接诊价格 + + return success($result); + } } \ No newline at end of file diff --git a/config/routes.php b/config/routes.php index 1cc3246..6d004e0 100644 --- a/config/routes.php +++ b/config/routes.php @@ -141,6 +141,12 @@ Router::addGroup('/doctor', function () { // 修改医生问诊配置-随访包 Router::put('', [DoctorInquiryConfigController::class, 'putDoctorInquiryFollowConfig']); }); + + // 健康包 + Router::addGroup('/health', function () { + // 获取医生问诊配置-健康包 + Router::get('', [DoctorInquiryConfigController::class, 'getDoctorInquiryHealthConfig']); + }); }); // 获取医生问诊消息列表