IntegralRepository.php 999 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace app\common\repositories\store;
  3. use app\common\repositories\BaseRepository;
  4. use think\facade\Cache;
  5. class IntegralRepository extends BaseRepository
  6. {
  7. const CACHE_KEY = 'sys_int_next_day';
  8. public function getNextDay()
  9. {
  10. return strtotime(date('Y-m-d', strtotime('first day of +1 month 00:00:00')));
  11. }
  12. public function getInvalidDay()
  13. {
  14. $month = systemConfig('integral_clear_time');
  15. if ($month <= 0) return 0;
  16. return strtotime('last day of -' . $month . ' month 23:59:59', $this->getTimeoutDay() - 1);
  17. }
  18. public function getTimeoutDay($clear = false)
  19. {
  20. $driver = Cache::store('file');
  21. if (!$driver->has(self::CACHE_KEY) || $clear) {
  22. $driver->set(self::CACHE_KEY, $this->getNextDay(), (20 * 24 * 3600) + 3600 * 12);
  23. }
  24. return $driver->get(self::CACHE_KEY);
  25. }
  26. public function clearTimeoutDay()
  27. {
  28. Cache::store('file')->delete(self::CACHE_KEY);
  29. }
  30. }