cqp před 2 měsíci
rodič
revize
232d87a0e7
1 změnil soubory, kde provedl 7 přidání a 17 odebrání
  1. 7 17
      app/Service/StatisticService.php

+ 7 - 17
app/Service/StatisticService.php

@@ -521,24 +521,14 @@ class StatisticService extends Service
             }
         }
 
-        // 确定起始时间:默认当年 1 月 1 日
-        if (!isset($data['month_start'])) {
-            $month_start = date('Y-01-01 00:00:00');
-        } else {
-            $month_start = date('Y-m-01 00:00:00', strtotime($data['month_start']));
-        }
-
-        // 确定结束时间
-        if (!isset($data['month_end'])) {
-            $month_end = date('Y-12-31 23:59:59', strtotime($month_start));
-        } else {
+        if (!isset($data['month_start'])) $month_start = date('Y-01-01');
+        else $month_start = date('Y-m-01', strtotime($data['month_start']));
+        if (!isset($data['month_end'])) $month_end = date('Y-01-01', strtotime('+1 year', strtotime($month_start)));
+        else {
             $start_year = date('Y', strtotime($month_start));
             $end_year = date('Y', strtotime($data['month_end']));
-
             if ($start_year != $end_year) return [false, "查询不得跨年!", ""];
-
-            // 取传入月份的最后一天最后一秒
-            $month_end = date('Y-m-t 23:59:59', strtotime($data['month_end']));
+            $month_end = date('Y-m-01', strtotime($data['month_end'] . ' +1 month'));
         }
 
         return [true, strtotime($month_start), strtotime($month_end)];
@@ -591,7 +581,7 @@ class StatisticService extends Service
         $item_list = $item->where('del_time', 0)
             ->where(function ($query) use ($month_start, $month_end) {
                 $query->where('start_time', '>=', $month_start)
-                    ->where('end_time', '<=', $month_end);
+                    ->where('end_time', '<', $month_end);
             })->select("code", "title", "start_time", "end_time", "id", "state")->orderby("start_time", "asc")->get()->toArray();
         $item_key_list = [];
         foreach ($item_list as $v) {
@@ -939,7 +929,7 @@ class StatisticService extends Service
         $item_list = $item->where('del_time', 0)
             ->where(function ($query) use ($month_start, $month_end) {
                 $query->where('start_time', '>=', $month_start)
-                    ->where('end_time', '<=', $month_end);
+                    ->where('end_time', '<', $month_end);
             })->select("code", "title", "start_time", "end_time", "id", "state")->orderby("start_time", "asc")->get()->toArray();
         $item_key_list = [];
         foreach ($item_list as $v) {