SyncBroadcastStatusListen.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 crmeb\listens;
  12. use app\common\repositories\store\broadcast\BroadcastGoodsRepository;
  13. use app\common\repositories\store\broadcast\BroadcastRoomRepository;
  14. use crmeb\interfaces\ListenerInterface;
  15. use crmeb\services\TimerService;
  16. use Swoole\Timer;
  17. use think\facade\Log;
  18. class SyncBroadcastStatusListen extends TimerService implements ListenerInterface
  19. {
  20. public function handle($event): void
  21. {
  22. $this->tick(1000 * 60 * 5, function () {
  23. $broadcastGoodsRepository = app()->make(BroadcastGoodsRepository::class);
  24. try {
  25. $broadcastGoodsRepository->syncGoodStatus();
  26. } catch (\Exception $e) {
  27. Log::error('同步直播商品:' . $e->getMessage());
  28. }
  29. });
  30. $this->tick(1000 * 60 * 5, function () {
  31. $broadcastRoomRepository = app()->make(BroadcastRoomRepository::class);
  32. try {
  33. $broadcastRoomRepository->syncRoomStatus();
  34. } catch (\Exception $e) {
  35. Log::error('同步直播间:' . $e->getMessage());
  36. }
  37. });
  38. }
  39. }