AutoUpdateLiveJob.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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\jobs\activity;
  12. use crmeb\basic\BaseJobs;
  13. use crmeb\traits\QueueTrait;
  14. use think\facade\Log;
  15. use app\services\activity\live\LiveGoodsServices;
  16. use app\services\activity\live\LiveRoomServices;
  17. /**
  18. * 自动更新直播间状态和直播间产品状态
  19. * Class AutoUpdateLiveJob
  20. * @package app\jobs\live
  21. */
  22. class AutoUpdateLiveJob extends BaseJobs
  23. {
  24. use QueueTrait;
  25. /**
  26. * @return string
  27. */
  28. protected static function queueName()
  29. {
  30. return 'CRMEB_PRO_TASK';
  31. }
  32. public function doJob()
  33. {
  34. //更新直播商品状态
  35. try {
  36. /** @var LiveGoodsServices $liveGoods */
  37. $liveGoods = app()->make(LiveGoodsServices::class);
  38. return $liveGoods->syncGoodStatus();
  39. } catch (\Throwable $e) {
  40. Log::error('更新直播商品状态失败,失败原因:[' . class_basename($this) . ']' . $e->getMessage());
  41. }
  42. //更新直播间状态
  43. try {
  44. /** @var LiveRoomServices $liveRoom */
  45. $liveRoom = app()->make(LiveRoomServices::class);
  46. return $liveRoom->syncRoomStatus();
  47. } catch (\Throwable $e) {
  48. Log::error('更新直播间状态失败,失败原因:[' . class_basename($this) . ']' . $e->getMessage());
  49. }
  50. }
  51. }