diff --git a/app/Controller/InquiryController.php b/app/Controller/InquiryController.php index a7fb25c..2d21913 100644 --- a/app/Controller/InquiryController.php +++ b/app/Controller/InquiryController.php @@ -84,8 +84,16 @@ class InquiryController extends AbstractController return $this->response->json($data); } - - + /** + * 获取问诊最低价格 + * @return ResponseInterface + */ + public function getInquiryLowestPrice(): ResponseInterface + { + $InquiryService = new InquiryService(); + $data = $InquiryService->getInquiryLowestPrice(); + return $this->response->json($data); + } diff --git a/app/Controller/PatientOrderController.php b/app/Controller/PatientOrderController.php index b717481..ca880f4 100644 --- a/app/Controller/PatientOrderController.php +++ b/app/Controller/PatientOrderController.php @@ -141,4 +141,20 @@ class PatientOrderController extends AbstractController $data = $PatientOrderService->getPatientOrderPayInfo(); return $this->response->json($data); } + + /** + * 创建药品订单 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function addPatientProductOrder(): ResponseInterface + { + $request = $this->container->get(PatientOrderRequest::class); + $request->scene('addPatientProductOrder')->validateResolved(); + + $PatientOrderService = new PatientOrderService(); + $data = $PatientOrderService->addPatientProductOrder(); + return $this->response->json($data); + } } \ No newline at end of file diff --git a/app/Controller/SystemController.php b/app/Controller/SystemController.php index 75e3efc..adad20d 100644 --- a/app/Controller/SystemController.php +++ b/app/Controller/SystemController.php @@ -20,13 +20,13 @@ class SystemController extends AbstractController * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function getSystemInquiryConfig(): ResponseInterface + public function getSystemInquiryTime(): ResponseInterface { $request = $this->container->get(SystemRequest::class); - $request->scene('getSystemInquiryConfig')->validateResolved(); + $request->scene('getSystemInquiryTime')->validateResolved(); $SystemService = new SystemService(); - $data = $SystemService->getSystemInquiryConfig(); + $data = $SystemService->getSystemInquiryTime(); return $this->response->json($data); } } \ No newline at end of file diff --git a/app/Model/DoctorInquiryConfig.php b/app/Model/DoctorInquiryConfig.php index 0c0538d..62f6df4 100644 --- a/app/Model/DoctorInquiryConfig.php +++ b/app/Model/DoctorInquiryConfig.php @@ -94,4 +94,14 @@ class DoctorInquiryConfig extends Model { return self::where($params)->update($data); } + + /** + * 获取问诊价格最低的字段 + * @param array $params + * @return mixed|string|null + */ + public static function getMinInquiryPriceMinOne(array $params = []): mixed + { + return self::where($params)->min('inquiry_price'); + } } diff --git a/app/Request/PatientOrderRequest.php b/app/Request/PatientOrderRequest.php index 7f128f6..1a36847 100644 --- a/app/Request/PatientOrderRequest.php +++ b/app/Request/PatientOrderRequest.php @@ -22,6 +22,8 @@ class PatientOrderRequest extends FormRequest "order_type", // 订单类型(1:问诊订单 2:药品订单) "order_no"// 订单编号 ], + 'addPatientProductOrder' => [ // 创建药品订单 + ], ]; /** diff --git a/app/Request/SystemRequest.php b/app/Request/SystemRequest.php index 0cc52e0..e9a6165 100644 --- a/app/Request/SystemRequest.php +++ b/app/Request/SystemRequest.php @@ -10,7 +10,7 @@ use Hyperf\Validation\Request\FormRequest; class SystemRequest extends FormRequest { protected array $scenes = [ - 'getSystemInquiryConfig' => [ // 获取系统问诊配置 快速问诊-问诊购药 + 'getSystemInquiryTime' => [ // 获取系统问诊配置 快速问诊-问诊购药 'inquiry_type', // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药) 'inquiry_mode', // 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员) ], diff --git a/app/Services/InquiryService.php b/app/Services/InquiryService.php index 002f957..753df1b 100644 --- a/app/Services/InquiryService.php +++ b/app/Services/InquiryService.php @@ -7,6 +7,7 @@ use App\Constants\DoctorTitleCode; use App\Constants\HttpEnumCode; use App\Exception\BusinessException; use App\Model\DiseaseClass; +use App\Model\DoctorInquiryConfig; use App\Model\Hospital; use App\Model\InquiryCaseProduct; use App\Model\OrderEvaluation; @@ -18,6 +19,7 @@ use App\Model\PatientFamily; use App\Model\PatientFamilyHealth; use App\Model\PatientFamilyPersonal; use App\Model\Product; +use App\Model\SystemInquiryConfig; use App\Model\UserCoupon; use App\Model\UserDoctor; use App\Model\UserPatient; @@ -482,6 +484,73 @@ class InquiryService extends BaseService return success(); } + public function getInquiryLowestPrice(){ + $user_info = $this->request->getAttribute("userInfo") ?? []; + $doctor_id = $this->request->input('doctor_id'); + + // 快速 + $quick_inquiry_price = 0; + $params = array(); + $params['inquiry_type'] = 2; + $params['inquiry_mode'] = 1; + $system_inquiry_config = SystemInquiryConfig::getOne($params); + if (!empty($system_inquiry_config)){ + $quick_inquiry_price = $system_inquiry_config['inquiry_price']; + } + + // 问诊购药 + $medicine_inquiry_price = 0; + $params = array(); + $params['inquiry_type'] = 4; + $params['inquiry_mode'] = 1; + $system_inquiry_config = SystemInquiryConfig::getOne($params); + if (!empty($system_inquiry_config)){ + $medicine_inquiry_price = $system_inquiry_config['inquiry_price']; + } + + // 专家问诊 + $expert_inquiry_price = 0; + $params = array(); + $params['inquiry_type'] = 1; + $params['inquiry_mode'] = 1; + $expert_inquiry_price = DoctorInquiryConfig::getMinInquiryPriceMinOne($params); + if (empty($expert_inquiry_price) || $expert_inquiry_price == 0){ + $params = array(); + $params['inquiry_type'] = 1; + $params['inquiry_mode'] = 1; + $system_inquiry_config = SystemInquiryConfig::getOne($params); + if (!empty($system_inquiry_config)){ + $expert_inquiry_price = $system_inquiry_config['min_inquiry_price']; + } + } + + // 公益问诊 + $welfare_inquiry_price = 0; + $params = array(); + $params['inquiry_type'] = 1; + $params['inquiry_mode'] = 1; + $welfare_inquiry_price = DoctorInquiryConfig::getMinInquiryPriceMinOne($params); + + if (empty($welfare_inquiry_price) || $welfare_inquiry_price == 0){ + $params = array(); + $params['inquiry_type'] = 1; + $params['inquiry_mode'] = 1; + $system_inquiry_config = SystemInquiryConfig::getOne($params); + if (!empty($system_inquiry_config)){ + $inquiry_price = explode(',',$system_inquiry_config['inquiry_price']); + $welfare_inquiry_price = $inquiry_price[0] ?? 0; + } + } + + $result = array(); + $result['quick_inquiry_price'] = $quick_inquiry_price; + $result['medicine_inquiry_price'] = $medicine_inquiry_price; + $result['expert_inquiry_price'] = $expert_inquiry_price; + $result['welfare_inquiry_price'] = $welfare_inquiry_price; + + return success($result); + } + /** * 获取医生未接诊订单数量 * @param string $doctor_id 医生id diff --git a/app/Services/PatientOrderService.php b/app/Services/PatientOrderService.php index 7194e86..40bb003 100644 --- a/app/Services/PatientOrderService.php +++ b/app/Services/PatientOrderService.php @@ -701,4 +701,8 @@ class PatientOrderService extends BaseService return success($result); } + + public function addPatientProductOrder(){ + return success(); + } } \ No newline at end of file diff --git a/app/Services/SystemService.php b/app/Services/SystemService.php index 247937e..d6ca63c 100644 --- a/app/Services/SystemService.php +++ b/app/Services/SystemService.php @@ -15,7 +15,7 @@ class SystemService extends BaseService * 快速问诊-问诊购药 * @return array */ - public function getSystemInquiryConfig(): array + public function getSystemInquiryTime(): array { $user_info = $this->request->getAttribute("userInfo") ?? []; diff --git a/config/routes.php b/config/routes.php index 280bfb1..3fdcbe7 100644 --- a/config/routes.php +++ b/config/routes.php @@ -204,6 +204,9 @@ Router::addGroup('/patient', function () { // 新增问诊评价 Router::post('/evaluation', [InquiryController::class, 'addInquiryEvaluation']); + + // 获取问诊最低价格 + Router::get('/lowest-price', [InquiryController::class, 'getInquiryLowestPrice']); }); // 医生数据 @@ -306,7 +309,7 @@ Router::addGroup('/patient', function () { Router::delete('/{order_product_id:\d+}', [PatientOrderController::class, 'deletePatientProductOrder']); // 创建药品订单-未开发 - Router::post('', [PatientOrderController::class, 'imCallBack']); + Router::post('', [PatientOrderController::class, 'addPatientProductOrder']); }); // 处方订单 @@ -422,8 +425,8 @@ Router::get('/evaluation', [UserDoctorController::class, 'getDoctorEvaluationLis Router::addGroup('/system', function () { // 问诊 Router::addGroup('/inquiry', function () { - // 获取系统问诊配置 快速问诊-问诊购药 - Router::get('/config', [SystemController::class, 'getSystemInquiryConfig']); + // 获取系统问诊时间 快速问诊-问诊购药 + Router::get('/time', [SystemController::class, 'getSystemInquiryTime']); }); });