作者 lyh

gx

  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :UpdateVideoNumber.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/7/12 16:39
  8 + */
  9 +
  10 +namespace App\Console\Commands\KeywordInVideo;
  11 +
  12 +use Illuminate\Console\Command;
  13 +use Illuminate\Support\Facades\Cache;
  14 +
  15 +class UpdateVideoNumber extends Command
  16 +{
  17 + /**
  18 + * The name and signature of the console command.
  19 + *
  20 + * @var string
  21 + */
  22 + protected $signature = 'update_video_number';
  23 +
  24 + /**
  25 + * The console command description.
  26 + *
  27 + * @var string
  28 + */
  29 + protected $description = '更新每月视频数量';
  30 +
  31 + /**
  32 + * @remark :执行脚本(每月13日更新数量)
  33 + * @name :handle
  34 + * @author :lyh
  35 + * @method :post
  36 + * @time :2024/7/12 16:41
  37 + */
  38 + public function handle(){
  39 + if(date('Y-m-13') == date('Y-m-d')){
  40 + Cache::put('currentMonth13th',49000);
  41 + }
  42 + return true;
  43 + }
  44 +}
@@ -16,9 +16,11 @@ use App\Models\Product\Keyword; @@ -16,9 +16,11 @@ use App\Models\Product\Keyword;
16 use App\Models\Product\Product; 16 use App\Models\Product\Product;
17 use App\Services\ProjectServer; 17 use App\Services\ProjectServer;
18 use Illuminate\Console\Command; 18 use Illuminate\Console\Command;
  19 +use Illuminate\Support\Facades\Cache;
19 use Illuminate\Support\Facades\DB; 20 use Illuminate\Support\Facades\DB;
20 use Illuminate\Support\Facades\Http; 21 use Illuminate\Support\Facades\Http;
21 use Illuminate\Support\Facades\Log; 22 use Illuminate\Support\Facades\Log;
  23 +use Illuminate\Support\Facades\Redis;
22 24
23 class VideoTask extends Command 25 class VideoTask extends Command
24 { 26 {
@@ -50,13 +52,17 @@ class VideoTask extends Command @@ -50,13 +52,17 @@ class VideoTask extends Command
50 * @var int 最大子任务 52 * @var int 最大子任务
51 */ 53 */
52 public $max_sub_task = 200; 54 public $max_sub_task = 200;
53 - 55 + public $max_num;
54 /** 56 /**
55 * @return bool 57 * @return bool
56 */ 58 */
57 public function handle() 59 public function handle()
58 { 60 {
59 echo '开始:'.PHP_EOL; 61 echo '开始:'.PHP_EOL;
  62 + $this->max_num = Cache::get('currentMonth13th');
  63 + if($this->max_num <= 0){
  64 + return true;
  65 + }
60 Log::info('开始视频推广任务'); 66 Log::info('开始视频推广任务');
61 $this->createSubTask(); 67 $this->createSubTask();
62 $this->sendSubTask(); 68 $this->sendSubTask();
@@ -122,6 +128,7 @@ class VideoTask extends Command @@ -122,6 +128,7 @@ class VideoTask extends Command
122 if($rs && ($sub_task_num > 0)){ 128 if($rs && ($sub_task_num > 0)){
123 $sub_task_num--; 129 $sub_task_num--;
124 } 130 }
  131 + Cache::put('currentMonth13th',$this->max_num--);
125 } 132 }
126 } 133 }
127 $task_project->status = KeywordVideoTask::STATUS_CLOSE; 134 $task_project->status = KeywordVideoTask::STATUS_CLOSE;