修改自动推广的相关任务
This commit is contained in:
@@ -4,6 +4,7 @@ namespace app\api\job;
|
||||
|
||||
use think\queue\Job;
|
||||
use app\common\PromotionService;
|
||||
use app\common\QueueJob;
|
||||
|
||||
/**
|
||||
* 【已废弃 / 兼容保留】
|
||||
@@ -15,20 +16,35 @@ use app\common\PromotionService;
|
||||
*/
|
||||
class PromotionPrepare
|
||||
{
|
||||
private $oQueueJob;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->oQueueJob = new QueueJob();
|
||||
}
|
||||
|
||||
public function fire(Job $job, $data)
|
||||
{
|
||||
$taskId = intval(isset($data['task_id']) ? $data['task_id'] : 0);
|
||||
$service = new PromotionService();
|
||||
$this->oQueueJob->init($job);
|
||||
|
||||
if ($taskId > 0) {
|
||||
try {
|
||||
$service->enqueuePrepareTask($taskId);
|
||||
$service->log('[PromotionPrepare][deprecated] forwarded task=' . $taskId . ' -> PromotionPrepareTask');
|
||||
} catch (\Exception $e) {
|
||||
$service->log('[PromotionPrepare][deprecated] task=' . $taskId . ' forward_exception=' . $e->getMessage());
|
||||
}
|
||||
$taskId = isset($data['task_id']) ? intval($data['task_id']) : 0;
|
||||
if ($taskId <= 0) {
|
||||
$this->oQueueJob->log("PromotionPrepare[deprecated] 无效的 task_id,删除任务");
|
||||
$job->delete();
|
||||
return;
|
||||
}
|
||||
|
||||
$job->delete();
|
||||
try {
|
||||
$service = new PromotionService();
|
||||
$service->enqueuePrepareTask($taskId);
|
||||
$this->oQueueJob->log("PromotionPrepare[deprecated] forwarded task_id={$taskId} -> PromotionPrepareTask");
|
||||
$job->delete();
|
||||
} catch (\Exception $e) {
|
||||
$this->oQueueJob->handleException($e, $job, "[deprecated] task_id={$taskId}");
|
||||
} catch (\Throwable $e) {
|
||||
$this->oQueueJob->handleException($e, $job, "[deprecated] task_id={$taskId}");
|
||||
} finally {
|
||||
$this->oQueueJob->finnal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user