修改自动推广的相关任务
This commit is contained in:
@@ -17,40 +17,17 @@ use app\common\QueueJob;
|
||||
*/
|
||||
class PromotionPrepareTask
|
||||
{
|
||||
private $oQueueJob;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->oQueueJob = new QueueJob();
|
||||
}
|
||||
|
||||
public function fire(Job $job, $data)
|
||||
{
|
||||
$this->oQueueJob->init($job);
|
||||
|
||||
$taskId = isset($data['task_id']) ? intval($data['task_id']) : 0;
|
||||
if ($taskId <= 0) {
|
||||
$this->oQueueJob->log("PromotionPrepareTask 无效的 task_id,删除任务");
|
||||
$job->delete();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$service = new PromotionService();
|
||||
$result = $service->dispatchPrepareEmails($taskId);
|
||||
|
||||
$dispatched = isset($result['dispatched']) ? $result['dispatched'] : 0;
|
||||
$alreadyDone = isset($result['already_done']) ? $result['already_done'] : 0;
|
||||
$err = isset($result['error']) ? $result['error'] : '';
|
||||
$this->oQueueJob->log("PromotionPrepareTask 完成 | task_id={$taskId} dispatched={$dispatched} already_done={$alreadyDone} error={$err}");
|
||||
|
||||
$job->delete();
|
||||
} catch (\Exception $e) {
|
||||
$this->oQueueJob->handleException($e, $job, "task_id={$taskId}");
|
||||
} catch (\Throwable $e) {
|
||||
$this->oQueueJob->handleException($e, $job, "task_id={$taskId}");
|
||||
} finally {
|
||||
$this->oQueueJob->finnal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user