Sfoglia il codice sorgente

fix(finance): 修复上周时间范围计算逻辑

- 添加上周一日期计算逻辑
- 使用正确的日期变量替换硬编码的开始结束日期
- 确保上周时间范围查询使用动态计算的日期值
shichen 4 mesi fa
parent
commit
53ade622f4
1 ha cambiato i file con 5 aggiunte e 1 eliminazioni
  1. 5 1
      app/common/repositories/finance/FinanceRepository.php

+ 5 - 1
app/common/repositories/finance/FinanceRepository.php

@@ -496,8 +496,12 @@ class FinanceRepository extends BaseRepository
496 496
         $nextMonday = new \DateTime();
497 497
         $nextMonday->setISODate($year, $week + 1, 1);
498 498
 
499
+        // 上周一:周数减1
500
+        $lastMonday = new \DateTime();
501
+        $lastMonday->setISODate($year, $week - 1, 1);
502
+
499 503
         //上周时间条件
500
-        $sWeekWhere .= " and DATE(create_time) >= '" . $startDate . "' and DATE(create_time) <= '" . $endDate . "'";
504
+        $sWeekWhere .= " and DATE(create_time) >= '" . $lastMonday->format('Y-m-d') . "' and DATE(create_time) <= '" . $thisMonday->format('Y-m-d') . "'";
501 505
         //周时间条件
502 506
         $weekWhere .= " and DATE(create_time) >= '" . $thisMonday->format('Y-m-d') . "' and DATE(create_time) <= '" . $nextMonday->format('Y-m-d') . "'";
503 507
         //今日时间条件