Parcourir la source

控制台修复 order_counting_records_cache_clear

ANG YU il y a 4 ans
Parent
commit
6b40fe6db7

+ 12 - 0
app/Http/Controllers/TestController.php

@@ -1510,4 +1510,16 @@ TEXT;
         $logistic_number = $request->logistic_number;
         \App\Jobs\LogisticZopSync::dispatchNow($logistic_number);
     }
+
+    public function order_counting_records_cache_clear()
+    {
+        $owner_ids = Owner::query()->select('id')->pluck('id');
+        $dayClears = now()->subYear()->daysUntil(now());
+        foreach ($dayClears as $day) {
+            foreach ($owner_ids as $owner_id) {
+                $key = "order_counting_records_{$day->toDateString()}_{$owner_id}_日";
+                Cache::forget($key);
+            }
+        }
+    }
 }

+ 2 - 0
app/Services/NewOrderCountingRecordService.php

@@ -475,8 +475,10 @@ class NewOrderCountingRecordService
     private function getTtl($dateStr, $unit)
     {
         if ($this->isNotCurrentDate($dateStr, $unit)) {
+            LogService::log('NewOrderCountingRecordService', '缓存设置为永久', $dateStr);
             $ttl = config('cache.expirations.forever');//非当前日期的缓存为永久
         } else {
+            LogService::log('NewOrderCountingRecordService', '缓存设置为临时', $dateStr);
             $ttl = config('cache.expirations.orderCountingRecord');//当前日期缓存为1800s
         }
         return $ttl;