修改自动推广的相关任务

This commit is contained in:
wangjinlei
2026-04-24 16:26:48 +08:00
parent 13fd3af816
commit d21c33fcd0
3 changed files with 52 additions and 21 deletions

View File

@@ -1728,6 +1728,32 @@ class EmailClient extends Base
return jsonSuccess($result);
}
public function mytestg(){
$data = $this->request->post();
$rule = new Validate([
"id"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$service = new PromotionService();
$service->enqueuePrepareEmail($data['id']);
$service->log("dsadsadsad");
}
public function mytestqq(){
$data = $this->request->post();
$rule = new Validate([
"id"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$service = new PromotionService();
$service->prepareSingleEmail($data['id']);
}
/**
* 定时任务:为指定日期的任务预生成邮件(默认明天)
* 建议每天 22:00 执行curl .../EmailClient/prepareTasksForDate 或 prepareTasksForDate?date=2026-03-12

View File

@@ -25,28 +25,33 @@ class PromotionPrepareEmail
$logId = intval(isset($data['log_id']) ? $data['log_id'] : 0);
$service = new PromotionService();
$service->log('[PromotionPrepareEmail] m11ylog=' . $logId);
if (!$logId) {
$job->delete();
return;
}
try {
$result = $service->prepareSingleEmail($logId);
$service->log('[PromotionPrepareEmail] log=' . $logId
. ' code=' . $result['code']
. ' llm_status=' . $result['llm_status']
. ' msg=' . $result['msg']);
$job->delete();
} catch (\Exception $e) {
$service->log('[PromotionPrepareEmail] log=' . $logId
. ' attempts=' . $job->attempts()
. ' exception=' . $e->getMessage());
if ($job->attempts() >= 3) {
$job->delete();
} else {
$job->release(30);
}
}
$result = $service->prepareSingleEmail($logId);
$service->log('[PromotionPrepareEm111ail] m11ylog=' . $logId);
//
// try {
// $result = $service->prepareSingleEmail($logId);
// $service->log('[PromotionPrepareEmail] log=' . $logId
// . ' code=' . $result['code']
// . ' llm_status=' . $result['llm_status']
// . ' msg=' . $result['msg']);
// $job->delete();
// } catch (\Exception $e) {
// $service->log('[PromotionPrepareEmail] log=' . $logId
// . ' attempts=' . $job->attempts()
// . ' exception=' . $e->getMessage());
//
// if ($job->attempts() >= 3) {
// $job->delete();
// } else {
// $job->release(30);
// }
// }
}
}

View File

@@ -603,9 +603,9 @@ class PromotionService
$data = ['log_id' => intval($logId)];
if ($delay > 0) {
Queue::later($delay, $jobClass, $data, 'promotionPrepareEmail');
Queue::later($delay, $jobClass, $data, 'promotionmmm');
} else {
Queue::push($jobClass, $data, 'promotionPrepareEmail');
Queue::push($jobClass, $data, 'promotionmmm');
}
}