作者 lyh

gx

<?php
/**
* @remark :
* @name :UpdateVideoNumber.php
* @author :lyh
* @method :post
* @time :2024/7/12 16:39
*/
namespace App\Console\Commands\KeywordInVideo;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
class UpdateVideoNumber extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'update_video_number';
/**
* The console command description.
*
* @var string
*/
protected $description = '更新每月视频数量';
/**
* @remark :执行脚本(每月13日更新数量)
* @name :handle
* @author :lyh
* @method :post
* @time :2024/7/12 16:41
*/
public function handle(){
if(date('Y-m-13') == date('Y-m-d')){
Cache::put('currentMonth13th',49000);
}
return true;
}
}
... ...
... ... @@ -16,9 +16,11 @@ use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;
class VideoTask extends Command
{
... ... @@ -50,13 +52,17 @@ class VideoTask extends Command
* @var int 最大子任务
*/
public $max_sub_task = 200;
public $max_num;
/**
* @return bool
*/
public function handle()
{
echo '开始:'.PHP_EOL;
$this->max_num = Cache::get('currentMonth13th');
if($this->max_num <= 0){
return true;
}
Log::info('开始视频推广任务');
$this->createSubTask();
$this->sendSubTask();
... ... @@ -122,6 +128,7 @@ class VideoTask extends Command
if($rs && ($sub_task_num > 0)){
$sub_task_num--;
}
Cache::put('currentMonth13th',$this->max_num--);
}
}
$task_project->status = KeywordVideoTask::STATUS_CLOSE;
... ...