作者 lyh

gx视频任务

... ... @@ -65,7 +65,6 @@ class VideoTask extends Command
Log::info('当月以达到最大视频生成数,任务执行数:' . $number);
return true;
}
$this->createSubTask($number);
$this->sendSubTask();
Log::info('结束视频推广任务');
... ... @@ -73,31 +72,6 @@ class VideoTask extends Command
}
/**
* @remark :获取当月的数据总量
* @name :getVideoNumber
* @author :lyh
* @method :post
* @time :2024/7/12 18:02
*/
public function getVideoNumber()
{
$current_time = date('Y-m-d 00:00:00');
$number = Cache::get('video_keyword_number');
if(empty($number) || ($current_time == date('Y-m-13 00:00:00'))){
if($current_time <= date('Y-m-13 00:00:00')){
$startOfMonth = Carbon::now()->subMonth()->day(13)->format('Y-m-d 00:00:00');
$endOfMonth = Carbon::now()->day(13)->format('Y-m-d 00:00:00');
}else{
$startOfMonth = Carbon::now()->day(13)->format('Y-m-d 00:00:00');
$endOfMonth = Carbon::now()->addMonth()->day(13)->format('Y-m-d 00:00:00');
}
$taskLogModel = new KeywordVideoTaskLog();
$number = $taskLogModel->formatQuery(['created_at' => ['between', [$startOfMonth, $endOfMonth]]])->count();
Cache::put('video_keyword_number',$number);
}
return $number;
}
/**
* 创建子任务
* TODO 获取需要生成子任务的项目,获取项目中未生成视频的关键词,通过关键词生成初始化子任务
* @return bool
... ... @@ -109,6 +83,9 @@ class VideoTask extends Command
if ($sub_task_num <= 0){
break;
}
if($number >= $this->max_num){
break;
}
$task_project = KeywordVideoTask::where(['status' => KeywordVideoTask::STATUS_OPEN])->orderBy('sort', 'desc')->orderBy('id', 'desc')->first();
if (empty($task_project)){
break;
... ... @@ -155,9 +132,9 @@ class VideoTask extends Command
if($rs && ($sub_task_num > 0)){
$sub_task_num--;
}
Cache::put('video_keyword_number',$number++);
}
}
Cache::put('video_keyword_number_month',$number + count($keyword),3600);
$task_project->status = KeywordVideoTask::STATUS_CLOSE;
$task_project->save();
}
... ...
... ... @@ -38,7 +38,7 @@ class KeywordVideoTaskLog extends Base
$start_date = Carbon::now()->subMonth()->day(13)->format('Y-m-d 00:00:00');
}
$num = self::where('created_at', '>', $start_date)->count();
Cache::put($key, $num, 1800);
Cache::put($key, $num, 3600);
return $num;
});
return $num;
... ...