AutoClearPoster.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\listener\system;
  12. use app\services\system\attachment\SystemAttachmentServices;
  13. use crmeb\utils\Cron;
  14. use crmeb\interfaces\ListenerInterface;
  15. use think\facade\Log;
  16. /**
  17. * 定时清除海报
  18. * Class AutoClearPoster
  19. * @package app\listener\user
  20. */
  21. class AutoClearPoster extends Cron implements ListenerInterface
  22. {
  23. /**
  24. * @param $event
  25. */
  26. public function handle($event): void
  27. {
  28. //定时清除海报
  29. $this->tick(1000 * 60 * 60 * 30, function () {
  30. try {
  31. /** @var SystemAttachmentServices $attach */
  32. $attach = app()->make(SystemAttachmentServices::class);
  33. return $attach->emptyYesterdayAttachment();
  34. } catch (\Throwable $e) {
  35. Log::error('清除昨日海报,失败原因:[' . class_basename($this) . ']' . $e->getMessage());
  36. }
  37. });
  38. }
  39. }