Files
tougao/application/api/job/UserFieldAiFill.php
2026-05-20 11:58:10 +08:00

36 lines
965 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace app\api\job;
use think\queue\Job;
use app\common\UserFieldAiService;
/**
* 链式任务:为单个用户生成 field_ai完成后自动入队下一位用户。
*
* data:
* - user_id 当前处理的用户
* - queue 队列名(默认 UserFieldAi
* - force 1=强制重算
*
* Worker: php think queue:work --queue UserFieldAi
*/
class UserFieldAiFill
{
public function fire(Job $job, $data)
{
$userId = isset($data['user_id']) ? intval($data['user_id']) : 0;
$queue = isset($data['queue']) ? (string) $data['queue'] : UserFieldAiService::QUEUE_NAME;
$force = !empty($data['force']);
$svc = new UserFieldAiService();
if ($userId > 0) {
$svc->processUser($userId, $force);
}
$job->delete();
$delay = max(0, (int) (isset($data['delay']) ? $data['delay'] : 1));
$svc->enqueueNextFieldAi($delay, $queue, $userId, $force);
}
}