自动推广
This commit is contained in:
35
application/api/job/PromotionSend.php
Normal file
35
application/api/job/PromotionSend.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\job;
|
||||
|
||||
use think\queue\Job;
|
||||
use app\common\PromotionService;
|
||||
|
||||
class PromotionSend
|
||||
{
|
||||
public function fire(Job $job, $data)
|
||||
{
|
||||
$taskId = intval(isset($data['task_id']) ? $data['task_id'] : 0);
|
||||
$service = new PromotionService();
|
||||
|
||||
if (!$taskId) {
|
||||
$service->log('[PromotionSend] missing task_id, job deleted');
|
||||
$job->delete();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$result = $service->processNextEmail($taskId);
|
||||
$service->log('[PromotionSend] task=' . $taskId . ' result=' . json_encode($result));
|
||||
|
||||
if (!empty($result['done'])) {
|
||||
$reason = isset($result['reason']) ? $result['reason'] : '';
|
||||
$service->log('[PromotionSend] task=' . $taskId . ' finished, reason=' . $reason);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$service->log('[PromotionSend] task=' . $taskId . ' exception=' . $e->getMessage());
|
||||
}
|
||||
|
||||
$job->delete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user