diff --git a/app/Model/OrderDetection.php b/app/Model/OrderDetection.php index b2da6ba..cae0655 100644 --- a/app/Model/OrderDetection.php +++ b/app/Model/OrderDetection.php @@ -155,4 +155,14 @@ class OrderDetection extends Model return $data; } + + /** + * 获取数量 + * @param array $params + * @return int + */ + public static function getCount(array $params): int + { + return self::where($params)->count(); + } } diff --git a/app/Services/DetectionService.php b/app/Services/DetectionService.php index 4ca2a58..60db330 100644 --- a/app/Services/DetectionService.php +++ b/app/Services/DetectionService.php @@ -953,4 +953,18 @@ class DetectionService extends BaseService $params['order_detection_id'] = $order_detection['order_detection_id']; OrderDetection::editOrderDetection($params, $data); } + + /** + * 获取患者某一状态下的检测订单数量 + * @param string $patient_id 患者id + * @param int $detection_status 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消) + * @return int + */ + public function getPatientDetectionWithStatus(string $patient_id,int $detection_status): int + { + $params = array(); + $params['patient_id'] = $patient_id; + $params['detection_status'] = $detection_status; + return OrderDetection::getCount($params); + } } \ No newline at end of file diff --git a/app/Services/UserPatientService.php b/app/Services/UserPatientService.php index 6e2de0a..1df621b 100644 --- a/app/Services/UserPatientService.php +++ b/app/Services/UserPatientService.php @@ -59,6 +59,10 @@ class UserPatientService extends BaseService $OrderProductService = new OrderProductService(); $order_product_count = $OrderProductService->getPatientProductWithStatus($user_patient['patient_id'],1); + // 获取检测数量-待支付 + $detectionService = new DetectionService(); + $order_detection_count = $detectionService->getPatientDetectionWithStatus($user_patient['patient_id'],1); + // 处理头像 $user_patient['avatar'] = addAliyunOssWebsite($user_patient['avatar']); @@ -70,6 +74,7 @@ class UserPatientService extends BaseService $result['order_inquiry_count'] = $order_inquiry_count; $result['order_prescription_count'] = $order_prescription_count; $result['order_product_count'] = $order_product_count; + $result['order_detection_count'] = $order_detection_count; return success($result); }