From bd5c1a1cd3bc582c17aa75b5380c2eafa31b56dd Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Tue, 16 Apr 2024 14:56:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=81=E8=A3=85=E8=8E=B7=E5=8F=96=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=8C=85=E5=BD=93=E5=89=8D=E6=9C=88=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=8C=BA=E9=97=B4=E6=96=B9=E6=B3=95=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=82=A3=E8=80=85=E6=9C=8D=E5=8A=A1=E5=8C=85?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=9C=8D=E5=8A=A1=E6=9D=83=E7=9B=8A=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E8=BF=94=E5=9B=9E=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/OrderServicePackageService.php | 32 +++++++++++++++++++++ app/Services/PatientOrderService.php | 5 ++++ 2 files changed, 37 insertions(+) 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); }