作者 Your Name
... ... @@ -16,6 +16,7 @@ use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
... ... @@ -52,12 +53,16 @@ class VideoTask extends Command
* @var int 最大子任务
*/
public $max_sub_task = 200;
public $max_num;
public $max_num = 49000;
/**
* @return bool
*/
public function handle()
{
$number = $this->getVideoNumber();
if($number >= $this->max_num){
return true;
}
echo '开始:'.PHP_EOL;
Log::info('开始视频推广任务');
$this->createSubTask();
... ... @@ -67,6 +72,23 @@ class VideoTask extends Command
}
/**
* @remark :获取当月的数据总量
* @name :getVideoNumber
* @author :lyh
* @method :post
* @time :2024/7/12 18:02
*/
public function getVideoNumber()
{
$taskLogModel = new KeywordVideoTaskLog();
// 获取当月的开始时间
$startOfMonth = Carbon::now()->startOfMonth()->format('Y-m-d H:i:s');
// 获取当月的结束时间
$endOfMonth = Carbon::now()->endOfMonth()->format('Y-m-d H:i:s');
$number = $taskLogModel->formatQuery(['created_at' => ['between', [$startOfMonth, $endOfMonth]]])->count();
return $number;
}
/**
* 创建子任务
* TODO 获取需要生成子任务的项目,获取项目中未生成视频的关键词,通过关键词生成初始化子任务
* @return bool
... ...