AutoSmsCode.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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\message\sms\SmsRecordServices;
  13. use crmeb\utils\Cron;
  14. use crmeb\interfaces\ListenerInterface;
  15. use think\facade\Log;
  16. /**
  17. * 定时更新短信状态
  18. * Class AutoSmsCode
  19. * @package app\listener\system
  20. */
  21. class AutoSmsCode extends Cron implements ListenerInterface
  22. {
  23. /**
  24. * @param $event
  25. */
  26. public function handle($event): void
  27. {
  28. //更新短信状态
  29. $this->tick(1000 * 30, function () {
  30. try {
  31. //修改短信发送记录短信状态
  32. /** @var SmsRecordServices $smsRecord */
  33. $smsRecord = app()->make(SmsRecordServices::class);
  34. return $smsRecord->modifyResultCode();
  35. } catch (\Throwable $e) {
  36. Log::error('自动更新短信状态:[' . class_basename($this) . ']' . $e->getMessage());
  37. }
  38. });
  39. }
  40. }