diff --git a/app/Services/OrderServicePackageService.php b/app/Services/OrderServicePackageService.php index a30ccf2..2f3152a 100644 --- a/app/Services/OrderServicePackageService.php +++ b/app/Services/OrderServicePackageService.php @@ -1121,4 +1121,36 @@ class OrderServicePackageService extends BaseService return $month_inquiry_count; } + + /** + * 获取服务包当前月时间区间 + * @param string $start_time + * @return array + */ + public function getCurrentMonthDate(string $start_time): array + { + $current_month_start_date = 0; // 当前所属月开始时间 + $current_month_finish_date = 0; // 当前所属月结束时间 + + // 获取开启服务日期和今日的相差天数 + $diff = abs(time() - strtotime($start_time)); + $diff_days = ceil($diff / (60 * 60 * 24)); // 转换为天数 + + // 获取当前月次 + $month_time = ceil($diff_days / 30); + + $days = (int)$month_time * 30; + + // 当前所属月开始时间 + $current_month_finish_date = date('Y-m-d 23:59:59', strtotime($start_time . " +$days days")); + + // 当前所属月结束时间 + $current_month_start_date = date('Y-m-d 00:00:00', strtotime($current_month_finish_date . "-30 days")); + + $result = array(); + $result['current_month_start_date'] = $current_month_start_date; + $result['current_month_finish_date'] = $current_month_finish_date; + + return $result; + } } \ No newline at end of file diff --git a/app/Services/PatientOrderService.php b/app/Services/PatientOrderService.php index 217b0d4..8a53bd5 100644 --- a/app/Services/PatientOrderService.php +++ b/app/Services/PatientOrderService.php @@ -2893,6 +2893,11 @@ class PatientOrderService extends BaseService // 获取药品剩余数量 } + // 处理当月时间 + $current_month_date = $OrderServicePackageService->getCurrentMonthDate($order_service_package['start_time']); + $result['order_service_package']['current_month_start_date'] = $current_month_date['current_month_start_date']; + $result['order_service_package']['current_month_finish_date'] = $current_month_date['current_month_finish_date']; + return success($result); }