123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- declare(strict_types=1);
- namespace App\Task;
- use App\Master\Framework\Extend\BaseTask;
- use App\Model\Arts\LiveRoomModel;
- use App\Service\QueueService;
- use App\Utils\LogUtil;
- use Hyperf\Crontab\Annotation\Crontab;
- use Hyperf\Di\Annotation\Inject;
- #[Crontab(rule: "*\/10 * * * * *", name: "LiveRoomSendTask", callback: "execute", memo: "直播间数据推送 每3秒执行一次", enable: true)]
- class LiveRoomSendTask extends BaseTask {
- //日志板块
- protected string $LOG_MODULE = 'LiveRoomSendTask';
- #[Inject]
- protected QueueService $service;
- public function __construct()
- {
- parent::__construct();
- }
- public function do(): bool
- {
- // 查询正在直播的房间 推入到数据更新队列
- $model = new LiveRoomModel();
- $list = $model->getList(['status' => 1]);
- if (!empty($list)){
- foreach ($list as $item){
- // 加入点赞队列
- $this->service->liveRoomSendPush([
- 'room_no' => $item['room_no']
- ]);
- }
- }
- return $this->success('执行成功');
- }
- }
|